27#include "PhysicsEngine/ICollisionObject.h"
29#ifdef USE_BULLET_PHYSIC_ENGINE
30#include <btBulletCollisionCommon.h>
31#include <btBulletDynamicsCommon.h>
34#include "Collider/CCollider.h"
76 class CRigidbody :
public ICollisionObject
78 friend class CPhysicsEngine;
99 float m_rollingFriction;
100 float m_spinningFriction;
102 bool m_needUpdateTransform;
106#ifdef USE_BULLET_PHYSIC_ENGINE
107 btRigidBody* m_rigidBody;
108 btCollisionShape* m_shape;
116 virtual void initComponent();
118 virtual void startComponent();
120 virtual void updateComponent();
188 return m_rollingFriction;
203 return m_spinningFriction;
233 return m_restitution;
353 void applyForce(
const core::vector3df& force,
const core::vector3df& localPosition);
377 void applyImpulse(
const core::vector3df& impulse,
const core::vector3df& localPosition);
396 void applyPushImpulse(
const core::vector3df& impulse,
const core::vector3df& localPosition);
434 return m_needUpdateTransform;
443 m_needUpdateTransform = b;
464#ifdef USE_BULLET_PHYSIC_ENGINE
469 inline btRigidBody* getBody()
478 inline btCollisionShape* getShape()
489 DECLARE_GETTYPENAME(CRigidbody)
Utility functions for converting between Skylicht and Bullet data types.
Definition CObjectSerializable.h:36
Represents a physical rigid body in the physics simulation.
Definition CRigidbody.h:77
void setFriction(float f)
Sets the friction coefficient.
void setMass(float m)
Sets the mass of the rigid body.
void applyForce(const core::vector3df &force, const core::vector3df &localPosition)
Applies a force at a specific local position.
float getRestitution()
Gets the restitution coefficient.
Definition CRigidbody.h:231
void applyImpulse(const core::vector3df &impulse, const core::vector3df &localPosition)
Applies an instantaneous impulse at a specific local position.
core::quaternion getRotation()
Gets the world rotation as a quaternion.
virtual void setCollisionGroupAndFilter(int group, int filter)
Sets the collision group and filter mask.
float getRollingFriction()
Gets the rolling friction coefficient.
Definition CRigidbody.h:186
float getSpinningFriction()
Gets the spinning friction coefficient.
Definition CRigidbody.h:201
void releaseRigidbody()
Releases the rigid body from the physics world.
core::matrix4 getWorldTransform()
Gets the current world transform matrix.
void setState(EActivationState state)
Sets the activation state of the rigid body.
void applyCenterPushImpulse(const core::vector3df &impulse)
Applies a push impulse at the center of mass.
EActivationState getState()
Gets the current activation state.
void applyCenterImpulse(const core::vector3df &impulse)
Applies an instantaneous impulse at the center of mass.
void setRollingFriction(float f)
Sets the rolling friction coefficient.
void setCcdSweptSphereRadius(float r=0.0f)
Sets the radius for Continuous Collision Detection (CCD).
void applyPushImpulse(const core::vector3df &impulse, const core::vector3df &localPosition)
Applies a push impulse at a specific local position.
int getTag()
Gets the custom tag of the rigid body.
Definition CRigidbody.h:141
void setLinearVelocity(const core::vector3df &v)
Sets the linear velocity.
void setCcdMotionThreshold(float m=0.0f)
Sets the motion threshold for Continuous Collision Detection (CCD).
void setRotation(const core::quaternion &q)
Sets the world rotation using a quaternion.
void setDynamic(bool b)
Sets whether the body is dynamic.
bool isDynamic()
Checks if the body is dynamic.
Definition CRigidbody.h:156
float getMass()
Gets the mass of the rigid body.
Definition CRigidbody.h:216
core::vector3df getLinearVelocity()
Gets the current linear velocity.
core::vector3df getLocalScale()
Gets the local scale of the collision shape.
void setSpinningFriction(float f)
Sets the spinning friction coefficient.
void setRotation(const core::vector3df &eulerDeg)
Sets the world rotation using Euler angles.
core::vector3df getPosition()
Gets the world position of the rigid body.
void setRestitution(float s)
Sets the restitution (bounciness) coefficient.
void setSleepingThresholds(float linear, float angular)
Sets the thresholds for linear and angular velocity to enter sleep mode.
float getFriction()
Gets the friction coefficient.
Definition CRigidbody.h:171
bool enableDrawDebug()
Checks if debug drawing is enabled for this body.
Definition CRigidbody.h:459
core::vector3df getAngularVelocity()
Gets the current angular velocity.
bool initRigidbody()
Initializes the rigid body in the physics world.
void applyTorque(const core::vector3df &torque)
Applies a torque (rotational force).
void activate()
Manually activates the rigid body (wakes it up).
void applyTorqueImpulse(const core::vector3df &torqueImpulse)
Applies a torque impulse (instantaneous rotation).
void setTag(int i)
Sets a custom tag for the rigid body.
Definition CRigidbody.h:132
void applyCenterForce(const core::vector3df &force)
Applies a force at the center of mass.
void setDrawDebug(bool b)
Enables or disables debug drawing for this specific rigid body.
Definition CRigidbody.h:450
bool needUpdateTransform()
Checks if the transform needs updating.
Definition CRigidbody.h:432
void setAngularVelocity(const core::vector3df &v)
Sets the angular velocity.
void clearForce()
Clears all active forces and torques.
void setPosition(const core::vector3df &pos)
Sets the world position of the rigid body.
void setLocalScale(const core::vector3df &scale)
Sets the local scale of the collision shape.
void applyTorqueTurnImpulse(const core::vector3df &torqueImpulse)
Applies a torque turn impulse.
core::vector3df getRotationEuler()
Gets the world rotation as Euler angles.
void notifyUpdateTransform(bool b)
Notifies the component about transform update status.
Definition CRigidbody.h:441
const char * getStateName()
Gets the name of the current activation state as a string.
void syncTransform()
Synchronizes the GameObject's transform with the physics body's transform.
EActivationState
Activation states for the rigid body.
Definition CRigidbody.h:86
@ Sleep
The body is currently inactive (sleeping) to save performance.
Definition CRigidbody.h:88
@ Disable
Simulation is disabled for this body.
Definition CRigidbody.h:90
@ Activate
The body is active and simulating.
Definition CRigidbody.h:87
@ Alway
The body is always active and will not sleep.
Definition CRigidbody.h:89
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29