Commit: b32408eff896307741498bee4ec5dacb5b6953ee
Author: Campbell Barton
Date:   Mon Jul 11 15:28:39 2016 +1000
Branches: master
https://developer.blender.org/rBb32408eff896307741498bee4ec5dacb5b6953ee

BLI_math: move interp_*_cubic to its own function

===================================================================

M       source/blender/blenkernel/intern/mask.c
M       source/blender/blenlib/BLI_math_vector.h
M       source/blender/blenlib/intern/math_vector.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mask.c 
b/source/blender/blenkernel/intern/mask.c
index f804a4c..b5bb57a 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -533,7 +533,6 @@ void BKE_mask_point_segment_co(MaskSpline *spline, 
MaskSplinePoint *point, float
        MaskSplinePoint *points_array = 
BKE_mask_spline_point_array_from_point(spline, point);
 
        BezTriple *bezt = &point->bezt, *bezt_next;
-       float q0[2], q1[2], q2[2], r0[2], r1[2];
 
        bezt_next = BKE_mask_spline_point_next_bezt(spline, points_array, 
point);
 
@@ -542,14 +541,7 @@ void BKE_mask_point_segment_co(MaskSpline *spline, 
MaskSplinePoint *point, float
                return;
        }
 
-       interp_v2_v2v2(q0, bezt->vec[1], bezt->vec[2], u);
-       interp_v2_v2v2(q1, bezt->vec[2], bezt_next->vec[0], u);
-       interp_v2_v2v2(q2, bezt_next->vec[0], bezt_next->vec[1], u);
-
-       interp_v2_v2v2(r0, q0, q1, u);
-       interp_v2_v2v2(r1, q1, q2, u);
-
-       interp_v2_v2v2(co, r0, r1, u);
+       interp_v2_v2v2v2v2_cubic(co, bezt->vec[1], bezt->vec[2], 
bezt_next->vec[0], bezt_next->vec[1], u);
 }
 
 BLI_INLINE void orthogonal_direction_get(float vec[2], float result[2])
diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index 4d546ab..d15fe1a 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -221,6 +221,10 @@ bool interp_v2_v2v2_slerp(float target[2], const float 
a[2], const float b[2], c
 void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float 
b[3], const float t);
 void interp_v2_v2v2_slerp_safe(float target[2], const float a[2], const float 
b[2], const float t);
 
+void interp_v2_v2v2v2v2_cubic(
+        float p[2], const float v1[2], const float v2[2], const float v3[2], 
const float v4[2],
+        const float u);
+
 void interp_v3_v3v3_char(char target[3], const char a[3], const char b[3], 
const float t);
 void interp_v3_v3v3_uchar(unsigned char target[3], const unsigned char a[3], 
const unsigned char b[3], const float t);
 void interp_v4_v4v4_char(char target[4], const char a[4], const char b[4], 
const float t);
diff --git a/source/blender/blenlib/intern/math_vector.c 
b/source/blender/blenlib/intern/math_vector.c
index 9880343..95d5c9f 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -164,6 +164,27 @@ void interp_v2_v2v2_slerp_safe(float target[2], const 
float a[2], const float b[
        }
 }
 
+/** \name Cubic curve interpolation (bezier spline).
+ * \{ */
+
+void interp_v2_v2v2v2v2_cubic(
+        float p[2], const float v1[2], const float v2[2], const float v3[2], 
const float v4[2],
+        const float u)
+{
+       float q0[2], q1[2], q2[2], r0[2], r1[2];
+
+       interp_v2_v2v2(q0, v1, v2, u);
+       interp_v2_v2v2(q1, v2, v3, u);
+       interp_v2_v2v2(q2, v3, v4, u);
+
+       interp_v2_v2v2(r0, q0, q1, u);
+       interp_v2_v2v2(r1, q1, q2, u);
+
+       interp_v2_v2v2(p, r0, r1, u);
+}
+
+/** \} */
+
 /* weight 3 vectors,
  * 'w' must be unit length but is not a vector, just 3 weights */
 void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const 
float v3[3], const float w[3])

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to