![]() |
Colliding Shapes
Ian Parberry's "Introduction to Game Physics"
|
Dynamic circle. More...
#include <DynamicCircle.h>
Public Member Functions | |
CDynamicCircle (const CDynamicCircleDesc &) | |
Constructor. More... | |
void | move () |
Move using Euler integration. More... | |
bool | AABBCollide (CDynamicCircle *) |
Collide detection using AABBs. More... | |
void | PostCollide (const CContactDesc &) |
Collision response. More... | |
Vector2 | GetVel () |
Get velocity. More... | |
void | SetVel (const Vector2 &) |
Set velocity. More... | |
![]() | |
CCircle (const CCircleDesc &) | |
Constructor. More... | |
bool | PreCollide (CContactDesc &) |
Collision detection. More... | |
bool | PtInCircle (const Vector2 &) |
Point in circle test. More... | |
Vector2 | ClosestPt (const Vector2 &) |
Closest point on circle. More... | |
bool | Tangents (const Vector2 &, Vector2 &, Vector2 &) |
Tangents through external point. More... | |
bool | Tangents (CCircle *, CLineSegDesc &, CLineSegDesc &) |
Common tangents. More... | |
bool | Tangent (CCircle *, CLineSegDesc &) |
Common tangent. More... | |
float | GetRadius () |
Get radius. More... | |
![]() | |
CShape (const CShapeDesc &) | |
Constructor. More... | |
virtual | ~CShape () |
Destructor. More... | |
const eShape | GetShapeType () const |
Get shape type. More... | |
const eMotion | GetMotionType () const |
Get motion type. More... | |
const CAabb2D & | GetAABB () const |
Get AABB. More... | |
const bool | GetSensor () const |
Is this shape a sensor? More... | |
const Vector2 & | GetPos () const |
Get position. More... | |
void | SetPos (const Vector2 &) |
Set position. More... | |
void | SetAABBPoint (const Vector2 &) |
Set AABB point. More... | |
void | AddAABBPoint (const Vector2 &) |
Add AABB point. More... | |
void | SetCanCollide (bool=true) |
Turn collisions on or off. More... | |
const bool | GetCanCollide () const |
Get whether shape can collide. More... | |
virtual void | Rotate (const Vector2 &, float) |
Rotate. More... | |
virtual void | Reset () |
Reset orientation. More... | |
const bool | GetRotating () const |
Get whether rotating. More... | |
void | SetRotating (bool) |
Start or stop rotating. More... | |
const float | GetOrientation () const |
Get orientation. More... | |
const float | GetRotSpeed () const |
Get rotation speed. More... | |
const Vector2 & | GetRotCenter () const |
Get rotation speed. More... | |
const float | GetElasticity () const |
Get elasticity. More... | |
void | SetOrientation (float) |
Set orientation. More... | |
void | SetRotSpeed (float) |
Set rotation speed. More... | |
void | SetRotCenter (const Vector2 &) |
Set center of rotation. More... | |
void * | GetUserPtr () const |
Get user pointer. More... | |
void | SetUserPtr (void *) |
Set user pointer. More... | |
Private Member Functions | |
void | PostCollideStatic (const CContactDesc &) |
Collision response for static shape. More... | |
void | PostCollideKinematic (const CContactDesc &) |
Collision response for kinematic shape. More... | |
void | PostCollideDynamic (const CContactDesc &) |
Collision response for dynamic shape. More... | |
Private Attributes | |
Vector2 | m_vVel |
Velocity. Speed is measured in pixels per second. | |
float | m_fMass = 0.0f |
Mass. | |
Additional Inherited Members | |
![]() | |
float | m_fRadius = 0.0f |
Radius. | |
float | m_fRadiusSq = 0.0f |
Radius squared, used for faster distance calculations. | |
![]() | |
eShape | m_eShapeType = eShape::Unknown |
Type of shape. | |
eMotion | m_eMotionType = eMotion::Static |
How shape moves. | |
float | m_fElasticity = 1.0f |
Elasticity, aka restitution, bounciness. | |
bool | m_bIsSensor = false |
Sensor only, no rebound on collision. | |
CAabb2D | m_cAABB |
Axially aligned bounding box in World Space. | |
bool | m_bCanCollide = true |
Can collide with other shapes. | |
float | m_fOrientation = 0.0f |
Orientation angle. | |
void * | m_pUser |
Spare pointer for user in case they might need one. | |
Vector2 | m_vRotCenter |
Center of rotation. | |
float | m_fRotSpeed = 0.0f |
Rotation speed. | |
bool | m_bRotating = false |
Whether rotating. | |
![]() | |
static float | m_fGravity = 0.0f |
Gravitational constant. | |
static float | m_fTimeStep = 0.0f |
Time step per animation frame (fictional). | |
A dynamic circle is a circle shape that moves and can collide with static, kinematic, and dynamic shapes.
CDynamicCircle::CDynamicCircle | ( | const CDynamicCircleDesc & | r | ) |
Constructs a dynamic circle described by a dynamic circle descriptor.
r | Dynamic circle descriptor. |
bool CDynamicCircle::AABBCollide | ( | CDynamicCircle * | pCirc | ) |
Does the AABB for this dynamic circle overlap the AABB for another dynamic circle?
pCirc | Pointer to a dynamic circle. |
Vector2 CDynamicCircle::GetVel | ( | ) |
Reader function for the velocity.
|
virtual |
Move the shape using Euler integration, depending on the physics time step and the gravity constant.
Reimplemented from CShape.
void CDynamicCircle::PostCollide | ( | const CContactDesc & | cd | ) |
Collision response for a dynamic circle colliding with a shape.
cd | Contact descriptor which has been filled in by collision detection. |
|
private |
Collision response for a dynamic circle colliding with a dynamic shape.
cd | Contact descriptor which has been filled in by collision detection. |
|
private |
Collision response for a dynamic circle colliding with a kinematic shape. This circle's velocity is affected by the kinematic shape's rotation. This code assumes that all elasticities are less than unity.
cd | Contact descriptor that has been filled in by collision detection. |
|
private |
Collision response for a dynamic circle colliding with a static shape.
cd | Contact descriptor which has been filled in by collision detection. |
void CDynamicCircle::SetVel | ( | const Vector2 & | v | ) |
Set the velocity to a new value.
v | New velocity. |