diff options
author | Jacques Lucke <jacques@blender.org> | 2022-07-02 12:45:57 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-07-02 12:45:57 +0300 |
commit | 5d9ade27de54b6910ed32f92d20d8f692959603c (patch) | |
tree | 1dd2c2002178291273f0809284fbc6660a14ca70 /source/blender/blenkernel | |
parent | 3c60d62dba1214378c3348563167385385f6a539 (diff) |
BLI: improve span access to virtual arrays
* Make the class names more consistent.
* Implement missing move-constructors and assignment-operators.
Diffstat (limited to 'source/blender/blenkernel')
6 files changed, 24 insertions, 25 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index fef91d6f75d..9648b5b7cde 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -218,7 +218,7 @@ struct WriteAttributeLookup { * Supported convenience features: * - Implicit type conversion when writing to builtin attributes. * - Supports simple access to a span containing the attribute values (that avoids the use of - * VMutableArray_Span in many cases). + * MutableVArraySpan in many cases). * - An output attribute can live side by side with an existing attribute with a different domain * or data type. The old attribute will only be overwritten when the #save function is called. * @@ -234,7 +234,7 @@ class OutputAttribute { GVMutableArray varray_; eAttrDomain domain_ = ATTR_DOMAIN_AUTO; SaveFn save_; - std::unique_ptr<GVMutableArray_GSpan> optional_span_varray_; + std::unique_ptr<GMutableVArraySpan> optional_span_varray_; bool ignore_old_values_ = false; bool save_has_been_called_ = false; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 409941623d2..ee9358eb97e 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -155,10 +155,9 @@ GMutableSpan OutputAttribute::as_span() { if (!optional_span_varray_) { const bool materialize_old_values = !ignore_old_values_; - optional_span_varray_ = std::make_unique<GVMutableArray_GSpan>(varray_, - materialize_old_values); + optional_span_varray_ = std::make_unique<GMutableVArraySpan>(varray_, materialize_old_values); } - GVMutableArray_GSpan &span_varray = *optional_span_varray_; + GMutableVArraySpan &span_varray = *optional_span_varray_; return span_varray; } diff --git a/source/blender/blenkernel/intern/curve_eval.cc b/source/blender/blenkernel/intern/curve_eval.cc index dd2bd982506..c01a184c6f9 100644 --- a/source/blender/blenkernel/intern/curve_eval.cc +++ b/source/blender/blenkernel/intern/curve_eval.cc @@ -21,14 +21,14 @@ using blender::Array; using blender::float3; using blender::float4x4; using blender::GVArray; -using blender::GVArray_GSpan; +using blender::GVArraySpan; using blender::IndexRange; using blender::Map; using blender::MutableSpan; using blender::Span; using blender::StringRefNull; using blender::VArray; -using blender::VArray_Span; +using blender::VArraySpan; using blender::Vector; using blender::bke::AttributeIDRef; using blender::bke::OutputAttribute; @@ -360,7 +360,7 @@ static void copy_attributes_between_components(const GeometryComponent &src_comp if (!src_attribute) { return true; } - GVArray_GSpan src_attribute_data{src_attribute}; + GVArraySpan src_attribute_data{src_attribute}; OutputAttribute dst_attribute = dst_component.attribute_try_get_for_output_only( id, meta_data.domain, meta_data.data_type); @@ -383,16 +383,16 @@ std::unique_ptr<CurveEval> curves_to_curve_eval(const Curves &curves_id) VArray<int> resolution = curves.resolution(); VArray<int8_t> normal_mode = curves.normal_mode(); - VArray_Span<float> nurbs_weights{ + VArraySpan<float> nurbs_weights{ src_component.attribute_get_for_read<float>("nurbs_weight", ATTR_DOMAIN_POINT, 0.0f)}; - VArray_Span<int8_t> nurbs_orders{ + VArraySpan<int8_t> nurbs_orders{ src_component.attribute_get_for_read<int8_t>("nurbs_order", ATTR_DOMAIN_CURVE, 4)}; - VArray_Span<int8_t> nurbs_knots_modes{ + VArraySpan<int8_t> nurbs_knots_modes{ src_component.attribute_get_for_read<int8_t>("knots_mode", ATTR_DOMAIN_CURVE, 0)}; - VArray_Span<int8_t> handle_types_right{ + VArraySpan<int8_t> handle_types_right{ src_component.attribute_get_for_read<int8_t>("handle_type_right", ATTR_DOMAIN_POINT, 0)}; - VArray_Span<int8_t> handle_types_left{ + VArraySpan<int8_t> handle_types_left{ src_component.attribute_get_for_read<int8_t>("handle_type_left", ATTR_DOMAIN_POINT, 0)}; /* Create splines with the correct size and type. */ diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 58380a1a35f..78e5d07da96 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -228,8 +228,8 @@ struct CurvesInfo { const CurvesGeometry &profile; /* Make sure these are spans because they are potentially accessed many times. */ - VArray_Span<bool> main_cyclic; - VArray_Span<bool> profile_cyclic; + VArraySpan<bool> main_cyclic; + VArraySpan<bool> profile_cyclic; }; static CurvesInfo get_curves_info(const CurvesGeometry &main, const CurvesGeometry &profile) { @@ -700,8 +700,8 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main, if (profile.curve_type_counts()[CURVE_TYPE_BEZIER] > 0) { const VArray<int8_t> curve_types = profile.curve_types(); - const VArray_Span<int8_t> handle_types_left{profile.handle_types_left()}; - const VArray_Span<int8_t> handle_types_right{profile.handle_types_right()}; + const VArraySpan<int8_t> handle_types_left{profile.handle_types_left()}; + const VArraySpan<int8_t> handle_types_right{profile.handle_types_right()}; foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo &info) { if (curve_types[info.i_profile] == CURVE_TYPE_BEZIER) { diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 0326afca202..8d955a46275 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -477,8 +477,8 @@ static void calculate_evaluated_offsets(const CurvesGeometry &curves, VArray<int> resolution = curves.resolution(); VArray<bool> cyclic = curves.cyclic(); - VArray_Span<int8_t> handle_types_left{curves.handle_types_left()}; - VArray_Span<int8_t> handle_types_right{curves.handle_types_right()}; + VArraySpan<int8_t> handle_types_left{curves.handle_types_left()}; + VArraySpan<int8_t> handle_types_right{curves.handle_types_right()}; VArray<int8_t> nurbs_orders = curves.nurbs_orders(); VArray<int8_t> nurbs_knots_modes = curves.nurbs_knots_modes(); @@ -1013,8 +1013,8 @@ void CurvesGeometry::calculate_bezier_auto_handles() return; } const VArray<bool> cyclic = this->cyclic(); - const VArray_Span<int8_t> types_left{this->handle_types_left()}; - const VArray_Span<int8_t> types_right{this->handle_types_right()}; + const VArraySpan<int8_t> types_left{this->handle_types_left()}; + const VArraySpan<int8_t> types_right{this->handle_types_right()}; const Span<float3> positions = this->positions(); MutableSpan<float3> positions_left = this->handle_positions_left_for_write(); MutableSpan<float3> positions_right = this->handle_positions_right_for_write(); diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index 898869c3c44..5725c6043b2 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -17,7 +17,7 @@ using blender::GMutableSpan; using blender::GSpan; using blender::GVArray; -using blender::GVArray_GSpan; +using blender::GVArraySpan; /* -------------------------------------------------------------------- */ /** \name Geometry Component Implementation @@ -231,7 +231,7 @@ template<typename T> class VArray_For_SplineToPoint final : public VArrayImpl<T> GVArray original_varray_; /* Store existing data materialized if it was not already a span. This is expected * to be worth it because a single spline's value will likely be accessed many times. */ - VArray_Span<T> original_data_; + VArraySpan<T> original_data_; Array<int> offsets_; public: @@ -645,8 +645,8 @@ static bool create_point_attribute(GeometryComponent &component, GVArray source_varray = varray_from_initializer(initializer, data_type, splines); /* TODO: When we can call a variant of #set_all with a virtual array argument, * this theoretically unnecessary materialize step could be removed. */ - GVArray_GSpan source_varray_span{source_varray}; - write_attribute.varray.set_all(source_varray_span.data()); + GVArraySpan source_VArraySpan{source_varray}; + write_attribute.varray.set_all(source_VArraySpan.data()); if (initializer.type == AttributeInit::Type::MoveArray) { MEM_freeN(static_cast<const AttributeInitMove &>(initializer).data); |