[Bf-blender-cvs] [a69e5c23483] master: Cleanup: Avoid assigning constructed VArray to reference
Hans Goudey
noreply at git.blender.org
Fri Jul 1 02:26:18 CEST 2022
Commit: a69e5c234834ede518effb9f8b18a8968e55d297
Author: Hans Goudey
Date: Thu Jun 30 19:17:32 2022 -0500
Branches: master
https://developer.blender.org/rBa69e5c234834ede518effb9f8b18a8968e55d297
Cleanup: Avoid assigning constructed VArray to reference
This is clearer about what is actually happening (VArray is small
enough to be a by-value type and is constructed on demand, while
only the generic virtual array is stored).
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
M source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
M source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
M source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc
M source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
M source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc
M source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
M source/blender/nodes/geometry/nodes/node_geo_scale_instances.cc
M source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc
M source/blender/nodes/geometry/nodes/node_geo_set_id.cc
M source/blender/nodes/geometry/nodes/node_geo_set_position.cc
M source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
index a7404af8564..be7b3446125 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
@@ -223,8 +223,8 @@ template<typename T> class AccumulateFieldInput final : public GeometryFieldInpu
evaluator.add(input_);
evaluator.add(group_index_);
evaluator.evaluate();
- const VArray<T> &values = evaluator.get_evaluated<T>(0);
- const VArray<int> &group_indices = evaluator.get_evaluated<int>(1);
+ const VArray<T> values = evaluator.get_evaluated<T>(0);
+ const VArray<int> group_indices = evaluator.get_evaluated<int>(1);
Array<T> accumulations_out(domain_num);
@@ -309,8 +309,8 @@ template<typename T> class TotalFieldInput final : public GeometryFieldInput {
evaluator.add(input_);
evaluator.add(group_index_);
evaluator.evaluate();
- const VArray<T> &values = evaluator.get_evaluated<T>(0);
- const VArray<int> &group_indices = evaluator.get_evaluated<int>(1);
+ const VArray<T> values = evaluator.get_evaluated<T>(0);
+ const VArray<int> group_indices = evaluator.get_evaluated<int>(1);
if (group_indices.is_single()) {
T accumulation = T();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
index 35404725998..08e72dae8f6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
@@ -203,7 +203,7 @@ static void node_geo_exec(GeoNodeExecParams params)
data_evaluator.add(input_field);
data_evaluator.set_selection(selection_field);
data_evaluator.evaluate();
- const VArray<float> &component_data = data_evaluator.get_evaluated<float>(0);
+ const VArray<float> component_data = data_evaluator.get_evaluated<float>(0);
const IndexMask selection = data_evaluator.get_evaluated_selection_as_mask();
const int next_data_index = data.size();
@@ -281,7 +281,7 @@ static void node_geo_exec(GeoNodeExecParams params)
data_evaluator.add(input_field);
data_evaluator.set_selection(selection_field);
data_evaluator.evaluate();
- const VArray<float3> &component_data = data_evaluator.get_evaluated<float3>(0);
+ const VArray<float3> component_data = data_evaluator.get_evaluated<float3>(0);
const IndexMask selection = data_evaluator.get_evaluated_selection_as_mask();
const int next_data_index = data.size();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
index b52bf2571b5..db3f108aad5 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
@@ -64,8 +64,8 @@ class EndpointFieldInput final : public GeometryFieldInput {
evaluator.add(start_size_);
evaluator.add(end_size_);
evaluator.evaluate();
- const VArray<int> &start_size = evaluator.get_evaluated<int>(0);
- const VArray<int> &end_size = evaluator.get_evaluated<int>(1);
+ const VArray<int> start_size = evaluator.get_evaluated<int>(0);
+ const VArray<int> end_size = evaluator.get_evaluated<int>(1);
Array<bool> selection(curves.points_num(), false);
MutableSpan<bool> selection_span = selection.as_mutable_span();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
index c993a3d305d..2b90428acb1 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
@@ -512,8 +512,8 @@ static void geometry_set_curve_trim(GeometrySet &geometry_set,
evaluator.add(start_field);
evaluator.add(end_field);
evaluator.evaluate();
- const blender::VArray<float> &starts = evaluator.get_evaluated<float>(0);
- const blender::VArray<float> &ends = evaluator.get_evaluated<float>(1);
+ const VArray<float> starts = evaluator.get_evaluated<float>(0);
+ const VArray<float> ends = evaluator.get_evaluated<float>(1);
std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*geometry_set.get_curves_for_read());
MutableSpan<SplinePtr> splines = curve->splines();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
index 3eca92e37a3..59d7154db6e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc
@@ -424,7 +424,7 @@ static void extrude_mesh_edges(MeshComponent &component,
edge_evaluator.add(offset_field);
edge_evaluator.evaluate();
const IndexMask edge_selection = edge_evaluator.get_evaluated_selection_as_mask();
- const VArray<float3> &edge_offsets = edge_evaluator.get_evaluated<float3>(0);
+ const VArray<float3> edge_offsets = edge_evaluator.get_evaluated<float3>(0);
if (edge_selection.is_empty()) {
return;
}
@@ -686,7 +686,7 @@ static void extrude_mesh_face_regions(MeshComponent &component,
poly_evaluator.add(offset_field);
poly_evaluator.evaluate();
const IndexMask poly_selection = poly_evaluator.get_evaluated_selection_as_mask();
- const VArray<float3> &poly_offsets = poly_evaluator.get_evaluated<float3>(0);
+ const VArray<float3> poly_offsets = poly_evaluator.get_evaluated<float3>(0);
if (poly_selection.is_empty()) {
return;
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
index 58281df43d3..7839e148ee3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
@@ -100,7 +100,7 @@ class FieldAtIndex final : public GeometryFieldInput {
FieldEvaluator index_evaluator{index_field_context, &mask};
index_evaluator.add(index_field_);
index_evaluator.evaluate();
- const VArray<int> &indices = index_evaluator.get_evaluated<int>(0);
+ const VArray<int> indices = index_evaluator.get_evaluated<int>(0);
GVArray output_array;
attribute_math::convert_to_static_type(*type_, [&](auto dummy) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc
index da249278867..e0aaf43235c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_input_curve_handles.cc
@@ -37,7 +37,7 @@ class HandlePositionFieldInput final : public GeometryFieldInput {
fn::FieldEvaluator evaluator(field_context, &mask);
evaluator.add(relative_);
evaluator.evaluate();
- const VArray<bool> &relative = evaluator.get_evaluated<bool>(0);
+ const VArray<bool> relative = evaluator.get_evaluated<bool>(0);
VArray<float3> positions = component.attribute_get_for_read<float3>(
"position", ATTR_DOMAIN_POINT, {0, 0, 0});
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
index 532c3dc81e5..d02f7291704 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc
@@ -51,7 +51,7 @@ class PlanarFieldInput final : public GeometryFieldInput {
fn::FieldEvaluator evaluator{context, mesh->totpoly};
evaluator.add(threshold_);
evaluator.evaluate();
- const VArray<float> &thresholds = evaluator.get_evaluated<float>(0);
+ const VArray<float> thresholds = evaluator.get_evaluated<float>(0);
Span<float3> poly_normals{(float3 *)BKE_mesh_poly_normals_ensure(mesh), mesh->totpoly};
diff --git a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc
index 2126a5cc329..ffc6137cf83 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc
@@ -59,7 +59,7 @@ static void convert_instances_to_points(GeometrySet &geometry_set,
const VArray<float3> &positions = evaluator.get_evaluated<float3>(0);
copy_attribute_to_points(positions, selection, {(float3 *)pointcloud->co, pointcloud->totpoint});
- const VArray<float> &radii = evaluator.get_evaluated<float>(1);
+ const VArray<float> radii = evaluator.get_evaluated<float>(1);
copy_attribute_to_points(radii, selection, {pointcloud->radius, pointcloud->totpoint});
Map<AttributeIDRef, AttributeKind> attributes_to_propagate;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
index 59e203afd08..d414bb1fa1d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
@@ -29,9 +29,9 @@ static void rotate_instances(GeoNodeExecParams ¶ms, InstancesComponent &inst
evaluator.evaluate();
const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
- const VArray<float3> &rotations = evaluator.get_evaluated<float3>(0);
- const VArray<float3> &pivots = evaluator.get_evaluated<float3>(1);
- const VArray<bool> &local_spaces = evaluator.get_evaluated<bool>(2);
+ const VArray<float3> rotations = evaluator.get_evaluated<float3>(0);
+ const VArray<float3> pivots = evaluator.get_evaluated<float3>(1);
+ const VArray<bool> local_spaces = evaluator.get_evaluated<bool>(2);
MutableSpan<float4x4> instance_transforms = instances_component.instance_transforms();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_scale_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_s
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list