Browse Source

Fix crash on debug shapes update if CollisionObject3D is not in tree

trollodel 4 years ago
parent
commit
fea75bb112
1 changed files with 5 additions and 0 deletions
  1. 5 0
      scene/3d/collision_object_3d.cpp

+ 5 - 0
scene/3d/collision_object_3d.cpp

@@ -215,6 +215,11 @@ void CollisionObject3D::_shape_changed(const Ref<Shape3D> &p_shape) {
 }
 }
 
 
 void CollisionObject3D::_update_debug_shapes() {
 void CollisionObject3D::_update_debug_shapes() {
+	if (!is_inside_tree()) {
+		debug_shapes_to_update.clear();
+		return;
+	}
+
 	for (Set<uint32_t>::Element *shapedata_idx = debug_shapes_to_update.front(); shapedata_idx; shapedata_idx = shapedata_idx->next()) {
 	for (Set<uint32_t>::Element *shapedata_idx = debug_shapes_to_update.front(); shapedata_idx; shapedata_idx = shapedata_idx->next()) {
 		if (shapes.has(shapedata_idx->get())) {
 		if (shapes.has(shapedata_idx->get())) {
 			ShapeData &shapedata = shapes[shapedata_idx->get()];
 			ShapeData &shapedata = shapes[shapedata_idx->get()];