From decdf4fcbc51d3e3cff765bdecb5418f87fa3847 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 25 Apr 2021 08:01:14 +0100 Subject: [PATCH] Fix empty CSGShape error --- modules/csg/csg_gizmos.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index 43d7fcb7976..d5c63ce9ca5 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -317,27 +317,16 @@ bool CSGShapeSpatialGizmoPlugin::is_selectable_when_hidden() const { void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - CSGShape *cs = Object::cast_to(p_gizmo->get_spatial_node()); - p_gizmo->clear(); - Ref material; - switch (cs->get_operation()) { - case CSGShape::OPERATION_UNION: - material = get_material("shape_union_material", p_gizmo); - break; - case CSGShape::OPERATION_INTERSECTION: - material = get_material("shape_intersection_material", p_gizmo); - break; - case CSGShape::OPERATION_SUBTRACTION: - material = get_material("shape_subtraction_material", p_gizmo); - break; - } - - Ref handles_material = get_material("handles"); + CSGShape *cs = Object::cast_to(p_gizmo->get_spatial_node()); PoolVector faces = cs->get_brush_faces(); + if (faces.size() == 0) { + return; + } + Vector lines; lines.resize(faces.size() * 2); { @@ -353,6 +342,21 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } } + Ref material; + switch (cs->get_operation()) { + case CSGShape::OPERATION_UNION: + material = get_material("shape_union_material", p_gizmo); + break; + case CSGShape::OPERATION_INTERSECTION: + material = get_material("shape_intersection_material", p_gizmo); + break; + case CSGShape::OPERATION_SUBTRACTION: + material = get_material("shape_subtraction_material", p_gizmo); + break; + } + + Ref handles_material = get_material("handles"); + p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines);