From 24a6aac472d3d57bb0720c5ac46a98856e3bd5e0 Mon Sep 17 00:00:00 2001 From: hoontee <5272529+hoontee@users.noreply.github.com> Date: Sat, 26 Dec 2020 23:53:49 -0600 Subject: [PATCH] Properly handle empty CSGShapes --- modules/csg/csg_shape.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index cea006364f1..b08810c7e47 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -700,7 +700,7 @@ CSGPrimitive3D::CSGPrimitive3D() { CSGBrush *CSGMesh3D::_build_brush() { if (!mesh.is_valid()) { - return nullptr; + return memnew(CSGBrush); } Vector vertices; @@ -718,7 +718,7 @@ CSGBrush *CSGMesh3D::_build_brush() { if (arrays.size() == 0) { _make_dirty(); - ERR_FAIL_COND_V(arrays.size() == 0, nullptr); + ERR_FAIL_COND_V(arrays.size() == 0, memnew(CSGBrush)); } Vector avertices = arrays[Mesh::ARRAY_VERTEX]; @@ -839,7 +839,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } if (vertices.size() == 0) { - return nullptr; + return memnew(CSGBrush); } return _create_brush_from_arrays(vertices, uvs, smooth, materials); @@ -1501,7 +1501,7 @@ CSGBrush *CSGTorus3D::_build_brush() { float max_radius = outer_radius; if (min_radius == max_radius) { - return nullptr; //sorry, can't + return memnew(CSGBrush); //sorry, can't } if (min_radius > max_radius) { @@ -1720,7 +1720,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { // set our bounding box if (polygon.size() < 3) { - return nullptr; + return memnew(CSGBrush); } Vector final_polygon = polygon; @@ -1732,7 +1732,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { Vector triangles = Geometry2D::triangulate_polygon(final_polygon); if (triangles.size() < 3) { - return nullptr; + return memnew(CSGBrush); } Path3D *path = nullptr; @@ -1766,15 +1766,15 @@ CSGBrush *CSGPolygon3D::_build_brush() { if (mode == MODE_PATH) { if (!has_node(path_node)) { - return nullptr; + return memnew(CSGBrush); } Node *n = get_node(path_node); if (!n) { - return nullptr; + return memnew(CSGBrush); } path = Object::cast_to(n); if (!path) { - return nullptr; + return memnew(CSGBrush); } if (path != path_cache) { @@ -1792,10 +1792,10 @@ CSGBrush *CSGPolygon3D::_build_brush() { } curve = path->get_curve(); if (curve.is_null()) { - return nullptr; + return memnew(CSGBrush); } if (curve->get_baked_length() <= 0) { - return nullptr; + return memnew(CSGBrush); } } CSGBrush *brush = memnew(CSGBrush);