-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
[3.x] Fix duplicated edges in convex hull generator #52046
[3.x] Fix duplicated edges in convex hull generator #52046
Conversation
All edges where accumulated from all faces, which ended up with double the amount in the final mesh data leading to performance issues in godot physics.
} | ||
|
||
ConvexHullComputer ch; | ||
ch.compute(p_points, p_point_count, -1.0, -1.0); | ||
|
||
r_mesh.vertices = ch.vertices; | ||
int vertex_count = r_mesh.vertices.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do with a comment here and at the resize at the bottom of the function to explain why this is being done - it is clear in the PR text, but not in the source.
if (face.indices.size() >= 3) { | ||
face.plane = Plane(r_mesh.vertices[face.indices[0]], r_mesh.vertices[face.indices[1]], r_mesh.vertices[face.indices[2]]); | ||
} else { | ||
WARN_PRINT("Too few vertices per face."); | ||
} | ||
} | ||
|
||
r_mesh.edges.resize(edge_count); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment to explain.
Looks fine to me, I'd just add a couple of comments to explain what is going on in the source because it isn't immediately clear. |
Ah, you're of course right. Since this is a half edge data structure, there's a reverse edge for every edge. Rather than going through a set, you can simply pick one of the two as the canonical edge. (E.g. the one where |
I made a PR with my approach: #52059 |
Closing in favor of #52059. |
All edges where accumulated from all faces, which ended up with double the amount in the final mesh data leading to performance issues in godot physics.
Fix #51909 (regression from #48533)
CC @mortarroad if you would like to review
If this fix is ok I'll make a PR on master tomorrow.