diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-16 16:24:46 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-16 16:24:46 +0300 |
commit | 649803ea55ccf68ba48f10075afcac9ee1e5149a (patch) | |
tree | c3c3724c3cefe751221c5290e26767b44f6beeb3 | |
parent | 83cd4724164cd3c9a44e6ebcf454f517fce5cc67 (diff) |
cleanup
5 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh index 1c2101a3660..86bfd1fbbba 100644 --- a/source/blender/functions/FN_generic_virtual_array.hh +++ b/source/blender/functions/FN_generic_virtual_array.hh @@ -760,6 +760,11 @@ template<typename T> class GVArray_Typed { { return varray_->size(); } + + IndexRange index_range() const + { + return IndexRange(this->size()); + } }; template<typename T> class GVMutableArray_Typed { diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index 15201553f16..710552d25e2 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -45,8 +45,11 @@ using fn::GMutablePointer; using fn::GPointer; using fn::GValueMap; using fn::GVArray; +using fn::GVArray_GSpan; +using fn::GVArray_Span; using fn::GVArray_Typed; using fn::GVMutableArray; +using fn::GVMutableArray_GSpan; using fn::GVMutableArray_Typed; class GeoNodeExecParams { diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc index 0135b3da90b..c4d37a82617 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc @@ -53,7 +53,7 @@ namespace blender::nodes { static void align_rotations_auto_pivot(const VArray<float3> &vectors, const VArray<float> &factors, const float3 local_main_axis, - VMutableArray<float3> &rotations) + const MutableSpan<float3> rotations) { for (const int i : IndexRange(vectors.size())) { const float3 vector = vectors[i]; @@ -89,7 +89,7 @@ static void align_rotations_auto_pivot(const VArray<float3> &vectors, float3 new_rotation; mat3_to_eul(new_rotation, new_rotation_matrix); - rotations.set(i, new_rotation); + rotations[i] = new_rotation; } } @@ -97,7 +97,7 @@ static void align_rotations_fixed_pivot(const VArray<float3> &vectors, const VArray<float> &factors, const float3 local_main_axis, const float3 local_pivot_axis, - VMutableArray<float3> &rotations) + const MutableSpan<float3> rotations) { if (local_main_axis == local_pivot_axis) { /* Can't compute any meaningful rotation angle in this case. */ @@ -133,7 +133,7 @@ static void align_rotations_fixed_pivot(const VArray<float3> &vectors, float3 new_rotation; mat3_to_eul(new_rotation, new_rotation_matrix); - rotations.set(i, new_rotation); + rotations[i] = new_rotation; } } @@ -158,12 +158,13 @@ static void align_rotations_on_component(GeometryComponent &component, float3 local_main_axis{0, 0, 0}; local_main_axis[storage.axis] = 1; if (storage.pivot_axis == GEO_NODE_ALIGN_ROTATION_TO_VECTOR_PIVOT_AXIS_AUTO) { - align_rotations_auto_pivot(vectors, factors, local_main_axis, *rotations); + align_rotations_auto_pivot(vectors, factors, local_main_axis, rotations.as_span()); } else { float3 local_pivot_axis{0, 0, 0}; local_pivot_axis[storage.pivot_axis - 1] = 1; - align_rotations_fixed_pivot(vectors, factors, local_main_axis, local_pivot_axis, *rotations); + align_rotations_fixed_pivot( + vectors, factors, local_main_axis, local_pivot_axis, rotations.as_span()); } rotations.save(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc index 1f352525c62..b6fa4c0d48f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc @@ -39,15 +39,11 @@ static void compute_min_max_from_position_and_transform(const GeometryComponent float3 &r_min, float3 &r_max) { - ReadAttributeLookup position_attribute = component.attribute_try_get_for_read("position"); - if (!position_attribute) { - BLI_assert(component.attribute_domain_size(ATTR_DOMAIN_POINT) == 0); - return; - } - GVArray_Typed<float3> positions{*position_attribute.varray}; + GVArray_Typed<float3> positions = component.attribute_get_for_read<float3>( + "position", ATTR_DOMAIN_POINT, {0, 0, 0}); for (const float4x4 &transform : transforms) { - for (const int i : IndexRange(positions.size())) { + for (const int i : positions.index_range()) { const float3 position = positions[i]; const float3 transformed_position = transform * position; minmax_v3v3_v3(r_min, r_max, transformed_position); diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index 488d926e90f..6541d982629 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -73,7 +73,7 @@ static void copy_attributes_based_on_mask(const GeometryComponent &in_component, attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - fn::GVArray_Span<T> span{*attribute.varray}; + GVArray_Span<T> span{*attribute.varray}; MutableSpan<T> out_span = result_attribute.as_span<T>(); copy_data_based_on_mask(span, masks, invert, out_span); }); |