You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Improve collision generation usability in the new 3D scene import workflow.
With this PR it's possible to add a collision during the Mesh import, directly in editor. To generate the shape is possible to chose between the following options: - Decompose Convex: The Mesh is decomposed in one or many Convex Shapes (Using the VHACD library). - Simple Convex: Is generated a convex shape that enclose the entire mesh. - Trimesh: Generate a trimesh shape using the Mesh faces. - Box: Add a primitive box shape, where you can tweak the `size`, `position`, `rotation`. - Sphere: Add a primitive sphere shape, where you can tweak the `radius`, `position`, `rotation`. - Cylinder: Add a primitive cylinder shape, where you can tweak the `height`, `radius`, `position`, `rotation`. - Capsule: Add a primitive capsule shape, where you can tweak the `height`, `radius`, `position`, `rotation`. It's also possible to chose the generated body, so you can create: - Rigid Body. - Static Body. - Area.
This commit is contained in:
@@ -224,7 +224,9 @@ Vector<Face3> Mesh::get_faces() const {
|
||||
|
||||
Ref<Shape3D> Mesh::create_convex_shape(bool p_clean, bool p_simplify) const {
|
||||
if (p_simplify) {
|
||||
Vector<Ref<Shape3D>> decomposed = convex_decompose(1);
|
||||
ConvexDecompositionSettings settings;
|
||||
settings.max_convex_hulls = 1;
|
||||
Vector<Ref<Shape3D>> decomposed = convex_decompose(settings);
|
||||
if (decomposed.size() == 1) {
|
||||
return decomposed[0];
|
||||
} else {
|
||||
@@ -564,12 +566,12 @@ void Mesh::clear_cache() const {
|
||||
debug_lines.clear();
|
||||
}
|
||||
|
||||
Vector<Ref<Shape3D>> Mesh::convex_decompose(int p_max_convex_hulls) const {
|
||||
Vector<Ref<Shape3D>> Mesh::convex_decompose(const ConvexDecompositionSettings &p_settings) const {
|
||||
ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape3D>>());
|
||||
|
||||
const Vector<Face3> faces = get_faces();
|
||||
|
||||
Vector<Vector<Face3>> decomposed = convex_composition_function(faces, p_max_convex_hulls);
|
||||
const Vector<Vector<Face3>> decomposed = convex_composition_function(faces, p_settings);
|
||||
|
||||
Vector<Ref<Shape3D>> ret;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user