瀏覽代碼

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

Also fix ConcavePolygonShape not emitting the changed signal

(cherry picked from commit 7043d6d1c683357f311d83ffd5b8cf2669283e1b)
trollodel 4 年之前
父節點
當前提交
5b8b3f645e
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 5 0
      scene/3d/collision_object.cpp
  2. 1 0
      scene/resources/concave_polygon_shape.cpp

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

@@ -160,6 +160,11 @@ void CollisionObject::_shape_changed(const Ref<Shape> &p_shape) {
 }
 }
 
 
 void CollisionObject::_update_debug_shapes() {
 void CollisionObject::_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()];

+ 1 - 0
scene/resources/concave_polygon_shape.cpp

@@ -71,6 +71,7 @@ void ConcavePolygonShape::_update_shape() {
 void ConcavePolygonShape::set_faces(const PoolVector<Vector3> &p_faces) {
 void ConcavePolygonShape::set_faces(const PoolVector<Vector3> &p_faces) {
 
 
 	PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces);
 	PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces);
+	_update_shape();
 	notify_change_to_owners();
 	notify_change_to_owners();
 }
 }