Nebula
Loading...
Searching...
No Matches
PhysicsFeature::PhysicsManager Class Reference

#include <physicsmanager.h>

Detailed Description

Inherits Game::Manager.

Private Member Functions

virtual __DeclareClass(PhysicsManager) __DeclareSingleton(PhysicsManager) public ~PhysicsManager ()
void OnActivate () override
 called when added to game server
void OnDeactivate () override
 called when removed from game server
void OnDecay () override
 An entity whose handle goes away takes its physx actor with it.
void OnCleanup (Game::World *world) override
 called before unloading game state
void InitPhysicsFrameEvent ()
 builds the processors and callbacks of the physics frame event.
void RebuildQueued ()
 Rebuilds everything which has been queued since the last frame, and nothing else.

Static Private Member Functions

static void InitPhysicsActor (Game::World *, Game::Entity, PhysicsFeature::PhysicsActor *)
static void InitPhysicsResource (Game::World *, Game::Entity, PhysicsFeature::PhysicsResource *)
static void InitRigidbody (Game::World *, Game::Entity, PhysicsFeature::Rigidbody *)
static void InitStaticBody (Game::World *, Game::Entity, PhysicsFeature::StaticBody *)
static void InitBoxCollider (Game::World *, Game::Entity, PhysicsFeature::BoxCollider *)
static void InitSphereCollider (Game::World *, Game::Entity, PhysicsFeature::SphereCollider *)
static void InitCapsuleCollider (Game::World *, Game::Entity, PhysicsFeature::CapsuleCollider *)
static void InitPlaneCollider (Game::World *, Game::Entity, PhysicsFeature::PlaneCollider *)
static void InitMeshCollider (Game::World *, Game::Entity, PhysicsFeature::MeshCollider *)
static void InitHeightFieldCollider (Game::World *, Game::Entity, PhysicsFeature::HeightFieldCollider *)
static void Mark (Game::World *, Game::Entity, uint32_t pending)
 queues up work for an entity, see PhysicsPending.
static void MarkShapeChanged (Game::World *, Game::Entity)
 the collider components of the entity were changed, or added to an entity which already had a handle.
static void MarkBodyChanged (Game::World *, Game::Entity)
 the body component of the entity changed: actor type, mass, damping, gravity, ccd, collision group or collision feedback.
static void MarkPoseChanged (Game::World *, Game::Entity)
 the entity moved.
static void MarkComponentChange (Game::World *, Game::Entity, Game::ComponentId)
 the value of a component was written on an entity which already has a handle.
static MemDb::TableSignature const & ColliderSignature ()
 the collider components as a signature.
static bool HasCollider (Game::World *, Game::Entity)
 true when the entity has any of the collider components
static bool IsColliderComponent (Game::ComponentId)
 true when the component is one of the collider components
static Physics::ShapeId GetShapeForEntity (Game::World *, Game::Entity)
static void ReleaseShapeForEntity (Game::World *, Game::Entity)
template<typename COMPONENT_TYPE>
static void OnColliderComponentDecay (Game::World *, Game::Entity, COMPONENT_TYPE *)
 decay callback of the collider components, see MarkShapeChanged
template<typename COMPONENT_TYPE>
static void OnBodyComponentDecay (Game::World *, Game::Entity, COMPONENT_TYPE *)
 decay callback of the body components, which releases the physx actor of the entity

Private Attributes

Util::Array< Game::Entity > rebuildQueue

Additional Inherited Members

Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::String & GetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code
Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Constructor & Destructor Documentation

◆ ~PhysicsManager()

PhysicsFeature::PhysicsManager::~PhysicsManager ( )
privatevirtual

Member Function Documentation

◆ ColliderSignature()

MemDb::TableSignature const & PhysicsFeature::PhysicsManager::ColliderSignature ( )
staticprivate

the collider components as a signature.

An entity is only allowed one of them, so this can be used e.g. to check if an entity already has any collider component.

◆ GetShapeForEntity()

Physics::ShapeId PhysicsFeature::PhysicsManager::GetShapeForEntity ( Game::World * world,
Game::Entity entity )
staticprivate

◆ HasCollider()

bool PhysicsFeature::PhysicsManager::HasCollider ( Game::World * world,
Game::Entity entity )
staticprivate

true when the entity has any of the collider components

True when the entity has any of the collider components.

◆ InitBoxCollider()

void PhysicsFeature::PhysicsManager::InitBoxCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::BoxCollider *  )
staticprivate

◆ InitCapsuleCollider()

void PhysicsFeature::PhysicsManager::InitCapsuleCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::CapsuleCollider *  )
staticprivate

◆ InitHeightFieldCollider()

void PhysicsFeature::PhysicsManager::InitHeightFieldCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::HeightFieldCollider *  )
staticprivate

◆ InitMeshCollider()

void PhysicsFeature::PhysicsManager::InitMeshCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::MeshCollider *  )
staticprivate

◆ InitPhysicsActor()

void PhysicsFeature::PhysicsManager::InitPhysicsActor ( Game::World * ,
Game::Entity entity,
PhysicsFeature::PhysicsActor * actor )
staticprivate

◆ InitPhysicsFrameEvent()

void PhysicsFeature::PhysicsManager::InitPhysicsFrameEvent ( )
private

builds the processors and callbacks of the physics frame event.

The order inside the event is what keeps the actor writes before the step and the polls after it

◆ InitPhysicsResource()

void PhysicsFeature::PhysicsManager::InitPhysicsResource ( Game::World * world,
Game::Entity entity,
PhysicsFeature::PhysicsResource *  )
staticprivate

◆ InitPlaneCollider()

void PhysicsFeature::PhysicsManager::InitPlaneCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::PlaneCollider *  )
staticprivate

◆ InitRigidbody()

void PhysicsFeature::PhysicsManager::InitRigidbody ( Game::World * world,
Game::Entity entity,
PhysicsFeature::Rigidbody *  )
staticprivate

◆ InitSphereCollider()

void PhysicsFeature::PhysicsManager::InitSphereCollider ( Game::World * world,
Game::Entity entity,
PhysicsFeature::SphereCollider *  )
staticprivate

◆ InitStaticBody()

void PhysicsFeature::PhysicsManager::InitStaticBody ( Game::World * world,
Game::Entity entity,
PhysicsFeature::StaticBody *  )
staticprivate

◆ IsColliderComponent()

bool PhysicsFeature::PhysicsManager::IsColliderComponent ( Game::ComponentId component)
staticprivate

true when the component is one of the collider components

True when the component is one of the collider components.

The signature only has the collider bits set, so a bit test against it is the membership test.

◆ Mark()

void PhysicsFeature::PhysicsManager::Mark ( Game::World * world,
Game::Entity entity,
uint32_t pending )
staticprivate

queues up work for an entity, see PhysicsPending.

An entity which is already queued keeps what is already queued, its component values are read when the queue is drained

◆ MarkBodyChanged()

void PhysicsFeature::PhysicsManager::MarkBodyChanged ( Game::World * world,
Game::Entity entity )
staticprivate

the body component of the entity changed: actor type, mass, damping, gravity, ccd, collision group or collision feedback.

Adding or removing one is picked up on its own, by the init and the decay callback

◆ MarkComponentChange()

void PhysicsFeature::PhysicsManager::MarkComponentChange ( Game::World * world,
Game::Entity entity,
Game::ComponentId component )
staticprivate

the value of a component was written on an entity which already has a handle.

mapping from a component to the mark its change means. Lets a tool that writes component values ping without knowing which physics components are bodies and which are colliders

◆ MarkPoseChanged()

void PhysicsFeature::PhysicsManager::MarkPoseChanged ( Game::World * world,
Game::Entity entity )
staticprivate

the entity moved.

The poll processors push and pull the pose of kinematic and dynamic bodies every frame, so this is only needed to move a static body, or a collider relative to its body

◆ MarkShapeChanged()

void PhysicsFeature::PhysicsManager::MarkShapeChanged ( Game::World * world,
Game::Entity entity )
staticprivate

the collider components of the entity were changed, or added to an entity which already had a handle.

Removing one is picked up on its own, by the decay callback. Also call this after an entity with a collider has been moved to another parent, which detaches its shape from the actor it used to hang off and attaches it to the new one.

◆ OnActivate()

void PhysicsFeature::PhysicsManager::OnActivate ( )
overrideprivatevirtual

called when added to game server

Reimplemented from Game::Manager.

◆ OnBodyComponentDecay()

template<typename COMPONENT_TYPE>
void PhysicsFeature::PhysicsManager::OnBodyComponentDecay ( Game::World * world,
Game::Entity entity,
COMPONENT_TYPE *  )
inlinestaticprivate

decay callback of the body components, which releases the physx actor of the entity

A body component which goes away means that the entity is no longer a body, so its actor, and with it every shape attached to it, is released.

◆ OnCleanup()

void PhysicsFeature::PhysicsManager::OnCleanup ( Game::World * world)
overrideprivatevirtual

called before unloading game state

Reimplemented from Game::Manager.

◆ OnColliderComponentDecay()

template<typename COMPONENT_TYPE>
void PhysicsFeature::PhysicsManager::OnColliderComponentDecay ( Game::World * world,
Game::Entity entity,
COMPONENT_TYPE *  )
inlinestaticprivate

decay callback of the collider components, see MarkShapeChanged

A collider component which goes away releases the shape its entity built.

◆ OnDeactivate()

void PhysicsFeature::PhysicsManager::OnDeactivate ( )
overrideprivatevirtual

called when removed from game server

Reimplemented from Game::Manager.

◆ OnDecay()

void PhysicsFeature::PhysicsManager::OnDecay ( )
overrideprivatevirtual

An entity whose handle goes away takes its physx actor with it.

A handle which owned no actor was a collider belonging to another entity, and that entity is marked so that the shapes it no longer has a component for are released.

Reimplemented from Game::Manager.

◆ RebuildQueued()

void PhysicsFeature::PhysicsManager::RebuildQueued ( )
private

Rebuilds everything which has been queued since the last frame, and nothing else.

◆ ReleaseShapeForEntity()

void PhysicsFeature::PhysicsManager::ReleaseShapeForEntity ( Game::World * world,
Game::Entity entity )
staticprivate

Member Data Documentation

◆ rebuildQueue

Util::Array<Game::Entity> PhysicsFeature::PhysicsManager::rebuildQueue
private

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