-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix segment intersection consistency in Geometry2D #52110
Fix segment intersection consistency in Geometry2D #52110
Conversation
Checks are currently failing on this unit test:
It says |
That must have been a mistake of mine...at least the error message as they are cleary not parallel and touch in (1, -1). Maybe i tried to test that touching != intersecting at the time but i don't remember. You can replace the points in the test with |
509137a
to
fe61132
Compare
@mbrlabs Thanks! I've updated the parallel segment test following your suggestion and added new ones for touching segments. Edit: Also as a note, |
d916dde
to
3282d06
Compare
Segment collision results could be different depending on the direction when they exactly touch (order of the points in segments). This was due to the way parallelism was checked, using different logic based on positive or negative sign of cross products. Now the results are the same whatever the direction, without changing the current design, which is that parallel or colinear segments are not considered colinear. Fixes inconsistencies with raycasts exactly on edges of convex shapes depending on the direction.
3282d06
to
511c80b
Compare
Could this fix #41011 as well?
True. |
Yes, it will fix #41011 as well. Thanks! I've added it to the description. |
Segment collision results could be different depending on the direction when they exactly touch (order of the points in segments). This was due to the way parallelism was checked, using different logic based on positive or negative sign of cross product.
Now the results are the same whatever the direction, without changing the current design, which is that parallel or colinear segments are not considered colinear.
It's still probably safer to make this change only on master to avoid unexpected side effects.
Fixes inconsistencies with raycasts exactly on edges of convex shapes depending on the direction.
Fixes #52088
Edit: fixes #41011 as well
Apart from the physics issue, here's an example that shows inconsistencies.
Script (just needs a Control node to run):
Result (segments in green and blue, shows a yellow dot when there is an intersection):

With this PR, both of these cases detect the intersection the same way:
