group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
RagdollPbd.hpp File Reference

Position-Based-Dynamics ragdoll constraint system. More...

#include "ecs/registry/Registry.hpp"
#include <cstdint>
#include <entt/entt.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/vec3.hpp>
Include dependency graph for RagdollPbd.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::RagdollPbdJoint
 One articulated joint in a PBD ragdoll skeleton. More...

Namespaces

namespace  physics
 Pure physics math — no ECS types, no registry.

Functions

void physics::enforceRagdollConnectivity (Registry &registry, float dt, int iterations=8)
 Enforce ragdoll connectivity + angular limits via N PBD iterations.

Detailed Description

Position-Based-Dynamics ragdoll constraint system.

Replaces the velocity-bias (PGS+Baumgarte) joint solver for ragdoll bodies with a hard position-projection approach inspired by CS2 / Source 2 articulated ragdolls and the Müller PBD paper. The connectivity invariant — every parent-child anchor coincides in world space — is enforced directly by translating bodies, not by injecting corrective velocity into the next tick's solve. Bones therefore CANNOT detach under any forcing: gravity, contact impulses, knockback, etc. can only bend the joints (within angular limits) — never break them.

Per-tick order inside runDynamics:

  1. Integrate velocity (gravity).
  2. Sweep against static world → contact manifolds.
  3. PGS contact solver (impulses against the world only).
  4. enforceRagdollConnectivity — N PBD passes per joint, position projection then angular-limit projection.
  5. Velocity clamp + sleep.

Why this is more stable than the previous PGS joint pass:

  • Position error is corrected by moving bodies; the solver can't "overshoot" because the gap closes exactly each iteration.
  • Mass ratios still matter (heavier bodies move less) but no longer control whether the constraint converges at all.
  • Angular limits are clamped, not biased toward — chest-twisting past 90° is impossible by construction.