Stowy Physics Engine 0.1.0
Loading...
Searching...
No Matches
stw::Rigidbody Struct Reference

A Rigidbody that has dynamics. More...

#include <Rigidbody.hpp>

Inheritance diagram for stw::Rigidbody:
Collaboration diagram for stw::Rigidbody:

Public Member Functions

 Rigidbody ()
 
const Vector2GravityForce () const
 Gets the force of the gravity on this body.
 
void SetGravityForce (const Vector2 &gravityForce)
 Sets the gravity force.
 
const Vector2Force () const
 Gets the force on this body.
 
void ApplyForce (const Vector2 &addedForce)
 Adds force to this body.
 
void SetForce (const Vector2 &force)
 Sets the force of this body.
 
const Vector2Velocity () const
 Gets the velocity of this body.
 
void SetVelocity (const Vector2 &velocity)
 Sets the velocity of this body.
 
float Mass () const
 Computes the mass of this body. Only the inverted mass is stored, so it's computed as 1 / InvMass();.
 
float InvMass () const
 Returns 1 / Mass of this body.
 
void SetMass (float mass)
 Sets the mass of this body.
 
bool TakesGravity () const
 Gets a boolean indicating whether this body takes gravity.
 
void SetTakesGravity (bool takesGravity)
 Sets a boolean indicating whether this body takes gravity.
 
float StaticFriction () const
 Gets the static friction of this body.
 
void SetStaticFriction (float staticFriction)
 Sets the static friction of this body.
 
float DynamicFriction () const
 Gets the dynamic friction of this body.
 
void SetDynamicFriction (float dynamicFriction)
 Sets the dynamic friction of this body.
 
float Restitution () const
 Gets the restitution of this body. Can be seen as the "Bounciness".
 
void SetRestitution (float restitution)
 Sets the restitution of this body. Can be seen as the "Bounciness".
 
- Public Member Functions inherited from stw::CollisionBody
 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.
 

Additional Inherited Members

- Public Attributes inherited from stw::CollisionBody
std::uint64_t id
 
- Protected Attributes inherited from stw::CollisionBody
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 Rigidbody that has dynamics.

Constructor & Destructor Documentation

◆ Rigidbody()

stw::Rigidbody::Rigidbody ( )

Member Function Documentation

◆ ApplyForce()

void stw::Rigidbody::ApplyForce ( const Vector2 & addedForce)

Adds force to this body.

Parameters
addedForceThe force to add to this body.

◆ DynamicFriction()

float stw::Rigidbody::DynamicFriction ( ) const

Gets the dynamic friction of this body.

Returns
The dynamic friction.

◆ Force()

const Vector2 & stw::Rigidbody::Force ( ) const

Gets the force on this body.

Returns
The force on this body.

◆ GravityForce()

const Vector2 & stw::Rigidbody::GravityForce ( ) const

Gets the force of the gravity on this body.

Returns
The force of the gravity.

◆ InvMass()

float stw::Rigidbody::InvMass ( ) const

Returns 1 / Mass of this body.

Returns
The inverted mass of this body.

◆ Mass()

float stw::Rigidbody::Mass ( ) const

Computes the mass of this body. Only the inverted mass is stored, so it's computed as 1 / InvMass();.

See also
InvMass()
Returns
The mass of this body.

◆ Restitution()

float stw::Rigidbody::Restitution ( ) const

Gets the restitution of this body. Can be seen as the "Bounciness".

Returns
The restitution.

◆ SetDynamicFriction()

void stw::Rigidbody::SetDynamicFriction ( float dynamicFriction)

Sets the dynamic friction of this body.

Parameters
dynamicFrictionThe new dynamic friction.

◆ SetForce()

void stw::Rigidbody::SetForce ( const Vector2 & force)

Sets the force of this body.

Parameters
forceThe new force.

◆ SetGravityForce()

void stw::Rigidbody::SetGravityForce ( const Vector2 & gravityForce)

Sets the gravity force.

Parameters
gravityForceNew gravity force.

◆ SetMass()

void stw::Rigidbody::SetMass ( float mass)

Sets the mass of this body.

Parameters
massThe new mass.

◆ SetRestitution()

void stw::Rigidbody::SetRestitution ( float restitution)

Sets the restitution of this body. Can be seen as the "Bounciness".

Parameters
restitutionThe new restitution.

◆ SetStaticFriction()

void stw::Rigidbody::SetStaticFriction ( float staticFriction)

Sets the static friction of this body.

Parameters
staticFrictionThe new static friction.

◆ SetTakesGravity()

void stw::Rigidbody::SetTakesGravity ( bool takesGravity)

Sets a boolean indicating whether this body takes gravity.

Parameters
takesGravityThe new takesGravity.
Here is the call graph for this function:

◆ SetVelocity()

void stw::Rigidbody::SetVelocity ( const Vector2 & velocity)

Sets the velocity of this body.

Parameters
velocityThe new velocity.

◆ StaticFriction()

float stw::Rigidbody::StaticFriction ( ) const

Gets the static friction of this body.

Returns
The static friction.

◆ TakesGravity()

bool stw::Rigidbody::TakesGravity ( ) const

Gets a boolean indicating whether this body takes gravity.

Returns
True if this body takes gravity.

◆ Velocity()

const Vector2 & stw::Rigidbody::Velocity ( ) const

Gets the velocity of this body.

Returns
The velocity of this body.

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