diff options
author | Jacques Lucke <jacques@blender.org> | 2022-01-05 13:47:09 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-01-05 13:47:09 +0300 |
commit | d960c78693368b34c88eb2cf56d038464d0ed808 (patch) | |
tree | 9d820d3bd8b29ee8703aeb756472b146662804fa /source/blender/blenkernel/intern | |
parent | 33400ffcc9821506eb12d3189d220da6d0d8ba14 (diff) |
Fix T94545: support realizing instanced collections
This case wasn't handled in rBf5ce243a56a22d718 correctly.
Now `object_get_evaluated_geometry_set` just returns a geometry
set that contains the collection instance for collection instance objects.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set_instances.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 4d84d5d899d..42d2211c360 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -69,9 +69,18 @@ GeometrySet object_get_evaluated_geometry_set(const Object &object) } /* Otherwise, construct a new geometry set with the component based on the object type. */ - GeometrySet geometry_set; if (object.type == OB_MESH) { + GeometrySet geometry_set; add_final_mesh_as_geometry_component(object, geometry_set); + return geometry_set; + } + if (object.type == OB_EMPTY && object.instance_collection != nullptr) { + GeometrySet geometry_set; + Collection &collection = *object.instance_collection; + InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); + const int handle = instances.add_reference(collection); + instances.add_instance(handle, float4x4::identity()); + return geometry_set; } /* TODO: Cover the case of point clouds without modifiers-- they may not be covered by the @@ -80,7 +89,7 @@ GeometrySet object_get_evaluated_geometry_set(const Object &object) /* TODO: Add volume support. */ /* Return by value since there is not always an existing geometry set owned elsewhere to use. */ - return geometry_set; + return {}; } static void geometry_set_collect_recursive_collection_instance( @@ -98,13 +107,6 @@ static void geometry_set_collect_recursive_object(const Object &object, { GeometrySet instance_geometry_set = object_get_evaluated_geometry_set(object); geometry_set_collect_recursive(instance_geometry_set, transform, r_sets); - - if (object.type == OB_EMPTY) { - const Collection *collection_instance = object.instance_collection; - if (collection_instance != nullptr) { - geometry_set_collect_recursive_collection_instance(*collection_instance, transform, r_sets); - } - } } static void geometry_set_collect_recursive_collection(const Collection &collection, |