![]() |
Colliding Shapes
Ian Parberry's "Introduction to Game Physics"
|
Line segment shape. More...
#include <LineSeg.h>
Public Member Functions | |
CLineSeg (CLineSegDesc &) | |
Constructor. More... | |
bool | PreCollide (CContactDesc &) |
Collision detection. More... | |
void | GetEndPts (Vector2 &, Vector2 &) |
Get end points. More... | |
void | GetTangents (Vector2 &, Vector2 &) |
Get tangents. More... | |
const Vector2 & | GetNormal () |
Get normal. More... | |
![]() | |
CLine (const Vector2 &, float) | |
Constructor. 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... | |
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 Member Functions | |
void | Update () |
Update other properties from the end points. More... | |
![]() | |
Vector2 | Intersect (const CLine &) |
Get intersection point with line. More... | |
Vector2 | ClosestPt (const Vector2 &) |
Get closest point on line. More... | |
Protected Attributes | |
Vector2 | m_vPt0 |
Point at end of line segment. | |
Vector2 | m_vPt1 |
Point at other end of line segment. | |
Vector2 | m_vTangent0 |
Tangent at point 0. | |
Vector2 | m_vTangent1 |
Tangent at point 1. | |
Vector2 | m_vNormal |
Normal to line segment. | |
![]() | |
float | m_fGradient = 0.0f |
Gradient. | |
float | m_fInverseGradient = 0.0f |
Inverse gradient. | |
float | m_fYIntercept = 0.0f |
Intercept with Y axis. | |
float | m_fXIntercept = 0.0f |
Intercept with X axis. | |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
static float | m_fGravity = 0.0f |
Gravitational constant. | |
static float | m_fTimeStep = 0.0f |
Time step per animation frame (fictional). | |
A line segment is the portion of a line drawn from one point to another, that is, it is finite in both directions.
CLineSeg::CLineSeg | ( | CLineSegDesc & | r | ) |
Constructs a line segment described by a line segment descriptor.
r | Line segment descriptor. |
void CLineSeg::GetEndPts | ( | Vector2 & | p0, |
Vector2 & | p1 | ||
) |
Reader function for the end points of the line segment.
p0 | [out] One end. |
p1 | [out] The other end. |
const Vector2 & CLineSeg::GetNormal | ( | ) |
Reader function for the normal.
void CLineSeg::GetTangents | ( | Vector2 & | v0, |
Vector2 & | v1 | ||
) |
Reader function for the tangents at the end points of the line segment. These will be in the same order as the parameters of function GetEndPoints, that is, v0 will be the tangent at p0 and v1 will be the tangent at p1.
v0 | [out] One tangent. |
v1 | [out] The other tangent. |
|
virtual |
Collision detection with a dynamic circle.
c | [in, out] Contact descriptor for this collision. |
Reimplemented from CShape.
|
protected |
Update the line segment properties from its position and end points. The tangents and AABB are recomputed along with line properties such as the gradient.