![]() |
Colliding Shapes
Ian Parberry's "Introduction to Game Physics"
|
Shape. More...
#include <Shape.h>
Public Member Functions | |
| 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... | |
| virtual bool | PreCollide (CContactDesc &) |
| Collision detection. More... | |
| virtual void | move () |
| Translate. 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... | |
Protected Attributes | |
| 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. | |
Private Attributes | |
| Vector2 | m_vPos |
| Position, access ONLY through get and set functions. | |
| CAabb2D | m_cObjSpaceAABB |
| Axially aligned bounding box in Object Space. | |
Additional Inherited Members | |
Static Protected Attributes inherited from CShapeCommon | |
| static float | m_fGravity = 0.0f |
| Gravitational constant. | |
| static float | m_fTimeStep = 0.0f |
| Time step per animation frame (fictional). | |
CShape is the base class for all shapes. It contains shape type information and has a couple of handy constructors.
| CShape::CShape | ( | const CShapeDesc & | r | ) |
Constructs a shape described by a shape descriptor. It is assumed that the shape is collidable.
| r | Shape descriptor. |
|
virtual |
This is needed because virtual functions. Otherwise you risk memory leaks. Apparently.
| void CShape::AddAABBPoint | ( | const Vector2 & | p | ) |
Extend m_cObjSpaceAABB and m_cAABB to cover a new point.
| p | A point in Object Space. |
| const CAabb2D & CShape::GetAABB | ( | ) | const |
Reader function for the axially aligned bounding box.
| const bool CShape::GetCanCollide | ( | ) | const |
Reader function for the collidable flag.
| const float CShape::GetElasticity | ( | ) | const |
Reader function for the elasticity.
| const eMotion CShape::GetMotionType | ( | ) | const |
Reader function for the motion type.
| const float CShape::GetOrientation | ( | ) | const |
Reader function for orientation.
| const Vector2 & CShape::GetPos | ( | ) | const |
Reader function for the position.
| const bool CShape::GetRotating | ( | ) | const |
Reader function for rotation flag.
| const Vector2 & CShape::GetRotCenter | ( | ) | const |
Reader function for the center of rotation.
| const float CShape::GetRotSpeed | ( | ) | const |
Reader function for rotation speed.
| const bool CShape::GetSensor | ( | ) | const |
Reader function for the sensor setting.
| const eShape CShape::GetShapeType | ( | ) | const |
Reader function for the shape type.
| void * CShape::GetUserPtr | ( | ) | const |
Reader function for the user pointer.
|
virtual |
Virtual move function. This is for shapes that move, obviously not static ones. Kinematic shapes are handled here. Dynamic shapes get handled by a virtual function in CDynamicCircle.
Reimplemented in CDynamicCircle.
|
virtual |
Collision detection with a dynamic circle. This virtual function is a stub that will be overridden by the appropriate functions that do collision detection for various specific shapes.
| c | [in, out] Contact descriptor for this collision. |
|
virtual |
Reset to original orientation. This virtual function is a stub only. It will be overridden by the appropriate functions that perform a reset for various specific kinematic shapes.
Reimplemented in CKinematicArc, CKinematicLineSeg, CKinematicCircle, and CKinematicPoint.
|
virtual |
Rotate to a given orientation This virtual function is a stub only. It will be overridden by the appropriate functions that perform a rotation for various specific kinematic shapes.
| v | Center of rotation. |
| a | Angle increment from original orientation. |
Reimplemented in CKinematicArc, CKinematicLineSeg, CKinematicCircle, and CKinematicPoint.
| void CShape::SetAABBPoint | ( | const Vector2 & | p | ) |
Set m_cObjSpaceAABB and m_cAABB to a single point.
| p | A point in Object Space. |
| void CShape::SetCanCollide | ( | bool | b = true | ) |
This function should be used to enable or disable collisions at run-time.
| b | true if collisions are enabled, false if disabled. |
| void CShape::SetOrientation | ( | float | a | ) |
| a | Angle. |
| void CShape::SetPos | ( | const Vector2 & | p | ) |
Writer function for the position. This both changes the shape's position and translates its AABB.
| p | New position. |
| void CShape::SetRotating | ( | bool | b | ) |
| b | true to start rotating, false to stop rotating. |
| void CShape::SetRotCenter | ( | const Vector2 & | p | ) |
| p | Center of rotation. |
| void CShape::SetRotSpeed | ( | float | s | ) |
| s | Rotation speed. |
| void CShape::SetUserPtr | ( | void * | p | ) |
Writer function for the user pointer.
| p | User pointer. |
1.8.14