![]() |
The Shapes Library
Game Physics with Bespoke Code
|
Compound shape. More...
#include <Compound.h>

Public Member Functions | |
| CCompoundShape (CShape *) | |
| Constructor. | |
| CCompoundShape () | |
| Default constructor. | |
| void | AddShape (CShape *p) |
| Add a shape. | |
| void | SetOrientation (float) |
| Set orientation. | |
| void | SetRotSpeed (float) |
| Set rotation speed. | |
| void | SetRotCenter (const Vector2 &) |
| Set center of rotation. | |
| const float | GetOrientation () const |
| Get orientation. | |
| const float | GetRotSpeed () const |
| Get rotation speed. | |
| const Vector2 | GetRotCenter () const |
| Get center of rotation. | |
| const bool | IsPartOf (CShape *) |
| Test whether shape is in compound shape. | |
| const CShape * | GetCenterPoint () const |
| Get center point. | |
Protected Attributes | |
| std::vector< CShape * > | m_stdShapes |
| List of shapes. | |
| CShape * | m_pCenterPoint = nullptr |
| Point at center. | |
A compound shape consists of a collection of shapes that ought to be grouped together for convenience.
| CCompoundShape::CCompoundShape | ( | CShape * | p | ) |
Initialize a compound shape given its center. The center point is set to not collide with anything.
| p | Pointer to a point shape at the center. |

| void CCompoundShape::AddShape | ( | CShape * | p | ) |
Append a given shape to the shape list. There is no attempt to ensure that it's not already in there, so beware.
| p | Pointer to shape to be added. |
| const CShape * CCompoundShape::GetCenterPoint | ( | ) | const |
Reader function for the center point.
m_pCenterPoint. | const float CCompoundShape::GetOrientation | ( | ) | const |
Reader function for the current orientation. This function assumes that all of the shapes in the shape list have the same orientation, so it just returns the orientation of the first shape (zero if there are no shapes yet).
| const Vector2 CCompoundShape::GetRotCenter | ( | ) | const |
Reader function for the center of rotation. This function assumes that all of the shapes in the shape list have the same rotation speed, so it just returns the center of rotation of the first shape (or the zero vector if there are no shapes yet).
| const float CCompoundShape::GetRotSpeed | ( | ) | const |
Reader function for the current rotation speed. This function assumes that all of the shapes in the shape list have the same rotation speed, so it just returns the rotation speed of the first shape (zero if there are no shapes yet).
| const bool CCompoundShape::IsPartOf | ( | CShape * | pShape | ) |
Test whether a shape is part of this compound shape. This function can be used during collision response when the compound shape has a sprite that changes on collision.
| pShape | Pointer to a shape. |
| void CCompoundShape::SetOrientation | ( | float | a | ) |
Set the orientation of all of the shapes in the shape list. Make sure you call this after all shapes have been added, since this orientation won't be applied to shapes added after this function is called.
| a | Angle. |
| void CCompoundShape::SetRotCenter | ( | const Vector2 & | p | ) |
Set the center of rotation of all of the shapes in the shape list. Make sure you call this after all shapes have been added, since this rotation center won't be applied to shapes added after this function is called.
| p | Center of rotation. |
| void CCompoundShape::SetRotSpeed | ( | float | s | ) |
Set the rotation speed of all of the shapes in the shape list. Make sure you call this after all shapes have been added, since this rotation speed won't be applied to shapes added after this function is called.
| s | Rotation speed in radians per millisecond. |