[Bf-blender-cvs] [f51bef75f44] master: Geometry Nodes: instance on points in instances

Jacques Lucke noreply at git.blender.org
Wed Sep 29 10:10:48 CEST 2021


Commit: f51bef75f44681c7a33cf54c790ff4cee949c274
Author: Jacques Lucke
Date:   Wed Sep 29 10:08:40 2021 +0200
Branches: master
https://developer.blender.org/rBf51bef75f44681c7a33cf54c790ff4cee949c274

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

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

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

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

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



More information about the Bf-blender-cvs mailing list