summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsjtxietian <jsjtxietian@outlook.com>2024-05-14 11:43:09 +0800
committerjsjtxietian <jsjtxietian@outlook.com>2024-05-14 11:43:09 +0800
commitd9399f59f5be664bc0513772a115341b5128913f (patch)
tree765882748e3d95d08a0c4b63d92d7019fe558e6e
parentbdc0316217940a8ccc80ce536547d42e6477adf4 (diff)
downloadredot-engine-d9399f59f5be664bc0513772a115341b5128913f.tar.gz
Add useful error msg in `GodotSoftBody3D::set_mesh`
-rw-r--r--servers/physics_3d/godot_soft_body_3d.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp
index fd9141f46e..7284076a47 100644
--- a/servers/physics_3d/godot_soft_body_3d.cpp
+++ b/servers/physics_3d/godot_soft_body_3d.cpp
@@ -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();
}