Skip to content

five-on-it / apps/client/src/renderer/ragdoll

apps/client/src/renderer/ragdoll ​

A light cosmetic ragdoll (GAME_DESIGN §4 "Falls"): when a person goes down (run over, rammed, thrown by a blast, punched, shot, put to sleep, killed), the drawn body goes limp, flung along the hit, tumbles and slides on the ground, bumps into walls and cars and comes to rest in a sprawl. It is the client's alone: the server's capsule, the knockdown and the determinism gates are untouched, and each client may see a slightly different fall.

The solver is Verlet points at the figure's joints (the pelvis, the neck, the head, the shoulders, elbows, hands, hips, knees and feet), kept apart by distance constraints (the torso a rigid cluster, the limbs their lengths), limits on how far a limb folds (an elbow bends forward and a knee backward, never the other way, and never folded flat) and a few to keep the limbs from crossing. Gravity and a little air drag move them; the ground under the pelvis (the level's surface and its decks, @foi/world's ground-probe.ts) stops them with a small bounce and friction; a ray from where a moving point was to where it is (cast: the local world's level and cars, never a person: SCENERY_GROUPS) stops it at a wall or a car. The body's seed is the server's: the capsule's velocity when it went down (the hit shoved it: a car's way, a blast's, a punch's) and its spin.

It follows the server softly: the whole body drifts toward the capsule (more firmly as it slows), so a survivor gets up where the server stands it, without a jump; one too far from it (respawned) ends. A body that has been still for a moment is settled: frozen, costing nothing. Ragdolls keeps at most RAGDOLL_CAP active, the nearest to the camera: a new one beyond it settles the farthest at once (laid flat where it is), and one outside the view does not simulate.

What it draws are the parts' world matrices, which the batches take in place of a pose (models.ts' worlds): a part's joint at its point, its length along its limb, its left the torso's. Getting up, the figure starts from the torso's turn (Ragdoll.lying).

Classes ​

Interfaces ​

Type Aliases ​

Variables ​

Functions ​