[Bf-blender-cvs] [2887d872320] blender-v3.0-release: Fix T92324: crash caused by recursive instancing

Jacques Lucke noreply at git.blender.org
Fri Oct 29 10:11:06 CEST 2021


Commit: 2887d872320efc50d377ebe299c7e0beaedb67d8
Author: Jacques Lucke
Date:   Fri Oct 29 10:10:58 2021 +0200
Branches: blender-v3.0-release
https://developer.blender.org/rB2887d872320efc50d377ebe299c7e0beaedb67d8

Fix T92324: crash caused by recursive instancing

This fixes one (of possibly multiple) root issues. The collection passed into
the Collection Info node must not contain the current object, because that
would result in a dependency cycle and recursive instancing.

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_collection_info.cc

===================================================================

diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
index eca4e3d2d14..18fc09daf01 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
@@ -71,6 +71,14 @@ static void geo_node_collection_info_exec(GeoNodeExecParams params)
     params.set_output("Geometry", geometry_set_out);
     return;
   }
+  const Object *self_object = params.self_object();
+  const bool is_recursive = BKE_collection_has_object_recursive_instanced(collection,
+                                                                          (Object *)self_object);
+  if (is_recursive) {
+    params.error_message_add(NodeWarningType::Error, "Collection contains current object");
+    params.set_output("Geometry", geometry_set_out);
+    return;
+  }
 
   const bNode &bnode = params.node();
   NodeGeometryCollectionInfo *node_storage = (NodeGeometryCollectionInfo *)bnode.storage;
@@ -79,8 +87,6 @@ static void geo_node_collection_info_exec(GeoNodeExecParams params)
 
   InstancesComponent &instances = geometry_set_out.get_component_for_write<InstancesComponent>();
 
-  const Object *self_object = params.self_object();
-
   const bool separate_children = params.get_input<bool>("Separate Children");
   if (separate_children) {
     const bool reset_children = params.get_input<bool>("Reset Children");



More information about the Bf-blender-cvs mailing list