|
Monad Engine da02fba2
> Undercity Codex_
|
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 |
| GameObject * | GetOwner () |
Static Public Member Functions | |
| template<typename T > | |
| static size_t | StaticTypeId () |
Protected Attributes | |
| GameObject * | m_owner = nullptr |
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.
|
default |
| 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.
|
inherited |
Definition at line 12 of file Component.cpp.
References mnd::Component::m_owner.
Referenced by mnd::MeshComponent::Update(), and mnd::SkinnedMeshComponent::Update().
| const std::shared_ptr< RigidBody > & mnd::PhysicsComponent::GetRigidBody | ( | ) |
Definition at line 110 of file PhysicsComponent.cpp.
|
pure virtualinherited |
|
overridevirtual |
Register the rigid body with the PhysicsManager.
Reimplemented from mnd::Component.
Definition at line 74 of file PhysicsComponent.cpp.
References mnd::PhysicsManager::AddRigidBody(), mnd::Engine::GetInstance(), mnd::Engine::GetPhysicsManager(), mnd::GameObject::GetWorldPosition(), mnd::GameObject::GetWorldRotation(), and mnd::Component::m_owner.
|
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.
| 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().
|
inlinestaticinherited |
Definition at line 50 of file Component.h.
|
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().
|
protectedinherited |
Definition at line 57 of file Component.h.
Referenced by mnd::GameObject::AddComponent(), mnd::HealthComponent::ApplyDamage(), mnd::Component::GetOwner(), mnd::CameraComponent::GetViewMatrix(), Init(), mnd::PlayerControllerComponent::Init(), mnd::PlayerControllerComponent::Update(), mnd::AudioComponent::Update(), mnd::AudioListenerComponent::Update(), and Update().