Fix T38594: Incorrect behaviour when editing aligned handles in curve editor

With the right handle selected, the movement of the left handle appears constrained
to the frame it is currently on, leading to unpredictable and wild overshoots of the
bezier curve. There appears to be little benefit in doing so.

The effect of this patch is that makes it so that instead of trying (initially) to
maintain the same distance between the two handles and then overshooting randomly
later, the handles now try to keep the same distance from each other (i.e. similar
doing a rotation around the keyframe) at all times. While this means that it isn't
possible to set up assymetric handles (i.e. where ease in to the key is less than the
ease out for example) using aligned handles (it's still possible using free; it's just
a lot more work to keep them aligned), the benefits of removing of the random blips and jumps
when things jump outweight the losses.


Patch by Brecht
This commit is contained in:
Joshua Leung 2014-04-28 17:15:23 +12:00
parent 4a1b87790d
commit 0985bb483d

@ -2912,6 +2912,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;
const float eps = 1e-5;
if (bezt->h1 == 0 && bezt->h2 == 0) {
@ -2956,6 +2957,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;
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
float tvec[3];
@ -3092,15 +3094,11 @@ 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 (len_a == 0.0f)
len_a = 1.0f;
if (len_b == 0.0f)
len_b = 1.0f;
if (bezt->f1 & SELECT) { /* order of calculation */
if (ELEM(bezt->h2, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) { /* aligned */
if (len_a > eps) {
len = len_b / len_a;
len = 1.0f / orig_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]);
@ -3108,7 +3106,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 = len_a / len_b;
len = orig_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]);
@ -3118,7 +3116,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 = len_a / len_b;
len = 1.0f / orig_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]);
@ -3126,7 +3124,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 = len_b / len_a;
len = orig_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]);