Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Physics::Resource::PhysicsManager Class Reference

#include <PhysicsManager.hpp>

Public Member Functions

 PhysicsManager ()
 ~PhysicsManager ()=default
void Init (Engine::Core &core)
 Initialize the physics system.
JPH::PhysicsSystem & GetPhysicsSystem ()
 Get a reference to the physics system.
JPH::BodyInterface & GetBodyInterface ()
 Get a reference to the body interface for manipulating bodies.
JPH::TempAllocator * GetTempAllocator ()
 Get a pointer to the temp allocator.
JPH::JobSystem * GetJobSystem ()
 Get a pointer to the job system.
int GetCollisionSteps ()
 Get the number of collision steps.
void SetCollisionSteps (int steps)
 Set the number of collision steps.
std::shared_ptr< Utils::ContactListenerImplGetContactListener ()
 Get the contact listener, casted back as a ContactListenerImpl.
bool IsPhysicsActivated () const
 Check if the physics system should be updated.
void ActivatePhysics ()
 Set the physics system to be updated.
void DeactivatePhysics ()
 Set the physics system to not be updated.

Private Attributes

std::shared_ptr< JPH::Factory > _factory
std::shared_ptr< JPH::PhysicsSystem > _physicsSystem
std::shared_ptr< JPH::BroadPhaseLayerInterface > _broadPhaseLayerInterface
std::shared_ptr< JPH::ObjectVsBroadPhaseLayerFilter > _objectVsBroadPhaseLayerFilter
std::shared_ptr< JPH::ObjectLayerPairFilter > _objectLayerPairFilter
std::shared_ptr< JPH::TempAllocator > _tempAllocator
std::shared_ptr< JPH::JobSystem > _jobSystem
std::shared_ptr< JPH::ContactListener > _contactListener
bool _shouldUpdatePhysics = true
int _collisionSteps = 1

Detailed Description

Constructor & Destructor Documentation

◆ PhysicsManager()

Physics::Resource::PhysicsManager::PhysicsManager ( )

Constructor.

◆ ~PhysicsManager()

Physics::Resource::PhysicsManager::~PhysicsManager ( )
default

Destructor.

Member Function Documentation

◆ ActivatePhysics()

void Physics::Resource::PhysicsManager::ActivatePhysics ( )
inline

Set the physics system to be updated.

◆ DeactivatePhysics()

void Physics::Resource::PhysicsManager::DeactivatePhysics ( )
inline

Set the physics system to not be updated.

◆ GetBodyInterface()

JPH::BodyInterface & Physics::Resource::PhysicsManager::GetBodyInterface ( )
inline

Get a reference to the body interface for manipulating bodies.

Returns
JPH::BodyInterface&
Note
Use this to apply forces, impulses, or modify body properties.

◆ GetCollisionSteps()

int Physics::Resource::PhysicsManager::GetCollisionSteps ( )
inline

Get the number of collision steps.

Returns
int

◆ GetContactListener()

std::shared_ptr< Utils::ContactListenerImpl > Physics::Resource::PhysicsManager::GetContactListener ( )
inline

Get the contact listener, casted back as a ContactListenerImpl.

Returns
std::shared_ptr<Utils::ContactListenerImpl>
Note
This is safe because the contact listener is always created as a ContactListenerImpl.

◆ GetJobSystem()

JPH::JobSystem * Physics::Resource::PhysicsManager::GetJobSystem ( )
inline

Get a pointer to the job system.

Returns
JPH::JobSystem*
Note
A raw pointer is returned for ease of use with JoltPhysics APIs. Memory ownership is managed by the PhysicsManager.

◆ GetPhysicsSystem()

JPH::PhysicsSystem & Physics::Resource::PhysicsManager::GetPhysicsSystem ( )
inline

Get a reference to the physics system.

Returns
JPH::PhysicsSystem&

◆ GetTempAllocator()

JPH::TempAllocator * Physics::Resource::PhysicsManager::GetTempAllocator ( )
inline

Get a pointer to the temp allocator.

Returns
JPH::TempAllocator*
Note
A raw pointer is returned for ease of use with JoltPhysics APIs. Memory ownership is managed by the PhysicsManager.

◆ Init()

void Physics::Resource::PhysicsManager::Init ( Engine::Core & core)

Initialize the physics system.

Parameters
coreA reference to the core engine, used for the contact listener.
Returns
void
Examples
/home/runner/work/EngineSquared/EngineSquared/src/plugin/physics/src/system/ConstraintSystem.hpp.

◆ IsPhysicsActivated()

bool Physics::Resource::PhysicsManager::IsPhysicsActivated ( ) const
inline

Check if the physics system should be updated.

Returns
true if the physics system should be updated, false otherwise.

◆ SetCollisionSteps()

void Physics::Resource::PhysicsManager::SetCollisionSteps ( int steps)
inline

Set the number of collision steps.

Parameters
steps
Note
This will be used to set the number of steps in the physics system.
Returns
void

Member Data Documentation

◆ _broadPhaseLayerInterface

std::shared_ptr<JPH::BroadPhaseLayerInterface> Physics::Resource::PhysicsManager::_broadPhaseLayerInterface
private

◆ _collisionSteps

int Physics::Resource::PhysicsManager::_collisionSteps = 1
private

◆ _contactListener

std::shared_ptr<JPH::ContactListener> Physics::Resource::PhysicsManager::_contactListener
private

◆ _factory

std::shared_ptr<JPH::Factory> Physics::Resource::PhysicsManager::_factory
private

◆ _jobSystem

std::shared_ptr<JPH::JobSystem> Physics::Resource::PhysicsManager::_jobSystem
private

◆ _objectLayerPairFilter

std::shared_ptr<JPH::ObjectLayerPairFilter> Physics::Resource::PhysicsManager::_objectLayerPairFilter
private

◆ _objectVsBroadPhaseLayerFilter

std::shared_ptr<JPH::ObjectVsBroadPhaseLayerFilter> Physics::Resource::PhysicsManager::_objectVsBroadPhaseLayerFilter
private

◆ _physicsSystem

std::shared_ptr<JPH::PhysicsSystem> Physics::Resource::PhysicsManager::_physicsSystem
private

◆ _shouldUpdatePhysics

bool Physics::Resource::PhysicsManager::_shouldUpdatePhysics = true
private

◆ _tempAllocator

std::shared_ptr<JPH::TempAllocator> Physics::Resource::PhysicsManager::_tempAllocator
private

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