summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2021-08-30 11:30:36 -0300
committerGitHub <noreply@github.com>2021-08-30 11:30:36 -0300
commit6dab6e4136540152558eff0085de1acdea143fd9 (patch)
tree8f99a2b6042fadf8afde25f0e41c9a69d9651270 /scene
parentb60a51f0232246be0c8a0544253336e34d346724 (diff)
Revert " Improve collision generation usability in the new 3D scene import workflow."
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/mesh_instance_3d.cpp3
-rw-r--r--scene/resources/mesh.cpp8
-rw-r--r--scene/resources/mesh.h35
3 files changed, 6 insertions, 40 deletions
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index 7e7db57af3..de6925244a 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -274,8 +274,7 @@ Node *MeshInstance3D::create_multiple_convex_collisions_node() {
return nullptr;
}
- Mesh::ConvexDecompositionSettings settings;
- Vector<Ref<Shape3D>> shapes = mesh->convex_decompose(settings);
+ Vector<Ref<Shape3D>> shapes = mesh->convex_decompose();
if (!shapes.size()) {
return nullptr;
}
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 4f301fca95..ad589a605e 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -224,9 +224,7 @@ Vector<Face3> Mesh::get_faces() const {
Ref<Shape3D> Mesh::create_convex_shape(bool p_clean, bool p_simplify) const {
if (p_simplify) {
- ConvexDecompositionSettings settings;
- settings.max_convex_hulls = 1;
- Vector<Ref<Shape3D>> decomposed = convex_decompose(settings);
+ Vector<Ref<Shape3D>> decomposed = convex_decompose(1);
if (decomposed.size() == 1) {
return decomposed[0];
} else {
@@ -566,12 +564,12 @@ void Mesh::clear_cache() const {
debug_lines.clear();
}
-Vector<Ref<Shape3D>> Mesh::convex_decompose(const ConvexDecompositionSettings &p_settings) const {
+Vector<Ref<Shape3D>> Mesh::convex_decompose(int p_max_convex_hulls) const {
ERR_FAIL_COND_V(!convex_composition_function, Vector<Ref<Shape3D>>());
const Vector<Face3> faces = get_faces();
- const Vector<Vector<Face3>> decomposed = convex_composition_function(faces, p_settings);
+ Vector<Vector<Face3>> decomposed = convex_composition_function(faces, p_max_convex_hulls);
Vector<Ref<Shape3D>> ret;
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 240182361f..27b0eb098b 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -159,42 +159,11 @@ public:
Size2i get_lightmap_size_hint() const;
void clear_cache() const;
- struct ConvexDecompositionSettings {
- enum Mode : int {
- CONVEX_DECOMPOSITION_MODE_VOXEL = 0,
- CONVEX_DECOMPOSITION_MODE_TETRAHEDRON
- };
-
- /// Maximum concavity. [Range: 0.0 -> 1.0]
- real_t max_concavity = 1.0;
- /// Controls the bias toward clipping along symmetry planes. [Range: 0.0 -> 1.0]
- real_t symmetry_planes_clipping_bias = 0.05;
- /// Controls the bias toward clipping along revolution axes. [Range: 0.0 -> 1.0]
- real_t revolution_axes_clipping_bias = 0.05;
- real_t min_volume_per_convex_hull = 0.0001;
- /// Maximum number of voxels generated during the voxelization stage.
- uint32_t resolution = 10'000;
- uint32_t max_num_vertices_per_convex_hull = 32;
- /// Controls the granularity of the search for the "best" clipping plane.
- /// [Range: 1 -> 16]
- uint32_t plane_downsampling = 4;
- /// Controls the precision of the convex-hull generation process during the
- /// clipping plane selection stage.
- /// [Range: 1 -> 16]
- uint32_t convexhull_downsampling = 4;
- /// enable/disable normalizing the mesh before applying the convex decomposition.
- bool normalize_mesh = false;
- Mode mode = CONVEX_DECOMPOSITION_MODE_VOXEL;
- bool convexhull_approximation = true;
- /// This is the maximum number of convex hulls to produce from the merge operation.
- uint32_t max_convex_hulls = 1;
- bool project_hull_vertices = true;
- };
- typedef Vector<Vector<Face3>> (*ConvexDecompositionFunc)(const Vector<Face3> &p_faces, const ConvexDecompositionSettings &p_settings);
+ typedef Vector<Vector<Face3>> (*ConvexDecompositionFunc)(const Vector<Face3> &p_faces, int p_max_convex_hulls);
static ConvexDecompositionFunc convex_composition_function;
- Vector<Ref<Shape3D>> convex_decompose(const ConvexDecompositionSettings &p_settings) const;
+ Vector<Ref<Shape3D>> convex_decompose(int p_max_convex_hulls = -1) const;
virtual int get_builtin_bind_pose_count() const;
virtual Transform3D get_builtin_bind_pose(int p_index) const;