diff options
Diffstat (limited to 'modules/csg/csg_shape.cpp')
-rw-r--r-- | modules/csg/csg_shape.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 7cafccfdcb..9c178997c5 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -300,7 +300,7 @@ void CSGShape3D::_update_shape() { root_mesh.unref(); //byebye root mesh CSGBrush *n = _get_brush(); - ERR_FAIL_COND_MSG(!n, "Cannot get CSGBrush."); + ERR_FAIL_NULL_MSG(n, "Cannot get CSGBrush."); OAHashMap<Vector3, Vector3> vec_map; @@ -458,7 +458,7 @@ void CSGShape3D::_update_shape() { void CSGShape3D::_update_collision_faces() { if (use_collision && is_root_shape() && root_collision_shape.is_valid()) { CSGBrush *n = _get_brush(); - ERR_FAIL_COND_MSG(!n, "Cannot get CSGBrush."); + ERR_FAIL_NULL_MSG(n, "Cannot get CSGBrush."); Vector<Vector3> physics_faces; physics_faces.resize(n->faces.size() * 3); Vector3 *physicsw = physics_faces.ptrw(); @@ -488,7 +488,9 @@ bool CSGShape3D::_is_debug_collision_shape_visible() { } void CSGShape3D::_update_debug_collision_shape() { - // NOTE: This is called only for the root shape with collision, when root_collision_shape is valid. + if (!use_collision || !is_root_shape() || !root_collision_shape.is_valid() || !_is_debug_collision_shape_visible()) { + return; + } ERR_FAIL_NULL(RenderingServer::get_singleton()); @@ -573,6 +575,11 @@ void CSGShape3D::_notification(int p_what) { // Update this node's parent only if its own visibility has changed, not the visibility of parent nodes parent_shape->_make_dirty(); } + if (is_visible()) { + _update_debug_collision_shape(); + } else { + _clear_debug_collision_shape(); + } last_visible = is_visible(); } break; |