RigidBodies
Every rigid body in a PhysicsWorld, as parallel arrays that a RigidBody handle indexes: bodies that keep their shape and turn. A removed body's slot is handed out again by the next add.
A body has a position, the point it turns about (its centre of mass), and an angle in radians, clockwise on screen since y grows down. Unlike a particle it keeps its velocity explicitly, linear and angular, because turning needs one: each substep the world
remembers where the body was, adds gravity to its velocity and moves it by that velocity,
lets the solver push it about, by position and angle,
and then takes the velocity to be how far it really moved, divided by the substep.
The solver moves a body only through shove, which keeps count, so step 3 adds what it moved the body to the velocity rather than measuring the move from two positions: a body far from the origin keeps every digit of its speed.
That's Müller et al. 2020, "Detailed Rigid Body Simulation with Extended Position Based Dynamics": the same XPBD as the particles, with rotation added. A BodyKind.KINEMATIC body skips steps 2 and 3, and a BodyKind.STATIC one all three.
The arrays grow by doubling when a body is added, never during a step.
toString gives how many bodies are alive and asleep, for example RigidBodies(size=40, asleep=12).
Types
Functions
Returns how fast body turns, in radians per second, clockwise on screen.
Returns one over how hard body is to turn: 0 for a body nothing turns. A sleeping body keeps its own.
Returns one over body's mass: 0 for a body nothing moves, a static or kinematic one. A sleeping body keeps its own.
Returns how fast the world point (x, y) of body moves down: see pointVelocityXOf.
Returns what body does to what it overlaps: see setResponse.
Sets how fast body turns, in radians per second, and wakes it. A static body stays still.
Puts body on layers and has it collide with what is on a layer of mask and holds a layer of body's in its own mask; see PhysicsLayers. The layers say nothing about the solids: see setSolidCollision. It wakes, as what it rested on may no longer hold it.
Sets how body moves. A Motion.BULLET is not held to PhysicsConfig.maxStep a substep: it goes as fast as it is thrown, and every substep it is swept from where it was to where it went and stopped where it first meets a body or a solid, so nothing fast passes through a thin wall or another body. It costs a few shape tests a substep for each bullet; use it for the few things that need it.
Sets what body does to what it overlaps. A ContactResponse.SENSE body, a sensor, never pushes or is pushed: it only notices what is in it, and Events.sensorsEntered and Events.sensorsExited say what came and went. It notices rigid bodies, soft bodies and loose particles its layers let it collide with, but not the solids or other sensors, and raycasts pass through it. It moves as its kind says, so a dynamic sensor falls; most are static, or kinematic to carry them about.
Sets whether body is kept out of the solids, the SolidGrid and its moving solids. It is SolidCollision.COLLIDE by default; a SolidCollision.PASS body falls through the level. A body set back to SolidCollision.COLLIDE while a little way into a solid is pushed out; one sunk most of the way in stays there. A change wakes it; setting the value it already has does nothing.
Returns whether body is kept out of the solids: see setSolidCollision.
Returns how fast body moves across, in units per second.
Returns how fast body moves down, in units per second.
Wakes body and every body that fell asleep with it: its island, everything it touched or was joined to. A body wakes by itself when an awake one hits it, when it is grabbed, given a velocity, moved or joined, and when what holds it up is removed; call this when you change the world some other way, such as removing a particle it rests on. Waking an awake body does nothing.