Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::PhysicsManager Class Reference

Owns the Bullet btDiscreteDynamicsWorld and all auxiliary collision structures (broadphase, dispatcher, solver). More...

#include <PhysicsManager.h>

Public Member Functions

 PhysicsManager ()
 
 ~PhysicsManager ()
 
void Init ()
 Allocate broadphase, dispatcher, solver, and dynamics world. Call once.
 
void Update (float deltaTime)
 Step the simulation by deltaTime seconds.
 
void AddRigidBody (RigidBody *body)
 Register a rigid body so it participates in simulation and collision.
 
void RemoveRigidBody (RigidBody *body)
 Unregister a rigid body (e.g. when its owning component is destroyed).
 
bool Raycast (const vec3 &from, const vec3 &to, RayHit &out)
 
btDiscreteDynamicsWorld * GetWorld ()
 Raw pointer to the underlying Bullet world (for advanced/internal use).
 

Detailed Description

Owns the Bullet btDiscreteDynamicsWorld and all auxiliary collision structures (broadphase, dispatcher, solver).

One instance lives on the Engine singleton. PhysicsComponent pushes its RigidBody here via AddRigidBody; Engine::Run calls Update once per frame to step the simulation.

Definition at line 33 of file PhysicsManager.h.

Constructor & Destructor Documentation

◆ PhysicsManager()

mnd::PhysicsManager::PhysicsManager ( )

Definition at line 13 of file PhysicsManager.cpp.

◆ ~PhysicsManager()

mnd::PhysicsManager::~PhysicsManager ( )

Definition at line 15 of file PhysicsManager.cpp.

Member Function Documentation

◆ AddRigidBody()

void mnd::PhysicsManager::AddRigidBody ( RigidBody body)

Register a rigid body so it participates in simulation and collision.

Definition at line 67 of file PhysicsManager.cpp.

References mnd::RigidBody::GetBody(), and mnd::RigidBody::SetAddedToWorld().

Referenced by mnd::PhysicsComponent::Init().

◆ GetWorld()

btDiscreteDynamicsWorld * mnd::PhysicsManager::GetWorld ( )

Raw pointer to the underlying Bullet world (for advanced/internal use).

Definition at line 95 of file PhysicsManager.cpp.

Referenced by mnd::KinematicCharacterController::KinematicCharacterController(), and mnd::KinematicCharacterController::~KinematicCharacterController().

◆ Init()

void mnd::PhysicsManager::Init ( )

Allocate broadphase, dispatcher, solver, and dynamics world. Call once.

Definition at line 17 of file PhysicsManager.cpp.

References kGravity.

Referenced by mnd::Engine::Init().

◆ Raycast()

bool mnd::PhysicsManager::Raycast ( const vec3 from,
const vec3 to,
RayHit out 
)

Cast a ray from from to to and fill out with the closest hit. out.object is the GameObject behind the hit collision object, when one has been set via CollisionObject::SetOwner; otherwise null.

Returns
true if any collider was hit.

Definition at line 100 of file PhysicsManager.cpp.

References mnd::RayHit::fraction, mnd::RayHit::normal, mnd::RayHit::object, and mnd::RayHit::point.

◆ RemoveRigidBody()

void mnd::PhysicsManager::RemoveRigidBody ( RigidBody body)

Unregister a rigid body (e.g. when its owning component is destroyed).

Definition at line 81 of file PhysicsManager.cpp.

References mnd::RigidBody::GetBody(), and mnd::RigidBody::SetAddedToWorld().

Referenced by mnd::RigidBody::~RigidBody().

◆ Update()

void mnd::PhysicsManager::Update ( float  deltaTime)

Step the simulation by deltaTime seconds.

Definition at line 30 of file PhysicsManager.cpp.

References kFixedTimeStep, and kMaxSubSteps.

Referenced by mnd::Engine::Run().


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