Hymn to Beauty
C++ 3D Engine
PhysicsManager Class Reference

Updates the physics of the world. More...

#include <PhysicsManager.hpp>

Public Member Functions

void Update (float deltaTime)
 Moves entities and updates the physics component. More...
 
void UpdateEntityTransforms ()
 
void OnTriggerEnter (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object, std::function< void()> callback)
 Set up listener for when |object| has entered |trigger|. More...
 
void ForgetTriggerEnter (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object)
 Stop listening for when |object| has entered |trigger|. More...
 
void OnTriggerRetain (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object, std::function< void()> callback)
 Set up listener for when |object| is intersecting |trigger|. More...
 
void ForgetTriggerRetain (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object)
 Stop listening for when |object| is intersecting |trigger|. More...
 
void OnTriggerLeave (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object, std::function< void()> callback)
 Set up listener for when |object| has left |trigger|. More...
 
void ForgetTriggerLeave (Utility::LockBox< Physics::Trigger > trigger, Component::RigidBody *object)
 Stop listening for when |object| has left |trigger|. More...
 
Component::RigidBodyCreateRigidBody (Entity *owner)
 Create rigid body component. More...
 
Component::ShapeCreateShape (Entity *owner)
 Create a component that represents a physical shape. More...
 
Utility::LockBox< Physics::TriggerCreateTrigger (std::shared_ptr< Physics::Shape > shape)
 
void ReleaseTriggerVolume (Utility::LockBox< Physics::Trigger > &&trigger)
 
void SetPosition (Utility::LockBox< Physics::Trigger > trigger, const glm::vec3 &position)
 Set the position of a trigger volume. More...
 
void SetShape (Component::Shape *comp, std::shared_ptr<::Physics::Shape > shape)
 Set the shape of a given Component::Shape component. More...
 
float GetMass (Component::RigidBody *comp)
 Get the mass of a rigid body component. More...
 
void SetShape (Utility::LockBox< Physics::Trigger > trigger, std::shared_ptr< Physics::Shape > shape)
 Set the volume shape of a trigger. More...
 
void SetMass (Component::RigidBody *comp, float mass)
 Set the mass of a Component::RigidBody component. More...
 
void SetFriction (Component::RigidBody *comp, float friction)
 Set the friction coefficient of a Component::RigidBody component. More...
 
void SetRollingFriction (Component::RigidBody *comp, float friction)
 
void SetSpinningFriction (Component::RigidBody *comp, float friction)
 
void SetRestitution (Component::RigidBody *comp, float cor)
 Set the restitution (bounciness) of a Component::RigidBody component. More...
 
void SetLinearDamping (Component::RigidBody *comp, float damping)
 Set the linear damping factor of a Component::RigidBody component. More...
 
void SetAngularDamping (Component::RigidBody *comp, float damping)
 Set the angular damping factor of a Component::RigidBody component. More...
 
void MakeKinematic (Component::RigidBody *comp)
 
void MakeDynamic (Component::RigidBody *comp)
 Turn a rigid body into a dynamic object. More...
 
void SetGhost (Component::RigidBody *comp, bool ghost)
 Enables/disables ghost functionality on a rigid body. More...
 
void ForceTransformSync (Component::RigidBody *comp)
 
void HaltMovement (Component::RigidBody *comp)
 Halts movement of a kinematic rigid body. More...
 
const std::vector< Component::Shape * > & GetShapeComponents () const
 Get all shape components. More...
 
void ClearKilledComponents ()
 Remove all killed components. More...
 
btDiscreteDynamicsWorld * GetDynamicsWorld ()
 Get the Bullet dynamics world. More...
 

Friends

class Hub
 

Detailed Description

Updates the physics of the world.

Member Function Documentation

◆ ClearKilledComponents()

void PhysicsManager::ClearKilledComponents ( )

Remove all killed components.

◆ CreateRigidBody()

Component::RigidBody * PhysicsManager::CreateRigidBody ( Entity owner)

Create rigid body component.

Parameters
ownerThe Entity that will own the component.
Returns
The created component.

◆ CreateShape()

Component::Shape * PhysicsManager::CreateShape ( Entity owner)

Create a component that represents a physical shape.

Parameters
ownerThe Entity that will own the component.
Returns
The created component.

◆ CreateTrigger()

Utility::LockBox< Physics::Trigger > PhysicsManager::CreateTrigger ( std::shared_ptr< Physics::Shape shape)

Create a trigger volume that can be used to check intersection events against physics bodies.

Parameters
shapeShape of the trigger volume.
Returns
A reference to the internal trigger.

◆ ForceTransformSync()

void PhysicsManager::ForceTransformSync ( Component::RigidBody comp)

Forces a dynamic rigid body to synchronize its transform with that of its owning entity during the next simulation iteration.

Parameters
compRigid body to synchronize.

◆ ForgetTriggerEnter()

void PhysicsManager::ForgetTriggerEnter ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object 
)

Stop listening for when |object| has entered |trigger|.

Parameters
triggerWhat trigger to stop listening on.
objectBody that is to be forgotten.

◆ ForgetTriggerLeave()

void PhysicsManager::ForgetTriggerLeave ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object 
)

Stop listening for when |object| has left |trigger|.

Parameters
triggerWhat trigger to stop listening on.
objectBody that is to be forgotten.

◆ ForgetTriggerRetain()

void PhysicsManager::ForgetTriggerRetain ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object 
)

Stop listening for when |object| is intersecting |trigger|.

Parameters
triggerWhat trigger to stop listening on.
objectBody that is to be forgotten.

◆ GetDynamicsWorld()

btDiscreteDynamicsWorld * PhysicsManager::GetDynamicsWorld ( )

Get the Bullet dynamics world.

Returns
The dynamics world.

◆ GetMass()

float PhysicsManager::GetMass ( Component::RigidBody comp)

Get the mass of a rigid body component.

Parameters
compRigid body component to get mass of.
Returns
Mass in kilograms.

◆ GetShapeComponents()

const std::vector< Component::Shape * > & PhysicsManager::GetShapeComponents ( ) const

Get all shape components.

Returns
All shape components.

◆ HaltMovement()

void PhysicsManager::HaltMovement ( Component::RigidBody comp)

Halts movement of a kinematic rigid body.

Parameters
compRigid body to halt.

◆ MakeDynamic()

void PhysicsManager::MakeDynamic ( Component::RigidBody comp)

Turn a rigid body into a dynamic object.

Parameters
compRigid body to make dynamic.

◆ MakeKinematic()

void PhysicsManager::MakeKinematic ( Component::RigidBody comp)

Turn a rigid body into a kinematic object, putting movement in the control of the programmer.

Parameters
compRigid body to make kinematic.

◆ OnTriggerEnter()

void PhysicsManager::OnTriggerEnter ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object,
std::function< void()>  callback 
)

Set up listener for when |object| has entered |trigger|.

Parameters
triggerWhat trigger to check against.
objectBody that is to enter the trigger volume.
callbackFunction to call when resolving event.

◆ OnTriggerLeave()

void PhysicsManager::OnTriggerLeave ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object,
std::function< void()>  callback 
)

Set up listener for when |object| has left |trigger|.

Parameters
triggerWhat trigger to check against.
objectBody that is to cause trigger to fire.
callbackFunction to call when resolving event.

◆ OnTriggerRetain()

void PhysicsManager::OnTriggerRetain ( Utility::LockBox< Physics::Trigger trigger,
Component::RigidBody object,
std::function< void()>  callback 
)

Set up listener for when |object| is intersecting |trigger|.

Parameters
triggerWhat trigger to check against.
objectBody that is to cause trigger to fire.
callbackFunction to call when resolving event.

◆ ReleaseTriggerVolume()

void PhysicsManager::ReleaseTriggerVolume ( Utility::LockBox< Physics::Trigger > &&  trigger)

Inform the physics manager that a given trigger volume will no longer be used so that it can be freed from memory.

Parameters
triggerTrigger volume to release.

◆ SetAngularDamping()

void PhysicsManager::SetAngularDamping ( Component::RigidBody comp,
float  damping 
)

Set the angular damping factor of a Component::RigidBody component.

Parameters
compRigid body to alter.
dampingAngular damping.

◆ SetFriction()

void PhysicsManager::SetFriction ( Component::RigidBody comp,
float  friction 
)

Set the friction coefficient of a Component::RigidBody component.

Parameters
compRigid body to alter.
frictionFriction coefficient.

◆ SetGhost()

void PhysicsManager::SetGhost ( Component::RigidBody comp,
bool  ghost 
)

Enables/disables ghost functionality on a rigid body.

Parameters
compRigid body to alter state of.
ghostTrue: makes the rigid object a ghost, disregarding all collisions. False: disables ghost state, reverting to kinematic or dynamic as before.

◆ SetLinearDamping()

void PhysicsManager::SetLinearDamping ( Component::RigidBody comp,
float  damping 
)

Set the linear damping factor of a Component::RigidBody component.

Parameters
compRigid body to alter.
dampingLinear damping.

◆ SetMass()

void PhysicsManager::SetMass ( Component::RigidBody comp,
float  mass 
)

Set the mass of a Component::RigidBody component.

Parameters
compThe component on which to set mass.
massMass in kilograms.

◆ SetPosition()

void PhysicsManager::SetPosition ( Utility::LockBox< Physics::Trigger trigger,
const glm::vec3 &  position 
)

Set the position of a trigger volume.

Parameters
triggerVolume to reposition.
positionNew position in world space.

◆ SetRestitution()

void PhysicsManager::SetRestitution ( Component::RigidBody comp,
float  cor 
)

Set the restitution (bounciness) of a Component::RigidBody component.

Parameters
compRigid body to alter.
corCoefficient of restitution.

◆ SetRollingFriction()

void PhysicsManager::SetRollingFriction ( Component::RigidBody comp,
float  friction 
)

Set the rolling friction coefficient of a Component::RigidBody component.

Parameters
compRigid body to alter.
frictionFriction coefficient.

◆ SetShape() [1/2]

void PhysicsManager::SetShape ( Component::Shape comp,
std::shared_ptr<::Physics::Shape shape 
)

Set the shape of a given Component::Shape component.

Parameters
compThe component on which to set the shape.
shapeA Physics::Shape object that holds the shape definition.

◆ SetShape() [2/2]

void PhysicsManager::SetShape ( Utility::LockBox< Physics::Trigger trigger,
std::shared_ptr< Physics::Shape shape 
)

Set the volume shape of a trigger.

Parameters
triggerTrigger to alter shape of.
shapeShape definition.

◆ SetSpinningFriction()

void PhysicsManager::SetSpinningFriction ( Component::RigidBody comp,
float  friction 
)

Set the spinning friction coefficient of a Component::RigidBody component.

Parameters
compRigid body to alter.
frictionFriction coefficient.

◆ Update()

void PhysicsManager::Update ( float  deltaTime)

Moves entities and updates the physics component.

Parameters
deltaTimeTime since last frame (in seconds).

◆ UpdateEntityTransforms()

void PhysicsManager::UpdateEntityTransforms ( )

Update transforms of entities according to positions of physics components.

Friends And Related Function Documentation

◆ Hub

friend class Hub
friend

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