diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-01 16:11:58 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-01 16:12:41 +0300 |
commit | 00ba51d37bf5b152176409b393eafbb0ad9333e6 (patch) | |
tree | 499a1503c59f3558101bba52cef10d64c39a57fd /source/blender/blenkernel/BKE_curves.hh | |
parent | a250d3d1b7d8d497c21a1ef845e64f07e68beda9 (diff) |
Geometry Nodes: Port set handle nodes to new data-block
This commit ports the "Set Handle Positions" and "Set Hanle Type"
nodes to use the new curves data-block. The nodes become simpler
and likely much faster too, though they're usually not the bottleneck
anyway.
Most of the code is ported from `BezierSpline` directly. The majority
of the complexity comes from the interaction between different
automatically calculated handle types. In comparison `BezierSpline`,
the calculation of auto handles is done eagerly-- mostly because it's
simpler. Eventually lazy calculation might be good to add.
Differential Revision: https://developer.blender.org/D14464
Diffstat (limited to 'source/blender/blenkernel/BKE_curves.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_curves.hh | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index 67671e46ad4..f097acc497f 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -338,6 +338,8 @@ class CurvesGeometry : public ::CurvesGeometry { void translate(const float3 &translation); void transform(const float4x4 &matrix); + void calculate_bezier_auto_handles(); + void update_customdata_pointers(); void remove_curves(IndexMask curves_to_delete); @@ -397,9 +399,37 @@ void calculate_evaluated_offsets(Span<int8_t> handle_types_left, MutableSpan<int> evaluated_offsets); /** + * Recalculate all auto (#BEZIER_HANDLE_AUTO) and vector (#BEZIER_HANDLE_VECTOR) handles with + * positions automatically derived from the neighboring control points, and update aligned + * (#BEZIER_HANDLE_ALIGN) handles to line up with neighboring non-aligned handles. The choices + * made here are relatively arbitrary, but having standardized behavior is essential. + */ +void calculate_auto_handles(bool cyclic, + Span<int8_t> types_left, + Span<int8_t> types_right, + Span<float3> positions, + MutableSpan<float3> positions_left, + MutableSpan<float3> positions_right); + +/** + * Change the handles of a single control point, aligning any aligned (#BEZIER_HANDLE_ALIGN) + * handles on the other side of the control point. + * + * \note This ignores the inputs if the handle types are automatically calculated, + * so the types should be updated before-hand to be editable. + */ +void set_handle_position(const float3 &position, + HandleType type, + HandleType type_other, + const float3 &new_handle, + float3 &handle, + float3 &handle_other); + +/** * Evaluate a cubic Bezier segment, using the "forward differencing" method. - * A generic Bezier curve is made up by four points, but in many cases the first and last points - * are referred to as the control points, and the middle points are the corresponding handles. + * A generic Bezier curve is made up by four points, but in many cases the first and last + * points are referred to as the control points, and the middle points are the corresponding + * handles. */ void evaluate_segment(const float3 &point_0, const float3 &point_1, |