diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-29 11:10:58 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-29 11:10:58 +0300 |
commit | 2887d872320efc50d377ebe299c7e0beaedb67d8 (patch) | |
tree | e801b2f2fd015c091c86133928cd5f72e89a2239 | |
parent | cf771807b7997949611dbf76b43150592c9977cb (diff) |
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.
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_collection_info.cc | 10 |
1 files changed, 8 insertions, 2 deletions
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"); |