Skip to content

Add explicit recentering stand-down coverage for pinned/frozen bodies - #398

Merged
matt-edmondson merged 2 commits into
mainfrom
copilot/add-tests-for-recentring-with-pinned-frozen-bodies
Sep 13, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
copilot/add-tests-for-recentring-with-pinned-frozen-bodies

Conversation

Copilot AI commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

RecentreOnOrigin is documented to stand down entirely when any body is pinned or frozen, but RecentringTests did not exercise that branch. A refactor that only skipped pinned/frozen bodies during shift application could preserve incidental tests while violating translation invariants.

  • Coverage gap closed: pinned/frozen stand-down behavior

    • Added focused tests in RecentringTests for both IsPinned and IsFrozen.
    • Each test settles a corpus graph, moves it off-origin, anchors one body, then steps again and verifies:
      • the anchored body position is unchanged, and
      • the drawn-box center is unchanged (i.e., no partial recentering of unanchored bodies).
  • Test isolation for mechanism-level assertion

    • Added a small helper that disables non-recentring forces (repulsion, springs, directional/flattening/untwist terms, gravity, overlap pass) so assertions are specific to recentering stand-down semantics.
core.Bodies[0].IsPinned = 1; // equivalent frozen-path test uses IsFrozen
Vec2D centreBefore = DrawnCentre(core);

for (int frame = 0; frame < 120; frame++)
{
	core.Step(1.0 / 60.0);
}

Vec2D centreAfter = DrawnCentre(core);
Assert.AreEqual(centreBefore.X, centreAfter.X, 0.0001);
Assert.AreEqual(centreBefore.Y, centreAfter.Y, 0.0001);

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for recentring pass with pinned or frozen bodies Add explicit recentering stand-down coverage for pinned/frozen bodies Sep 13, 2026
@matt-edmondson
matt-edmondson marked this pull request as ready for review September 13, 2026 13:04
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test covers the recentring pass standing down when a body is pinned or frozen

2 participants