Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-07-04 19:50:33 +0300
committerHans Goudey <h.goudey@me.com>2022-07-04 19:51:10 +0300
commitdccdc6213ec6ff3c3ff681090f56648ec4023034 (patch)
tree4ed21ee7c9554b7a1b3ef69edb2f45b16d63c1c8 /source/blender/blenkernel/BKE_curves.hh
parent8fb8a6529fa64d6e17042cdf469d9920eb939660 (diff)
Curves: Expose function to calculate vector handles
Diffstat (limited to 'source/blender/blenkernel/BKE_curves.hh')
-rw-r--r--source/blender/blenkernel/BKE_curves.hh13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh
index b1f096b1c39..cc0c607f9bb 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -516,6 +516,14 @@ void calculate_evaluated_offsets(Span<int8_t> handle_types_left,
MutableSpan<int> evaluated_offsets);
/**
+ * Calculate the automatically defined positions for a vector handle (#BEZIER_HANDLE_VECTOR). While
+ * this can be calculated automatically with #calculate_auto_handles, when more context is
+ * available, it can be preferable for performance reasons to calculate it for a single segment
+ * when necessary.
+ */
+float3 calculate_vector_handle(const float3 &point, const float3 &next_point);
+
+/**
* 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
@@ -819,6 +827,11 @@ inline bool point_is_sharp(const Span<int8_t> handle_types_left,
ELEM(handle_types_right[index], BEZIER_HANDLE_VECTOR, BEZIER_HANDLE_FREE);
}
+inline float3 calculate_vector_handle(const float3 &point, const float3 &next_point)
+{
+ return math::interpolate(point, next_point, 1.0f / 3.0f);
+}
+
/** \} */
} // namespace curves::bezier