[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13008] trunk/blender/source/blender/ blenkernel/intern/colortools.c: Node curves to maintain handle status after adding a control point

Juho Vepsalainen bebraw at gmail.com
Wed Dec 26 18:04:21 CET 2007


Revision: 13008
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13008
Author:   bebraw
Date:     2007-12-26 18:04:21 +0100 (Wed, 26 Dec 2007)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/colortools.c

Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c	2007-12-26 16:15:27 UTC (rev 13007)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c	2007-12-26 17:04:21 UTC (rev 13008)
@@ -167,18 +167,30 @@
 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; a<cuma->totpoint; 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; a<cuma->totpoint; a++, cmp++)
-		cmp->flag= 0;
-	cuma->totpoint++;
 }
 
 void curvemap_reset(CurveMap *cuma, rctf *clipr)





More information about the Bf-blender-cvs mailing list