StevEngine
StevEngine is a customizable C++ game engine.
|
Physics rigid body component. More...
#include <physics/RigidBody.hpp>
Public Member Functions | |
JPH::Body * | GetBody () const |
Get Jolt physics body. | |
RigidBody (JPH::EMotionType motionType, Layer *layer, float mass=1000) | |
Create rigid body. | |
RigidBody (Utilities::Stream &stream) | |
Create rigidbody from text serialized data. | |
std::string | GetType () const |
Get component type. | |
Utilities::Stream | Export (Utilities::StreamType type) const |
Serialize component to a stream. | |
void | Start () |
Initialize component. | |
void | Deactivate () |
Clean up when deactivated. | |
void | Update (double deltaTime) |
Update transform from physics. | |
~RigidBody () | |
Clean up resources. | |
void | SetMotionProperties (MotionProperties properties) |
Set motion properties. | |
bool | IsActive () const |
Check if body is currently active in the physics simulation. | |
bool | IsStatic () const |
Check if this is a static body. | |
bool | IsKinematic () const |
Check if this is a kinematic body. | |
bool | IsDynamic () const |
Check if this is a dynamic body. | |
float | GetFriction () const |
Get the friction coefficient. | |
void | SetFriction (float inFriction) |
Set the friction coefficient. | |
Utilities::Vector3 | GetLinearVelocity () const |
Get the current linear velocity. | |
void | SetLinearVelocity (Utilities::Vector3 inLinearVelocity) |
Set the linear velocity. | |
void | SetLinearVelocityClamped (Utilities::Vector3 inLinearVelocity) |
Set linear velocity clamped to the maximum configured value. | |
Utilities::Vector3 | GetAngularVelocity () const |
Get the current angular velocity. | |
void | SetAngularVelocity (Utilities::Vector3 inAngularVelocity) |
Set the angular velocity. | |
void | SetAngularVelocityClamped (Utilities::Vector3 inAngularVelocity) |
Set angular velocity clamped to the maximum configured value. | |
Utilities::Vector3 | GetPointVelocityCOM (Utilities::Vector3 inPointRelativeToCOM) const |
Get velocity of a point relative to center of mass. | |
Utilities::Vector3 | GetPointVelocity (Utilities::Vector3 inPoint) const |
Get velocity of a point in world space. | |
void | AddForce (Utilities::Vector3 inForce) |
Add force to center of mass. | |
void | AddForce (Utilities::Vector3 inForce, Utilities::Vector3 inPosition) |
Add force at specified world space position. | |
void | AddTorque (Utilities::Vector3 inTorque) |
Add torque around center of mass. | |
void | AddImpulse (Utilities::Vector3 inImpulse) |
Add linear impulse to center of mass. | |
void | AddImpulse (Utilities::Vector3 inImpulse, Utilities::Vector3 inPosition) |
Add linear impulse at specified world space position. | |
void | AddAngularImpulse (Utilities::Vector3 inAngularImpulse) |
Add angular impulse around center of mass. | |
void | MoveKinematic (Utilities::Vector3 inTargetPosition, Utilities::Quaternion inTargetRotation, float inDeltaTime) |
Move kinematic body towards target transform. | |
![]() | |
Component () | |
Create new component. | |
virtual | ~Component () |
Clean up component resources. | |
GameObject & | GetParent () const |
Get parent GameObject. | |
Scene & | GetScene () const |
Get containing Scene. | |
Public Attributes | |
const JPH::EMotionType | motionType |
Motion type (static/dynamic/kinematic) | |
const Layer * | layer |
Physics collision layer. | |
const float | mass |
Body mass in kg. | |
Friends | |
class | Collider |
class | StevEngine::GameObject |
Additional Inherited Members | |
![]() | |
std::vector< std::pair< Utilities::ID, std::string > > | handlers |
Event handler registrations. | |
Physics rigid body component.
Adds physical simulation to game objects using Jolt physics. Handles collision shapes, forces, and motion simulation.
StevEngine::Physics::RigidBody::RigidBody | ( | JPH::EMotionType | motionType, |
Layer * | layer, | ||
float | mass = 1000 ) |
Create rigid body.
motionType | Body motion type |
layer | Collision layer |
mass | Mass in kg |
StevEngine::Physics::RigidBody::RigidBody | ( | Utilities::Stream & | stream | ) |
Create rigidbody from text serialized data.
stream | Stream containing serialized component data |
|
inline |
Add angular impulse around center of mass.
inAngularImpulse | Angular impulse vector in world space |
|
inline |
Add force to center of mass.
inForce | Force vector in world space |
|
inline |
Add force at specified world space position.
inForce | Force vector in world space |
inPosition | Position to apply force in world space |
|
inline |
Add linear impulse to center of mass.
inImpulse | Impulse vector in world space |
|
inline |
Add linear impulse at specified world space position.
inImpulse | Impulse vector in world space |
inPosition | Position to apply impulse in world space |
|
inline |
Add torque around center of mass.
inTorque | Torque vector in world space |
|
virtual |
Clean up when deactivated.
Reimplemented from StevEngine::Component.
|
virtual |
Serialize component to a stream.
type | Type of stream to export to |
Implements StevEngine::Component.
|
inline |
Get the current angular velocity.
|
inline |
Get the friction coefficient.
|
inline |
Get the current linear velocity.
|
inline |
Get velocity of a point in world space.
inPoint | Point in world space |
|
inline |
Get velocity of a point relative to center of mass.
inPointRelativeToCOM | Point relative to center of mass |
|
inlinevirtual |
|
inline |
Check if body is currently active in the physics simulation.
|
inline |
Check if this is a dynamic body.
|
inline |
Check if this is a kinematic body.
|
inline |
Check if this is a static body.
|
inline |
Move kinematic body towards target transform.
inTargetPosition | Target position in world space |
inTargetRotation | Target rotation in world space |
inDeltaTime | Time step for the movement |
|
inline |
Set the angular velocity.
inAngularVelocity | New angular velocity in world space (radians/s) |
|
inline |
Set angular velocity clamped to the maximum configured value.
inAngularVelocity | Desired angular velocity in world space (radians/s) |
|
inline |
Set the friction coefficient.
inFriction | New friction value [0, INF] |
|
inline |
Set the linear velocity.
inLinearVelocity | New velocity in world space |
|
inline |
Set linear velocity clamped to the maximum configured value.
inLinearVelocity | Desired velocity in world space |
void StevEngine::Physics::RigidBody::SetMotionProperties | ( | MotionProperties | properties | ) |
Set motion properties.
properties | New motion settings |
|
virtual |
Initialize component.
Reimplemented from StevEngine::Component.
|
virtual |
Update transform from physics.
deltaTime | Time since last update |
Reimplemented from StevEngine::Component.