Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-03-25 21:54:27 +0300
committerHans Goudey <h.goudey@me.com>2021-03-25 21:54:27 +0300
commit64ca2865404ed95b1be0eb875f153673cdf5a212 (patch)
tree912573271ba375f275346133cc7064107e3eef7e
parent926f7612fd75078f5fb802d165f9c25af0bdb0df (diff)
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.
-rw-r--r--source/blender/blenkernel/BKE_geometry_set_instances.hh3
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc15
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc3
3 files changed, 11 insertions, 10 deletions
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;