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

Sequential-Impulse (PGS) constraint solver for contacts + joints. More...

#include "ecs/physics/ContactCache.hpp"
#include "ecs/registry/Registry.hpp"
#include <cstdint>
Include dependency graph for Solver.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::SolverConfig

Namespaces

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

Functions

void physics::solveContacts (Registry &registry, ContactCache &cache, const SolverConfig &cfg, float dt)
 Solve every cached contact manifold for the current tick.

Detailed Description

Sequential-Impulse (PGS) constraint solver for contacts + joints.

Reference: Erin Catto, Iterative Dynamics with Temporal Coherence (GDC 2005) — the canonical formulation that Box2D / Bullet use. Per-tick:

  1. Build ContactConstraint rows from every cached ContactManifold.
  2. Warm-start: apply each cached impulse from the previous tick.
  3. Iterate ~8 times: per contact, compute relative velocity at the contact point, derive a normal impulse λN, clamp accumulated impulse ≥ 0, apply to both bodies. Then the friction tangents with Coulomb clamping |λT| ≤ μ * λN.
  4. Position correction (optional / NGS) for residual penetration.