Anvil Engine
Loading...
Searching...
No Matches
RigidBodyComponent Class Reference

#include <RigidBodyComponent.h>

Inheritance diagram for RigidBodyComponent:
IComponent

Public Member Functions

 RigidBodyComponent (glm::vec3 size, float mass=1.0f, bool isStatic=false)
void OnInit (AEntity *owner) override
void OnUpdate (float dt) override
void OnRender (AShader *shader) override
 Called to render the component.
void ApplyPush (glm::vec3 force)
void ApplyTorque (glm::vec3 torque)
bool IsGrounded ()
void SetBouciness (float bounciness)
Public Member Functions inherited from IComponent
virtual ~IComponent ()
 Virtual destructor for the IComponent class. Ensures proper cleanup of derived class objects when deleted through a base class pointer.

Public Attributes

ABodym_body = nullptr
glm::vec3 m_size
float m_mass
bool m_isStatic
Public Attributes inherited from IComponent
AEntitym_owner = nullptr
 Pointer to the entity that owns this component. This allows the component to access its parent entity and other components attached to it.

Constructor & Destructor Documentation

◆ RigidBodyComponent()

RigidBodyComponent::RigidBodyComponent ( glm::vec3 size,
float mass = 1.0f,
bool isStatic = false )
inline

Member Function Documentation

◆ ApplyPush()

void RigidBodyComponent::ApplyPush ( glm::vec3 force)

Applies a push force to the rigid body

Parameters
forceThe force vector to be applied to the rigid body

◆ ApplyTorque()

void RigidBodyComponent::ApplyTorque ( glm::vec3 torque)

Apply torque to the rigid body

Parameters
torqueThe torque vector to apply in world coordinates

◆ IsGrounded()

bool RigidBodyComponent::IsGrounded ( )

Checks if the rigid body is currently grounded

Returns
true if the rigid body is on the ground, false otherwise

◆ OnInit()

void RigidBodyComponent::OnInit ( AEntity * owner)
overridevirtual

Initialize the RigidBodyComponent

Parameters
ownerPointer to the entity that owns this component

Implements IComponent.

◆ OnRender()

void RigidBodyComponent::OnRender ( AShader * shader)
inlineoverridevirtual

Called to render the component.

Parameters
shaderThe shader program to use for rendering.

Implements IComponent.

◆ OnUpdate()

void RigidBodyComponent::OnUpdate ( float dt)
overridevirtual

Update method for the RigidBodyComponent, called each frame

Parameters
dtDelta time since last update, used for time-based calculations

Implements IComponent.

◆ SetBouciness()

void RigidBodyComponent::SetBouciness ( float bounciness)

Sets the bounciness of the rigid body

Parameters
bouncinessA value between 0 and 1 that determines how bouncy the object is 0 means no bounce, 1 means perfect bounce

Member Data Documentation

◆ m_body

ABody* RigidBodyComponent::m_body = nullptr

◆ m_isStatic

bool RigidBodyComponent::m_isStatic

◆ m_mass

float RigidBodyComponent::m_mass

◆ m_size

glm::vec3 RigidBodyComponent::m_size

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