diff options
author | Jacques Lucke <jacques@blender.org> | 2021-09-29 11:08:40 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-09-29 11:10:12 +0300 |
commit | f51bef75f44681c7a33cf54c790ff4cee949c274 (patch) | |
tree | 6aa1e73cbb4a594ff809c612966dafd2a11736c5 /source/blender | |
parent | 8cbec0beb2f31447dc20784f66334c997bbc3b0f (diff) |
Geometry Nodes: instance on points in instances
For consistency with other nodes, we also want to process
all instances in the Points input independently. This allows
for more efficient instancing of many objects but also leads
to nested instancing. All instances are processed in their
local space, so that instances don't have to be realized.
Differential Revision: https://developer.blender.org/D12660
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index cf9f04f3fe8..490535224c8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -163,28 +163,31 @@ static void add_instances_from_component(InstancesComponent &dst_component, static void geo_node_instance_on_points_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input<GeometrySet>("Points"); - GeometrySet geometry_set_out; - InstancesComponent &instances = geometry_set_out.get_component_for_write<InstancesComponent>(); + geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) { + InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); - if (geometry_set.has<MeshComponent>()) { - add_instances_from_component( - instances, *geometry_set.get_component_for_read<MeshComponent>(), params); - } - if (geometry_set.has<PointCloudComponent>()) { - add_instances_from_component( - instances, *geometry_set.get_component_for_read<PointCloudComponent>(), params); - } - if (geometry_set.has<CurveComponent>()) { - add_instances_from_component( - instances, *geometry_set.get_component_for_read<CurveComponent>(), params); - } - - /* Unused references may have been added above. Remove those now so that other nodes don't - * process them needlessly. */ - instances.remove_unused_references(); + if (geometry_set.has<MeshComponent>()) { + add_instances_from_component( + instances, *geometry_set.get_component_for_read<MeshComponent>(), params); + geometry_set.remove(GEO_COMPONENT_TYPE_MESH); + } + if (geometry_set.has<PointCloudComponent>()) { + add_instances_from_component( + instances, *geometry_set.get_component_for_read<PointCloudComponent>(), params); + geometry_set.remove(GEO_COMPONENT_TYPE_POINT_CLOUD); + } + if (geometry_set.has<CurveComponent>()) { + add_instances_from_component( + instances, *geometry_set.get_component_for_read<CurveComponent>(), params); + geometry_set.remove(GEO_COMPONENT_TYPE_CURVE); + } + /* Unused references may have been added above. Remove those now so that other nodes don't + * process them needlessly. */ + instances.remove_unused_references(); + }); - params.set_output("Instances", std::move(geometry_set_out)); + params.set_output("Instances", std::move(geometry_set)); } } // namespace blender::nodes |