|
Axmol 3.0.0-89d6d9a
|
The physics information container for Axmol 3D physics components. More...
#include <PhysicsWorld3D.h>
Inherits Object.
Classes | |
| struct | HitResult |
| Result data returned by ray casts and sweep tests. More... | |
Public Member Functions | |
| JPH::PhysicsSystem & | internalHandle () |
| Returns the native Jolt physics system. | |
| const JPH::PhysicsSystem & | internalHandle () const |
| Returns the native Jolt physics system. | |
| Scene * | getScene () const |
| Returns the scene that owns this physics world. | |
| void | setPreSolveCallback (PreSolveCallback cb) |
| Set the PreSolve callback for the 3D physics world. | |
| void | setGravity (const Vec3 &gravity) |
| Sets gravity for the physics world. | |
| Vec3 | getGravity () const |
| Gets the current world gravity. | |
| void | setAutoStep (bool autoStep) |
| To control the step of physics. | |
| bool | isAutoStep () |
| Get the auto step of this physics world. | |
| void | stepSimulation (float delta) |
| Advances the physics simulation by one step. | |
| void | setDebugDrawEnabled (bool enableDebugDraw) |
| Enables or disables debug drawing for this world. | |
| bool | isDebugDrawEnabled () const |
| Returns whether debug drawing is enabled. | |
| void | debugDraw (const ax::SceneRenderState &state) |
| Renders debug physics geometry. | |
| bool | rayCast (const ax::Vec3 &startPos, const ax::Vec3 &endPos, HitResult *result) |
| Casts a ray through the physics world. | |
| bool | sweepTest (Collider3D *collider, const ax::Mat4 &startTransform, const ax::Mat4 &endTransform, HitResult *result) |
| Performs a swept shape cast on all objects in the PhysicsWorld3D. | |
| PhysicsWorld3D () | |
| Constructs an uninitialized 3D physics world. | |
| ~PhysicsWorld3D () override | |
| Destroys the world and releases native physics resources. | |
| void | setGlobalEventEnabled (ContactEventBits events, bool enabled) |
| Enable or disable specific collision events globally in this physics world. | |
| bool | isGlobalEventEnabled (ContactEventBits events) const |
| Returns whether all requested collision event bits are globally enabled. | |
| Public Member Functions inherited from Object | |
| void | retain () |
| Retains the ownership. | |
| void | release () |
| Releases the ownership immediately. | |
| Object * | autorelease () |
| Releases the ownership sometime soon automatically. | |
| unsigned int | getReferenceCount () const |
| Returns the Object's current reference count. | |
| uint64_t | getObjectID () const noexcept |
| Returns the process-local diagnostic identifier assigned at construction. | |
| virtual | ~Object () |
| Destructor. | |
Static Public Member Functions | |
| static PhysicsWorld3D * | obtain (Scene *scene) |
| Obtains the 3D physics world associated with a scene. | |
| static void | release (PhysicsWorld3D *world) |
| Releases a world obtained through obtain(). | |
The physics information container for Axmol 3D physics components.
|
static |
Obtains the 3D physics world associated with a scene.
| scene | Scene that owns the physics world. |
|
static |
Releases a world obtained through obtain().
| world | Physics world to release. Passing nullptr is allowed. |
|
inline |
Returns the native Jolt physics system.
|
inline |
Returns the native Jolt physics system.
|
inline |
Returns the scene that owns this physics world.
| void setPreSolveCallback | ( | PreSolveCallback | cb | ) |
Set the PreSolve callback for the 3D physics world.
The PreSolve callback is invoked during JoltPhysics contact validation (OnContactValidate), allowing the user to decide whether a contact should be accepted or rejected. The callback runs inside the JobSystem worker threads and must return immediately.
| cb | User-provided callback function with signature: bool(const ContactInfo3D&)
|
| void setGravity | ( | const Vec3 & | gravity | ) |
Sets gravity for the physics world.
| gravity | Gravity vector in world units per second squared. |
| Vec3 getGravity | ( | ) | const |
Gets the current world gravity.
|
inline |
To control the step of physics.
If you want control it by yourself( fixed-timestep for example ), you can set this to false and call step by yourself.
| autoStep | A bool object, default value is true. |
|
inline |
Get the auto step of this physics world.
| void stepSimulation | ( | float | delta | ) |
Advances the physics simulation by one step.
By default, the physics world runs with auto-step enabled, and this function is called automatically each frame. If you disable auto-step via setAutoStep(false), you must call this function manually to update the simulation.
| delta | The time step (in seconds) to simulate. |
| void setDebugDrawEnabled | ( | bool | enableDebugDraw | ) |
Enables or disables debug drawing for this world.
| enableDebugDraw | True to enable debug rendering. |
| bool isDebugDrawEnabled | ( | ) | const |
Returns whether debug drawing is enabled.
| void debugDraw | ( | const ax::SceneRenderState & | state | ) |
Renders debug physics geometry.
| Renderer | Renderer used by the owning scene. |
Casts a ray through the physics world.
| startPos | The start position of ray. |
| endPos | The end position of ray. |
| result | Output hit result, or nullptr to only test for any hit. |
| bool sweepTest | ( | Collider3D * | collider, |
| const ax::Mat4 & | startTransform, | ||
| const ax::Mat4 & | endTransform, | ||
| HitResult * | result ) |
Performs a swept shape cast on all objects in the PhysicsWorld3D.
| collider | Collider shape to sweep. |
| startTransform | World transform at the start of the sweep. |
| endTransform | World transform at the end of the sweep. |
| result | Output hit result, or nullptr to only test for any hit. |
| void setGlobalEventEnabled | ( | ContactEventBits | events, |
| bool | enabled ) |
Enable or disable specific collision events globally in this physics world.
This modifies the world's global event mask by turning on or off the specified event bits. Colliders can only generate these events if they are enabled both locally and globally.
| events | Collision event bits to modify. |
| enabled | True to enable the specified events globally, false to disable them. |
| bool isGlobalEventEnabled | ( | ContactEventBits | events | ) | const |
Returns whether all requested collision event bits are globally enabled.
| events | Collision event bits to test. |