[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46418] trunk/blender/source/blender/ editors/curve/editcurve.c: style cleanup: editcurve

Campbell Barton ideasman42 at gmail.com
Tue May 8 13:42:29 CEST 2012


Revision: 46418
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46418
Author:   campbellbarton
Date:     2012-05-08 11:42:29 +0000 (Tue, 08 May 2012)
Log Message:
-----------
style cleanup: editcurve

Modified Paths:
--------------
    trunk/blender/source/blender/editors/curve/editcurve.c

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2012-05-08 11:39:32 UTC (rev 46417)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2012-05-08 11:42:29 UTC (rev 46418)
@@ -29,7 +29,6 @@
  *  \ingroup edcurve
  */
 
-
 #include <math.h>
 #include <string.h>
 
@@ -108,9 +107,9 @@
 static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus);
 
 /* still need to eradicate a few :( */
-#define callocstructN(x, y, name) (x*)MEM_callocN((y)* sizeof(x), name)
+#define callocstructN(x, y, name) (x *)MEM_callocN((y) * sizeof(x), name)
 
-static float nurbcircle[8][2]= {
+static float nurbcircle[8][2] = {
 	{0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0,  1.0},
 	{0.0,  1.0}, { 1.0,  1.0}, { 1.0, 0.0}, { 1.0, -1.0}
 };
@@ -118,7 +117,7 @@
 ListBase *object_editcurve_get(Object *ob)
 {
 	if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) {
-		Curve *cu= ob->data;
+		Curve *cu = ob->data;
 		return &cu->editnurb->nurbs;
 	}
 	return NULL;
@@ -127,39 +126,39 @@
 /* this replaces the active flag used in uv/face mode */
 static void set_actNurb(Object *obedit, Nurb *nu)
 {
-	Curve *cu= obedit->data;
+	Curve *cu = obedit->data;
 	
-	if (nu==NULL)
+	if (nu == NULL)
 		cu->actnu = -1;
 	else {
-		ListBase *nurbs= BKE_curve_editNurbs_get(cu);
+		ListBase *nurbs = BKE_curve_editNurbs_get(cu);
 		cu->actnu = BLI_findindex(nurbs, nu);
 	}
 }
 
 static Nurb *get_actNurb(Object *obedit)
 {
-	Curve *cu= obedit->data;
-	ListBase *nurbs= BKE_curve_editNurbs_get(cu);
+	Curve *cu = obedit->data;
+	ListBase *nurbs = BKE_curve_editNurbs_get(cu);
 
 	return BLI_findlink(nurbs, cu->actnu);
 }
 
 /* ******************* SELECTION FUNCTIONS ********************* */
 
-#define HIDDEN			1
-#define VISIBLE			0
+#define HIDDEN          1
+#define VISIBLE         0
 
-#define FIRST			1
-#define LAST			0
+#define FIRST           1
+#define LAST            0
 
 
 /* returns 1 in case (de)selection was successful */
 static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden)
 {	
 	if (bezt) {
-		if ((bezt->hide==0) || (hidden==1)) {
-			if (selstatus==1) { /* selects */			
+		if ((bezt->hide == 0) || (hidden == 1)) {
+			if (selstatus == 1) { /* selects */
 				bezt->f1 |= flag;
 				bezt->f2 |= flag;
 				bezt->f3 |= flag;
@@ -181,8 +180,8 @@
 static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden) 
 {	
 	if (bp) {
-		if ((bp->hide==0) || (hidden==1)) {
-			if (selstatus==1) {
+		if ((bp->hide == 0) || (hidden == 1)) {
+			if (selstatus == 1) {
 				bp->f1 |= flag;
 				return 1;
 			}
@@ -219,18 +218,18 @@
 	int a;
 
 	if (nu->type == CU_BEZIER) {
-		bezt= nu->bezt;
-		a= nu->pntsu;
+		bezt = nu->bezt;
+		a = nu->pntsu;
 		while (a--) {
 			if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1;
 			bezt++;
 		}
 	}
 	else {
-		bp= nu->bp;
-		a= nu->pntsu*nu->pntsv;
+		bp = nu->bp;
+		a = nu->pntsu * nu->pntsv;
 		while (a--) {
-			if ( (bp->f1 & SELECT) ) return 1;
+			if (bp->f1 & SELECT) return 1;
 			bp++;
 		}
 	}
@@ -241,19 +240,19 @@
 {
 	BezTriple *bezt;
 	BPoint *bp;
-	int a, sel=0;
+	int a, sel = 0;
 
 	if (nu->type == CU_BEZIER) {
-		bezt= nu->bezt;
-		a= nu->pntsu;
+		bezt = nu->bezt;
+		a = nu->pntsu;
 		while (a--) {
 			if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++;
 			bezt++;
 		}
 	}
 	else {
-		bp= nu->bp;
-		a= nu->pntsu*nu->pntsv;
+		bp = nu->bp;
+		a = nu->pntsu * nu->pntsv;
 		while (a--) {
 			if ( (bp->f1 & SELECT) ) sel++;
 			bp++;
@@ -266,19 +265,19 @@
 
 void printknots(Object *obedit)
 {
-	ListBase *editnurb= object_editcurve_get(obedit);
+	ListBase *editnurb = object_editcurve_get(obedit);
 	Nurb *nu;
 	int a, num;
 
-	for (nu= editnurb->first; nu; nu= nu->next) {
+	for (nu = editnurb->first; nu; nu = nu->next) {
 		if (isNurbsel(nu) &&  nu->type == CU_NURBS) {
 			if (nu->knotsu) {
-				num= KNOTSU(nu);
-				for (a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
+				num = KNOTSU(nu);
+				for (a = 0; a < num; a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
 			}
 			if (nu->knotsv) {
-				num= KNOTSV(nu);
-				for (a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
+				num = KNOTSV(nu);
+				for (a = 0; a < num; a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
 			}
 		}
 	}
@@ -290,66 +289,66 @@
 {
 	CVKeyIndex *cvIndex = MEM_callocN(sizeof(CVKeyIndex), "init_cvKeyIndex");
 
-	cvIndex->orig_cv= cv;
-	cvIndex->key_index= key_index;
-	cvIndex->nu_index= nu_index;
-	cvIndex->pt_index= pt_index;
-	cvIndex->switched= 0;
-	cvIndex->orig_nu= orig_nu;
+	cvIndex->orig_cv = cv;
+	cvIndex->key_index = key_index;
+	cvIndex->nu_index = nu_index;
+	cvIndex->pt_index = pt_index;
+	cvIndex->switched = 0;
+	cvIndex->orig_nu = orig_nu;
 
 	return cvIndex;
 }
 
 static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
 {
-	Nurb *nu= editnurb->nurbs.first;
-	Nurb *orignu= origBase->first;
+	Nurb *nu = editnurb->nurbs.first;
+	Nurb *orignu = origBase->first;
 	GHash *gh;
 	BezTriple *bezt, *origbezt;
 	BPoint *bp, *origbp;
 	CVKeyIndex *keyIndex;
-	int a, key_index= 0, nu_index= 0, pt_index= 0;
+	int a, key_index = 0, nu_index = 0, pt_index = 0;
 
 	if (editnurb->keyindex) return;
 
-	gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex");
+	gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex");
 
 	while (orignu) {
 		if (orignu->bezt) {
-			a= orignu->pntsu;
-			bezt= nu->bezt;
-			origbezt= orignu->bezt;
-			pt_index= 0;
+			a = orignu->pntsu;
+			bezt = nu->bezt;
+			origbezt = orignu->bezt;
+			pt_index = 0;
 			while (a--) {
-				keyIndex= init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu);
+				keyIndex = init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu);
 				BLI_ghash_insert(gh, bezt, keyIndex);
-				key_index+= 12;
+				key_index += 12;
 				bezt++;
 				origbezt++;
 				pt_index++;
 			}
 		}
 		else {
-			a= orignu->pntsu * orignu->pntsv;
-			bp= nu->bp;
-			origbp= orignu->bp;
-			pt_index= 0;
+			a = orignu->pntsu * orignu->pntsv;
+			bp = nu->bp;
+			origbp = orignu->bp;
+			pt_index = 0;
 			while (a--) {
-				keyIndex= init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu);
+				keyIndex = init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu);
 				BLI_ghash_insert(gh, bp, keyIndex);
-				key_index+= 4;
+				key_index += 4;
 				bp++;
 				origbp++;
 				pt_index++;
 			}
 		}
 
-		nu= nu->next;
-		orignu= orignu->next;
+		nu = nu->next;
+		orignu = orignu->next;
 		nu_index++;
 	}
 
-	editnurb->keyindex= gh;
+	editnurb->keyindex = gh;
 }
 
 static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv)
@@ -359,29 +358,29 @@
 
 static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, BezTriple *bezt)
 {
-	CVKeyIndex *index= getCVKeyIndex(editnurb, bezt);
+	CVKeyIndex *index = getCVKeyIndex(editnurb, bezt);
 
 	if (!index) {
 		return NULL;
 	}
 
-	return (BezTriple*)index->orig_cv;
+	return (BezTriple *)index->orig_cv;
 }
 
 static BPoint *getKeyIndexOrig_bp(EditNurb *editnurb, BPoint *bp)
 {
-	CVKeyIndex *index= getCVKeyIndex(editnurb, bp);
+	CVKeyIndex *index = getCVKeyIndex(editnurb, bp);
 
 	if (!index) {
 		return NULL;
 	}
 
-	return (BPoint*)index->orig_cv;
+	return (BPoint *)index->orig_cv;
 }
 
 static int getKeyIndexOrig_keyIndex(EditNurb *editnurb, void *cv)
 {
-	CVKeyIndex *index= getCVKeyIndex(editnurb, cv);
+	CVKeyIndex *index = getCVKeyIndex(editnurb, cv);
 
 	if (!index) {
 		return -1;
@@ -418,8 +417,8 @@
 	}
 
 	if (nu->bezt) {
-		BezTriple *bezt= nu->bezt;
-		a= nu->pntsu;
+		BezTriple *bezt = nu->bezt;
+		a = nu->pntsu;
 
 		while (a--) {
 			BLI_ghash_remove(editnurb->keyindex, bezt, NULL, (GHashValFreeFP)MEM_freeN);
@@ -427,8 +426,8 @@
 		}
 	}
 	else {
-		BPoint *bp= nu->bp;
-		a= nu->pntsu * nu->pntsv;
+		BPoint *bp = nu->bp;
+		a = nu->pntsu * nu->pntsv;
 
 		while (a--) {
 			BLI_ghash_remove(editnurb->keyindex, bp, NULL, (GHashValFreeFP)MEM_freeN);
@@ -439,17 +438,17 @@
 
 static void keyIndex_delNurbList(EditNurb *editnurb, ListBase *nubase)
 {
-	Nurb *nu= nubase->first;
+	Nurb *nu = nubase->first;
 
 	while (nu) {
 		keyIndex_delNurb(editnurb, nu);
 
-		nu= nu->next;
+		nu = nu->next;
 	}
 }
 
 static void keyIndex_updateCV(EditNurb *editnurb, char *cv,
-	char *newcv, int count, int size)
+                              char *newcv, int count, int size)
 {
 	int i;
 	CVKeyIndex *index;
@@ -460,7 +459,7 @@
 	}
 
 	for (i = 0; i < count; i++) {
-		index= getCVKeyIndex(editnurb, cv);
+		index = getCVKeyIndex(editnurb, cv);
 
 		BLI_ghash_remove(editnurb->keyindex, cv, NULL, NULL);
 
@@ -474,15 +473,15 @@
 }
 
 static void keyIndex_updateBezt(EditNurb *editnurb, BezTriple *bezt,
-	BezTriple *newbezt, int count)
+                                BezTriple *newbezt, int count)
 {
-	keyIndex_updateCV(editnurb, (char*)bezt, (char*)newbezt, count, sizeof(BezTriple));
+	keyIndex_updateCV(editnurb, (char *)bezt, (char *)newbezt, count, sizeof(BezTriple));
 }
 
 static void keyIndex_updateBP(EditNurb *editnurb, BPoint *bp,
-	BPoint *newbp, int count)
+                              BPoint *newbp, int count)
 {
-	keyIndex_updateCV(editnurb, (char*)bp, (char*)newbp, count, sizeof(BPoint));
+	keyIndex_updateCV(editnurb, (char *)bp, (char *)newbp, count, sizeof(BPoint));
 }
 
 static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu)
@@ -497,8 +496,8 @@
 
 static void keyIndex_swap(EditNurb *editnurb, void *a, void *b)
 {
-	CVKeyIndex *index1= getCVKeyIndex(editnurb, a);
-	CVKeyIndex *index2= getCVKeyIndex(editnurb, b);
+	CVKeyIndex *index1 = getCVKeyIndex(editnurb, a);
+	CVKeyIndex *index2 = getCVKeyIndex(editnurb, b);
 
 	BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL);
 	BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL);
@@ -515,25 +514,25 @@
 	if (nu->bezt) {
 		BezTriple *bezt1, *bezt2;
 
-		a= nu->pntsu;
+		a = nu->pntsu;
 
-		bezt1= nu->bezt;
-		bezt2= bezt1+(a-1);
+		bezt1 = nu->bezt;
+		bezt2 = bezt1 + (a - 1);
 
 		if (a & 1) ++a;
 
-		a/=2;
+		a /= 2;
 
 		while (a--) {
-			index1= getCVKeyIndex(editnurb, bezt1);
-			index2= getCVKeyIndex(editnurb, bezt2);
+			index1 = getCVKeyIndex(editnurb, bezt1);
+			index2 = getCVKeyIndex(editnurb, bezt2);
 
-			if (index1) index1->switched= !index1->switched;
+			if (index1) index1->switched = !index1->switched;
 
 			if (bezt1 != bezt2) {
 				keyIndex_swap(editnurb, bezt1, bezt2);
 
-				if (index2) index2->switched= !index2->switched;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list