Abstract base class for generic collider object. More...
#include <Core/Collider/Collider3.h>
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 Surface3Ptr & | 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 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 |
Default destructor.
Member Function Documentation
◆ GetClosestPoint()
|
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()
|
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
-
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::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] callback The callback function.
◆ SetSurface()
|
protected |
Assigns the surface instance from the subclass.
◆ Update()
void CubbyFlow::Collider3::Update | ( | double | currentTimeInSeconds, |
double | timeIntervalInSeconds | ||
) |
Updates the collider state.
◆ VelocityAt()
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:
- Core/Collider/Collider3.h