[Bf-blender-cvs] [64ca2865404] master: Cleanup: Pass instance group result vector as an argument

Hans Goudey noreply at git.blender.org
Thu Mar 25 19:54:32 CET 2021


Commit: 64ca2865404ed95b1be0eb875f153673cdf5a212
Author: Hans Goudey
Date:   Thu Mar 25 14:54:27 2021 -0400
Branches: master
https://developer.blender.org/rB64ca2865404ed95b1be0eb875f153673cdf5a212

Cleanup: Pass instance group result vector as an argument

This will allow retrieving the instance groups from multiple geometry
sets and avoiding needing vectors of vectors to store the results.
This is useful when retrieving instances from a multi-input socket
of geometries.

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

M	source/blender/blenkernel/BKE_geometry_set_instances.hh
M	source/blender/blenkernel/intern/geometry_set_instances.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc

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

diff --git a/source/blender/blenkernel/BKE_geometry_set_instances.hh b/source/blender/blenkernel/BKE_geometry_set_instances.hh
index 16c28e32e3c..c372fdff049 100644
--- a/source/blender/blenkernel/BKE_geometry_set_instances.hh
+++ b/source/blender/blenkernel/BKE_geometry_set_instances.hh
@@ -39,7 +39,8 @@ struct GeometryInstanceGroup {
   Vector<float4x4> transforms;
 };
 
-Vector<GeometryInstanceGroup> geometry_set_gather_instances(const GeometrySet &geometry_set);
+void geometry_set_gather_instances(const GeometrySet &geometry_set,
+                                   Vector<GeometryInstanceGroup> &r_instance_groups);
 
 GeometrySet geometry_set_realize_mesh_for_modifier(const GeometrySet &geometry_set);
 GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set);
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 24a402ac545..10c88a47416 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -153,16 +153,13 @@ static void geometry_set_collect_recursive(const GeometrySet &geometry_set,
  *
  * \note This doesn't extract instances from the "dupli" system for non-geometry-nodes instances.
  */
-Vector<GeometryInstanceGroup> geometry_set_gather_instances(const GeometrySet &geometry_set)
+void geometry_set_gather_instances(const GeometrySet &geometry_set,
+                                   Vector<GeometryInstanceGroup> &r_instance_groups)
 {
-  Vector<GeometryInstanceGroup> result_vector;
-
   float4x4 unit_transform;
   unit_m4(unit_transform.values);
 
-  geometry_set_collect_recursive(geometry_set, unit_transform, result_vector);
-
-  return result_vector;
+  geometry_set_collect_recursive(geometry_set, unit_transform, r_instance_groups);
 }
 
 void gather_attribute_info(Map<std::string, AttributeKind> &attributes,
@@ -436,7 +433,8 @@ GeometrySet geometry_set_realize_mesh_for_modifier(const GeometrySet &geometry_s
   }
 
   GeometrySet new_geometry_set = geometry_set;
-  Vector<GeometryInstanceGroup> set_groups = geometry_set_gather_instances(geometry_set);
+  Vector<GeometryInstanceGroup> set_groups;
+  geometry_set_gather_instances(geometry_set, set_groups);
   join_instance_groups_mesh(set_groups, true, new_geometry_set);
   /* Remove all instances, even though some might contain other non-mesh data. We can't really
    * keep only non-mesh instances in general. */
@@ -454,7 +452,8 @@ GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set)
 
   GeometrySet new_geometry_set;
 
-  Vector<GeometryInstanceGroup> set_groups = geometry_set_gather_instances(geometry_set);
+  Vector<GeometryInstanceGroup> set_groups;
+  geometry_set_gather_instances(geometry_set, set_groups);
   join_instance_groups_mesh(set_groups, false, new_geometry_set);
   join_instance_groups_pointcloud(set_groups, new_geometry_set);
   join_instance_groups_volume(set_groups, new_geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 2e3460ee5fe..1e1f5e9d085 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -636,7 +636,8 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params)
     return;
   }
 
-  Vector<GeometryInstanceGroup> set_groups = bke::geometry_set_gather_instances(geometry_set);
+  Vector<GeometryInstanceGroup> set_groups;
+  geometry_set_gather_instances(geometry_set, set_groups);
   if (set_groups.is_empty()) {
     params.set_output("Geometry", GeometrySet());
     return;



More information about the Bf-blender-cvs mailing list