|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <RigidbodyComponent.hpp>
Public Member Functions | |
| RigidbodyComponent (GameObject *owner, BodyType type=BodyType::Kinematic) | |
| ~RigidbodyComponent () override=default | |
| void | AddForce (const Math::Vector3D &force) |
| void | ClearCollisionState () |
| Resets HadCollision/HadGroundCollision/HadWallCollision for the next frame. | |
| BodyType | GetBodyType () const |
| Math::Vector3D | GetGravity () const |
| Math::Vector3D | GetGroundNormal () const |
| Math::Vector3D | GetLastCollisionNormal () const |
| float | GetMass () const |
| float | GetTerminalVelocity () const |
| bool | GetUseGravity () const |
| Math::Vector3D | GetVelocity () const |
| Math::Vector3D | GetWallNormal () const |
| bool | HadCollision () const |
| bool | HadGroundCollision () const |
| bool | HadWallCollision () const |
| bool | Initialize () override |
| One-time setup, called after the component is attached and the owner is initialized. | |
| bool | IsGrounded () const |
| void | ResolveCollision (const Math::Vector3D &normal, float penetration) |
| Pushes the body out along normal by penetration and updates ground/wall collision state. | |
| void | SetBodyType (BodyType type) |
| void | SetGravity (const Math::Vector3D &gravity) |
| void | SetGrounded (bool grounded) |
| void | SetMass (float mass) |
| void | SetTerminalVelocity (float tv) |
| void | SetUseGravity (bool useGravity) |
| void | SetVelocity (const Math::Vector3D &velocity) |
| void | Update (float deltaTime) override |
| Public Member Functions inherited from Sleak::Component | |
| Component (GameObject *object) | |
| virtual | ~Component ()=default |
| virtual void | FixedUpdate (float fixedDeltaTime) |
| GameObject * | GetOwner () |
| virtual void | LateUpdate (float deltaTime) |
| virtual void | OnDestroy () |
| Called when the component is detached or the owner is destroyed. | |
| virtual void | OnDisable () |
| virtual void | OnEnable () |
| Public Member Functions inherited from Sleak::Object | |
| Object (const std::string &name="Object") | |
| virtual | ~Object ()=default |
| const std::string & | GetName () const |
| uint64_t | GetUniqueID () const |
| void | SetName (const std::string &value) |
Additional Inherited Members | |
| Protected Attributes inherited from Sleak::Component | |
| bool | bIsInitialized |
| GameObject * | owner |
Tracks velocity, gravity, and collision state for a GameObject; PhysicsWorld drives its integration.
Pair this with a ColliderComponent to make an object participate in simulation. The collider supplies the shape, the rigidbody supplies the motion state, and Physics::PhysicsWorld integrates and resolves both. Without a collider, the rigidbody moves but never collides.
BodyType decides the response. Static bodies never move. Kinematic bodies move under your control and push others without being pushed. Dynamic bodies respond by mass and fall under their own gravity vector, which defaults to standard earth gravity but is yours to change: platformers and voxel games routinely run heavier gravity for a snappier feel.
Gravity is off by default, so call SetUseGravity(true) on anything that should fall. Collision flags are separated into ground and wall contacts, which is what a character controller needs to tell "landed" from "walked into something". Those flags are per-frame: call ClearCollisionState() once you have consumed them.
Definition at line 66 of file RigidbodyComponent.hpp.
| Sleak::RigidbodyComponent::RigidbodyComponent | ( | GameObject * | owner, |
| BodyType | type = BodyType::Kinematic ) |
Definition at line 8 of file RigidbodyComponent.cpp.
|
overridedefault |
|
inline |
Definition at line 96 of file RigidbodyComponent.hpp.
| void Sleak::RigidbodyComponent::ClearCollisionState | ( | ) |
Resets HadCollision/HadGroundCollision/HadWallCollision for the next frame.
Definition at line 20 of file RigidbodyComponent.cpp.
|
inline |
Definition at line 77 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 99 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 86 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 82 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 109 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 113 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 101 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 94 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 88 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 81 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 85 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 87 of file RigidbodyComponent.hpp.
|
overridevirtual |
One-time setup, called after the component is attached and the owner is initialized.
Implements Sleak::Component.
Definition at line 11 of file RigidbodyComponent.cpp.
|
inline |
Definition at line 105 of file RigidbodyComponent.hpp.
| void Sleak::RigidbodyComponent::ResolveCollision | ( | const Math::Vector3D & | normal, |
| float | penetration ) |
Pushes the body out along normal by penetration and updates ground/wall collision state.
Definition at line 29 of file RigidbodyComponent.cpp.
|
inline |
Definition at line 78 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 100 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 106 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 110 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 114 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 102 of file RigidbodyComponent.hpp.
|
inline |
Definition at line 95 of file RigidbodyComponent.hpp.
|
overridevirtual |
Implements Sleak::Component.
Definition at line 16 of file RigidbodyComponent.cpp.