![]() |
Skylicht Engine
|
The main physics engine manager. More...
#include <PhysicsEngine/CPhysicsEngine.h>
Public Member Functions | |
| DECLARE_SINGLETON (CPhysicsEngine) | |
| void | initPhysics () |
| Initializes the physics world and configuration. | |
| void | exitPhysics () |
| Cleans up and releases physics world resources. | |
| bool | isInitialized () |
| Checks if the physics engine has been initialized. | |
| void | updatePhysics (float timestepSec, int step=1) |
| Steps the physics simulation. | |
| void | syncTransformToPhysics () |
| Synchronizes Skylicht transforms to the physics engine. | |
| void | debugDrawWorld () |
| Draws the physics world for debugging. | |
| void | enableDrawDebug (bool b, bool alwayDraw=false) |
| Enables or disables physics debug visualization. | |
| float | getGravity () |
| Gets the current gravity value. | |
| void | setGravity (float g) |
| Sets the gravity on the Y-axis. | |
| void | updateAABBs () |
| Updates the Axis-Aligned Bounding Boxes (AABBs) for all objects. | |
| bool | rayTest (const core::vector3df &from, const core::vector3df &to, SAllRaycastResult &result) |
| Performs a raycast test returning all hits. | |
| bool | rayTest (const core::vector3df &from, const core::vector3df &to, SClosestRaycastResult &result) |
| Performs a raycast test returning only the closest hit. | |
| core::array< SRigidbodyData * > & | getBodies () |
| Gets all registered rigid bodies. | |
| core::array< SCharacterData * > & | getCharacters () |
| Gets all registered character controllers. | |
Public Attributes | |
| bool | IsInEditor |
| Indicates if the engine is running within the editor. | |
Protected Attributes | |
| float | m_gravity |
| core::array< SRigidbodyData * > | m_bodies |
| core::array< SCharacterData * > | m_characters |
| bool | m_enableDrawDebug |
Friends | |
| class | CRigidbody |
| class | CCharacterController |
The main physics engine manager.
This singleton class orchestrates the physics simulation, manages collision objects, and provides raycasting utilities. It wraps the Bullet Physics engine.
Example: Initializing the physics engine
Example: Performing a raycast
| void Skylicht::Physics::CPhysicsEngine::enableDrawDebug | ( | bool | b, |
| bool | alwayDraw = false ) |
Enables or disables physics debug visualization.
| b | True to enable, false to disable. |
| alwayDraw | If true, debug lines are drawn even if objects are inactive. |
|
inline |
Gets all registered rigid bodies.
|
inline |
Gets all registered character controllers.
|
inline |
Gets the current gravity value.
| bool Skylicht::Physics::CPhysicsEngine::isInitialized | ( | ) |
Checks if the physics engine has been initialized.
| bool Skylicht::Physics::CPhysicsEngine::rayTest | ( | const core::vector3df & | from, |
| const core::vector3df & | to, | ||
| SAllRaycastResult & | result ) |
Performs a raycast test returning all hits.
| from | Ray start position. |
| to | Ray end position. |
| result | Structure to store all hit results. |
| bool Skylicht::Physics::CPhysicsEngine::rayTest | ( | const core::vector3df & | from, |
| const core::vector3df & | to, | ||
| SClosestRaycastResult & | result ) |
Performs a raycast test returning only the closest hit.
| from | Ray start position. |
| to | Ray end position. |
| result | Structure to store the closest hit result. |
| void Skylicht::Physics::CPhysicsEngine::setGravity | ( | float | g | ) |
Sets the gravity on the Y-axis.
| g | Gravity value. |
| void Skylicht::Physics::CPhysicsEngine::updatePhysics | ( | float | timestepSec, |
| int | step = 1 ) |
Steps the physics simulation.
| timestepSec | Time elapsed since the last frame in seconds. |
| step | Maximum number of sub-steps (default: 1). |