[Bf-blender-cvs] [ea6671a] master: Fix for aligned handles in masking and curve objects

Sergey Sharybin noreply at git.blender.org
Sat May 3 21:59:40 CEST 2014


Commit: ea6671a6309b6d9363758a945f681c1adb2a4c6b
Author: Sergey Sharybin
Date:   Sat May 3 21:58:02 2014 +0200
https://developer.blender.org/rBea6671a6309b6d9363758a945f681c1adb2a4c6b

Fix for aligned handles in masking and curve objects

The issue has been introduced in 0985bb4, made it so curves and masks
stick to old behavior.

FCurves are still flaky, namely, grabbing both handles selected would
change the length of one of the handles which is not nice imo.

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

M	source/blender/blenkernel/intern/curve.c

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

diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index d734262..14fd44e 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -2899,7 +2899,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 	float *p1, *p2, *p3, pt[3];
 	float dvec_a[3], dvec_b[3];
 	float len, len_a, len_b;
-	float orig_len_ratio;
+	float len_ratio;
 	const float eps = 1e-5;
 
 	if (bezt->h1 == 0 && bezt->h2 == 0) {
@@ -2944,7 +2944,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 	if (len_a == 0.0f) len_a = 1.0f;
 	if (len_b == 0.0f) len_b = 1.0f;
 
-	orig_len_ratio = len_a / len_b;
+	len_ratio = len_a / len_b;
 
 	if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {    /* auto */
 		float tvec[3];
@@ -3081,11 +3081,18 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 
 	len_a = len_v3v3(p2, p2_h1);
 	len_b = len_v3v3(p2, p2_h2);
+	if (is_fcurve == false) {
+		if (len_a == 0.0f)
+			len_a = 1.0f;
+		if (len_b == 0.0f)
+			len_b = 1.0f;
+		len_ratio = len_a / len_b;
+	}
 
 	if (bezt->f1 & SELECT) { /* order of calculation */
 		if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
 			if (len_a > eps) {
-				len = 1.0f / orig_len_ratio;
+				len = 1.0f / len_ratio;
 				p2_h2[0] = p2[0] + len * (p2[0] - p2_h1[0]);
 				p2_h2[1] = p2[1] + len * (p2[1] - p2_h1[1]);
 				p2_h2[2] = p2[2] + len * (p2[2] - p2_h1[2]);
@@ -3093,7 +3100,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 		}
 		if (ELEM(bezt->h1, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
 			if (len_b > eps) {
-				len = orig_len_ratio;
+				len = len_ratio;
 				p2_h1[0] = p2[0] + len * (p2[0] - p2_h2[0]);
 				p2_h1[1] = p2[1] + len * (p2[1] - p2_h2[1]);
 				p2_h1[2] = p2[2] + len * (p2[2] - p2_h2[2]);
@@ -3103,7 +3110,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 	else {
 		if (ELEM(bezt->h1, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
 			if (len_b > eps) {
-				len = orig_len_ratio;
+				len = len_ratio;
 				p2_h1[0] = p2[0] + len * (p2[0] - p2_h2[0]);
 				p2_h1[1] = p2[1] + len * (p2[1] - p2_h2[1]);
 				p2_h1[2] = p2[2] + len * (p2[2] - p2_h2[2]);
@@ -3111,7 +3118,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
 		}
 		if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {   /* aligned */
 			if (len_a > eps) {
-				len = 1.0f / orig_len_ratio;
+				len = 1.0f / len_ratio;
 				p2_h2[0] = p2[0] + len * (p2[0] - p2_h1[0]);
 				p2_h2[1] = p2[1] + len * (p2[1] - p2_h1[1]);
 				p2_h2[2] = p2[2] + len * (p2[2] - p2_h1[2]);




More information about the Bf-blender-cvs mailing list