[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16015] branches/nurbs/blender: Changes I had lying on my harddrive.

Emmanuel Stone emmanuel.stone at gmail.com
Fri Aug 8 06:49:19 CEST 2008


Revision: 16015
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16015
Author:   eman
Date:     2008-08-08 06:49:18 +0200 (Fri, 08 Aug 2008)

Log Message:
-----------
Changes I had lying on my harddrive.
These are clearly unfinished, or I would have committed them, but it seems best to share the changes since other people are now looking at this branch.
This should still compile, but there is silly 'debug code' like turning off incremental calculations.
I suspect the tesselation code might be broken also.

Modified Paths:
--------------
    branches/nurbs/blender/intern/nurbana/extern/nurbana.h
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_Base.h
    branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.h
    branches/nurbs/blender/intern/nurbana/intern/libNurbana.cpp
    branches/nurbs/blender/source/blender/blenkernel/intern/curve.c
    branches/nurbs/blender/source/blender/blenkernel/intern/displist.c
    branches/nurbs/blender/source/blender/blenloader/intern/readfile.c
    branches/nurbs/blender/source/blender/makesdna/DNA_curve_types.h
    branches/nurbs/blender/source/blender/src/buttons_editing.c
    branches/nurbs/blender/source/blender/src/editcurve.c

Modified: branches/nurbs/blender/intern/nurbana/extern/nurbana.h
===================================================================
--- branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-08-07 22:31:35 UTC (rev 16014)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-08-08 04:49:18 UTC (rev 16015)
@@ -106,6 +106,10 @@
 
 extern void NRB_changeCyclic(NurbanaObj_ptr nop,int uv); 
 
+
+
+extern void NRB_SizeChanged(NurbanaObj_ptr nop, int newU, int newV);
+
 extern void NRB_ConvertToPrimitive(NurbanaObj_ptr nop,unsigned char type);
 
 extern void NRB_RecalculateKnots(NurbanaObj_ptr nop,int uv,int type); 

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp	2008-08-07 22:31:35 UTC (rev 16014)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp	2008-08-08 04:49:18 UTC (rev 16015)
@@ -2,747 +2,789 @@
 
 
 void NURBS_Degree::Elevate(Object_NURBS *obj, int Uinc, int Vinc) {
-  int		Npts,Order,Degree,Curve,UV,Inc,ph,mpi,mh,kind,r,a,b,cind,mul,oldr,lbz,rbz,s,save;
-  int		i,j,k,first,last,tr,kj,FnlLU,FnlLV,Length;
+	int		Npts,Order,Degree,Curve,UV,Inc,ph,mpi,mh,kind,r,a,b,cind,mul,oldr,lbz,rbz,s,save;
+	int		i,j,k,first,last,tr,kj,FnlLU,FnlLV,Length;
 
-  float		ua,ub,alf,gam,bet,temp;
-  float		*Uh,*Coef,*Coefb,*FnlKVU,*FnlKVV;
+	float		ua,ub,alf,gam,bet,temp;
+	float		*Uh,*Coef,*Coefb,*FnlKVU,*FnlKVV;
 
-  Point3d	*Nextbpts,*Qw,*Pts,*FnlPts,*bpts,*ebpts;
+	Point3d	*Nextbpts,*Qw,*Pts,*FnlPts,*bpts,*ebpts,*ctlPts,*newCtlPts;
 
-  // Memory Allocation
-  // Resize Surface
-  obj -> SetLength(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc,obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc);
+	int pntsU, pntsV, orderU, orderV, newPntsU, newPntsV;
 
-  UV = (obj -> Order(0) > obj -> Order(1)) ? obj -> Order(0) : obj -> Order(1);
-    bpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate "); //FIXME CHECKME 64???
-    Coefb = (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Elevate ");
-    Nextbpts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
+	ctlPts = obj->CtlPts();
+	pntsU = obj->Length(0);
+	pntsV = obj->Length(1);
+	orderU = obj->Order(0);
+	orderV = obj->Order(1);
 
-  UV = (obj -> Order(0)+Uinc > obj -> Order(1)+Vinc) ? obj -> Order(0)+Uinc : obj -> Order(1)+Vinc;
-    ebpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate ");
-    UV *= (obj -> Order(0) > obj -> Order(1)) ? obj -> Order(0) : obj -> Order(1);
-    Coef = (float*)MEM_callocN(sizeof(float)*(UV),"NURBS_Degree::Elevate ");
+	// Memory Allocation
+	// Resize Surface
+	// obj -> SetLength(obj -> Length(0)+(obj -> Length(0)-(orderU-1))*Uinc,pntsV+(pntsV-(orderV-1))*Vinc);
+	int newCtlPtsSize = (pntsU+(pntsU-(orderU-1))*Uinc)*(pntsV+(pntsV-(orderV-1)));
+//	newCtlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*pntsU+(pntsU-(orderU-1))*Uinc*pntsV+(pntsV-(orderV-1))*Vinc,"NURBS_Degree::Elevate newCtlPts");
 
-  UV = (obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc) > (obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc) ? obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc : obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc;
-    Qw = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
-    Pts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
-  FnlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc),"NURBS_Degree::Elevate ");
-  FnlKVU = (float*)MEM_callocN(sizeof(float)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)),"NURBS_Degree::Elevate ");
-  FnlKVV = (float*)MEM_callocN(sizeof(float)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)),"NURBS_Degree::Elevate ");
-  Uh = (float*)MEM_callocN(sizeof(float)*((obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)) > (obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)) ? obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0) : obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)),"NURBS_Degree::Elevate ");
 
-  for(UV = 0; UV < 2; UV++) {
-    Inc = UV ? Uinc : Vinc;
+	newPntsU = obj -> Length(0)+(obj -> Length(0)-(orderU-1))*Uinc;
+	newPntsV = pntsV+(pntsV-(orderV-1))*Vinc;
+	newCtlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*newPntsU*newPntsV,"NURBS_Degree::Elevate newCtlPts");
 
-    if(Inc) {
-      Npts = obj -> Length(UV);
-      Order = obj -> Order(UV);
-      Degree = Order-1;
-      ph = Degree+Inc;
+	for(i=0;i<pntsU;i++)
+		for(j=0;j<pntsV;j++)
+			newCtlPts[i+(j*pntsV)] = ctlPts[i+(j*pntsV)];
 
-      // Compute Bezier degree elevation coefficients
-      Coef[0] = Coef[(ph+1)*(Degree+1)-1] = 1.0;
-      for(i = 1; i <= ph/2; i++) {
-        temp = 1.0/NurbanaMath::Comb(ph,i);
-        mpi = NurbanaMath::Min(Degree,i);
-        for(j = NurbanaMath::Max(0,i-Inc); j <= mpi; j++)
-          Coef[i*(Degree+1)+j] = temp*NurbanaMath::Comb(Degree,j)*NurbanaMath::Comb(Inc,i-j);
-      } //eof
+	UV = (orderU > orderV) ? orderU : orderV;
+	bpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate bpts"); //FIXME CHECKME 64???
+	Coefb = (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Elevate Coefb");
+	Nextbpts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Nextbpts");
 
-      for(i = (ph/2)+1; i <= ph-1; i++) {
-        mpi = NurbanaMath::Min(Degree,i);
-        for(j = NurbanaMath::Max(0,i-Inc); j <= mpi; j++)
-          Coef[i*(Degree+1)+j] = Coef[(ph-i)*(Degree+1)+(Degree-j)];
-      } //eof
+	UV = (orderU+Uinc > orderV+Vinc) ? orderU+Uinc : orderV+Vinc;
+	ebpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate ebpts");
+	UV *= (orderU > orderV) ? orderU : orderV;
+	Coef = (float*)MEM_callocN(sizeof(float)*(UV),"NURBS_Degree::Elevate Coef");
 
-      // ---------------------------
+	UV = (pntsU+(pntsU-(orderU-1))*Uinc) > (pntsV+(pntsV-(orderV-1))*Vinc) ? pntsU+(pntsU-(orderU-1))*Uinc : pntsV+(pntsV-(orderV-1))*Vinc;
+	Qw = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Qw");
+	Pts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Pts");
 
-      Length = obj -> Length(!UV);
-      if(UV && Uinc) Length+= (obj -> Length(1)-(obj -> Order(1)-1))*Uinc;
-      for(Curve = 0; Curve < Length; Curve++) {
-        Npts = obj -> Length(UV);
-        mh = ph;
-        kind = ph+1;
-        r = -1;
-        a = Degree;
-        b = Order;
-        cind = 1;
-        ua = obj -> KnotVector(UV)[0];
+	int fnlPtsSize = (pntsU+(pntsU-(orderU-1))*Uinc)*(pntsV+(pntsV-(orderV-1))*Vinc);
+	FnlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*fnlPtsSize,"NURBS_Degree::Elevate FnlPts");
+//	FnlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*(pntsU+(pntsU-(orderU-1))*Uinc)*(pntsV+(pntsV-(orderV-1))*Vinc),"NURBS_Degree::Elevate FnlPts");
+	FnlKVU = (float*)MEM_callocN(sizeof(float)*(pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU),"NURBS_Degree::Elevate FnlKVU");
+	FnlKVV = (float*)MEM_callocN(sizeof(float)*(pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV),"NURBS_Degree::Elevate FnlKVV");
+	Uh = (float*)MEM_callocN(sizeof(float)*((pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU) > (pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV) ? pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU : pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV),"NURBS_Degree::Elevate Uh");
 
-        // Copy CtlPts into Pts for degree elevation
-        if(UV) {
-          // V Directional Curves
-          for(i = 0; i < obj -> Length(1); i++) {
-            Pts[i].x = obj -> CtlPts()[i+obj -> Length(1)*Curve].x;
-            Pts[i].y = obj -> CtlPts()[i+obj -> Length(1)*Curve].y;
-            Pts[i].z = obj -> CtlPts()[i+obj -> Length(1)*Curve].z;
-          } //eof
-        } else {
-          // U Directional Curves
-          for(i = 0; i < obj -> Length(0); i++) {
-            Pts[i].x = obj -> CtlPts()[i*obj -> Length(1)+Curve].x;
-            Pts[i].y = obj -> CtlPts()[i*obj -> Length(1)+Curve].y;
-            Pts[i].z = obj -> CtlPts()[i*obj -> Length(1)+Curve].z;
-          } //eof
-        } //fi
+	for(UV = 0; UV < 2; UV++) { // FIXME put in check for curve? eman
+		Inc = UV ? Uinc : Vinc;
 
-        Qw[0].x = Pts[0].x;
-        Qw[0].y = Pts[0].y;
-        Qw[0].z = Pts[0].z;
+		if(Inc) {
+			Npts = obj -> Length(UV);
+			Order = obj -> Order(UV);
+			Degree = Order-1;
+			ph = Degree+Inc;
 
-        for(i = 0; i <= ph; i++)
-          Uh[i] = ua;
+			// Compute Bezier degree elevation coefficients
+			Coef[0] = Coef[(ph+1)*(Degree+1)-1] = 1.0;
+			for(i = 1; i <= ph/2; i++) {
+				temp = 1.0/NurbanaMath::Comb(ph,i);
+				mpi = NurbanaMath::Min(Degree,i);
+				for(j = NurbanaMath::Max(0,i-Inc); j <= mpi; j++)
+					Coef[i*(Degree+1)+j] = temp*NurbanaMath::Comb(Degree,j)*NurbanaMath::Comb(Inc,i-j);
+			} //eof
 
-        // Initialize first Bezier segment
-        for(i = 0; i <= Degree; i++) {
-          bpts[i].x = Pts[i].x;
-          bpts[i].y = Pts[i].y;
-          bpts[i].z = Pts[i].z;
-        } //eof
+			for(i = (ph/2)+1; i <= ph-1; i++) {
+				mpi = NurbanaMath::Min(Degree,i);
+				for(j = NurbanaMath::Max(0,i-Inc); j <= mpi; j++)
+					Coef[i*(Degree+1)+j] = Coef[(ph-i)*(Degree+1)+(Degree-j)];
+			} //eof
 
-        while(b < Npts+Order) {
-          i = b;
+			// ---------------------------
 
-          while(b < Npts+Degree && obj -> KnotVector(UV)[b] == obj -> KnotVector(UV)[b+1])
-            b++;
+			Length = obj -> Length(!UV);
+			if(UV && Uinc) Length+= (pntsV-(orderV-1))*Uinc;
+			for(Curve = 0; Curve < Length; Curve++) {
+				Npts = obj -> Length(UV);
+				mh = ph;
+				kind = ph+1;
+				r = -1;
+				a = Degree;
+				b = Order;
+				cind = 1;
+				ua = obj -> KnotVector(UV)[0];
 
-          mul = b - i + 1;
-          mh += mul + Inc;
-          ub = obj -> KnotVector(UV)[b];
-          oldr = r;
-          r= Degree - mul;
+				// Copy CtlPts into Pts for degree elevation
+				if(UV) {
+					// V Directional Curves
+					for(i = 0; i < pntsV; i++) {
+						Pts[i].x = ctlPts[i+pntsV*Curve].x;
+						Pts[i].y = ctlPts[i+pntsV*Curve].y;
+						Pts[i].z = ctlPts[i+pntsV*Curve].z;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list