From 2daf4c978cc889c6056759114a9bdaa53a13c930 Mon Sep 17 00:00:00 2001 From: Juho Vepsalainen Date: Wed, 26 Dec 2007 17:04:21 +0000 Subject: Node curves to maintain handle status after adding a control point Node curves maintain handles status (normal, auto, vector) even after adding a control point now. This makes the behavior the same as in case of removing a control point. Previously the status of handles was reseted. --- source/blender/blenkernel/intern/colortools.c | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 83b014cdd63..e4336576e2a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -167,18 +167,30 @@ void curvemap_remove(CurveMap *cuma, int flag) void curvemap_insert(CurveMap *cuma, float x, float y) { CurveMapPoint *cmp= MEM_callocN((cuma->totpoint+1)*sizeof(CurveMapPoint), "curve points"); - int a; - - memcpy(cmp, cuma->curve, (cuma->totpoint)*sizeof(CurveMapPoint)); + int a, b, foundloc= 0; + + /* insert fragments of the old one and the new point to the new curve */ + cuma->totpoint++; + for(a=0, b=0; atotpoint; a++) { + if((x < cuma->curve[a].x) && !foundloc) { + cmp[a].x= x; + cmp[a].y= y; + cmp[a].flag= CUMA_SELECT; + foundloc= 1; + } + else { + cmp[a].x= cuma->curve[b].x; + cmp[a].y= cuma->curve[b].y; + cmp[a].flag= cuma->curve[b].flag; + cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */ + cmp[a].shorty= cuma->curve[b].shorty; + b++; + } + } + + /* free old curve and replace it with new one */ MEM_freeN(cuma->curve); cuma->curve= cmp; - - cuma->curve[cuma->totpoint].x= x; - cuma->curve[cuma->totpoint].y= y; - cuma->curve[cuma->totpoint].flag = CUMA_SELECT; - for(a=0; atotpoint; a++, cmp++) - cmp->flag= 0; - cuma->totpoint++; } void curvemap_reset(CurveMap *cuma, rctf *clipr) -- cgit v1.2.3