3D rigid body dynamics. Reuses BodyType (Static/Dynamic/Kinematic).
orientation is the physics source of truth for rotation (a quaternion);
the step integrates it and writes the result into the entity's
Transform3D (position + matrix_override) each frame. NOTE: the 3D pipeline
(step3d, raycast3d, queries) reads rotation ONLY from this field and IGNORES
Transform3D.rotation. A rotated static collider must therefore be given its
orientation via RigidBody3D.static(orientation:), and every entity that
participates in 3D collision MUST carry a RigidBody3D — a bare
Collider3D + Transform3D is invisible to the 3D collision system.
inv_inertia is the DIAGONAL inverse inertia in the body frame (0 locks
that axis). Sphere/box/capsule all have diagonal body-frame inertia, so the
solver can apply the world inverse inertia as q * (Ibody^-1 * (q^-1 * v))
without materialising a 3x3 matrix.
Constructors
box(mass :
Number, half :
Flock::Vec3, restitution :
Number = 0.2, friction :
Number = 0.5, velocity :
Flock::Vec3 =
Flock::Vec3.new) :
RigidBody3D Solid box with half-extents half. I_axis = 1/3 m (sum of the other two
half-extents squared) using full extents (2*half).
Sourcedynamic(mass :
Number = 1.0, inertia :
Flock::Vec3 =
Flock::Vec3.new(1, 1, 1), restitution :
Number = 0.2, friction :
Number = 0.5, velocity :
Flock::Vec3 =
Flock::Vec3.new, angular_vel :
Flock::Vec3 =
Flock::Vec3.new, orientation :
Flock::Quaternion =
Flock::Quaternion.identity, ccd :
Bool = false) :
RigidBody3D Movable body with an explicit diagonal inertia (principal moments; <= 0
locks that axis). A mass <= 0 is clamped to a tiny positive value (1e-6),
keeping the body a valid Dynamic body that still feels gravity/impulses
rather than an infinite-mass body that silently skips gravity.
Sourcekinematic(velocity :
Flock::Vec3 =
Flock::Vec3.new, angular_vel :
Flock::Vec3 =
Flock::Vec3.new, restitution :
Number = 0.2, friction :
Number = 0.5, orientation :
Flock::Quaternion =
Flock::Quaternion.identity) :
RigidBody3D Driven purely by its own velocity (moving platforms): pushes dynamic
bodies but is unaffected by gravity or impulses.
Sourcenew(velocity :
Flock::Vec3 =
Flock::Vec3.new, angular_vel :
Flock::Vec3 =
Flock::Vec3.new, orientation :
Flock::Quaternion =
Flock::Quaternion.identity, inv_mass :
Number = 1.0, inv_inertia :
Flock::Vec3 =
Flock::Vec3.new(1, 1, 1), restitution :
Number = 0.2, friction :
Number = 0.5, body_type :
BodyType =
BodyType::Dynamic, sleeping :
Bool = false, sleep_timer :
Float32 = 0.0_f32, ccd :
Bool = false)
Sourcesphere(mass :
Number, radius :
Number, restitution :
Number = 0.2, friction :
Number = 0.5, velocity :
Flock::Vec3 =
Flock::Vec3.new, ccd :
Bool = false) :
RigidBody3D Solid sphere: I = 2/5 m r^2 on every axis.
Sourcestatic(restitution :
Number = 0.2, friction :
Number = 0.5, orientation :
Flock::Quaternion =
Flock::Quaternion.identity) :
RigidBody3D An immovable body (walls, floors). Pass orientation: to rotate static
geometry — the 3D pipeline ignores Transform3D.rotation, so this is the
only way to orient a static collider.
SourceInstance methods
angular_vel=(angular_vel : Flock::Vec3)
Sourcebody_type=(body_type : BodyType)
Sourceinv_inertia=(inv_inertia : Flock::Vec3)
Sourceorientation=(orientation : Flock::Quaternion)
Sourcesleeping
Sleeping state (managed by the physics step).
Sourcesleeping=(sleeping :
Bool)
Sleeping state (managed by the physics step).
Sourcevelocity=(velocity : Flock::Vec3)
Source