Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::PhysicsComponent Class Referenceabstract

Component bridge between a GameObject and the physics world. More...

#include <PhysicsComponent.h>

+ Inheritance diagram for mnd::PhysicsComponent:
+ Collaboration diagram for mnd::PhysicsComponent:

Public Member Functions

 PhysicsComponent ()=default
 
 PhysicsComponent (const std::shared_ptr< RigidBody > &body)
 Construct from an already-built rigid body (skips JSON parsing).
 
void LoadProperties (const nlohmann::json &json) override
 Parse collider + body sub-objects and build the RigidBody.
 
void Init () override
 Register the rigid body with the PhysicsManager.
 
void Update (float deltaTime) override
 Copy the simulated pose onto the owning GameObject.
 
void SetRigidBody (const std::shared_ptr< RigidBody > &body)
 Replace the component's rigid body at runtime.
 
const std::shared_ptr< RigidBody > & GetRigidBody ()
 
virtual size_t GetTypeId () const =0
 
GameObjectGetOwner ()
 

Static Public Member Functions

template<typename T >
static size_t StaticTypeId ()
 

Protected Attributes

GameObjectm_owner = nullptr
 

Detailed Description

Component bridge between a GameObject and the physics world.

Reads collider and body blocks from its JSON definition in a scene file, registers the resulting RigidBody with the engine's PhysicsManager, and each frame copies the simulated transform back onto the owning GameObject.

Definition at line 21 of file PhysicsComponent.h.

Constructor & Destructor Documentation

◆ PhysicsComponent() [1/2]

mnd::PhysicsComponent::PhysicsComponent ( )
default

◆ PhysicsComponent() [2/2]

mnd::PhysicsComponent::PhysicsComponent ( const std::shared_ptr< RigidBody > &  body)

Construct from an already-built rigid body (skips JSON parsing).

Definition at line 8 of file PhysicsComponent.cpp.

Member Function Documentation

◆ GetOwner()

GameObject * mnd::Component::GetOwner ( )
inherited

◆ GetRigidBody()

const std::shared_ptr< RigidBody > & mnd::PhysicsComponent::GetRigidBody ( )

Definition at line 110 of file PhysicsComponent.cpp.

◆ GetTypeId()

virtual size_t mnd::Component::GetTypeId ( ) const
pure virtualinherited

◆ Init()

void mnd::PhysicsComponent::Init ( )
overridevirtual

◆ LoadProperties()

void mnd::PhysicsComponent::LoadProperties ( const nlohmann::json &  json)
overridevirtual

Parse collider + body sub-objects and build the RigidBody.

Reimplemented from mnd::Component.

Definition at line 13 of file PhysicsComponent.cpp.

References mnd::Dynamic, mnd::Kinematic, SetRigidBody(), and mnd::Static.

◆ SetRigidBody()

void mnd::PhysicsComponent::SetRigidBody ( const std::shared_ptr< RigidBody > &  body)

Replace the component's rigid body at runtime.

Definition at line 105 of file PhysicsComponent.cpp.

Referenced by LoadProperties().

◆ StaticTypeId()

template<typename T >
static size_t mnd::Component::StaticTypeId ( )
inlinestaticinherited

Definition at line 50 of file Component.h.

◆ Update()

void mnd::PhysicsComponent::Update ( float  deltaTime)
overridevirtual

Copy the simulated pose onto the owning GameObject.

Implements mnd::Component.

Definition at line 91 of file PhysicsComponent.cpp.

References mnd::Dynamic, mnd::Component::m_owner, mnd::GameObject::SetWorldPosition(), and mnd::GameObject::SetWorldRotation().

Member Data Documentation

◆ m_owner


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