|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Engine::Core::PhysicsEngine exposes immediate Bullet queries for gameplay code. Use these from actor logic when you need hit information without waiting for rigid body collision callbacks.
| Query | Function | Use case |
|---|---|---|
| Ray trace | raycastClosest(origin, direction, maxDistance, hit) | Hitscan weapons, line of sight, placement checks |
| Sphere overlap | sphereClosest(position, radius, hit, ignoredObject) | Detect one object inside a radius at the current frame |
| Sphere trace | sphereSweepClosest(from, to, radius, hit, ignoredObject) | Continuous projectile overlap and other CCD-style checks |
All three functions return true when they hit something and fill Engine::Physics::RaycastHit.
RaycastHit::getPhysicsBody() converts the Bullet collision object user pointer back to the engine PhysicsBody component.
Use a ray trace when the query has no volume.
direction does not need to be normalized. hit.distance is the distance from origin to hit.point.
Use a sphere overlap when the sphere is already at the position you want to test.
sphereClosest() uses Bullet contactTest() with a temporary sphere object. hit.distance stores the contact penetration depth for the selected overlap. hit.fraction is 0.0f because the query does not move.
Use a sphere trace when the sphere moves during the frame.
sphereSweepClosest() uses Bullet convexSweepTest(). It checks the full movement from from to to, so fast projectiles do not skip thin targets between frames.
Pass the projectile body as ignoredObject when the query object already has collision in the world.
ignoredObject is optional. Use nullptr or omit the argument when the query has no world collision body.