[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31178] branches/nurbs25: Patch from Sergey/nazgul to change UI knot selection.

Emmanuel Stone emmanuel.stone at gmail.com
Sun Aug 8 22:18:53 CEST 2010


Revision: 31178
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31178
Author:   eman
Date:     2010-08-08 22:18:53 +0200 (Sun, 08 Aug 2010)

Log Message:
-----------
Patch from Sergey/nazgul to change UI knot selection.
Changed naming of knots to Clamped/Unclamped/Cyclic as more intuitive than Periodic/Open/Endpoint

Modified Paths:
--------------
    branches/nurbs25/intern/nurbana/intern/nbGenerate.cpp
    branches/nurbs25/intern/nurbana/intern/nbGenerate.h
    branches/nurbs25/release/scripts/ui/properties_data_curve.py
    branches/nurbs25/source/blender/blenkernel/BKE_curve.h
    branches/nurbs25/source/blender/blenkernel/intern/curve.c
    branches/nurbs25/source/blender/editors/curve/editcurve.c
    branches/nurbs25/source/blender/makesdna/DNA_curve_types.h
    branches/nurbs25/source/blender/makesrna/intern/rna_curve.c
    branches/nurbs25/source/blender/render/intern/source/convertblender.c

Modified: branches/nurbs25/intern/nurbana/intern/nbGenerate.cpp
===================================================================
--- branches/nurbs25/intern/nurbana/intern/nbGenerate.cpp	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/intern/nurbana/intern/nbGenerate.cpp	2010-08-08 20:18:53 UTC (rev 31178)
@@ -366,27 +366,22 @@
 }
 
 void nbGenerate::resetKnotVector(nbNURBS *obj, int uv) {
-	//	void makeknots(Nurb *nu, short uv, short type)	/* 0: uniform, 1: endpoints, 2: bezier */	
-	//#define	NURBS_KV_Periodic		0
-	//#define	NURBS_KV_Open			1 // endpoints tied
-	//#define	NURBS_KV_Bezier		2
+	if(obj->getCyclic(uv)) {
+		PeriodicKnot(obj->Length(uv) + obj->getOrder(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
+	} else {
+		short type= obj->getKnotType(uv);
 
-	if(obj->getKnotType(uv) == NURBS_KV_Periodic) {
-		if(obj->getCyclic(uv))
-			PeriodicKnot(obj->Length(uv) + obj->getOrder(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
-		else
-			PeriodicKnot(obj->Length(uv), obj->getOrder(uv), obj->getKnotVector(uv));
-
-	} else if(obj->getKnotType(uv) == NURBS_KV_Open) {
-		if(obj->getCyclic(uv))
-			OpenKnot(obj->Length(uv) - 1 + obj ->getOrder(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
-		else	
-			OpenKnot(obj->Length(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
-	} else if(obj->getKnotType(uv) == NURBS_KV_Bezier) {
-		if(obj->getCyclic(uv))
-			BezierKnot(obj->Length(uv) + obj->getOrder(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
-		else	
-			BezierKnot(obj->Length(uv), obj->getOrder(uv), obj->getKnotVector(uv));
+		switch(type) {
+			case NURBS_KV_Periodic:
+				PeriodicKnot(obj->Length(uv), obj->getOrder(uv), obj->getKnotVector(uv));
+				break;
+			case NURBS_KV_Open:
+				OpenKnot(obj->Length(uv) - 1, obj->getOrder(uv), obj->getKnotVector(uv));
+				break;
+			case NURBS_KV_Bezier:
+				BezierKnot(obj->Length(uv), obj->getOrder(uv), obj->getKnotVector(uv));
+				break;
+		}
 	}
 }
 

Modified: branches/nurbs25/intern/nurbana/intern/nbGenerate.h
===================================================================
--- branches/nurbs25/intern/nurbana/intern/nbGenerate.h	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/intern/nurbana/intern/nbGenerate.h	2010-08-08 20:18:53 UTC (rev 31178)
@@ -69,4 +69,4 @@
 	static void surface(nbNURBS *obj, int origTessU, int origTessV, int dim, nbReal *TssPts, nbReal3 *bevpBuffer, nbReal *tiltBuffer, nbReal *radiusBuffer, int stride, nbReal *sum, int Index, bool Change, bool Update);
 
 }; //eof class nbGenerate
-#endif
\ No newline at end of file
+#endif

Modified: branches/nurbs25/release/scripts/ui/properties_data_curve.py
===================================================================
--- branches/nurbs25/release/scripts/ui/properties_data_curve.py	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/release/scripts/ui/properties_data_curve.py	2010-08-08 20:18:53 UTC (rev 31178)
@@ -210,54 +210,44 @@
         is_surf = (ob.type == 'SURFACE')
         is_poly = (act_spline.type == 'POLY')
 
-        split = layout.split()
-
         if is_poly:
             # These settings are below but its easier to have
             # poly's set aside since they use so few settings
+            split = layout.split()
+
             col = split.column()
             col.label(text="Cyclic:")
             col.prop(act_spline, "smooth")
             col = split.column()
-            col.prop(act_spline, "cyclic_u", text="U")
 
         else:
+            split = layout.split()
             col = split.column()
-            col.label(text="Cyclic:")
-            if act_spline.type == 'NURBS':
-                col.label(text="Bezier:")
-                col.label(text="Endpoint:")
-                col.label(text="Order:")
 
-            col.label(text="Resolution:")
+            if is_surf:
+                col.label(text="Surface type U:")
 
-            col = split.column()
-            col.prop(act_spline, "cyclic_u", text="U")
-
             if act_spline.type == 'NURBS':
                 sub = col.column()
-                # sub.active = (not act_spline.cyclic_u)
-                sub.prop(act_spline, "bezier_u", text="U")
-                sub.prop(act_spline, "endpoint_u", text="U")
+                sub.prop(act_spline, "knots_type_u", text="")
 
                 sub = col.column()
-                sub.prop(act_spline, "order_u", text="U")
-            col.prop(act_spline, "resolution_u", text="U")
+                col.prop(act_spline, "order_u", text="Order")
 
+            col.prop(act_spline, "resolution_u", text="Resolution")
+
             if is_surf:
                 col = split.column()
-                col.prop(act_spline, "cyclic_v", text="V")
+                col.label(text="Surface type V:")
 
-                # its a surface, assume its a nurb.
                 sub = col.column()
-                sub.active = (not act_spline.cyclic_v)
-                sub.prop(act_spline, "bezier_v", text="V")
-                sub.prop(act_spline, "endpoint_v", text="V")
+                sub.prop(act_spline, "knots_type_v", text="")
+
                 sub = col.column()
-                sub.prop(act_spline, "order_v", text="V")
-                sub.prop(act_spline, "resolution_v", text="V")
+                col.prop(act_spline, "order_v", text="Order")
 
-            if not is_surf:
+                col.prop(act_spline, "resolution_v", text="Resolution")
+            else:
                 split = layout.split()
                 col = split.column()
                 col.active = (curve.dimensions == '3D')

Modified: branches/nurbs25/source/blender/blenkernel/BKE_curve.h
===================================================================
--- branches/nurbs25/source/blender/blenkernel/BKE_curve.h	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/source/blender/blenkernel/BKE_curve.h	2010-08-08 20:18:53 UTC (rev 31178)
@@ -69,7 +69,7 @@
 void test2DNurb( struct Nurb *nu);
 void minmaxNurb( struct Nurb *nu, float *min, float *max);
 
-void makeknots( struct Nurb *nu, short uv, short type);
+void makeknots( struct Nurb *nu, short uv);
 
 //nurbana functions
 void nurbanaInit( struct Nurb *nu);

Modified: branches/nurbs25/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/nurbs25/source/blender/blenkernel/intern/curve.c	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/source/blender/blenkernel/intern/curve.c	2010-08-08 20:18:53 UTC (rev 31178)
@@ -626,24 +626,47 @@
 	}
 }
 
-/* type - 0: uniform, 1: endpoints, 2: bezier, note, cyclic nurbs are always uniform */
-void makeknots(Nurb *nu, short uv, short type)
+static short getNRBKnotType(Nurb *nu, short uv)
 {
+	short flag= 0;
+
+	if(uv == 0) flag= nu->flagu;
+	else flag= nu->flagv;
+
+	if(flag & CU_NURB_BEZIER){
+		return 2; // NURBS_KV_BezierClamp
+	} else if(flag & CU_NURB_ENDPOINT){
+		return 1; // NURBS_KV_Open
+	}
+
+	return 0;
+}
+
+void makeknots(Nurb *nu, short uv)
+{
 	if(nu->type == CU_NURBS) {
+		short type;
+
 		if(uv == 1) {
-			if(nu->nurbanaPtr){			
+			if(nu->nurbanaPtr){
+				type= getNRBKnotType(nu, 0);
+
 				if(nu->knotsu) 
 					MEM_freeN(nu->knotsu);
+
 				nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots U"); // FIXME what's the +4 for?
 				printf( "makeknots U: %d",KNOTSU(nu)); 
 				NRB_recalculateKnots(nu->nurbanaPtr,0,type);
 				}
 			}
+
 		if(uv & 2) {
-		
 			if(nu->nurbanaPtr){
+				type= getNRBKnotType(nu, 1);
+
 				if(nu->knotsv) 
 					MEM_freeN(nu->knotsv);
+
 				nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots V");
 				printf( "makeknots V: %d",KNOTSV(nu)); 
 				NRB_recalculateKnots(nu->nurbanaPtr,1,type);

Modified: branches/nurbs25/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/nurbs25/source/blender/editors/curve/editcurve.c	2010-08-08 20:15:54 UTC (rev 31177)
+++ branches/nurbs25/source/blender/editors/curve/editcurve.c	2010-08-08 20:18:53 UTC (rev 31178)
@@ -1491,7 +1491,7 @@
 				MEM_freeN(nu->bp);
 				nu->bp= newbp;
 				clamp_nurb_order_v(nu);
-				//makeknots(nu, 2, nu->flagv>>1);
+				//makeknots(nu, 2);
 			}
 			else {
 				/* is the nurb in V direction selected */
@@ -1541,7 +1541,7 @@
 						nu->pntsu= newu;
 						clamp_nurb_order_u(nu);
 					}
-					//makeknots(nu, 1, nu->flagu>>1);
+					//makeknots(nu, 1);
 				}
 			}
 		}
@@ -1748,7 +1748,7 @@
 					nurbanaInit(newnu); 	
 					/* knots */
 					newnu->knotsu= NULL;
-					makeknots(newnu, 1, newnu->flagu>>1);
+					makeknots(newnu, 1);
 				}
 				bp++;
 			}
@@ -1814,13 +1814,13 @@
 						if(nu->pntsu==newnu->pntsu && nu->knotsu) {
 							newnu->knotsu= MEM_dupallocN( nu->knotsu );
 						} else {
-							makeknots(newnu, 1, newnu->flagu>>1);
+							makeknots(newnu, 1);
 						}
 					}
 					else {
 						newnu->knotsu= 0;
 						nurbanaInit(newnu);
-						makeknots(newnu, 1, newnu->flagu>>1);
+						makeknots(newnu, 1);
 					}
 				}
 				MEM_freeN(usel);
@@ -3692,7 +3692,7 @@
 
 				if(nu->type & CU_NURBS) {
 					NRB_updateSize(nu->nurbanaPtr); // FIXME CHECKME eman
-					makeknots(nu, 1, nu->flagu>>1);
+					makeknots(nu, 1);
 				}
 			}
 		} /* End of 'else if(nu->pntsv==1)' */
@@ -3803,8 +3803,8 @@
 				nu->bp= bpnew;
 				nu->pntsu= 2*nu->pntsu-1;
 				nu->pntsv= 2*nu->pntsv-1;
-				makeknots(nu, 1, nu->flagu>>1);
-				makeknots(nu, 2, nu->flagv>>1);
+				makeknots(nu, 1);
+				makeknots(nu, 2);
 				NRB_updateSize(nu->nurbanaPtr);
 			} /* End of 'if(sel== nu->pntsu*nu->pntsv)' (subdivide entire NURB) */
 			else {
@@ -3848,7 +3848,7 @@
 					MEM_freeN(nu->bp);
 					nu->bp= bpnew;
 					nu->pntsv+= sel;
-					makeknots(nu, 2, nu->flagv>>1);
+					makeknots(nu, 2);
 					NRB_updateSize(nu->nurbanaPtr);
 				}
 				else {
@@ -3889,7 +3889,7 @@
 						MEM_freeN(nu->bp);
 						nu->bp= bpnew;
 						nu->pntsu+= sel;
-						makeknots(nu, 1, nu->flagu>>1); /* shift knots forward */
+						makeknots(nu, 1); /* shift knots forward */
 						NRB_updateSize(nu->nurbanaPtr);
 					}
 				}
@@ -4115,7 +4115,7 @@
 			nu->orderu= 4;
 			nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */
 			nu->flagu += 4;
-			makeknots(nu, 1, nu->flagu>>1);
+			makeknots(nu, 1);
 			a= nu->pntsu*nu->pntsv;
 			bp= nu->bp;
 			while(a--) {
@@ -4168,7 +4168,7 @@
 			if(type== CU_NURBS) {
 				nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */
 				nu->flagu += 4;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list