Revision: 18051
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18051
Author:   eman
Date:     2008-12-25 03:34:05 +0100 (Thu, 25 Dec 2008)

Log Message:
-----------
* Laurynas moved NURBS primitive creation from Blender into libNurbana.cpp. 
thanks!
 - The G.vd->grid code from the old primitives hasn't been ported
 - I can't find the grid variable being set anywhere in the codebase, is this 
used?
* A few random whitespace changes, dead code removal and typo fixes
* __Experimental__ 3D UI changes for NURBS surfaces in drawobject.c
 - Changes NURBS control cage draw colours
 - Renamed tekenVertsN to draw_nurbscontrolpoints
 - Added new type of control point drawing 
http://img407.imageshack.us/my.php?image=new3ej1.png
 - Changed lines between CPs to be stippled, as I don't think they need the 
same visual prominence as CP
 - Draw lines between first and last Control Points for cyclic surfaces
 - I had some endian issues with cpack(), so I added cpack2. not sure why this 
was needed.
 - Added Occlude Background Geometry option for NURBS surfaces

*

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_Knot.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_Primitives.cpp
    branches/nurbs/blender/intern/nurbana/intern/Object_Primitives.h
    branches/nurbs/blender/intern/nurbana/intern/libNurbana.cpp
    branches/nurbs/blender/source/blender/blenkernel/BKE_utildefines.h
    branches/nurbs/blender/source/blender/blenkernel/intern/curve.c
    branches/nurbs/blender/source/blender/include/BIF_gl.h
    branches/nurbs/blender/source/blender/src/drawobject.c
    branches/nurbs/blender/source/blender/src/editcurve.c
    branches/nurbs/blender/source/blender/src/header_view3d.c

Modified: branches/nurbs/blender/intern/nurbana/extern/nurbana.h
===================================================================
--- branches/nurbs/blender/intern/nurbana/extern/nurbana.h      2008-12-24 
21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h      2008-12-25 
02:34:05 UTC (rev 18051)
@@ -101,7 +101,7 @@
 
 extern NurbanaObj_ptr NRB_addObject(Point3d** CtlPts, short* numCPu, short* 
numCPv, short* orderU, short* orderV, nbReal** knotsU, nbReal** knotsV,  short* 
cyclicU,  short* cyclicV, short* knottypeu, short* knottypev,  short* resolu,  
short* resolv, short* isores, short* isoden, short* isovis) ;
 
-extern NurbanaObj_ptr NRB_CreatePrimitive(unsigned char type);
+extern NurbanaObj_ptr NRB_CreatePrimitive(NurbanaObj_ptr nop, unsigned char 
type);
 extern void NRB_removeObject(NurbanaObj_ptr nop);
 
 extern void NRB_changeCyclic(NurbanaObj_ptr nop,int uv);

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp     
2008-12-24 21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp     
2008-12-25 02:34:05 UTC (rev 18051)
@@ -17,15 +17,13 @@
                Surface(obj,resU, resV , dim, buffer, NULL, NULL, obj -> Sum(), 
0, 0, 1);
 }
 
-void   NURBS_Generate::IsoLines(Object_NURBS *obj, nbReal* buffer) {
+void NURBS_Generate::IsoLines(Object_NURBS *obj, nbReal* buffer) {
        int Change;
        Change= obj->Change(1);
 
        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, 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 *tiltBuffer, nbReal *radiusBuffer, nbReal *Sum, 
int Index, bool Change, bool Update) {

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp 2008-12-24 
21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp 2008-12-25 
02:34:05 UTC (rev 18051)
@@ -767,7 +767,7 @@
                Insert(obj, KV, 1, 1);
                Refine(obj, U, V - 1);
        } //fi
-} //eof NURBS_Knot::Insert()
+} //eof NURBS_Knot::Refine()
 
 
 float _Dist4d(Point3d P1, Point3d P2) {

Modified: branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp        
2008-12-24 21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp        
2008-12-25 02:34:05 UTC (rev 18051)
@@ -104,15 +104,17 @@
 void Object_Base::reallocCtlPts(int U, int V, int shiftU, int shiftV) {
     Point3d *_tmp = (Point3d*) MEM_callocN(sizeof(Point3d)*U*V,"_CtlPts 
realloc");
 
-    if (*_LengthUV[0] != U) {
-        Point3d *newRow = _tmp + shiftV * *_LengthUV[0] + shiftU, *oldRow = 
*_CtlPts;
-        int oldVLen = *_LengthUV[1], oldULen = *_LengthUV[0];
-        for (int i = 0; i < oldVLen; i++, newRow += U, oldRow += oldULen)
-            memcpy(newRow, oldRow, oldULen * sizeof(**_CtlPts));
-       } else { 
-               int len = *_LengthUV[0]* *_LengthUV[1];
-        memcpy(_tmp + shiftV * *_LengthUV[0], *_CtlPts, len * 
sizeof(**_CtlPts));
-       }
-    MEM_freeN(*_CtlPts);
+    if (*_CtlPts) {
+               if (*_LengthUV[0] != U) {
+                       Point3d *newRow = _tmp + shiftV * *_LengthUV[0] + 
shiftU, *oldRow = *_CtlPts;
+                       int oldVLen = *_LengthUV[1], oldULen = *_LengthUV[0];
+                       for (int i = 0; i < oldVLen; i++, newRow += U, oldRow 
+= oldULen)
+                               memcpy(newRow, oldRow, oldULen * 
sizeof(**_CtlPts));
+               } else { 
+                       int len = *_LengthUV[0]* *_LengthUV[1];
+                       memcpy(_tmp + shiftV * *_LengthUV[0], *_CtlPts, len * 
sizeof(**_CtlPts));
+               }
+        MEM_freeN(*_CtlPts);
+    }
     *_CtlPts = _tmp;
 }

Modified: branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp       
2008-12-24 21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp       
2008-12-25 02:34:05 UTC (rev 18051)
@@ -16,16 +16,22 @@
        _FlagUV[0] = flagU;
        _FlagUV[1] = flagV;
        
-       //_CtlPtsOld = (Point3d*)CtlPtsOld;
-       _CtlPtsOld = (Point3d*)MEM_mallocN((*numCPu)*(*numCPv)*sizeof(Point3d), 
"_CtlPtsOld");
+       _IsoVis = isovis;
+       _SumIPC[0] = NULL;
+       _SumIPC[1] = NULL;
 
-
-
+       _KnotVectorU = knotsU;
+       _KnotVectorV = knotsV;
+       
+       _CtlPtsOld = NULL;
+       _OldBuffer = NULL;
+       _Sum = NULL;
+       
+       if (*_LengthUV[0] + *_LengthUV[1]) {
+               SetCacheBuffer();
+               ResetIsoLines();
+       }
        // Allocate tessU*pntsU*tessV*pntsV control points ala Blender
-       int numTessPts = *_TessUV[0] * *_TessUV[1] * *_LengthUV[0] * 
*_LengthUV[1];
-       _Sum = (nbReal*)MEM_mallocN(sizeof(nbReal)*4*numTessPts, "_Sum");
-
-       _OldBuffer = 
(nbReal*)MEM_callocN(sizeof(nbReal)*4*(numTessPts),"_OldBuffer(Cached tess 
points)");// ( OBJECT_MAX_DENSITY*OBJECT_MAX_DENSITY, "_OldBuffer"); //FIXME 
eman
        // FIXME for curves.
 
        //len= nu->resolu*nu->resolv;
@@ -36,14 +42,6 @@
 
        //dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
        //dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
-
-       _IsoVis = isovis;
-       _SumIPC[0] = NULL;
-       _SumIPC[1] = NULL;
-       ResetIsoLines();
-
-       _KnotVectorU = knotsU;
-       _KnotVectorV = knotsV;
        
        /* // Trim Curves, Let first Curve ID be 1
                _TCID= 1;
@@ -383,23 +381,28 @@
        nbReal *_tmpKnotVectorU,*_tmpKnotVectorV;
        Point3d *tmpCP;
 
-       if (*_KnotVectorU && newLenU != oldLenU) {
+       if (newLenU != oldLenU) {
                _tmpKnotVectorU = 
(nbReal*)MEM_callocN(sizeof(nbReal)*(newLenU), "_KnotVectorU realloc");
-               if (copy)
-                   memcpy(_tmpKnotVectorU,  *_KnotVectorU, oldLenU * 
sizeof(**_KnotVectorU));
-               MEM_freeN(*_KnotVectorU);
+               if (*_KnotVectorU) {
+                       if (copy)
+                           memcpy(_tmpKnotVectorU,  *_KnotVectorU, oldLenU * 
sizeof(**_KnotVectorU));
+                   MEM_freeN(*_KnotVectorU);
+               }
                *_KnotVectorU = _tmpKnotVectorU;
        }
 
-       if(*_KnotVectorV && newLenV != oldLenV) {
+       if(newLenV != oldLenV) {
                _tmpKnotVectorV = 
(nbReal*)MEM_callocN(sizeof(nbReal)*(newLenV),"_KnotVectorV realloc");
-               if (copy)
-                   memcpy(_tmpKnotVectorV, *_KnotVectorV, oldLenV * 
sizeof(**_KnotVectorV));
-               MEM_freeN(*_KnotVectorV);
+               if (*_KnotVectorV) {
+                       if (copy)
+                       memcpy(_tmpKnotVectorV, *_KnotVectorV, oldLenV * 
sizeof(**_KnotVectorV));
+                   MEM_freeN(*_KnotVectorV);
+               }
                *_KnotVectorV = _tmpKnotVectorV;
        }       
 }
 
+
 void Object_NURBS::SetLengthRef(int U, int V, int shiftU, int shiftV, bool 
copyKnots) {
     reallocKnots(U, V, copyKnots);
 //     if(_CtlPtsOld)

Modified: branches/nurbs/blender/intern/nurbana/intern/Object_Primitives.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/Object_Primitives.cpp  
2008-12-24 21:53:15 UTC (rev 18050)
+++ branches/nurbs/blender/intern/nurbana/intern/Object_Primitives.cpp  
2008-12-25 02:34:05 UTC (rev 18051)
@@ -1,631 +1,279 @@
 #include "Object_Primitives.h"
 
-void Object_Primitives::Curve(Object_NURBS *ptr) {
-  ptr -> SetLength(4, 1);
-  ptr -> Length(0, 4);
-  ptr -> Length(1,1);
 
-  Point3d* ctlpts = ptr -> CtlPts();
-  
-  ctlpts[0].x = -2;
-  ctlpts[0].y = 0;
-  ctlpts[0].z = 0;
-  
-  ctlpts[1].x = -1;
-  ctlpts[1].y = 1;
-  ctlpts[1].z = 0;
+int Object_Primitives::unitCircle[][2] = {
+               {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, 
{-1, 1} 
+};
 
-  ctlpts[2].x = 1;
-  ctlpts[2].y = -1;
-  ctlpts[2].z = 0;
+nbReal  Object_Primitives::circleWeights[] = {1, 0.354, 1, 0.354, 1, 0.354, 1, 
0.354};
+nbReal  Object_Primitives::sphereVKnots[] = {0, 0, 0, 1, 1, 2, 2, 2};
 
-  ctlpts[3].x = 2;
-  ctlpts[3].y = 0;
-  ctlpts[3].z = 0;
 
-  ptr -> Order(0, 4);
-  ptr -> Order(1, 2);
+void Object_Primitives::Curve(Object_NURBS *ptr) {
+       const int lengthU = 4;
+       const int lengthV = 1;
+       Object_NURBS &no = *ptr;
+       no.Order(0, 4);
+       no.Order(1, 4);
+       no.KnotType(0, NURBS_KV_Open);
+       
+       no.SetLengthRef(lengthU, lengthV);
+       no.Length(0, lengthU);
+       no.Length(1, lengthV);
+       
+       Point3d* ctlPts = no.CtlPts();
+  
+    ctlPts -> x = -1.5;
+    ctlPts -> y = 0;
+    ctlPts ++;
+    
+    ctlPts -> x = -1;
+    ctlPts -> y = 1;
+    ctlPts ++;
+    
+    ctlPts -> x = 1;
+    ctlPts -> y = 1;
+    ctlPts++;
 
-  ptr->KnotType(0,NURBS_KV_Open);
-  NURBS_Generate::KnotVector(ptr);
-  ptr -> RecalculateKnotVector(1);
+    ctlPts -> x = 1.5;
+    ctlPts -> y = 0;
+    ctlPts++;
+    
+    ctlPts = no.CtlPts();
+    for (int i = 0; i < lengthU; i++) {
+        ctlPts -> z = 0;
+        ctlPts -> H = 1;
+       ctlPts++;
+    }
+    
+    NURBS_Generate::KnotVector(ptr);
+    no.RecalculateKnotVector(1);
 }
 
 
 void Object_Primitives::Surface(Object_NURBS *ptr) {
-  int  i;
-       Point3d* ctlpts = ptr -> CtlPts();
+       const int lengthU = 4;
+       const int lengthV = 4;
+    Object_NURBS &no = *ptr;
+       no.Order(0, 4);
+       no.Order(1, 4);
+       no.KnotType(0, NURBS_KV_Open);
+       no.KnotType(1, NURBS_KV_Open);
+       
+       no.SetLengthRef(lengthU, lengthV);
+       no.Length(0, lengthU);
+       no.Length(1, lengthV);
+       Point3d* ctlPts = no.CtlPts();
 
-  ptr -> SetLength(4,4);
-  ptr -> Length(0, 4);
-  ptr -> Length(1, 4);
-  
-/*
-  // X
-  for (i= 0; i < 4; i++)
-    ctlpts[i].x= -1.5;
-  for (i= 4; i < 8; i++)
-    ctlpts[i].x= -0.5;
-  for (i= 8; i < 12; i++)
-    ctlpts[i].x= 0.5;
-  for (i= 12; i < 16; i++)
-    ctlpts[i].x= 1.5;
+    const double start = -1.5;
+       double valueU = start, valueV = start;
+       double stepSize = 1;
+    
+       for (int u = 0; u < lengthU; u++, valueU += stepSize) {
+               for (int v = 0; v < lengthV; v++, valueV += stepSize) {
+                       ctlPts -> x = valueU;
+                       ctlPts -> y = valueV;
+                       ctlPts -> z = 0;
+                       ctlPts -> H = 1;
+                       ctlPts++;
+               }
+               valueV = start;
+       }
+       
+       ctlPts = no.CtlPts();
+       ctlPts += (lengthU / 4) * lengthU + lengthV / 4;
+       for (int u = 0; u < lengthU / 2; u++, ctlPts += lengthU / 2)
+               for (int v = 0; v <lengthV / 2; v++) {
+                       ctlPts -> z = 1;
+                       ctlPts ++;
+               }
 
-  // Y
-  for (i= 0; i < 16; i+= 4)
-    ctlpts[i].y= 1.5;
-  for (i= 1; i < 16; i+= 4)
-    ctlpts[i].y= 0.5;
-  for (i= 2; i < 16; i+= 4)
-    ctlpts[i].y= -0.5;
-  for (i= 3; i < 16; i+= 4)
-    ctlpts[i].y= -1.5;
+    NURBS_Generate::KnotVector(ptr);
 
-  // Z
-  for (i= 0; i < 16; i++)

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to