Skip to main content

Module physics

Module physics 

Source
Expand description

The rigid-body simulation, and the driver that runs it over a world.

Two halves that stay apart all the way down. The simulation is the solver: the shapes, body parameters, joints, layer masks, and step results that cross the boundary between a caller and the Simulation, plus the PhysicsBudget a world reserves its bodies against. Everything crossing that boundary is plain data in the engine’s [f32; 3] and Euler-degree representation, addressed by an opaque BodyHandle. That is what lets the simulation hold whatever math types it likes without those types reaching a caller, and it names no engine domain type in either direction.

The driver around it builds a simulation from the world’s physics content at init, steps it on the fixed tick, and writes the results back as component data: prop bodies, character rigs, probes, contact shaping, and layer resolution. Where a module holds both halves they sit in separate files, never one.

Nothing here reads a clock, a file, or a device. The one thing only a host can supply is threads, which it lends through PhysicsFanout; a world with none steps on the calling thread.

Structs§

BodyHandle
Opaque handle to a body inside a simulation.
CharacterCapsule
A character’s collision capsule: a cylinder of 2 * half_height capped by hemispheres of radius, standing on the y axis.
CharacterMove
Result of moving a character capsule for one tick.
CharacterMoveInput
One character-capsule move request.
ContactHit
One contact strong enough to pass the simulation’s force threshold.
DynamicParams
Physical parameters for a dynamic (freely simulated) body.
Inline
The fan-out for a caller that has no threads to lend: every unit runs on the calling thread, in order.
JointMotor
Velocity-driven motor parameters for a revolute or prismatic joint.
LayerMask
Membership and filter bits applied to a collider or query.
PhysicsBudget
The reservation a world’s physics content implies.
PhysicsCounts
Tallies of a world’s authored physics content.
PhysicsSystem
Rigid-body simulation behavior. Constructed internally by World::start from the world’s PhysicsConfig; never a declarable asset.
RayHit
One raycast hit: the surface point, its outward normal, and the distance from the ray origin.
SensorCrossing
One boundary crossing of a sensor region recorded during a step: something began or stopped overlapping the sensor tagged tag.
SerialFanout
The fan-out for a host with no threads to lend: every step runs on the calling thread.
ShapeCast
A shape swept through the world along a straight line.
ShapeCastHit
What a ShapeCast ran into.
SimConfig
Tuning for one simulation.
Simulation
A rigid-body simulation: bodies fall under gravity, collide, and come to rest.

Enums§

ColliderShape
A collision shape, in the body’s local space.
JointSpec
Constraint shape connecting two bodies.

Constants§

GRAVITY
Acceleration due to gravity in world units per second squared. Shared with the third-person controller so its jump takeoff matches the rig’s fall.

Traits§

Fanout
A caller’s way of running independent work at the same time.
PhysicsFanout
A host’s way of lending the simulation the threads it has.

Functions§

euler_deg_from_quat
Engine Euler degrees [pitch, yaw, roll] for an [x, y, z, w] rotation quaternion, which need not be normalised.
quat_from_euler_deg
The [x, y, z, w] rotation quaternion for engine Euler degrees [pitch, yaw, roll], applied in YXZ order.