From 5506d18fa8b185924799ee5b370253e79029a1e4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 9 Jul 2011 14:22:52 +0000 Subject: Fox #27866: Curve handle snaps/locks when it shouldnt It was a precision error in calchandleNurb. Do not align handles along handle which si too short. --- source/blender/blenkernel/intern/curve.c | 41 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 704af73dd10..202a3f28d9a 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2431,6 +2431,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) { float *p1,*p2,*p3, pt[3]; float dx1,dy1,dz1,dx,dy,dz,vx,vy,vz,len,len1,len2; + const float eps= 1e-5; if(bezt->h1==0 && bezt->h2==0) return; @@ -2587,30 +2588,38 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(bezt->f1 & SELECT) { /* order of calculation */ if(bezt->h2==HD_ALIGN) { /* aligned */ - len= len2/len1; - p2[3]= p2[0]+len*(p2[0]-p2[-3]); - p2[4]= p2[1]+len*(p2[1]-p2[-2]); - p2[5]= p2[2]+len*(p2[2]-p2[-1]); + if(len1>eps) { + len= len2/len1; + p2[3]= p2[0]+len*(p2[0]-p2[-3]); + p2[4]= p2[1]+len*(p2[1]-p2[-2]); + p2[5]= p2[2]+len*(p2[2]-p2[-1]); + } } if(bezt->h1==HD_ALIGN) { - len= len1/len2; - p2[-3]= p2[0]+len*(p2[0]-p2[3]); - p2[-2]= p2[1]+len*(p2[1]-p2[4]); - p2[-1]= p2[2]+len*(p2[2]-p2[5]); + if(len2>eps) { + len= len1/len2; + p2[-3]= p2[0]+len*(p2[0]-p2[3]); + p2[-2]= p2[1]+len*(p2[1]-p2[4]); + p2[-1]= p2[2]+len*(p2[2]-p2[5]); + } } } else { if(bezt->h1==HD_ALIGN) { - len= len1/len2; - p2[-3]= p2[0]+len*(p2[0]-p2[3]); - p2[-2]= p2[1]+len*(p2[1]-p2[4]); - p2[-1]= p2[2]+len*(p2[2]-p2[5]); + if(len2>eps) { + len= len1/len2; + p2[-3]= p2[0]+len*(p2[0]-p2[3]); + p2[-2]= p2[1]+len*(p2[1]-p2[4]); + p2[-1]= p2[2]+len*(p2[2]-p2[5]); + } } if(bezt->h2==HD_ALIGN) { /* aligned */ - len= len2/len1; - p2[3]= p2[0]+len*(p2[0]-p2[-3]); - p2[4]= p2[1]+len*(p2[1]-p2[-2]); - p2[5]= p2[2]+len*(p2[2]-p2[-1]); + if(len1>eps) { + len= len2/len1; + p2[3]= p2[0]+len*(p2[0]-p2[-3]); + p2[4]= p2[1]+len*(p2[1]-p2[-2]); + p2[5]= p2[2]+len*(p2[2]-p2[-1]); + } } } } -- cgit v1.2.3