diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-30 04:11:38 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-30 04:11:38 +0300 |
commit | f4f89a76a8f4ca77bc59c9572cd2aab6da1e9023 (patch) | |
tree | 8633173b659decf46f0a5911b66016c1ff738357 /source/blender/blenkernel | |
parent | 87e9451d660e8288d70aa781530b69f4005bf0ea (diff) |
Curves: Port parameter node to the new data-block
Using the evaluated lengths cache from 72d25fa41d8c575, re-implement
the curve parameter node with the new data structure. Conceptually
it works the same way, but the code is restructured and cleaned up
a bit as well. This also adds support for Catmull Rom curves.
Differential Revision: https://developer.blender.org/D14461
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_curves.hh | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curves_geometry.cc | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 13b3d280bc7..29cf38421d1 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -273,6 +273,12 @@ class CurvesGeometry : public ::CurvesGeometry { /** Makes sure the data described by #evaluated_offsets if necessary. */ void ensure_evaluated_offsets() const; + /** + * Retrieve offsets into a Bezier curve's avaluated points for each control point. + * Call #ensure_evaluated_offsets() first to ensure that the evaluated offsets cache is current. + */ + Span<int> bezier_evaluated_offsets_for_curve(int curve_index) const; + Span<float3> evaluated_positions() const; /** @@ -285,6 +291,7 @@ class CurvesGeometry : public ::CurvesGeometry { * but is passed for performance reasons to avoid looking up the attribute. */ Span<float> evaluated_lengths_for_curve(int curve_index, bool cyclic) const; + float evaluated_length_total_for_curve(int curve_index, bool cyclic) const; /** Calculates the data described by #evaluated_lengths_for_curve if necessary. */ void ensure_evaluated_lengths() const; diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index c4e9a06aad0..94402f0e548 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -548,6 +548,12 @@ Span<int> CurvesGeometry::evaluated_offsets() const return this->runtime->evaluated_offsets_cache; } +Span<int> CurvesGeometry::bezier_evaluated_offsets_for_curve(const int curve_index) const +{ + const IndexRange points = this->points_for_curve(curve_index); + return this->runtime->bezier_evaluated_offsets.as_span().slice(points); +} + IndexMask CurvesGeometry::indices_for_curve_type(const CurveType type, Vector<int64_t> &r_indices) const { @@ -779,6 +785,12 @@ Span<float> CurvesGeometry::evaluated_lengths_for_curve(const int curve_index, return this->runtime->evaluated_length_cache.as_span().slice(range); } +float CurvesGeometry::evaluated_length_total_for_curve(const int curve_index, + const bool cyclic) const +{ + return this->evaluated_lengths_for_curve(curve_index, cyclic).last(); +} + /** \} */ /* -------------------------------------------------------------------- */ |