The Game Engine  1
Collision Class Reference

This defines Collision caching as well as the ability to sort into buckets. More...

#include <Collision.h>

+ Collaboration diagram for Collision:

Public Member Functions

 Collision ()
 
 ~Collision ()
 
bool collided (WorldObject *a, WorldObject *b)
 Lets us know if a collision had precviously occurred (order independent). More...
 
bool collided (pair< WorldObject *, WorldObject * > key)
 Lets us know if a collision had precviously occurred (order independent). More...
 
void markCollision (WorldObject *a, CollisionObject *ac, WorldObject *b, CollisionObject *bc)
 Mark Collision as occurred. More...
 
vector< tuple< WorldObject
*, CollisionObject
*, WorldObject
*, CollisionObject * > > * 
getCollisions (WorldObject *a, WorldObject *b)
 returns list of collisions More...
 
void clear ()
 Clears all collision data from last run. More...
 

Static Public Member Functions

static Collisioncollider ()
 gives us our Collision helper singleton More...
 

Public Attributes

vector< vector< WorldObject * > > CollisionLists
 Sets of collision lists to check detection. More...
 
vector< map< Point2D, vector
< WorldObject * > > > 
Buckets
 Buckets into which items fall for collision (determined each loop) More...
 
map< pair< WorldObject
*, WorldObject * >, vector
< tuple< WorldObject
*, CollisionObject
*, WorldObject
*, CollisionObject * > > * > 
Collisions
 Map that provides a cache of all collidied objects for a given object (clears each loop) Note:initial key is pair of two objects checking collision, values are world object and associated collision object. More...
 
unsigned int CellWidth
 The width of partition cells. More...
 
unsigned int CellHeight
 The height of partition cells. More...
 

Static Public Attributes

static Collisionm_instance = NULL
 instance of Collision helper More...
 

Detailed Description

This defines Collision caching as well as the ability to sort into buckets.

This class is tasked with the following:

  • Handling and Caching collisoins
    • Splitting objects into buckets
    • Storing Collision lists
Todo:
change this to where you can specify collision from object poll perspective or by partitioning and listing collisions for all objects in a map.

Definition at line 25 of file Collision.h.

Constructor & Destructor Documentation

Collision::Collision ( )
inline

Definition at line 28 of file Collision.h.

+ Here is the caller graph for this function:

Collision::~Collision ( )
inline

Definition at line 29 of file Collision.h.

+ Here is the call graph for this function:

Member Function Documentation

void Collision::clear ( )
inline

Clears all collision data from last run.

Definition at line 94 of file Collision.h.

+ Here is the caller graph for this function:

bool Collision::collided ( WorldObject a,
WorldObject b 
)
inline

Lets us know if a collision had precviously occurred (order independent).

Parameters
afirst object
bsecond object
Returns
whether there was a previous collision

Definition at line 55 of file Collision.h.

+ Here is the caller graph for this function:

bool Collision::collided ( pair< WorldObject *, WorldObject * >  key)
inline

Lets us know if a collision had precviously occurred (order independent).

Parameters
keythe combined pair of two worldobject*s
Returns
whether there was a previous collision

Definition at line 62 of file Collision.h.

static Collision* Collision::collider ( )
inlinestatic

gives us our Collision helper singleton

Definition at line 43 of file Collision.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

vector< tuple< WorldObject*, CollisionObject*, WorldObject*, CollisionObject* > >* Collision::getCollisions ( WorldObject a,
WorldObject b 
)
inline

returns list of collisions

Parameters
afirst object
bsecond object
Returns
list of all collisions

Definition at line 83 of file Collision.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Collision::markCollision ( WorldObject a,
CollisionObject ac,
WorldObject b,
CollisionObject bc 
)
inline

Mark Collision as occurred.

Definition at line 67 of file Collision.h.

Member Data Documentation

vector< map< Point2D, vector< WorldObject* > > > Collision::Buckets

Buckets into which items fall for collision (determined each loop)

Definition at line 34 of file Collision.h.

unsigned int Collision::CellHeight

The height of partition cells.

Definition at line 37 of file Collision.h.

unsigned int Collision::CellWidth

The width of partition cells.

Definition at line 36 of file Collision.h.

vector< vector< WorldObject* > > Collision::CollisionLists

Sets of collision lists to check detection.

Todo:
make sure that things get removed from this and add at the appropriate time (think streaming maybe instead of hard level boundaries because otherwise we're going to have overlap issues)

Definition at line 33 of file Collision.h.

map< pair< WorldObject*, WorldObject* >, vector< tuple< WorldObject*, CollisionObject*, WorldObject*, CollisionObject* > >* > Collision::Collisions

Map that provides a cache of all collidied objects for a given object (clears each loop) Note:initial key is pair of two objects checking collision, values are world object and associated collision object.

Definition at line 35 of file Collision.h.

Collision * Collision::m_instance = NULL
static

instance of Collision helper

Definition at line 38 of file Collision.h.


The documentation for this class was generated from the following files: