diff options
-rw-r--r-- | source/blender/blenkernel/BKE_spline.hh | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_bezier.cc | 37 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_nurbs.cc | 48 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/spline_poly.cc | 9 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc | 2 |
5 files changed, 54 insertions, 55 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh index b5d06da4651..38a6d41a4d3 100644 --- a/source/blender/blenkernel/BKE_spline.hh +++ b/source/blender/blenkernel/BKE_spline.hh @@ -196,7 +196,7 @@ class Spline { * exceed the lifetime of the input data. */ virtual blender::fn::GVArrayPtr interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const = 0; + const blender::fn::GVArray &src) const = 0; blender::fn::GVArrayPtr interpolate_to_evaluated(blender::fn::GSpan data) const; template<typename T> blender::fn::GVArray_Typed<T> interpolate_to_evaluated(blender::Span<T> data) const @@ -332,8 +332,7 @@ class BezierSpline final : public Spline { }; InterpolationData interpolation_data_from_index_factor(const float index_factor) const; - virtual blender::fn::GVArrayPtr interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const override; + virtual blender::fn::GVArrayPtr interpolate_to_evaluated(const blender::fn::GVArray &src) const; void evaluate_segment(const int index, const int next_index, @@ -455,13 +454,12 @@ class NURBSpline final : public Spline { blender::Span<blender::float3> evaluated_positions() const final; - blender::fn::GVArrayPtr interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const final; + blender::fn::GVArrayPtr interpolate_to_evaluated(const blender::fn::GVArray &src) const final; protected: void correct_end_tangents() const final; void calculate_knots() const; - void calculate_basis_cache() const; + blender::Span<BasisCache> calculate_basis_cache() const; }; /** @@ -505,8 +503,7 @@ class PolySpline final : public Spline { blender::Span<blender::float3> evaluated_positions() const final; - blender::fn::GVArrayPtr interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const final; + blender::fn::GVArrayPtr interpolate_to_evaluated(const blender::fn::GVArray &src) const final; protected: void correct_end_tangents() const final; diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc index 2aacc5cf720..e4f26eaf466 100644 --- a/source/blender/blenkernel/intern/spline_bezier.cc +++ b/source/blender/blenkernel/intern/spline_bezier.cc @@ -25,6 +25,9 @@ using blender::float3; using blender::IndexRange; using blender::MutableSpan; using blender::Span; +using blender::fn::GVArray; +using blender::fn::GVArray_For_ArrayContainer; +using blender::fn::GVArrayPtr; SplinePtr BezierSpline::copy() const { @@ -546,44 +549,44 @@ BezierSpline::InterpolationData BezierSpline::interpolation_data_from_index_fact /* Use a spline argument to avoid adding this to the header. */ template<typename T> static void interpolate_to_evaluated_impl(const BezierSpline &spline, - const blender::VArray<T> &source_data, - MutableSpan<T> result_data) + const blender::VArray<T> &src, + MutableSpan<T> dst) { + BLI_assert(src.size() == spline.size()); + BLI_assert(dst.size() == spline.evaluated_points_size()); Span<float> mappings = spline.evaluated_mappings(); - for (const int i : result_data.index_range()) { + for (const int i : dst.index_range()) { BezierSpline::InterpolationData interp = spline.interpolation_data_from_index_factor( mappings[i]); - const T &value = source_data[interp.control_point_index]; - const T &next_value = source_data[interp.next_control_point_index]; + const T &value = src[interp.control_point_index]; + const T &next_value = src[interp.next_control_point_index]; - result_data[i] = blender::attribute_math::mix2(interp.factor, value, next_value); + dst[i] = blender::attribute_math::mix2(interp.factor, value, next_value); } } -blender::fn::GVArrayPtr BezierSpline::interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const +GVArrayPtr BezierSpline::interpolate_to_evaluated(const GVArray &src) const { - BLI_assert(source_data.size() == this->size()); + BLI_assert(src.size() == this->size()); - if (source_data.is_single()) { - return source_data.shallow_copy(); + if (src.is_single()) { + return src.shallow_copy(); } const int eval_size = this->evaluated_points_size(); if (eval_size == 1) { - return source_data.shallow_copy(); + return src.shallow_copy(); } - blender::fn::GVArrayPtr new_varray; - blender::attribute_math::convert_to_static_type(source_data.type(), [&](auto dummy) { + GVArrayPtr new_varray; + blender::attribute_math::convert_to_static_type(src.type(), [&](auto dummy) { using T = decltype(dummy); if constexpr (!std::is_void_v<blender::attribute_math::DefaultMixer<T>>) { Array<T> values(eval_size); - interpolate_to_evaluated_impl<T>(*this, source_data.typed<T>(), values); - new_varray = std::make_unique<blender::fn::GVArray_For_ArrayContainer<Array<T>>>( - std::move(values)); + interpolate_to_evaluated_impl<T>(*this, src.typed<T>(), values); + new_varray = std::make_unique<GVArray_For_ArrayContainer<Array<T>>>(std::move(values)); } }); diff --git a/source/blender/blenkernel/intern/spline_nurbs.cc b/source/blender/blenkernel/intern/spline_nurbs.cc index 569b6abcef8..90aadb319b7 100644 --- a/source/blender/blenkernel/intern/spline_nurbs.cc +++ b/source/blender/blenkernel/intern/spline_nurbs.cc @@ -26,7 +26,10 @@ using blender::float3; using blender::IndexRange; using blender::MutableSpan; using blender::Span; +using blender::fn::GVArray; +using blender::fn::GVArray_For_ArrayContainer; using blender::fn::GVArray_Typed; +using blender::fn::GVArrayPtr; SplinePtr NURBSpline::copy() const { @@ -326,15 +329,15 @@ static void calculate_basis_for_point(const float parameter, basis_cache.start_index = start; } -void NURBSpline::calculate_basis_cache() const +Span<NURBSpline::BasisCache> NURBSpline::calculate_basis_cache() const { if (!basis_cache_dirty_) { - return; + return basis_cache_; } std::lock_guard lock{basis_cache_mutex_}; if (!basis_cache_dirty_) { - return; + return basis_cache_; } const int points_len = this->size(); @@ -371,50 +374,47 @@ void NURBSpline::calculate_basis_cache() const } basis_cache_dirty_ = false; + return basis_cache_; } template<typename T> void interpolate_to_evaluated_impl(Span<NURBSpline::BasisCache> weights, - const blender::VArray<T> &source_data, - MutableSpan<T> result_data) + const blender::VArray<T> &src, + MutableSpan<T> dst) { - const int points_len = source_data.size(); - BLI_assert(result_data.size() == weights.size()); - blender::attribute_math::DefaultMixer<T> mixer(result_data); + const int size = src.size(); + BLI_assert(dst.size() == weights.size()); + blender::attribute_math::DefaultMixer<T> mixer(dst); - for (const int i : result_data.index_range()) { + for (const int i : dst.index_range()) { Span<float> point_weights = weights[i].weights; const int start_index = weights[i].start_index; - for (const int j : point_weights.index_range()) { - const int point_index = (start_index + j) % points_len; - mixer.mix_in(i, source_data[point_index], point_weights[j]); + const int point_index = (start_index + j) % size; + mixer.mix_in(i, src[point_index], point_weights[j]); } } mixer.finalize(); } -blender::fn::GVArrayPtr NURBSpline::interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const +GVArrayPtr NURBSpline::interpolate_to_evaluated(const GVArray &src) const { - BLI_assert(source_data.size() == this->size()); + BLI_assert(src.size() == this->size()); - if (source_data.is_single()) { - return source_data.shallow_copy(); + if (src.is_single()) { + return src.shallow_copy(); } - this->calculate_basis_cache(); - Span<BasisCache> weights(basis_cache_); + Span<BasisCache> basis_cache = this->calculate_basis_cache(); - blender::fn::GVArrayPtr new_varray; - blender::attribute_math::convert_to_static_type(source_data.type(), [&](auto dummy) { + GVArrayPtr new_varray; + blender::attribute_math::convert_to_static_type(src.type(), [&](auto dummy) { using T = decltype(dummy); if constexpr (!std::is_void_v<blender::attribute_math::DefaultMixer<T>>) { Array<T> values(this->evaluated_points_size()); - interpolate_to_evaluated_impl<T>(weights, source_data.typed<T>(), values); - new_varray = std::make_unique<blender::fn::GVArray_For_ArrayContainer<Array<T>>>( - std::move(values)); + interpolate_to_evaluated_impl<T>(basis_cache, src.typed<T>(), values); + new_varray = std::make_unique<GVArray_For_ArrayContainer<Array<T>>>(std::move(values)); } }); diff --git a/source/blender/blenkernel/intern/spline_poly.cc b/source/blender/blenkernel/intern/spline_poly.cc index ebbe595e319..e344b8d4910 100644 --- a/source/blender/blenkernel/intern/spline_poly.cc +++ b/source/blender/blenkernel/intern/spline_poly.cc @@ -22,6 +22,8 @@ using blender::float3; using blender::MutableSpan; using blender::Span; +using blender::fn::GVArray; +using blender::fn::GVArrayPtr; SplinePtr PolySpline::copy() const { @@ -115,10 +117,9 @@ Span<float3> PolySpline::evaluated_positions() const * the original data. Therefore the lifetime of the returned virtual array must not be longer than * the source data. */ -blender::fn::GVArrayPtr PolySpline::interpolate_to_evaluated( - const blender::fn::GVArray &source_data) const +GVArrayPtr PolySpline::interpolate_to_evaluated(const GVArray &src) const { - BLI_assert(source_data.size() == this->size()); + BLI_assert(src.size() == this->size()); - return source_data.shallow_copy(); + return src.shallow_copy(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index dbfe3211ac4..2725c625913 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -326,8 +326,6 @@ static void geo_node_curve_to_points_exec(GeoNodeExecParams params) geometry_set = bke::geometry_set_realize_instances(geometry_set); - SCOPED_TIMER(__func__); - if (!geometry_set.has_curve()) { params.set_output("Geometry", GeometrySet()); return; |