Skip to content

Commit a5e87dd

Browse files
committed
Merge pull request #106725 from mihe/jolt/silent-degenerate-soft-bodies
Remove error for degenerate soft body faces when using Jolt Physics
2 parents ee82adc + d153a26 commit a5e87dd

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

modules/jolt_physics/objects/jolt_soft_body_3d.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444

4545
namespace {
4646

47-
bool is_face_degenerate(const int p_face[3]) {
48-
return p_face[0] == p_face[1] || p_face[0] == p_face[2] || p_face[1] == p_face[2];
49-
}
50-
5147
template <typename TJoltVertex>
5248
void pin_vertices(const JoltSoftBody3D &p_body, const HashSet<int> &p_pinned_vertices, const LocalVector<int> &p_mesh_to_physics, JPH::Array<TJoltVertex> &r_physics_vertices) {
5349
const int mesh_vertex_count = p_mesh_to_physics.size();
@@ -163,7 +159,6 @@ bool JoltSoftBody3D::_ref_shared_data() {
163159

164160
for (int i = 0; i < mesh_index_count; i += 3) {
165161
int physics_face[3];
166-
int mesh_face[3];
167162

168163
for (int j = 0; j < 3; ++j) {
169164
const int mesh_index = mesh_indices[i + j];
@@ -173,16 +168,16 @@ bool JoltSoftBody3D::_ref_shared_data() {
173168

174169
if (iter_physics_index == vertex_to_physics.end()) {
175170
physics_vertices.emplace_back(JPH::Float3((float)vertex.x, (float)vertex.y, (float)vertex.z), JPH::Float3(0.0f, 0.0f, 0.0f), 1.0f);
176-
177171
iter_physics_index = vertex_to_physics.insert(vertex, physics_index_count++);
178172
}
179173

180-
mesh_face[j] = mesh_index;
181174
physics_face[j] = iter_physics_index->value;
182175
mesh_to_physics[mesh_index] = iter_physics_index->value;
183176
}
184177

185-
ERR_CONTINUE_MSG(is_face_degenerate(physics_face), vformat("Failed to append face to soft body '%s'. Face was found to be degenerate. Face consist of indices %d, %d and %d.", to_string(), mesh_face[0], mesh_face[1], mesh_face[2]));
178+
if (physics_face[0] == physics_face[1] || physics_face[0] == physics_face[2] || physics_face[1] == physics_face[2]) {
179+
continue; // We skip degenerate faces, since they're problematic, and Jolt will assert about it anyway.
180+
}
186181

187182
// Jolt uses a different winding order, so we swap the indices to account for that.
188183
physics_faces.emplace_back((JPH::uint32)physics_face[2], (JPH::uint32)physics_face[1], (JPH::uint32)physics_face[0]);

0 commit comments

Comments
 (0)