The Shapes Library
Game Physics with Bespoke Code
Loading...
Searching...
No Matches
Shapes::CDynamicCircle Class Reference

Dynamic circle. More...

#include <DynamicCircle.h>

Inheritance diagram for Shapes::CDynamicCircle:
Collaboration diagram for Shapes::CDynamicCircle:

Public Member Functions

 CDynamicCircle (const CDynamicCircleDesc &)
 Constructor.
 
void move ()
 Move using Euler integration.
 
const bool AABBCollide (CDynamicCircle *) const
 Collide detection using AABBs.
 
void CollisionResponse (const CContactDesc &)
 Collision response.
 
const Vector2 GetVel () const
 Get velocity.

 
void SetVel (const Vector2 &)
 Set velocity.
 
- Public Member Functions inherited from Shapes::CCircle
 CCircle (const CCircleDesc &)
 Constructor.
 
const bool CollisionDetected (CContactDesc &) const
 Collision detection.
 
const bool PtInCircle (const Vector2 &) const
 Point in circle test.
 
const Vector2 ClosestPt (const Vector2 &) const
 Closest point on circle.
 
const bool Tangents (const Vector2 &, Vector2 &, Vector2 &) const
 Tangents through external point.
 
const bool Tangents (const CCircle *, CLineSegDesc &, CLineSegDesc &) const
 Common tangents.
 
const bool Tangent (const CCircle *, CLineSegDesc &) const
 Common tangent.
 
const float GetRadius () const
 Get radius.
 
- Public Member Functions inherited from Shapes::CShape
 CShape (const CShapeDesc &)
 Constructor.
 
virtual ~CShape ()
 Destructor.
 
const eShape GetShapeType () const
 Get shape type.
 
const eMotion GetMotionType () const
 Get motion type.
 
const CAabb2DGetAABB () const
 Get AABB.
 
const bool GetSensor () const
 Is this shape a sensor?
 
const Vector2 & GetPos () const
 Get position.
 
void SetPos (const Vector2 &)
 Set position.
 
void SetAABBPoint (const Vector2 &)
 Set AABB point.
 
void AddAABBPoint (const Vector2 &)
 Add AABB point.
 
void SetCanCollide (bool=true)
 Turn collisions on or off.
 
const bool GetCanCollide () const
 Get whether shape can collide.
 
const bool GetRotating () const
 Get whether rotating.
 
void SetRotating (bool)
 Start or stop rotating.
 
const float GetOrientation () const
 Get orientation.
 
void SetOrientation (float)
 Set orientation.
 
const float GetRotSpeed () const
 Get rotation speed.
 
void SetRotSpeed (float)
 Set rotation speed.
 
const Vector2 & GetRotCenter () const
 Get rotation speed.
 
void SetRotCenter (const Vector2 &)
 Set center of rotation.
 
const float GetElasticity () const
 Get elasticity.
 
void * GetUserPtr () const
 Get user pointer.
 
void SetUserPtr (void *)
 Set user pointer.
 
virtual void Rotate (const Vector2 &, float)
 Rotate.
 
virtual void Reset ()
 Reset orientation.
 

Private Member Functions

void CollisionResponseStatic (const CContactDesc &)
 Collision response for static shape.
 
void CollisionResponseKinematic (const CContactDesc &)
 Collision response for kinematic shape.
 
void CollisionResponseDynamic (const CContactDesc &)
 Collision response for dynamic shape.
 

Private Attributes

Vector2 m_vVel
 Velocity. Speed is measured in pixels per second.
 
float m_fMass = 0.0f
 Mass.
 

Additional Inherited Members

- Protected Attributes inherited from Shapes::CCircle
float m_fRadius = 0.0f
 Radius.
 
float m_fRadiusSq = 0.0f
 Radius squared, for fast distance calc.
 
- Protected Attributes inherited from Shapes::CShape
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 Protected Attributes inherited from Shapes::CShapeCommon
static float m_fGravity = 0.0f
 Gravitational constant.
 
static float m_fTimeStep = 0.0f
 Time step per animation frame (fictional).
 

Detailed Description

A dynamic circle is a circle shape that moves and can collide with static, kinematic, and dynamic shapes.

Constructor & Destructor Documentation

◆ CDynamicCircle()

CDynamicCircle::CDynamicCircle ( const CDynamicCircleDesc & r)

Constructs a dynamic circle described by a dynamic circle descriptor.

Parameters
rDynamic circle descriptor.
Here is the call graph for this function:

Member Function Documentation

◆ AABBCollide()

const bool CDynamicCircle::AABBCollide ( CDynamicCircle * pCirc) const

Does the AABB for this dynamic circle overlap the AABB for another dynamic circle?

Parameters
pCircPointer to a dynamic circle.
Returns
true if their AABBs overlap.

◆ CollisionResponse()

void CDynamicCircle::CollisionResponse ( const CContactDesc & cd)

Collision response for a dynamic circle colliding with a shape.

Parameters
cdContact descriptor which has been filled in by collision detection.
Here is the call graph for this function:

◆ CollisionResponseDynamic()

void CDynamicCircle::CollisionResponseDynamic ( const CContactDesc & cd)
private

Collision response for a dynamic circle colliding with a dynamic shape.

Parameters
cdContact descriptor which has been filled in by collision detection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CollisionResponseKinematic()

void CDynamicCircle::CollisionResponseKinematic ( const CContactDesc & cd)
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.

Parameters
cdContact descriptor that has been filled in by collision detection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CollisionResponseStatic()

void CDynamicCircle::CollisionResponseStatic ( const CContactDesc & cd)
private

Collision response for a dynamic circle colliding with a static shape.

Parameters
cdContact descriptor which has been filled in by collision detection.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVel()

const Vector2 CDynamicCircle::GetVel ( ) const

Reader function for the velocity.

Returns
The velocity.
Here is the caller graph for this function:

◆ move()

void CDynamicCircle::move ( )
virtual

Move the shape using Euler integration, depending on the physics time step and the gravity constant.

Reimplemented from Shapes::CShape.

Here is the call graph for this function:

◆ SetVel()

void CDynamicCircle::SetVel ( const Vector2 & v)

Set the velocity to a new value.

Parameters
vNew velocity.