Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

CollisionManager Class Reference

Collision Manager singleton class. More...

#include <CollisionManager.h>

List of all members.

Public Member Functions

bool CheckCollision (PhysicsObject *discPhysics, PhysicsObject *colliderPhysics, double deltaTime)
bool CheckCollision (PhysicsObject *discPhysics, RectangleCollider *colliderPhysics, double deltaTime)
bool CheckCollision (float x1, float y1, float x2, float y2, float radius1, float radius2)
bool CheckButtonCollision (float x1, float y1, float x2, float y2, int width, int height)
void SolveCollision (PhysicsObject *discPhysics, PhysicsObject *colliderPhysics)
void SolveCollision (PhysicsObject *discPhysics, RectangleCollider *colliderPhysics, bool hasCleared)

Static Public Member Functions

static CollisionManagerInstance ()
static void DestroyInstance ()

Protected Member Functions

 CollisionManager ()
 ~CollisionManager ()

Protected Attributes

float m_colliderImpulse
 Impulse the grid collider's impart upon discs.

Static Protected Attributes

static CollisionManagerm_instance = 0
 Static CollisionManager instance which will be returned when the singleton's Instance() method is called.

Detailed Description

Collision Manager singleton class.

Returns an instance of a collision manager, which is used to detect and solve collisions.


Constructor & Destructor Documentation

CollisionManager::CollisionManager (  )  [protected]

Constructor.

Creates a CollisionManager object. Protected as this is a singleton, which is created when Instance() is first called.

CollisionManager::~CollisionManager (  )  [protected]

Destructor.

Destroys the CollisionManager object. Protected as this is a singleton, which should instead be deleted using DestroyInstance().


Member Function Documentation

bool CollisionManager::CheckButtonCollision ( float  x1,
float  y1,
float  x2,
float  y2,
int  width,
int  height 
)

Check collision between point and rectangle.

Checks for a collision between a point and a rectangle.

Parameters:
[in] x1 X position of the point.
[in] y1 Y position of the point.
[in] x2 X position of the rectangle (top left corner).
[in] y2 Y position of the rectangle (top left corner).
[in] width Width of the rectangle.
[in] height Height of the rectangle.
Returns:
Bool representing whether the two objects are colliding.
bool CollisionManager::CheckCollision ( PhysicsObject discPhysics,
RectangleCollider colliderPhysics,
double  deltaTime 
)

Check collision between a disc and a grid side collider.

Checks for a collision between a circular PhysicsObject and a rectangular PhysicsObject using the standard distance formula.

Parameters:
[in] discPhysics The disc's PhysicsObject.
[in] colliderPhysics The grid collider's PhysicsObject.
[in] deltaTime Time since the last update.
Returns:
Bool representing whether the two PhysicsObjects are colliding.
bool CollisionManager::CheckCollision ( float  x1,
float  y1,
float  x2,
float  y2,
float  radius1,
float  radius2 
)

Check collision between two circles.

Checks for a collision between a circles given their (x, y) positions and their radii.

Parameters:
[in] x1 X position of the centre of the first circle.
[in] y1 Y position of the centre of the first circle.
[in] x2 X position of the centre of the second circle.
[in] y2 Y position of the centre of the second circle.
[in] radius1 Radius of the first circle.
[in] radius2 Radius of the second circle.
Returns:
Bool representing whether the two PhysicsObjects are colliding.
bool CollisionManager::CheckCollision ( PhysicsObject discPhysics,
PhysicsObject colliderPhysics,
double  deltaTime 
)

Check collision between a disc and a grid top collider.

Checks for a collision between two circular PhysicsObjects using the standard distance formula.

Parameters:
[in] discPhysics The disc's PhysicsObject.
[in] colliderPhysics The grid collider's PhysicsObject.
[in] deltaTime Time since the last update.
Returns:
Bool representing whether the two PhysicsObjects are colliding.
void CollisionManager::DestroyInstance (  )  [static]

Delete this singleton.

Safely deletes the singleton instance and releases any memory it was using.

CollisionManager * CollisionManager::Instance (  )  [static]

Return the static CollisionManager instance.

Returns a static instance of CollisionManager. If no CollisionManager instance exists, one is created.

Returns:
Static CollisionManager instance.
void CollisionManager::SolveCollision ( PhysicsObject discPhysics,
RectangleCollider colliderPhysics,
bool  hasCleared 
)

Solve a collision between a disc and a grid side collider.

Solves the collision by giving the disc a new velocity, and translating it using a minimum translation vector so there is no further contact.

Parameters:
[in] discPhysics The disc's PhysicsObject.
[in] colliderPhysics The grid collider's PhysicsObject.
[in] hasCleared Has the disc cleared the top-left corner of the grid?
void CollisionManager::SolveCollision ( PhysicsObject discPhysics,
PhysicsObject colliderPhysics 
)

Solve a collision between a disc and a grid top collider.

Solves the collision by giving the disc a new velocity, and translating it using a minimum translation vector so there is no further contact. Modifies the amount of bounce the disc has based on the number of previous collisions.

Parameters:
[in] discPhysics The disc's PhysicsObject.
[in] colliderPhysics The grid collider's PhysicsObject.

The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations