CubbyFlow::Collider< N > Class Template Referenceabstract

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

#include <Core/Geometry/Collider.hpp>

Inheritance diagram for CubbyFlow::Collider< N >:
CubbyFlow::ColliderSet< N > CubbyFlow::RigidBodyCollider< N >

Classes

struct  ColliderQueryResult
 Internal query result structure. More...
 

Public Types

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

Public Member Functions

 Collider ()=default
 Default constructor. More...
 
virtual ~Collider ()=default
 Default virtual destructor. More...
 
 Collider (const Collider &other)=default
 Default copy constructor. More...
 
 Collider (Collider &&other) noexcept=default
 Default move constructor. More...
 
Collideroperator= (const Collider &other)=default
 Default copy assignment operator. More...
 
Collideroperator= (Collider &&other) noexcept=default
 Default move assignment operator. More...
 
virtual Vector< double, N > VelocityAt (const Vector< double, N > &point) const =0
 Returns the velocity of the collider at given point. More...
 
void ResolveCollision (double radius, double restitutionCoefficient, Vector< double, N > *position, Vector< double, N > *velocity)
 
double GetFrictionCoefficient () const
 Returns friction coefficient. More...
 
void SetFrictionCoefficient (double newFrictionCoefficient)
 Sets the friction coefficient. More...
 
const std::shared_ptr< Surface< N > > & GetSurface () 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 Collider::update function is invoked. More...
 

Protected Member Functions

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

Detailed Description

template<size_t N>
class CubbyFlow::Collider< N >

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 Collider::VelocityAt. This class also let the subclasses to provide a Surface instance to define collider surface using Collider::SetSurface function.

Member Typedef Documentation

◆ OnBeginUpdateCallback

template<size_t N>
using CubbyFlow::Collider< N >::OnBeginUpdateCallback = std::function<void(Collider*, 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

◆ Collider() [1/3]

template<size_t N>
CubbyFlow::Collider< N >::Collider ( )
default

Default constructor.

◆ ~Collider()

template<size_t N>
virtual CubbyFlow::Collider< N >::~Collider ( )
virtualdefault

Default virtual destructor.

◆ Collider() [2/3]

template<size_t N>
CubbyFlow::Collider< N >::Collider ( const Collider< N > &  other)
default

Default copy constructor.

◆ Collider() [3/3]

template<size_t N>
CubbyFlow::Collider< N >::Collider ( Collider< N > &&  other)
defaultnoexcept

Default move constructor.

Member Function Documentation

◆ GetClosestPoint()

template<size_t N>
void CubbyFlow::Collider< N >::GetClosestPoint ( const std::shared_ptr< Surface< N >> &  surface,
const Vector< double, N > &  queryPoint,
ColliderQueryResult result 
) const
protected

Outputs closest point's information.

◆ GetFrictionCoefficient()

template<size_t N>
double CubbyFlow::Collider< N >::GetFrictionCoefficient ( ) const

Returns friction coefficient.

◆ GetSurface()

template<size_t N>
const std::shared_ptr<Surface<N> >& CubbyFlow::Collider< N >::GetSurface ( ) const

Returns the surface instance.

◆ IsPenetrating()

template<size_t N>
bool CubbyFlow::Collider< N >::IsPenetrating ( const ColliderQueryResult colliderPoint,
const Vector< double, N > &  position,
double  radius 
)
protected

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

◆ operator=() [1/2]

template<size_t N>
Collider& CubbyFlow::Collider< N >::operator= ( const Collider< N > &  other)
default

Default copy assignment operator.

◆ operator=() [2/2]

template<size_t N>
Collider& CubbyFlow::Collider< N >::operator= ( Collider< N > &&  other)
defaultnoexcept

Default move assignment operator.

◆ ResolveCollision()

template<size_t N>
void CubbyFlow::Collider< N >::ResolveCollision ( double  radius,
double  restitutionCoefficient,
Vector< double, N > *  position,
Vector< double, N > *  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()

template<size_t N>
void CubbyFlow::Collider< N >::SetFrictionCoefficient ( double  newFrictionCoefficient)

Sets the friction coefficient.

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

◆ SetOnBeginUpdateCallback()

template<size_t N>
void CubbyFlow::Collider< N >::SetOnBeginUpdateCallback ( const OnBeginUpdateCallback callback)

Sets the callback function to be called when Collider::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()

template<size_t N>
void CubbyFlow::Collider< N >::SetSurface ( const std::shared_ptr< Surface< N >> &  newSurface)
protected

Assigns the surface instance from the subclass.

◆ Update()

template<size_t N>
void CubbyFlow::Collider< N >::Update ( double  currentTimeInSeconds,
double  timeIntervalInSeconds 
)

Updates the collider state.

◆ VelocityAt()

template<size_t N>
virtual Vector<double, N> CubbyFlow::Collider< N >::VelocityAt ( const Vector< double, N > &  point) const
pure virtual

Returns the velocity of the collider at given point.

Implemented in CubbyFlow::RigidBodyCollider< N >, and CubbyFlow::ColliderSet< N >.


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