|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <PhysicsWorld.hpp>
Public Member Functions | |
| PhysicsWorld ()=default | |
| ~PhysicsWorld ()=default | |
| std::vector< CollisionPair > | OverlapAABB (const AABB &aabb, uint32_t layerMask=0xFFFFFFFF) const |
| Colliders overlapping an AABB, filtered by layerMask. | |
| std::vector< CollisionPair > | OverlapSphere (const Vector3D ¢er, float radius, uint32_t layerMask=0xFFFFFFFF) const |
| Query API: colliders overlapping a sphere, filtered by layerMask. | |
| RayHit | Raycast (const Vector3D &origin, const Vector3D &direction, float maxDist, uint32_t layerMask=0xFFFFFFFF) const |
| Casts a ray and returns the closest collider hit within maxDist. | |
| void | RegisterCollider (ColliderComponent *collider) |
| SweepResult | SphereSweep (const Vector3D &start, const Vector3D &direction, float radius, float maxDist, uint32_t layerMask=0xFFFFFFFF) const |
| Sweeps a sphere from start along direction and returns the first collider it hits within maxDist. | |
| void | Step (float dt) |
| void | UnregisterCollider (ColliderComponent *collider) |
Owns the broadphase tree and every registered collider; drives collision detection and resolution each step.
Each Scene creates one PhysicsWorld and steps it from its update, so you normally reach it with SceneBase::GetPhysicsWorld() rather than constructing one. You also rarely call RegisterCollider() by hand: adding a GameObject that carries a ColliderComponent registers it (and its children) automatically.
Step() integrates every dynamic RigidbodyComponent using that body's own gravity setting, refreshes the DynamicAABBTree broadphase, then finds and resolves overlapping pairs.
The part you will use directly is the query API. Raycast(), SphereSweep(), OverlapSphere(), and OverlapAABB() all take an optional layerMask that is matched against ColliderComponent::GetLayer(), so you can aim a query at exactly the kind of object you care about.
Definition at line 86 of file PhysicsWorld.hpp.
|
default |
|
default |
| std::vector< CollisionPair > Sleak::Physics::PhysicsWorld::OverlapAABB | ( | const AABB & | aabb, |
| uint32_t | layerMask = 0xFFFFFFFF ) const |
Colliders overlapping an AABB, filtered by layerMask.
Definition at line 194 of file PhysicsWorld.cpp.
| std::vector< CollisionPair > Sleak::Physics::PhysicsWorld::OverlapSphere | ( | const Vector3D & | center, |
| float | radius, | ||
| uint32_t | layerMask = 0xFFFFFFFF ) const |
Query API: colliders overlapping a sphere, filtered by layerMask.
Definition at line 176 of file PhysicsWorld.cpp.
| RayHit Sleak::Physics::PhysicsWorld::Raycast | ( | const Vector3D & | origin, |
| const Vector3D & | direction, | ||
| float | maxDist, | ||
| uint32_t | layerMask = 0xFFFFFFFF ) const |
Casts a ray and returns the closest collider hit within maxDist.
Definition at line 297 of file PhysicsWorld.cpp.
| void Sleak::Physics::PhysicsWorld::RegisterCollider | ( | ColliderComponent * | collider | ) |
Definition at line 13 of file PhysicsWorld.cpp.
| SweepResult Sleak::Physics::PhysicsWorld::SphereSweep | ( | const Vector3D & | start, |
| const Vector3D & | direction, | ||
| float | radius, | ||
| float | maxDist, | ||
| uint32_t | layerMask = 0xFFFFFFFF ) const |
Sweeps a sphere from start along direction and returns the first collider it hits within maxDist.
Definition at line 210 of file PhysicsWorld.cpp.
| void Sleak::Physics::PhysicsWorld::Step | ( | float | dt | ) |
Advances the simulation by dt: integrates each dynamic rigidbody's velocity, including its own gravity setting, into position, then updates the broadphase and resolves collisions.
Definition at line 41 of file PhysicsWorld.cpp.
| void Sleak::Physics::PhysicsWorld::UnregisterCollider | ( | ColliderComponent * | collider | ) |
Definition at line 27 of file PhysicsWorld.cpp.