Skip to content

QuickHull generates bad hull sometimes when multiple triangles share the same plane. #45946

Closed
@jitspoe

Description

Godot version:
3.2.3
3.2.4.rc2

OS/device including version:
Windows 10

Issue description:
QuickHull fails to merge edges sometimes and results in generating multiple of the same plane and wrong geometry. Errors printed to the log include things like:
core\math\quick_hull.cpp:402 - Condition "O == 0" is true. Continuing.
core\math\quick_hull.cpp:399 - Condition "!F" is true. Continuing.
core\math\quick_hull.cpp:428 - Condition "!F2" is true. Continuing.

Example:
image
Edit: Just tried in 3.2.4.rc2, and the result was slightly different, but still broken:
image
(Should just be an octagon)

Steps to reproduce:
Generate a convex collision from something like a cylinder or another object that has many triangles on the same face, preferably at some odd angle. Doesn't always reproduce.

Notes:
I've stepped through the QuickHull::build() function, and the problem seems to reside in the logic to merge faces and remove edges on a single plane. It makes some assumptions about the structure/order of vertices. If things overlap instead of being next to each other, the algorithm falls apart. When the errors happen, extra planes are left in the hull that shouldn't be there.

It might be better to just generate the the planes, ignoring edges and verts, then generate the edges and verts at the end based on plane intersections. It would also be nice if the edge generation was optional, because it's only necessary when displaying the hull, not when using it for collision purposes.

Minimal reproduction project:
test_quickull.zip

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions