Skip to content

Commit

Permalink
Merge pull request #91896 from jsjtxietian/softbody-msg
Browse files Browse the repository at this point in the history
Add useful error msg in `GodotSoftBody3D::set_mesh`
  • Loading branch information
akien-mga committed May 14, 2024
2 parents 598be9b + d9399f5 commit a8c6eb3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion servers/physics_3d/godot_soft_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ void GodotSoftBody3D::set_mesh(RID p_mesh) {
Array arrays = RenderingServer::get_singleton()->mesh_surface_get_arrays(soft_mesh, 0);
ERR_FAIL_COND(arrays.is_empty());

bool success = create_from_trimesh(arrays[RenderingServer::ARRAY_INDEX], arrays[RenderingServer::ARRAY_VERTEX]);
const Vector<int> &indices = arrays[RenderingServer::ARRAY_INDEX];
const Vector<Vector3> &vertices = arrays[RenderingServer::ARRAY_VERTEX];
ERR_FAIL_COND_MSG(indices.is_empty(), "Soft body's mesh needs to have indices");
ERR_FAIL_COND_MSG(vertices.is_empty(), "Soft body's mesh needs to have vertices");

bool success = create_from_trimesh(indices, vertices);
if (!success) {
destroy();
}
Expand Down

0 comments on commit a8c6eb3

Please sign in to comment.