Skip to content
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

Add a mesh simplification option for TriMesh collision shape generation in the advanced import settings #3603

Open
Calinou opened this issue Nov 26, 2021 · 0 comments · May be fixed by godotengine/godot#82649

Comments

@Calinou
Copy link
Member

Calinou commented Nov 26, 2021

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Levels with complex geometry will have complex triangle meshes generated by default, which lowers physics simulation performance and reliability. Maximizing physics server performance is important for games where CPU cycles come at a premium (mobile/web platforms) and for game servers that use server-side physics.

Using a separate hand-authored collision mesh with less details will result in faster and more reliable collisions. However, while iterating on the level geometry, having to maintain this mesh separately can take a lot of time.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add an option to simplify the generated trimesh collision shape using a decimation algorithm (below Shape Type when Trimesh is selected):

image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Like for LOD generation, use meshoptimizer to create a less detailed version of the base mesh to use as triangle data for a concave CollisionShape. By default, I would recommend using a very low level of simplification to weld faces that have no concrete angle difference. In meshoptimizer, this can be done by using a simplification threshold of 0.0001.

Unlike for occluder generation, we probably don't have to worry about shrinking the generated collider along the normal or something along those lines.

I created a minimal project for testing the feature implementation (4.0 only): test_trimesh_collision_simplify.zip

I have a WIP branch with an implementation of this feature, but I don't know if I'll be able to complete it: https://github.com/Calinou/godot/tree/trimesh-generation-add-simplification

If this enhancement will not be used often, can it be worked around with a few lines of script?

This may be feasible with a custom import script, but it will require more than a few lines of code.

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving performance in situations where creating hand-made shapes is not feasible due to lack of time or resources.

@Calinou Calinou added this to the 4.x milestone Nov 26, 2021
basicer added a commit to basicer/godot that referenced this issue Oct 4, 2023
… 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>
basicer added a commit to basicer/godot that referenced this issue Apr 20, 2024
… 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>
basicer added a commit to basicer/godot that referenced this issue Oct 5, 2024
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant