Fix ghost collisions in segment_intersects_convex() #106084
Merged
+5
−0
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.
Previously
segment_intersects_convex()ignored planes parallel to the segment. This is because the segment cannot intersect this plane. However, if the points are above the plane then that means the plane separates the hull from the segment and therefore the segment cannot possibly intersect the convex hull.I encountered this bug doing procedural level generation with a concave shape similar to a heightmap with true holes and found it much faster to skip the physics server and just do manual collision checking, but this bug caused many incorrect collisions and poor results. After the fix the collision works flawlessly.
master:

This pr:

As you can see the function works in most cases in master, however the two segment marked as "bad" are parallel to the plane of the box which is facing them. Currently this means that the top plane of the box is counted as intersecting (which is wrong).
The project from the screenshots is available here: mrp.zip
Notice how in master if you change the x coordinates for segments 0 or 1, they stop reporting false collisions.
Fixes #69455.