My Project
Loading...
Searching...
No Matches
Engine::RigidBodyComponent Class Reference

Component responsible for basic physics simulation. Handles velocity, forces, gravity, and position updates. More...

#include <RigidBodyComponent.hpp>

Inheritance diagram for Engine::RigidBodyComponent:
Engine::Component

Public Member Functions

 RigidBodyComponent ()=default
 Default constructor.
float GetMass () const
 Returns the mass of the rigid body.
const DirectX::XMFLOAT3 & GetVelocity () const
 Returns the current velocity.
void SetMass (float mass)
 Sets the mass of the rigid body.
void SetVelocity (const DirectX::XMFLOAT3 &vel)
 Sets the current velocity.
void AddForce (const DirectX::XMFLOAT3 &force)
 Adds a force to the rigid body. The force will be accumulated and applied during the next update.
void Start () override
 Called when the component starts. Logs that the rigid body has been attached to the GameObject.
void Update (float dt) override
 Updates the physics simulation each frame. Applies gravity, calculates acceleration, updates velocity, and moves the GameObject.
void OnDestroy () override
 Called when the component is destroyed. Logs that the rigid body has been removed.
std::string GetTypeName () const override
 Returns the type name of the component.
Public Member Functions inherited from Engine::Component
virtual ~Component ()=default
 Virtual destructor to allow proper cleanup of derived components.

Additional Inherited Members

Public Attributes inherited from Engine::Component
GameObjectgameObject = nullptr
 Pointer to the GameObject that owns this component.
Protected Member Functions inherited from Engine::Component
 Component ()=default
 Protected constructor to prevent direct instantiation of the base class.

Detailed Description

Component responsible for basic physics simulation. Handles velocity, forces, gravity, and position updates.

Constructor & Destructor Documentation

◆ RigidBodyComponent()

Engine::RigidBodyComponent::RigidBodyComponent ( )
default

Default constructor.

Member Function Documentation

◆ AddForce()

void Engine::RigidBodyComponent::AddForce ( const DirectX::XMFLOAT3 & force)
inline

Adds a force to the rigid body. The force will be accumulated and applied during the next update.

Parameters
forceForce vector

◆ GetMass()

float Engine::RigidBodyComponent::GetMass ( ) const
inline

Returns the mass of the rigid body.

◆ GetTypeName()

std::string Engine::RigidBodyComponent::GetTypeName ( ) const
inlineoverridevirtual

Returns the type name of the component.

Returns
Component type name

Implements Engine::Component.

◆ GetVelocity()

const DirectX::XMFLOAT3 & Engine::RigidBodyComponent::GetVelocity ( ) const
inline

Returns the current velocity.

◆ OnDestroy()

void Engine::RigidBodyComponent::OnDestroy ( )
inlineoverridevirtual

Called when the component is destroyed. Logs that the rigid body has been removed.

Reimplemented from Engine::Component.

◆ SetMass()

void Engine::RigidBodyComponent::SetMass ( float mass)
inline

Sets the mass of the rigid body.

Parameters
massNew mass value

◆ SetVelocity()

void Engine::RigidBodyComponent::SetVelocity ( const DirectX::XMFLOAT3 & vel)
inline

Sets the current velocity.

Parameters
velVelocity vector

◆ Start()

void Engine::RigidBodyComponent::Start ( )
inlineoverridevirtual

Called when the component starts. Logs that the rigid body has been attached to the GameObject.

Reimplemented from Engine::Component.

◆ Update()

void Engine::RigidBodyComponent::Update ( float dt)
inlineoverridevirtual

Updates the physics simulation each frame. Applies gravity, calculates acceleration, updates velocity, and moves the GameObject.

Parameters
dtDelta time between frames

Reimplemented from Engine::Component.


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