Skip to content

Conversation

@Kaleb-Reid
Copy link
Contributor

@Kaleb-Reid Kaleb-Reid commented May 5, 2025

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:
image

This pr:
image

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.

@Kaleb-Reid Kaleb-Reid requested review from a team as code owners May 5, 2025 05:47
@Chaosus Chaosus added this to the 4.5 milestone May 5, 2025
@Kaleb-Reid Kaleb-Reid changed the title Check if plane parallel to segment is separating in segment_intersects_convex Fix ghost collisions in segment_intersects_convex() May 5, 2025
@Repiteo Repiteo modified the milestones: 4.5, 4.x Jun 16, 2025
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. Code looks good to me.

While this is technically not involving physics engines, I suggest having someone from @godotengine/physics take a second look, just in case.

@Calinou Calinou requested a review from a team August 26, 2025 17:55
Copy link
Member

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check the rest of the function but the added code is correct and should be there indeed.

@Ivorforce Ivorforce added the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Aug 28, 2025
@Ivorforce Ivorforce modified the milestones: 4.x, 4.6 Aug 28, 2025
@Repiteo Repiteo merged commit 00f8f62 into godotengine:master Oct 3, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 3, 2025

Thanks!

@Kaleb-Reid Kaleb-Reid deleted the fix-geometry-3d branch October 3, 2025 17:15
@Repiteo Repiteo removed the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment