Skip to content

Commit bacf8d1

Browse files
committed
Merge pull request godotengine#101014 from BattyBovine/cs3d-separation-ray-fix-2
Prevent errors when drawing debug meshes with no mesh data.
2 parents cabd792 + 6dc6ad2 commit bacf8d1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
350350

351351
if (cs->get_debug_fill_enabled()) {
352352
Ref<ArrayMesh> array_mesh = s->get_debug_arraymesh_faces(collision_color);
353-
if (array_mesh.is_valid()) {
353+
if (array_mesh.is_valid() && array_mesh->get_surface_count() > 0) {
354354
p_gizmo->add_mesh(array_mesh, material_arraymesh);
355355
}
356356
}

scene/resources/3d/shape_3d.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
132132
debug_mesh_cache->surface_set_material(0, material);
133133

134134
if (debug_fill) {
135-
Array solid_array = get_debug_arraymesh_faces(debug_color * Color(1.0, 1.0, 1.0, 0.0625))->surface_get_arrays(0);
136-
debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, solid_array);
137-
debug_mesh_cache->surface_set_material(1, material);
135+
Ref<ArrayMesh> array_mesh = get_debug_arraymesh_faces(debug_color * Color(1.0, 1.0, 1.0, 0.0625));
136+
if (array_mesh.is_valid() && array_mesh->get_surface_count() > 0) {
137+
Array solid_array = array_mesh->surface_get_arrays(0);
138+
debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, solid_array);
139+
debug_mesh_cache->surface_set_material(1, material);
140+
}
138141
}
139142
}
140143

0 commit comments

Comments
 (0)