-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
When importing a mesh, allow the user to simplify the created physics TriMesh with mesh optimizer. #82649
base: master
Are you sure you want to change the base?
Conversation
This is my first patch for godot! I considered also implementing the simplification method on Mesh, but was a bit thrown off by how much code is duplicated between Mesh and ImporterMesh. |
035b9e2
to
59c7412
Compare
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.
Tested locally, it works as expected. The default parameters seem to generate a collision shape close to the original, but with fewer vertices.
59c7412
to
2c00b66
Compare
I think some of the options can be streamlined. For collision shapes, do we really care about topology? That is to say, do we need to have the 'sloppy' toggle? |
I agree. These options should be as simple as possible. Ideally just a slider for simplification amount. |
I thought about a few options to cut down on the number of tweakable but nothing really came out of it. Sometimes the mesh you get from sloppy is closer to the "idea" mesh, sometimes the non-sloppy one is better, it seems to just depend on the model. As far as trying to combine the target number or vertices and the target error into a single slider, I'm not sure how what sort of formula you would use to translate simplification amount into those two values. |
ea03473
to
4b2a6e6
Compare
4b2a6e6
to
e3a65a1
Compare
Godot uses the error metric to distance in autolod. Maybe there's something there you can remix. |
22950fc
to
7ef13cc
Compare
7ef13cc
to
74ff80a
Compare
74ff80a
to
426a41f
Compare
35190ac
to
429516d
Compare
429516d
to
c0b66cb
Compare
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.
Tested locally (rebased on top of master
4a01602), it mostly works as expected.
The single setting with 3 options makes the configuration much easier now.
However, the 3D preview doesn't always update after you change the simplification setting in the Advanced Import Settings dialog. It only seems to be consistently updated when you change the physics type from something else to Trimesh.
Testing project: test_collision_shape_simplify_on_import.zip
Off | Low (Conservative) |
---|---|
Medium (Balanced) | High (Aggressive) |
---|---|
I rebased this on top of 11d3768 and couldn't reproduce this problem, however I do vaguely remember having it at some point while developing. Does this trigger consistently for you? |
No, it's quite random and unpredictable 🙁 |
… TriMesh with mesh optimizer. Adds a new simplification option to the model importer when the trimesh physics mesh mode is selected similar to how the options for convex decomposition are presented. Also adds GDScript exports to generate a convex shapes and trimesh shapes (both simplified and simplified) to ImportMesh match Mesh. Closes godotengine/godot-proposals#3603, tested with the example project posted there. Update doc/classes/MeshSimplificationSettings.xml Update doc/classes/MeshSimplificationSettings.xml Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro> Update editor/import/3d/resource_importer_scene.cpp Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
be22db4
to
b367e93
Compare
In dm, we discussed: There's at least three ways of using the mesh optimizer, and I can probably think of three more ways. We can move the Godot Engine lod generator to a unified object. We don't think MeshLOD and physics simplification should be used similarly but add it as a separate option. So the idea is improving code organization. Move the lod generator to a unified thing. MeshLOD doesn't fit inside ImporterMesh, and you can add other methods. https://github.com/godotengine/godot/blob/master/scene/resources/3d/importer_mesh.cpp#L309 |
Adds a new simplification option to the model importer when the trimesh physics mesh mode is selected similar to how the options for convex decomposition are presented.
Also adds GDScript exports to generate a convex shapes and trimesh shapes (both simplified and simplified) to ImportMesh match Mesh.
Closes godotengine/godot-proposals#3603, tested with the example project posted there.