Stowy Physics Engine 0.1.0
Loading...
Searching...
No Matches
stw::CollisionBody Class Reference

A body that can receive collisions. More...

#include <CollisionBody.hpp>

Inheritance diagram for stw::CollisionBody:
Collaboration diagram for stw::CollisionBody:

Public Member Functions

 CollisionBody ()
 
TransformTrans ()
 Gets the transform of the body.
 
void SetTransform (const Transform &transform)
 Sets the transform of the body.
 
ColliderCol () const
 Gets the collider of the body.
 
void SetCollider (Collider *collider)
 Sets the collider of the body.
 
bool IsTrigger () const
 A boolean saying if the collider is a trigger collider. This means that it will not have a collision response and will only have a callback.
 
void SetIsTrigger (bool isTrigger)
 Sets is trigger on the body. True means that it will not have a collision response and will only have a callback.
 
void SetCollisionCallback (const std::function< void(const Collision &, float)> &callback)
 Sets the collision callback function.
 
void OnCollision (const Collision &collision, float deltaTime) const
 Triggers the collision callback function.
 
const Vector2Position () const
 Gets the position of the body in the world.
 
void SetPosition (const Vector2 &position)
 Sets the position of the body in the world.
 
bool IsKinematic () const
 Gets a boolean that indicates if this body will receive a collision response.
 
void SetIsKinematic (bool isKinematic)
 Sets a boolean that indicates if this body will receive a collision response.
 
bool IsDynamic () const
 Gets a boolean indicating if this body is dynamic. This means that this is a Rigidbody.
 

Public Attributes

std::uint64_t id
 

Protected Attributes

Transform _transform {}
 
Transform _lastTransform {}
 
Collider_collider {}
 
bool _isTrigger = false
 
bool _isKinematic = false
 
bool _isDynamic = false
 
std::function< void(const Collision &, float) _onCollisions )
 

Detailed Description

A body that can receive collisions.

Constructor & Destructor Documentation

◆ CollisionBody()

stw::CollisionBody::CollisionBody ( )

Member Function Documentation

◆ Col()

Collider * stw::CollisionBody::Col ( ) const

Gets the collider of the body.

Returns
The collider of the body.

◆ IsDynamic()

bool stw::CollisionBody::IsDynamic ( ) const

Gets a boolean indicating if this body is dynamic. This means that this is a Rigidbody.

See also
Rigidbody
Returns
A boolean indicating if this body is dynamic.

◆ IsKinematic()

bool stw::CollisionBody::IsKinematic ( ) const

Gets a boolean that indicates if this body will receive a collision response.

Returns
A boolean that indicates if this body is kinematic.

◆ IsTrigger()

bool stw::CollisionBody::IsTrigger ( ) const

A boolean saying if the collider is a trigger collider. This means that it will not have a collision response and will only have a callback.

Returns
If the collider is a trigger collider.

◆ OnCollision()

void stw::CollisionBody::OnCollision ( const Collision & collision,
float deltaTime ) const

Triggers the collision callback function.

Parameters
collisionObject representing the collision.
deltaTimeThe time elapsed since the last frame.

◆ Position()

const Vector2 & stw::CollisionBody::Position ( ) const

Gets the position of the body in the world.

Returns
The position of the body in the world.

◆ SetCollider()

void stw::CollisionBody::SetCollider ( Collider * collider)

Sets the collider of the body.

Parameters
colliderThe collider to set on the body.

◆ SetCollisionCallback()

void stw::CollisionBody::SetCollisionCallback ( const std::function< void(const Collision &, float)> & callback)

Sets the collision callback function.

Parameters
callbackThe callback function.

◆ SetIsKinematic()

void stw::CollisionBody::SetIsKinematic ( bool isKinematic)

Sets a boolean that indicates if this body will receive a collision response.

Parameters
isKinematicThe new isKinematic status.

◆ SetIsTrigger()

void stw::CollisionBody::SetIsTrigger ( bool isTrigger)

Sets is trigger on the body. True means that it will not have a collision response and will only have a callback.

Parameters
isTriggerThe boolean saying if the collider is trigger.

◆ SetPosition()

void stw::CollisionBody::SetPosition ( const Vector2 & position)

Sets the position of the body in the world.

Parameters
positionThe new position of the body.

◆ SetTransform()

void stw::CollisionBody::SetTransform ( const Transform & transform)

Sets the transform of the body.

Parameters
transformTransform to set to the body.

◆ Trans()

Transform * stw::CollisionBody::Trans ( )

Gets the transform of the body.

Returns
The transform of the body.

Member Data Documentation

◆ _collider

Collider* stw::CollisionBody::_collider {}
protected

◆ _isDynamic

bool stw::CollisionBody::_isDynamic = false
protected

◆ _isKinematic

bool stw::CollisionBody::_isKinematic = false
protected

◆ _isTrigger

bool stw::CollisionBody::_isTrigger = false
protected

◆ _lastTransform

Transform stw::CollisionBody::_lastTransform {}
protected

◆ _onCollisions

std::function<void(const Collision&, float) stw::CollisionBody::_onCollisions)
protected

◆ _transform

Transform stw::CollisionBody::_transform {}
protected

◆ id

std::uint64_t stw::CollisionBody::id

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