Browse Source

Merge pull request #101014 from BattyBovine/cs3d-separation-ray-fix-2

Prevent errors when drawing debug meshes with no mesh data.
Thaddeus Crews 7 tháng trước cách đây
mục cha
commit
bacf8d198d

+ 1 - 1
editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp

@@ -350,7 +350,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
 
 	if (cs->get_debug_fill_enabled()) {
 		Ref<ArrayMesh> array_mesh = s->get_debug_arraymesh_faces(collision_color);
-		if (array_mesh.is_valid()) {
+		if (array_mesh.is_valid() && array_mesh->get_surface_count() > 0) {
 			p_gizmo->add_mesh(array_mesh, material_arraymesh);
 		}
 	}

+ 6 - 3
scene/resources/3d/shape_3d.cpp

@@ -132,9 +132,12 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
 		debug_mesh_cache->surface_set_material(0, material);
 
 		if (debug_fill) {
-			Array solid_array = get_debug_arraymesh_faces(debug_color * Color(1.0, 1.0, 1.0, 0.0625))->surface_get_arrays(0);
-			debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, solid_array);
-			debug_mesh_cache->surface_set_material(1, material);
+			Ref<ArrayMesh> array_mesh = get_debug_arraymesh_faces(debug_color * Color(1.0, 1.0, 1.0, 0.0625));
+			if (array_mesh.is_valid() && array_mesh->get_surface_count() > 0) {
+				Array solid_array = array_mesh->surface_get_arrays(0);
+				debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, solid_array);
+				debug_mesh_cache->surface_set_material(1, material);
+			}
 		}
 	}