[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16869] branches/nurbs/blender: Modified tesselation algorithm to handle Tilt and Radius ( fetched from BPoint struct inside Blender) for ideasman/Campbell's new code .

Emmanuel Stone emmanuel.stone at gmail.com
Wed Oct 1 19:08:51 CEST 2008


Revision: 16869
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16869
Author:   eman
Date:     2008-10-01 19:08:51 +0200 (Wed, 01 Oct 2008)

Log Message:
-----------
Modified tesselation algorithm to handle Tilt and Radius (fetched from BPoint struct inside Blender) for ideasman/Campbell's new code.
Cleaned up some commented out code.

Modified Paths:
--------------
    branches/nurbs/blender/intern/nurbana/extern/nurbana.h
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.h
    branches/nurbs/blender/intern/nurbana/intern/libNurbana.cpp
    branches/nurbs/blender/source/blender/blenkernel/intern/curve.c
    branches/nurbs/blender/source/blender/makesdna/DNA_curve_types.h

Modified: branches/nurbs/blender/intern/nurbana/extern/nurbana.h
===================================================================
--- branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-10-01 17:02:38 UTC (rev 16868)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-10-01 17:08:51 UTC (rev 16869)
@@ -61,7 +61,7 @@
 	// This extra data should make Point4d 'struct'rally equivalent to BPoint from Blender::DNA_Data_Types.h
 	nbReal alfa, weight;		/* alfa: tilt in 3D View, weight: used for softbody goal weight */
 	short f1, hide;
-	float radius, pad;		/* user-set radius per point for bevelling etc */
+	nbReal radius, pad;		/* user-set radius per point for bevelling etc */
 }Point3d;
 
 //typedef Point3d nbReal3;
@@ -137,7 +137,7 @@
 //extern nbReal* NRB_GenerateSurface(NurbanaObj_ptr nop, nbReal* buffer, int dim );
 extern nbReal* NRB_GenerateSurface(NurbanaObj_ptr nop, nbReal* buffer, int resU, int resV, int dim);
 
-nbReal* NRB_GenerateCurve(NurbanaObj_ptr nop, nbReal* buffer, int dim, int res);
+extern nbReal* NRB_GenerateCurve(NurbanaObj_ptr nop, nbReal* buffer, nbReal* tiltBuffer, nbReal* radiusBuffer, int res);
 
 extern nbReal3_ptr NRB_GenerateNormals(NurbanaObj_ptr nop);
 

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp	2008-10-01 17:02:38 UTC (rev 16868)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp	2008-10-01 17:08:51 UTC (rev 16869)
@@ -1,8 +1,8 @@
 #include "NURBS_Generate.h"
 //NurbData	NURBS_Generate::nurbData;
 
-void NURBS_Generate::Curve(Object_NURBS *obj, nbReal* buffer, int dim, int res, bool update) {
-	Surface(obj, res, 1 , dim, buffer, obj -> Sum(), 0, 0, update);
+void NURBS_Generate::Curve(Object_NURBS *obj, nbReal* buffer, nbReal* tiltBuffer, nbReal* radiusBuffer, int res, bool update) {
+	Surface(obj, res, 1 , 3, buffer, tiltBuffer, radiusBuffer, obj -> Sum(), 0, 0, update);
 }
 
 void NURBS_Generate::Surface(Object_NURBS *obj, nbReal* buffer, int resU, int resV, int dim) {
@@ -12,9 +12,9 @@
 
 	// Blender seems to use a different tess for curves and surfaces, numCPu*resU vs resU*resV
 	if(Vnpts == 1) 
-		Surface(obj, resU , resV * Vnpts , dim, buffer, obj -> Sum(), 0, 0, 1);
+		Surface(obj, resU , resV * Vnpts , dim, buffer, NULL, NULL, obj -> Sum(), 0, 0, 1);
 	else
-		Surface(obj,resU, resV , dim, buffer, obj -> Sum(), 0, 0, 1);
+		Surface(obj,resU, resV , dim, buffer, NULL, NULL, obj -> Sum(), 0, 0, 1);
 
 	//IsoLines(obj);
 }
@@ -26,14 +26,14 @@
 	//	if(!Change) obj->Change(1,0);
 	//	Surface(obj,obj->IPCDensity(),obj->IPCResolution(),obj->IPCPts(),obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),1,0);
 	//
-	Surface(obj, obj -> IPCDensity(), obj -> IPCResolution(), 3, buffer, obj -> SumIPC(0), 0, 0, 0);
+	Surface(obj, obj -> IPCDensity(), obj -> IPCResolution(), 3, buffer, NULL, NULL, obj -> SumIPC(0), 0, 0, 0);
 	if(!Change) obj->Change(1,0);
-	Surface(obj,obj->IPCResolution(),obj->IPCDensity(), 3, buffer, obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),0,0);
+	Surface(obj,obj->IPCResolution(),obj->IPCDensity(), 3, buffer, NULL, NULL, obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),0,0);
 
 
 }
 
-void NURBS_Generate::Surface(Object_NURBS *obj, int origTessU, int origTessV, int dim, nbReal *TssPts, nbReal *Sum, int Index, bool Change, bool Update) {
+void NURBS_Generate::Surface(Object_NURBS *obj, int origTessU, int origTessV, int dim, nbReal *TssPts, nbReal *tiltBuffer, nbReal *radiusBuffer, nbReal *Sum, int Index, bool Change, bool Update) {
 	int n,k,l,m,j,j0;
 	nbReal BasisResult;
 	int i, OrderU, OrderV, Unpts, Vnpts, extraPntsU, extraPntsV,CyclicU,CyclicV;
@@ -127,21 +127,6 @@
 			NURBSBasis(OrderV, tv, (Vnpts+extraPntsV), Vnpts,obj -> KnotVector(1), obj -> CtlPtsOld(), BasisV[i], 1);
 			tv += stepV;
 		}
-		/*for(i = 0; i <= TessU; i++) {
-			if(obj -> KnotType(0) == NURBS_KV_Periodic) { // FIXME eman new is this correct, new and old CtlPts?
-				NURBSBasis(OrderU, (OrderU-1)+i*nbReal((Unpts+extraPntsU)-(OrderU-1))/nbReal(TessU), (Unpts+extraPntsU),Unpts, obj -> KnotVector(0), obj -> CtlPtsOld(), BasisU[i], 1);
-			} else {// if(obj -> KnotType(0) == NURBS_KV_Open) {
-				NURBSBasis(OrderU, (i*nbReal((obj -> KnotVector(0))[(Unpts+extraPntsU)-1+OrderU])/nbReal(TessU)),(Unpts+extraPntsU),Unpts, (obj -> KnotVector(0)), (obj -> CtlPts()), BasisU[i], 1);
-			}
-		}
-
-		for(i = 0; i <= TessV; i++) {
-			if(obj -> KnotType(1) == NURBS_KV_Periodic) {
-				NURBSBasis(OrderV, (OrderV-1)+i*nbReal((Vnpts+extraPntsV)-(OrderV-1))/nbReal(TessV),(Vnpts+extraPntsV), Vnpts, obj -> KnotVector(1), obj -> CtlPtsOld(), BasisV[i], 1);
-			} else {// if(obj -> KnotType(1) == NURBS_KV_Open) {
-				NURBSBasis(OrderV, i*nbReal(obj -> KnotVector(1)[(Vnpts+extraPntsV)-1+OrderV])/nbReal(TessV),(Vnpts+extraPntsV), Vnpts, obj -> KnotVector(1), obj -> CtlPts(), BasisV[i], 1);
-			}
-		}*/
 	}
 
 	// Compute Surface
@@ -151,13 +136,6 @@
 		else
 			TssPts3 = (nbReal3*)(TssPts);
 
-/*		// Copy B into Bold -- FIXME memcpy
-		for(i = 0; i < Unpts * Vnpts; i++) {
-			//obj -> CtlPtsOld()[i] = obj -> H()[i];
-			obj -> CtlPtsOld()[i] = obj -> CtlPts()[i];
-		}
-*/
-
 		if(Update) {
 			for(i = 0; i < Unpts*Vnpts; i++) {
 				// Update Old with New
@@ -212,6 +190,10 @@
 									TssPts3[Index+m].y += (obj -> CtlPts()[j].y*BasisResult);
 									TssPts3[Index+m].z += (obj -> CtlPts()[j].z*BasisResult);
 
+									if(tiltBuffer)
+										tiltBuffer[Index+m] += (obj -> CtlPts()[j].alfa*BasisResult);
+									if(radiusBuffer)
+										radiusBuffer[Index+m] += (obj -> CtlPts()[j].radius*BasisResult);
 
 									//float cutoff = 0.0001;
 								//	if(TssPts3[Index+m].x < cutoff && TssPts3[Index+m].y < cutoff && TssPts3[Index+m].z > -cutoff && TssPts3[Index+m].x > -cutoff && TssPts3[Index+m].y > -cutoff && TssPts3[Index+m].z > -cutoff)

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.h
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.h	2008-10-01 17:02:38 UTC (rev 16868)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.h	2008-10-01 17:08:51 UTC (rev 16869)
@@ -1,75 +1,75 @@
-/********************************************************
- * NURBS Generations Class
- * Start Date: Dec 17, 2000
- * Author: Justin Shumaker
- *
- * Description:
- * - Knot Vector
- * - Surface
- * - Cyclic Surface
- ********************************************************/
-
-
-#ifndef NURBS_Generate_H
-#define NURBS_Generate_H
-
-#include "NurbanaMath.h"
-#include "NURBS.h"
-#include "NURBS_Knot.h"
-#include "Object_NURBS.h"
-//#include "NURBS_TrimCurve.h"
-
-#include "MEM_guardedalloc.h"
-
-#ifndef NGLOBAL_H
-#include "NGlobal.h"
-#endif
-
-#define	NURBS_KV_Periodic		0
-#define	NURBS_KV_Open			1 // endpoints tied
-#define	NURBS_KV_Bezier			2
-#define  NURBS_KV_Custom		9 
-
-#define	NURBS_KV_U			0
-#define	NURBS_KV_V			1
-
-class Object_NURBS;
-
-class NURBS_Generate {
-  public:
+/********************************************************
+ * NURBS Generations Class
+ * Start Date: Dec 17, 2000
+ * Author: Justin Shumaker
+ *
+ * Description:
+ * - Knot Vector
+ * - Surface
+ * - Cyclic Surface
+ ********************************************************/
+
+
+#ifndef NURBS_Generate_H
+#define NURBS_Generate_H
+
+#include "NurbanaMath.h"
+#include "NURBS.h"
+#include "NURBS_Knot.h"
+#include "Object_NURBS.h"
+//#include "NURBS_TrimCurve.h"
+
+#include "MEM_guardedalloc.h"
+
+#ifndef NGLOBAL_H
+#include "NGlobal.h"
+#endif
+
+#define	NURBS_KV_Periodic		0
+#define	NURBS_KV_Open			1 // endpoints tied
+#define	NURBS_KV_Bezier			2
+#define  NURBS_KV_Custom		9 
+
+#define	NURBS_KV_U			0
+#define	NURBS_KV_V			1
+
+class Object_NURBS;
+
+class NURBS_Generate {
+  public:
 	static void		Surface(Object_NURBS *obj, nbReal* buffer, int resU, int resV, int dim);
-
-//    static void		Surface(Object_NURBS *obj, nbReal* buffer, int dim = 3);
-	static void			Curve(Object_NURBS *obj, nbReal* buffer, int dim, int res, bool update);
-    static void 		IsoLines(Object_NURBS *obj, nbReal* buffer); 
-
- //   static	void		TrimSurface(Object_NURBS *obj);
-    static	void		Cyclic(Object_NURBS *obj);
-    static	void		KnotVector(Object_NURBS *obj);
-	 static	void		KnotVector(Object_NURBS *obj, int uv);
-
-    static	void		Duplicate(Object_NURBS *obj1, Object_NURBS *obj2);
-
-  private:
-  /*  // Intersecting 2 NURBS Curves
-    static	void		NURBSCurveIntersect(int NPts1, int Order1, Point3d *CtlPts1, nbReal *H1, nbReal *KV1, int NPts2, int Order2, Point3d *CtlPts2, nbReal *H2, nbReal *KV2, nbReal s, nbReal t, int iteration);
-    // Intersecting a NURBS Curve with a Parametric Line
-    static	void		NURBSCurveIntersect(nbReal j, NURBS_TrimCurve *Curve, nbReal s, nbReal t, int iteration);
-*/
-    static	Point3d		NURBSCurvePt(int Order, int Npts, Point3d *CtlPts, nbReal *KV, nbReal t, bool D);
-
-    static	void		BezierKnot(int npts, int Order, nbReal *KnotVector);
-    static	void		PeriodicKnot(int npts, int Order, nbReal *KnotVector);
-    static	void		OpenKnot(int npts, int Order, nbReal *KnotVector);
-
-	 static	void		NURBSBasis(int Order, nbReal t, int npts, int realPts, nbReal *KnotVector, Point3d *cp, nbReal *BasisValues, bool Type);
-
-//    static	void		NURBSBasis(int Order, nbReal t, int npts, nbReal *KnotVector, Point3d *cp, nbReal *BasisValues, bool Type);
-    static	void		NURBSBasisDer1(int Order, nbReal t, int npts, nbReal *KnotVector, Point3d *cp, nbReal *BasisValues, bool Type);
-   // static	nbReal		fSum(Point3d *cp, nbReal *BasisU, nbReal *BasisV, int Unpts, int Vnpts); 
-	 static nbReal fSum(Point3d *cp, nbReal *BasisU, nbReal *BasisV, int Unpts, int realUnpts, int Vnpts, int realVnpts);
-
-	static void Surface(Object_NURBS *obj, int TessU, int TessV, int dim, nbReal *TssPts, nbReal *Sum, int Index, bool Change, bool Update);
-
-}; //eof class NURBS_Generate
-#endif
+
+//    static void		Surface(Object_NURBS *obj, nbReal* buffer, int dim = 3);
+	static void			Curve(Object_NURBS *obj, nbReal* buffer, nbReal* tiltBufer, nbReal* radiusBuffer, int res, bool update);
+    static void 		IsoLines(Object_NURBS *obj, nbReal* buffer); 
+
+ //   static	void		TrimSurface(Object_NURBS *obj);
+    static	void		Cyclic(Object_NURBS *obj);
+    static	void		KnotVector(Object_NURBS *obj);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list