[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16893] branches/nurbs/blender: - Added UpdateSize function for reallocating nurbana buffers based on current size .
Emmanuel Stone
emmanuel.stone at gmail.com
Fri Oct 3 08:10:57 CEST 2008
Revision: 16893
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16893
Author: eman
Date: 2008-10-03 08:10:57 +0200 (Fri, 03 Oct 2008)
Log Message:
-----------
- Added UpdateSize function for reallocating nurbana buffers based on current size.
- Used in 'old' Subdivide call.
- NURBS_Degree
- Converted floats to nbReals
- Degree Elevate is working
- Only works on Endtied curves and surfaces (Algorithm limitation)
- Changes Degree/Order without changing the shape of the Surface
- Blender seems to cap Order at 6 (which is pretty high anyway)
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/libNurbana.cpp
branches/nurbs/blender/source/blender/include/butspace.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-10-03 04:41:02 UTC (rev 16892)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h 2008-10-03 06:10:57 UTC (rev 16893)
@@ -110,6 +110,7 @@
extern void NRB_ResChanged(NurbanaObj_ptr nop );
extern void NRB_SizeChanged(NurbanaObj_ptr nop, int newU, int newV);
+extern void NRB_UpdateSize(NurbanaObj_ptr nop);
extern void NRB_ConvertToPrimitive(NurbanaObj_ptr nop,unsigned char type);
Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp 2008-10-03 04:41:02 UTC (rev 16892)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp 2008-10-03 06:10:57 UTC (rev 16893)
@@ -5,8 +5,8 @@
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;
+ nbReal ua,ub,alf,gam,bet,temp;
+ nbReal *Uh,*Coef,*Coefb,*FnlKVU,*FnlKVV;
Point3d *Nextbpts,*Qw,*Pts,*FnlPts,*bpts,*ebpts,*ctlPts,*newCtlPts;
@@ -29,20 +29,22 @@
newPntsV = pntsV+(pntsV-(orderV-1))*Vinc;
newCtlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*newPntsU*newPntsV,"NURBS_Degree::Elevate newCtlPts");
+ // memcpy FIXME eman
for(i=0;i<pntsU;i++)
for(j=0;j<pntsV;j++)
- newCtlPts[i+(j*pntsV)] = ctlPts[i+(j*pntsV)];
+ newCtlPts[i+(j*pntsU)] = ctlPts[i+(j*pntsU)];
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");
+ Coefb = (nbReal*)MEM_callocN(sizeof(nbReal)*UV,"NURBS_Degree::Elevate Coefb");
Nextbpts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Nextbpts");
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");
+ Coef = (nbReal*)MEM_callocN(sizeof(nbReal)*(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;
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");
@@ -50,12 +52,12 @@
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");
+ FnlKVU = (nbReal*)MEM_callocN(sizeof(nbReal)*(pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU),"NURBS_Degree::Elevate FnlKVU");
+ FnlKVV = (nbReal*)MEM_callocN(sizeof(nbReal)*(pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV),"NURBS_Degree::Elevate FnlKVV");
+ Uh = (nbReal*)MEM_callocN(sizeof(nbReal)*((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");
- for(UV = 0; UV < 2; UV++) { // FIXME put in check for curve? eman
- Inc = UV ? Uinc : Vinc;
+ for(UV = 1; UV >= 0; UV--) { // FIXME put in check for curve? eman
+ Inc = UV ? Vinc : Uinc;
if(Inc) {
Npts = obj -> Length(UV);
@@ -96,18 +98,18 @@
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;
- // Pts[i].H = ctlPts[i+pntsV*Curve].H;
+ Pts[i].x = ctlPts[i*pntsU+Curve].x;
+ Pts[i].y = ctlPts[i*pntsU+Curve].y;
+ Pts[i].z = ctlPts[i*pntsU+Curve].z;
+ Pts[i].H = ctlPts[i*pntsU+Curve].H;
} //eof
} else {
// U Directional Curves
for(i = 0; i < pntsU; 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;
- // Pts[i].H = ctlPts[i*pntsV+Curve].H;
+ Pts[i].x = ctlPts[i+pntsU*Curve].x;
+ Pts[i].y = ctlPts[i+pntsU*Curve].y;
+ Pts[i].z = ctlPts[i+pntsU*Curve].z;
+ Pts[i].H = ctlPts[i+pntsU*Curve].H;
} //eof
} //fi
@@ -124,7 +126,7 @@
bpts[i].x = Pts[i].x;
bpts[i].y = Pts[i].y;
bpts[i].z = Pts[i].z;
- // bpts[i].H = Pts[i].H;
+ bpts[i].H = Pts[i].H;
} //eof
@@ -167,11 +169,13 @@
bpts[k].x = Coefb[k - s] * bpts[k].x + (1.0 - Coefb[k - s]) * bpts[k - 1].x;
bpts[k].y = Coefb[k - s] * bpts[k].y + (1.0 - Coefb[k - s]) * bpts[k - 1].y;
bpts[k].z = Coefb[k - s] * bpts[k].z + (1.0 - Coefb[k - s]) * bpts[k - 1].z;
+ bpts[k].H = Coefb[k - s] * bpts[k].H + (1.0 - Coefb[k - s]) * bpts[k - 1].H;
} //eof
Nextbpts[save].x = bpts[Degree].x;
Nextbpts[save].y = bpts[Degree].y;
Nextbpts[save].z = bpts[Degree].z;
+ Nextbpts[save].H = bpts[Degree].H;
} //eof
} //fi
@@ -180,12 +184,14 @@
ebpts[i].x = 0;
ebpts[i].y = 0;
ebpts[i].z = 0;
+ ebpts[i].H = 0;
mpi = NurbanaMath::Min(Degree,i);
for(j = NurbanaMath::Max(0,i-Inc); j <= mpi; j++) {
ebpts[i].x += Coef[i*(Degree+1)+j] * bpts[j].x;
ebpts[i].y += Coef[i*(Degree+1)+j] * bpts[j].y;
ebpts[i].z += Coef[i*(Degree+1)+j] * bpts[j].z;
+ ebpts[i].H += Coef[i*(Degree+1)+j] * bpts[j].H;
} //eof
} //eof
@@ -209,6 +215,7 @@
Qw[i].x = alf * Qw[i].x + (1.0 - alf) * Qw[i - 1].x;
Qw[i].y = alf * Qw[i].y + (1.0 - alf) * Qw[i - 1].y;
Qw[i].z = alf * Qw[i].z + (1.0 - alf) * Qw[i - 1].z;
+ Qw[i].H = alf * Qw[i].H + (1.0 - alf) * Qw[i - 1].H;
} //fi
if(j >= lbz) {
@@ -217,10 +224,12 @@
ebpts[kj].x = gam * ebpts[kj].x + (1.0 - gam) * ebpts[kj + 1].x;
ebpts[kj].y = gam * ebpts[kj].y + (1.0 - gam) * ebpts[kj + 1].y;
ebpts[kj].z = gam * ebpts[kj].z + (1.0 - gam) * ebpts[kj + 1].z;
+ ebpts[kj].H = gam * ebpts[kj].H + (1.0 - gam) * ebpts[kj + 1].H;
} else {
ebpts[kj].x = bet * ebpts[kj].x + (1.0 - bet) * ebpts[kj + 1].x;
ebpts[kj].y = bet * ebpts[kj].y + (1.0 - bet) * ebpts[kj + 1].y;
ebpts[kj].z = bet * ebpts[kj].z + (1.0 - bet) * ebpts[kj + 1].z;
+ ebpts[kj].H = bet * ebpts[kj].H + (1.0 - bet) * ebpts[kj + 1].H;
} //fi
} //fi
@@ -247,6 +256,7 @@
Qw[cind].x = ebpts[j].x;
Qw[cind].y = ebpts[j].y;
Qw[cind].z = ebpts[j].z;
+ Qw[cind].H = ebpts[j].H;
cind++;
} //eof
@@ -255,6 +265,7 @@
bpts[j].x = Nextbpts[j].x;
bpts[j].y = Nextbpts[j].y;
bpts[j].z = Nextbpts[j].z;
+ bpts[j].H = Nextbpts[j].H;
} //eof
for(j = r; j <= Degree; j++) {
@@ -262,6 +273,7 @@
bpts[j].x = Pts[b-Degree+j].x;
bpts[j].y = Pts[b-Degree+j].y;
bpts[j].z = Pts[b-Degree+j].z;
+ bpts[j].H = Pts[b-Degree+j].H;
} //fi
} //eof
@@ -280,32 +292,44 @@
Pts[i].x = Qw[i].x;
Pts[i].y = Qw[i].y;
Pts[i].z = Qw[i].z;
+ Pts[i].H = Qw[i].H;
} //eof
// Save Curve Permanently
if(UV) {
// V Directional Curves
for(i = 0; i < Npts; i++) {
- if((i+Npts*Curve) >= fnlPtsSize)
- printf("o noes\n");
- FnlPts[i+Npts*Curve].x = Pts[i].x;
- FnlPts[i+Npts*Curve].y = Pts[i].y;
- FnlPts[i+Npts*Curve].z = Pts[i].z;
+ //if((i+Npts*Curve) >= fnlPtsSize)
+ // printf("o noes\n");
+ //int indx = i+Npts*Curve;
+ int indx = i*(pntsU+(pntsU-(orderU-1))*Uinc)+Curve;
+ FnlPts[indx].x = Pts[i].x;
+ FnlPts[indx].y = Pts[i].y;
+ FnlPts[indx].z = Pts[i].z;
+ FnlPts[indx].H = Pts[i].H;
+
+ ctlPts = newCtlPts; //HMMM FIXME CHECKME eman - moot for now since only allowing increase in one dir per call
+ // Update Original because we know V is just tacked onto the end of the array and
+ //// may be needed for U directional elevation if this is a U and V elevation
+ //newCtlPts[i*pntsU+Curve].x = Pts[i].x;
+ //newCtlPts[i*pntsU+Curve].y = Pts[i].y;
+ //newCtlPts[i*pntsU+Curve].z = Pts[i].z;
+ //newCtlPts[i*pntsU+Curve].H = Pts[i].H;
+ printf("V FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
} //eof
} else {
// U Directional Curves
for(i= 0; i < Npts; i++) {
- if((i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve) >= fnlPtsSize)
- printf("o noes\n");
- FnlPts[i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve].x = Pts[i].x;
- FnlPts[i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve].y = Pts[i].y;
- FnlPts[i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve].z = Pts[i].z;
-
- // Update Original because we know U is just tacked onto the end of the array and
- // may be needed for V directional elevation if this is a U and V elevation
- newCtlPts[i*pntsV+Curve].x = Pts[i].x;
- newCtlPts[i*obj -> Length(1)+Curve].y = Pts[i].y;
- newCtlPts[i*obj -> Length(1)+Curve].z = Pts[i].z;
+ //if((i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve) >= fnlPtsSize)
+ // printf("o noes\n");
+ int indx = i+Npts*Curve;
+ //int indx = i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list