From 8b9f532f785ac5f9d2ddf9b81b484aec6a09ad5f Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 20 May 2022 10:47:29 +0800 Subject: [PATCH] Fix editor crash when opening scene with CSGMesh (cherry picked from commit de93286b1defaae24bfeb52e4d1eb4d75e36392a) --- modules/csg/csg_gizmos.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 1f34a6ad7ee..46ba78aec45 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -379,9 +379,11 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { if (cs->is_root_shape()) { Array csg_meshes = cs->get_meshes(); - Ref csg_mesh = csg_meshes[1]; - if (csg_mesh.is_valid()) { - p_gizmo->add_collision_triangles(csg_mesh->generate_triangle_mesh()); + if (csg_meshes.size() == 2) { + Ref csg_mesh = csg_meshes[1]; + if (csg_mesh.is_valid()) { + p_gizmo->add_collision_triangles(csg_mesh->generate_triangle_mesh()); + } } }