From 1892b131edc76abb4439ca6fcc69b95a208ab7d7 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 12 May 2021 10:21:12 -0500 Subject: Geometry Nodes Curves: Expose first builtin point attributes This commit exposes the first spline control point attributes. The implementation incorporates the attributes into the virtual array system, providing efficient methods to flatten the data into a contiguous array and to apply changes from a flattened array. This is only part of the eventual goal, which includes changes to run attribute nodes separately for each spline to completely avoid copying. So far `tilt` and `radius`, the two generic attributes common to all spline types, are implemented. The more complex `position` attribute is also added. It requires some special handling for Bezier splines, where the control point handles need to be moved along with the control points. To make that work I also added automatic handle recalculation to the Bezier spline. Differential Revision: https://developer.blender.org/D11187 --- source/blender/blenkernel/BKE_spline.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/BKE_spline.hh') diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh index 48b5dfb1623..35bbc23b21a 100644 --- a/source/blender/blenkernel/BKE_spline.hh +++ b/source/blender/blenkernel/BKE_spline.hh @@ -206,8 +206,12 @@ class BezierSpline final : public Spline { blender::Vector handle_types_left_; blender::Vector handle_types_right_; - blender::Vector handle_positions_left_; - blender::Vector handle_positions_right_; + /* These are mutable to allow lazy recalculation of #Auto and #Vector handle positions. */ + mutable blender::Vector handle_positions_left_; + mutable blender::Vector handle_positions_right_; + + mutable std::mutex auto_handle_mutex_; + mutable bool auto_handles_dirty_ = true; /** Start index in evaluated points array for every control point. */ mutable blender::Vector offset_cache_; @@ -296,6 +300,7 @@ class BezierSpline final : public Spline { const blender::fn::GVArray &source_data) const override; private: + void ensure_auto_handles() const; void correct_end_tangents() const final; bool segment_is_vector(const int start_index) const; void evaluate_bezier_segment(const int index, -- cgit v1.2.3