From 7043d6d1c683357f311d83ffd5b8cf2669283e1b Mon Sep 17 00:00:00 2001 From: trollodel <33117082+trollodel@users.noreply.github.com> Date: Sat, 22 May 2021 17:33:51 +0200 Subject: [PATCH] Fix crash on debug shapes update if CollisionObject is not in tree Also fix ConcavePolygonShape not emitting the changed signal --- scene/3d/collision_object.cpp | 5 +++++ scene/resources/concave_polygon_shape.cpp | 1 + 2 files changed, 6 insertions(+) diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 01baf9fad11..42560be95cd 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -212,6 +212,11 @@ void CollisionObject::_shape_changed(const Ref &p_shape) { } void CollisionObject::_update_debug_shapes() { + if (!is_inside_tree()) { + debug_shapes_to_update.clear(); + return; + } + for (Set::Element *shapedata_idx = debug_shapes_to_update.front(); shapedata_idx; shapedata_idx = shapedata_idx->next()) { if (shapes.has(shapedata_idx->get())) { ShapeData &shapedata = shapes[shapedata_idx->get()]; diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp index 2b87a3d74e9..83eac9048b7 100644 --- a/scene/resources/concave_polygon_shape.cpp +++ b/scene/resources/concave_polygon_shape.cpp @@ -66,6 +66,7 @@ void ConcavePolygonShape::_update_shape() { void ConcavePolygonShape::set_faces(const PoolVector &p_faces) { PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces); + _update_shape(); notify_change_to_owners(); }