Box3D pin c790839: rebuild the broad-phase trees on an empty move buffer
RemoveBody runs between steps, so Ymir's call order was not at fault: a body destroyed after its last step enlarged its proxy, while it was the only buffered move, left its tree ancestors flagged enlarged and b3UpdateBroadPhasePairs returned before the rebuild that clears them, so the next solve aborted in Debug validation (dynamic_tree.c:1081). The fork now rebuilds on that path (DestroyEnlargedProxyTest). Add_and_remove_churn_keeps_the_world_valid: 12 seeds of add/remove churn on a floor; aborts the Debug test host at ebe346a, passes at c790839. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2cb5b588bc
commit
66f9440a36
3 changed files with 45 additions and 4 deletions
|
|
@ -6,14 +6,17 @@ Box3D v0.1.0 is Ymir's physics implementation and executable semantics oracle.
|
|||
The production native session ABI and snapshot lowering are live; explicit
|
||||
retained-world ownership is still being connected. The exact upstream source is pinned as the
|
||||
`extern/box3d` submodule at the GameCult fork's commit
|
||||
`fb719c4` (substep callback; `https://eureka.gamecult.org/forge/GameCult/box3d`, branch `gamecult/step-normal-impulse`).
|
||||
The fork is upstream `8441b4a06d6d09dcfb0b0f704df4d847d1437b92` plus three commits: an observed field,
|
||||
`c790839` (`https://eureka.gamecult.org/forge/GameCult/box3d`, branch `gamecult/destroy-enlarged-proxy`).
|
||||
The fork is upstream `8441b4a06d6d09dcfb0b0f704df4d847d1437b92` plus these commits: an observed field,
|
||||
`b3ManifoldPoint.stepNormalImpulse`, the normal impulse each contact point applied over the whole step; a
|
||||
static assert that `RELAX_ITERATIONS` is 1, the one setting under which that sum is exact; and a substep callback
|
||||
(`b3World_SetSubStepCallback`, with `b3Body_GetSubStepState` and `b3Body_ApplySubStepImpulse`, valid only inside it)
|
||||
that the particle phase runs in, after the biased solve and before positions integrate. The first two change no solver
|
||||
arithmetic and a world with no callback registered runs exactly as before, so dynamics are bit-identical to upstream
|
||||
(the six ABI 8 hashes pin it). To rebase it onto a newer Box3D, re-apply those commits, re-run the Soa impulse and
|
||||
(the six ABI 8 hashes pin it). Then the contact friction hook (`ebe346a`, see `soa-world.md`), and a broad-phase
|
||||
fix: a proxy destroyed after its step enlarged it, while it was the only buffered move, left its tree ancestors flagged
|
||||
enlarged and the empty move buffer skipped the rebuild that clears them, so Debug validation aborted the next step;
|
||||
the empty-buffer path now rebuilds (a root walk on a clean tree; the fork's `DestroyEnlargedProxyTest`). To rebase it onto a newer Box3D, re-apply those commits, re-run the Soa impulse and
|
||||
particle tests and compare a pile's state hash against the upstream build.
|
||||
|
||||
Box3D does not own GameCult entity ids, gameplay policy, persistence, or result
|
||||
|
|
|
|||
2
extern/box3d
vendored
2
extern/box3d
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit ebe346a92506c64b770b9b5e1b038871c3477445
|
||||
Subproject commit c7908394eb3ec3aa0f54bf26a98a683c1950ac15
|
||||
|
|
@ -299,6 +299,44 @@ public sealed class Box3DSoaRemoveTests
|
|||
_ = c;
|
||||
}
|
||||
|
||||
/// <summary>Random add/remove churn of falling spheres on a floor. Run it in Debug too: Box3D validates its broad-phase there, and a
|
||||
/// body removed while its proxy was the only one moving left the dynamic tree flagged enlarged (fixed in box3d c790839).</summary>
|
||||
[Fact]
|
||||
public void Add_and_remove_churn_keeps_the_world_valid()
|
||||
{
|
||||
for (var seed = 1; seed <= 12; seed++)
|
||||
{
|
||||
using var world = World(bodies: 6, joints: 0);
|
||||
world.AddStaticBox(1, (0f, -0.5f, 0f), (4f, 0.5f, 4f));
|
||||
var rng = new Random(seed);
|
||||
var live = new List<Box3DSoaBodyHandle>();
|
||||
var next = 2ul;
|
||||
var removals = 0;
|
||||
for (var step = 0; step < 120; step++)
|
||||
{
|
||||
if (rng.Next(3) == 0)
|
||||
{
|
||||
if (live.Count > 0 && (world.FreeBodySlots == 0 || rng.Next(2) == 0))
|
||||
{
|
||||
var k = rng.Next(live.Count);
|
||||
world.RemoveBody(live[k]);
|
||||
live.RemoveAt(k);
|
||||
removals++;
|
||||
}
|
||||
else if (world.FreeBodySlots > 0)
|
||||
{
|
||||
live.Add(world.AddSphere(next++, (4f * rng.NextSingle() - 2f, 0.2f + 2f * rng.NextSingle(), 4f * rng.NextSingle() - 2f), 0.1f, 1000f));
|
||||
}
|
||||
}
|
||||
world.Step(Dt);
|
||||
}
|
||||
Assert.True(removals >= 5, $"seed {seed}: {removals} removals");
|
||||
var view = world.View;
|
||||
Assert.All(live, h => Assert.Equal((uint)Box3DSoaKind.Sphere, view.Kind[h]));
|
||||
Assert.All(live, h => Assert.InRange(view.PositionY[h], 0f, 2.5f)); // on or above the floor, none lost through it
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] Replay()
|
||||
{
|
||||
using var world = World(bodies: 8, joints: 4);
|
||||
|
|
|
|||
Loading…
Reference in a new issue