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

Prevent errors when drawing debug meshes with no mesh data.
This commit is contained in:
Thaddeus Crews 2025-01-20 16:25:48 -06:00
commit bacf8d198d
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
2 changed files with 7 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}
}