Abstract base class for generic collider object. More...
#include <Core/Geometry/Collider.hpp>
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... | |
Collider & | operator= (const Collider &other)=default |
Default copy assignment operator. More... | |
Collider & | operator= (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
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]
|
default |
Default constructor.
◆ ~Collider()
|
virtualdefault |
Default virtual destructor.
◆ Collider() [2/3]
|
default |
Default copy constructor.
◆ Collider() [3/3]
|
defaultnoexcept |
Default move constructor.
Member Function Documentation
◆ GetClosestPoint()
|
protected |
Outputs closest point's information.
◆ GetFrictionCoefficient()
double CubbyFlow::Collider< N >::GetFrictionCoefficient | ( | ) | const |
Returns friction coefficient.
◆ GetSurface()
const std::shared_ptr<Surface<N> >& CubbyFlow::Collider< N >::GetSurface | ( | ) | const |
Returns the surface instance.
◆ IsPenetrating()
|
protected |
Returns true if given point is in the opposite side of the surface.
◆ operator=() [1/2]
|
default |
Default copy assignment operator.
◆ operator=() [2/2]
|
defaultnoexcept |
Default move assignment operator.
◆ ResolveCollision()
void CubbyFlow::Collider< N >::ResolveCollision | ( | double | radius, |
double | restitutionCoefficient, | ||
Vector< double, N > * | position, | ||
Vector< double, N > * | velocity | ||
) |
Resolves collision for given point.
- Parameters
-
radius Radius of the colliding point. restitutionCoefficient Defines the restitution effect. position Input and output position of the point. velocity Input and output velocity of the point.
◆ SetFrictionCoefficient()
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()
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] callback The callback function.
◆ SetSurface()
|
protected |
Assigns the surface instance from the subclass.
◆ Update()
void CubbyFlow::Collider< N >::Update | ( | double | currentTimeInSeconds, |
double | timeIntervalInSeconds | ||
) |
Updates the collider state.
◆ VelocityAt()
|
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:
- Core/Geometry/Collider.hpp