SoA contact force reads the final sub-step impulse; contact fact tests

totalNormalImpulse accumulates the accumulated impulse once per solve and
once per relax pass, so a resting body read twice its weight. ContactForce
is now normalImpulse * sub_steps / dt, which reads the weight at rest.
Tests cover drop begin/hit, lift end, resting force, materials, one-step
lifetime, overflow counting, per-step determinism and zero allocation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-20 01:09:44 +01:00
commit 5a4cde33ae
3 changed files with 234 additions and 8 deletions

View file

@ -304,7 +304,7 @@ public readonly unsafe struct Box3DSoaView
public Span<float> TorqueZ => Write(_v.TorqueZ, Count);
// Contact lanes, read-only, refreshed by every Step.
/// <summary>Newtons: the sum over the body's touching contact manifolds of totalNormalImpulse / dt. 0 for a body touching nothing.</summary>
/// <summary>Newtons: the sum over the body's touching contact manifold points of normalImpulse * sub-steps / dt (the final sub-step's impulse as a force). 0 for a body touching nothing.</summary>
public ReadOnlySpan<float> ContactForce => Lane(_v.ContactForce, Count);
/// <summary>Number of touching contacts.</summary>
public ReadOnlySpan<int> ContactCount => Lane(_v.ContactCount, Count);