Repository navigation
Fix Distance() witness points for overlapping shapes with useRadii - #320
Merged
Merged
Conversation
The matrix refactor replaced Vec2.mid(pointA, pointB) with subVec2(pointA, pointB), so both witness points became pointA - pointB. Use combine2Vec2(0.5, pointA, 0.5, pointB) like Box2D. Fixes #318
|
@bardrop is attempting to deploy a commit to the Piqnt Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
Thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #318
When
input.useRadiiis set and the shapes overlap after the radii,Distance()should move both witness points to the middle (the comment says so, and Box2D uses0.5f * (pointA + pointB)). Since the matrix refactor (b7ce8be) the line wasmatrix.subVec2(temp, pointA, pointB), so both points becamepointA - pointB, e.g.(-1.5, 0)instead of(0.75, 0)for two unit circles 1.5 apart.Now it is
matrix.combine2Vec2(temp, 0.5, pointA, 0.5, pointB).Testing
src/__test__/Collision.test.ts: two overlapping circle cases from the issue (one away from the origin) plus a separated case that must keep the surface points. It fails on master, passes now.npx vitest run(18 tests) passes;npm run lintshows the same 8 warnings as master.