CubbyFlow::Collider3 Class Referenceabstract

Abstract base class for generic collider object. More...

#include <Core/Collider/Collider3.h>

Inheritance diagram for CubbyFlow::Collider3:
CubbyFlow::ColliderSet3 CubbyFlow::RigidBodyCollider3

Classes

struct  ColliderQueryResult
 Internal query result structure. More...
 

Public Types

using OnBeginUpdateCallback = std::function< void(Collider3 *, double, double)>
 Callback function type for update calls. More...
 

Public Member Functions

 Collider3 ()
 Default constructor. More...
 
virtual ~Collider3 ()
 Default destructor. More...
 
virtual Vector3D VelocityAt (const Vector3D &point) const =0
 Returns the velocity of the collider at given point. More...
 
void ResolveCollision (double radius, double restitutionCoefficient, Vector3D *position, Vector3D *velocity)
 
double GetFrictionCoefficient () const
 Returns friction coefficient. More...
 
void SetFrictionCoefficient (double newFrictionCoeffient)
 Sets the friction coefficient. More...
 
const Surface3PtrGetSurface () const
 Returns the surface instance. More...
 
void Update (double currentTimeInSeconds, double timeIntervalInSeconds)
 Updates the collider state. More...
 
void SetOnBeginUpdateCallback (const OnBeginUpdateCallback &callback)
 Sets the callback function to be called when Collider3::update function is invoked. More...
 

Protected Member Functions

void SetSurface (const Surface3Ptr &newSurface)
 Assigns the surface instance from the subclass. More...
 
void GetClosestPoint (const Surface3Ptr &surface, const Vector3D &queryPoint, ColliderQueryResult *result) const
 Outputs closest point's information. More...
 
bool IsPenetrating (const ColliderQueryResult &colliderPoint, const Vector3D &position, double radius)
 Returns true if given point is in the opposite side of the surface. More...
 

Detailed Description

Abstract base class for generic collider object.

This class contains basic interfaces for colliders. Most of the functionalities are implemented within this class, except the member function Collider3::VelocityAt. This class also let the subclasses to provide a Surface3 instance to define collider surface using Collider3::SetSurface function.

Member Typedef Documentation

◆ OnBeginUpdateCallback

using CubbyFlow::Collider3::OnBeginUpdateCallback = std::function<void(Collider3*, double, double)>

Callback function type for update calls.

This type of callback function will take the collider pointer, current time, and time interval in seconds.

Constructor & Destructor Documentation

◆ Collider3()

CubbyFlow::Collider3::Collider3 ( )

Default constructor.

◆ ~Collider3()

virtual CubbyFlow::Collider3::~Collider3 ( )
virtual

Default destructor.

Member Function Documentation

◆ GetClosestPoint()

void CubbyFlow::Collider3::GetClosestPoint ( const Surface3Ptr surface,
const Vector3D queryPoint,
ColliderQueryResult result 
) const
protected

Outputs closest point's information.

◆ GetFrictionCoefficient()

double CubbyFlow::Collider3::GetFrictionCoefficient ( ) const

Returns friction coefficient.

◆ GetSurface()

const Surface3Ptr& CubbyFlow::Collider3::GetSurface ( ) const

Returns the surface instance.

◆ IsPenetrating()

bool CubbyFlow::Collider3::IsPenetrating ( const ColliderQueryResult colliderPoint,
const Vector3D position,
double  radius 
)
protected

Returns true if given point is in the opposite side of the surface.

◆ ResolveCollision()

void CubbyFlow::Collider3::ResolveCollision ( double  radius,
double  restitutionCoefficient,
Vector3D position,
Vector3D velocity 
)

Resolves collision for given point.

Parameters
radiusRadius of the colliding point.
restitutionCoefficientDefines the restitution effect.
positionInput and output position of the point.
velocityInput and output velocity of the point.

◆ SetFrictionCoefficient()

void CubbyFlow::Collider3::SetFrictionCoefficient ( double  newFrictionCoeffient)

Sets the friction coefficient.

This function assigns the friction coefficient to the collider. Any negative inputs will be clamped to zero.

◆ SetOnBeginUpdateCallback()

void CubbyFlow::Collider3::SetOnBeginUpdateCallback ( const OnBeginUpdateCallback callback)

Sets the callback function to be called when Collider3::update function is invoked.

The callback function takes current simulation time in seconds unit. Use this callback to track any motion or state changes related to this collider.

Parameters
[in]callbackThe callback function.

◆ SetSurface()

void CubbyFlow::Collider3::SetSurface ( const Surface3Ptr newSurface)
protected

Assigns the surface instance from the subclass.

◆ Update()

void CubbyFlow::Collider3::Update ( double  currentTimeInSeconds,
double  timeIntervalInSeconds 
)

Updates the collider state.

◆ VelocityAt()

virtual Vector3D CubbyFlow::Collider3::VelocityAt ( const Vector3D point) const
pure virtual

Returns the velocity of the collider at given point.

Implemented in CubbyFlow::RigidBodyCollider3, and CubbyFlow::ColliderSet3.


The documentation for this class was generated from the following file: