Skip to content

Navigation Menu

Sign in
Sign up

Cover public API edge cases - #172

Open
mzl2233 wants to merge 1 commit into
NewKrok:master from
mzl2233:fix/public-api-edge-case-tests
Open

Cover public API edge cases #172
mzl2233 wants to merge 1 commit into
NewKrok:master from
mzl2233:fix/public-api-edge-case-tests

Conversation

@mzl2233

@mzl2233 mzl2233 commented May 15, 2026

Copy link
Copy Markdown

Adds a focused integration suite for the public API edge cases listed in the issue, including callback-time body removal, sensor-mode toggling during an active collision, and broadphase filter behavior for always-matching and never-matching filters. The sensor toggle path now allows the flag to change mid-step and wakes the shape so the new interaction state can be observed without throwing.

NewKrok commented May 15, 2026

Copy link
Copy Markdown
Owner

Hi @mzl2233, thanks for picking this up! A few things before I can merge:

1. The Shape.ts change removes the immutable_midstep guard on sensorEnabled

That guard is intentional — it's one of ~30 similar mid-step guards across the engine, all there to prevent inconsistent arbiter state. I ran a quick stress test on your branch:

// PreListener toggles wallShape.sensorEnabled = true
// Result on your branch:
// - COLLISION callback still fires (should be SENSOR)
// - visitor velocity 120 → 0 (collision impulse applied — sensors shouldn't impart impulse)
// - SENSOR callback fires too, but a step later

Could you revert the Shape.ts change and rewrite the sensor-toggle test to validate the intended behaviour, which is that it throws?

expect(() => { wallShape.sensorEnabled = true; }).toThrow(/cannotbesetduringaspacestep/);

If you want to actually support mid-step sensor toggling, that's a separate design discussion (would need arbiter destruction + recreation, or a deferred change queue) — let's keep it out of this PR.

2. The PR covers 3 of the 10 cases listed in #170

That's totally fine if the PR scope is narrower than the issue, but in that case could you either expand the coverage or update the PR title/description to reflect what's actually in scope? Here's where we stand:

# Edge case from #170 In this PR
1 Body removes itself in its own collision callback
2 Constraint removed during pre-step / post-step callback
3 Shape sensor flag toggled during active collision ⚠️ needs reframing (see #1 above)
4 Material / friction change during sustained contact
5 Listener throws — engine recovers, subsequent listeners fire
6 Very small / very large unit scales (non-1.0 systems)
7 Empty compound (zero shapes) added to space
8 Broadphase query FilterCallback always-true vs always-false
9 Compound de-parented mid-step
10 Body wake-up via applied impulse during sleep callback

3. Housekeeping

  • Please rebase onto current master (PR Feat/convex cast demo #156 landed since you forked).
  • Run npm run format:check — there's a small Prettier issue in the test file.
  • Add Closes #170 to the PR description so GitHub links the PR to the issue.

The body self-removal test and broadphase filter test look great. Thanks!

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /