From 2887d872320efc50d377ebe299c7e0beaedb67d8 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 29 Oct 2021 10:10:58 +0200 Subject: 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. --- .../blender/nodes/geometry/nodes/node_geo_collection_info.cc | 10 ++++++++-- 1 file 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(); - const Object *self_object = params.self_object(); - const bool separate_children = params.get_input("Separate Children"); if (separate_children) { const bool reset_children = params.get_input("Reset Children"); -- cgit v1.2.3