[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38886] trunk/blender/source/blender/ blenkernel/intern/curve.c: fix for failure to create curve knots when both endpoint and bezier U were enabled .

Campbell Barton ideasman42 at gmail.com
Mon Aug 1 04:52:09 CEST 2011


Revision: 38886
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38886
Author:   campbellbarton
Date:     2011-08-01 02:52:08 +0000 (Mon, 01 Aug 2011)
Log Message:
-----------
fix for failure to create curve knots when both endpoint and bezier U were enabled.
use default when invalid settings given.

removed odd/annoying bit shifting of the flagu/v for such basic function made code hard to understand and would fail if new flags were added.

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

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2011-08-01 02:40:09 UTC (rev 38885)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2011-08-01 02:52:08 UTC (rev 38886)
@@ -580,29 +580,24 @@
 /* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */
 
 
-static void calcknots(float *knots, short aantal, short order, short type)
-/* knots: number of pnts NOT corrected for cyclic */
-/* type;	 0: uniform, 1: endpoints, 2: bezier */
+static void calcknots(float *knots, const short aantal, const short order, const short flag)
 {
+	/* knots: number of pnts NOT corrected for cyclic */
+	const int t= aantal + order;
 	float k;
-	int a, t;
+	int a;
 
-		t = aantal+order;
-	if(type==0) {
-
-		for(a=0;a<t;a++) {
-			knots[a]= (float)a;
-		}
-	}
-	else if(type==1) {
+	switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
+	case CU_NURB_ENDPOINT:
 		k= 0.0;
 		for(a=1;a<=t;a++) {
 			knots[a-1]= k;
 			if(a>=order && a<=aantal) k+= 1.0f;
 		}
-	}
-	else if(type==2) {
-		/* Warning, the order MUST be 2 or 4, if this is not enforced, the displist will be corrupt */
+		break;
+	case CU_NURB_BEZIER:
+		/* Warning, the order MUST be 2 or 4,
+		 * if this is not enforced, the displist will be corrupt */
 		if(order==4) {
 			k= 0.34;
 			for(a=0;a<t;a++) {
@@ -620,6 +615,12 @@
 		else {
 			printf("bez nurb curve order is not 3 or 4, should never happen\n");
 		}
+		break;
+	default:
+		for(a=0;a<t;a++) {
+			knots[a]= (float)a;
+		}
+		break;
 	}
 }
 
@@ -662,7 +663,7 @@
 					calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0);  /* cyclic should be uniform */
 					makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
 				} else {
-					calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu>>1);
+					calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu);
 				}
 			}
 			else nu->knotsu= NULL;
@@ -675,7 +676,7 @@
 					calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0);  /* cyclic should be uniform */
 					makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
 				} else {
-					calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv>>1);
+					calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv);
 				}
 			}
 			else nu->knotsv= NULL;




More information about the Bf-blender-cvs mailing list