Collision Manager singleton class. More...
#include <CollisionManager.h>
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 CollisionManager * | Instance () |
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 CollisionManager * | m_instance = 0 |
Static CollisionManager instance which will be returned when the singleton's Instance() method is called. |
Collision Manager singleton class.
Returns an instance of a collision manager, which is used to detect and solve collisions.
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().
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.
[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. |
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.
[in] | discPhysics | The disc's PhysicsObject. |
[in] | colliderPhysics | The grid collider's PhysicsObject. |
[in] | deltaTime | Time since the last update. |
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.
[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. |
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.
[in] | discPhysics | The disc's PhysicsObject. |
[in] | colliderPhysics | The grid collider's PhysicsObject. |
[in] | deltaTime | Time since the last update. |
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.
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.
[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.
[in] | discPhysics | The disc's PhysicsObject. |
[in] | colliderPhysics | The grid collider's PhysicsObject. |