Curve cleanup
authorCampbell Barton <ideasman42@gmail.com>
Thu, 10 Sep 2009 02:57:25 +0000 (02:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 10 Sep 2009 02:57:25 +0000 (02:57 +0000)
Renamed BevPoint's members
* x,y,z -> vec[3]; compatible with other functions.
* f1 -> split_tag; used by displist to set the splitting flag.
* f2 -> dupe_tag; used in curve.c to remove duplicates.

BevList
* flag -> dupe_nr; was being used as a counter for duplicate points.

* use arithb.c functions where possible.

* arrays for coords, tilt and radius were being allocated, then copied into the BevPoint's, now write directly into the values without allocing/freeing arrays.

source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/makesdna/DNA_curve_types.h
source/blender/python/api2_2x/Geometry.c
source/blender/src/drawipo.c
source/blender/src/drawobject.c

index 79f4708fd41875d07be641b37a1a4b015d50f34d..2aa8e35391f021558996d2dfc5f5f30cda4fffdc 100644 (file)
@@ -70,7 +70,7 @@ void minmaxNurb( struct Nurb *nu, float *min, float *max);
 void makeknots( struct Nurb *nu, short uv);
 
 void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride);
-void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu);
+void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride);
 void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
 float *make_orco_curve( struct Object *ob);
 float *make_orco_surf( struct Object *ob);
index e75b31dd8928fb7a24fe2661a7ca70b08eb1c4cf..2e08763821f83c9d443caae3c25b9f591aed6916 100644 (file)
@@ -86,11 +86,11 @@ void free_path(Path *path)
 void calc_curvepath(Object *ob)
 {
        BevList *bl;
-       BevPoint *bevp, *bevpn, *bevpfirst, *bevplast, *tempbevp;
+       BevPoint *bevp, *bevpn, *bevpfirst, *bevplast;
        Curve *cu;
        Nurb *nu;
        Path *path;
-       float *fp, *dist, *maxdist, x, y, z;
+       float *fp, *dist, *maxdist, xyz[3];
        float fac, d=0, fac1, fac2;
        int a, tot, cycl=0;
        float *ft;
@@ -129,19 +129,12 @@ void calc_curvepath(Object *ob)
        *fp= 0;
        for(a=0; a<tot; a++) {
                fp++;
-               if(cycl && a==tot-1) {
-                       x= bevpfirst->x - bevp->x;
-                       y= bevpfirst->y - bevp->y;
-                       z= bevpfirst->z - bevp->z;
-               }
-               else {
-                        tempbevp = bevp+1;
-                       x= (tempbevp)->x - bevp->x;
-                       y= (tempbevp)->y - bevp->y;
-                       z= (tempbevp)->z - bevp->z;
-               }
-               *fp= *(fp-1)+ (float)sqrt(x*x+y*y+z*z);
+               if(cycl && a==tot-1)
+                       VecSubf(xyz, bevpfirst->vec, bevp->vec);
+               else
+                       VecSubf(xyz, (bevp+1)->vec, bevp->vec);
                
+               *fp= *(fp-1)+VecLength(xyz);
                bevp++;
        }
        
@@ -178,14 +171,11 @@ void calc_curvepath(Object *ob)
                fac2= *(fp)-d;
                fac1= fac2/fac1;
                fac2= 1.0f-fac1;
-
-               ft[0]= fac1*bevp->x+ fac2*(bevpn)->x;
-               ft[1]= fac1*bevp->y+ fac2*(bevpn)->y;
-               ft[2]= fac1*bevp->z+ fac2*(bevpn)->z;
+               
+               VecLerpf(ft, bevp->vec, bevpn->vec, fac2);
                ft[3]= fac1*bevp->alfa+ fac2*(bevpn)->alfa;
                
                ft+= 4;
-
        }
        
        MEM_freeN(dist);
index 1577eb4f850740830ae9caf30516bb351888f37b..9a73b3355ce16b29b3b5aaaca71820ea7cc87206 100644 (file)
@@ -654,10 +654,10 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
        if(bone->segments > MAX_BBONE_SUBDIV)
                bone->segments= MAX_BBONE_SUBDIV;
        
-       forward_diff_bezier(0.0, h1[0],         h2[0],                  0.0,            data[0],        MAX_BBONE_SUBDIV, 4);
-       forward_diff_bezier(0.0, h1[1],         length + h2[1], length,         data[0]+1,      MAX_BBONE_SUBDIV, 4);
-       forward_diff_bezier(0.0, h1[2],         h2[2],                  0.0,            data[0]+2,      MAX_BBONE_SUBDIV, 4);
-       forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1),    roll2,  data[0]+3,      MAX_BBONE_SUBDIV, 4);
+       forward_diff_bezier(0.0, h1[0],         h2[0],                  0.0,            data[0],        MAX_BBONE_SUBDIV, 4*sizeof(float));
+       forward_diff_bezier(0.0, h1[1],         length + h2[1], length,         data[0]+1,      MAX_BBONE_SUBDIV, 4*sizeof(float));
+       forward_diff_bezier(0.0, h1[2],         h2[2],                  0.0,            data[0]+2,      MAX_BBONE_SUBDIV, 4*sizeof(float));
+       forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1),    roll2,  data[0]+3,      MAX_BBONE_SUBDIV, 4*sizeof(float));
        
        equalize_bezier(data[0], bone->segments);       // note: does stride 4!
        
index 1bc34aea9a135896dab31ad276db682ba8a10372..96ff3264822c74ba6fe45f4873903b5c270f7cc9 100644 (file)
@@ -413,8 +413,8 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
        
        for(a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
                correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
-               forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2); 
-               forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2);
+               forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));   
+               forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
        }
        
        /* store first and last handle for extrapolation, unit length */
index 86cfe9d4c6fad252d0d703d258e856ad94150025..4d10308be201df1acfd7b870e64e752f63480443 100644 (file)
@@ -64,7 +64,6 @@
 #include "BKE_library.h"  
 #include "BKE_key.h"  
 
-
 /* globals */
 
 extern ListBase editNurb;  /* editcurve.c */
@@ -813,7 +812,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride)
        MEM_freeN(jend);
 }
 
-void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu)
+void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride)
 /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed
  * tilt_array and radius_array will be written to if valid */
 {
@@ -897,10 +896,10 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
                        }
                }
 
-               coord_fp+= 3;
+               coord_fp = (float *)(((char *)coord_fp) + stride);
                
-               if (tilt_fp) tilt_fp++;
-               if (radius_fp) radius_fp++;
+               if (tilt_fp)    tilt_fp = (float *)(((char *)tilt_fp) + stride);
+               if (radius_fp)  radius_fp = (float *)(((char *)radius_fp) + stride);
                
                u+= ustep;
        }
@@ -931,7 +930,7 @@ void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int i
   
        for(a=0; a<=it; a++) {
                *p= q0;
-               p+= stride;
+               p = (float *)(((char *)p)+stride);
                q0+= q1;
                q1+= q2;
                q2+= q3;
@@ -1350,8 +1349,8 @@ static short bevelinside(BevList *bl1,BevList *bl2)
        /* take first vertex of possible hole */
 
        bevp= (BevPoint *)(bl2+1);
-       hvec1[0]= bevp->x
-       hvec1[1]= bevp->y
+       hvec1[0]= bevp->vec[0]
+       hvec1[1]= bevp->vec[1]
        hvec1[2]= 0.0;
        VECCOPY(hvec2,hvec1);
        hvec2[0]+=1000;
@@ -1364,16 +1363,16 @@ static short bevelinside(BevList *bl1,BevList *bl2)
        prevbevp= bevp+(nr-1);
 
        while(nr--) {
-               min= prevbevp->y;
-               max= bevp->y;
+               min= prevbevp->vec[0];
+               max= bevp->vec[1];
                if(max<min) {
                        min= max;
-                       max= prevbevp->y;
+                       max= prevbevp->vec[1];
                }
                if(min!=max) {
                        if(min<=hvec1[1] && max>=hvec1[1]) {
                                /* there's a transition, calc intersection point */
-                               mode= cu_isectLL(&(prevbevp->x),&(bevp->x),hvec1,hvec2,0,1,&lab,&mu,vec);
+                               mode= cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec);
                                /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition
                                   only allow for one situation: we choose lab= 1.0
                                 */
@@ -1446,12 +1445,15 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si
 
 }
 
-static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, int resolu)
+static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, int resolu, int stride)
 {
        BezTriple *pprev, *next, *last;
        float fac, dfac, t[4];
        int a;
        
+       if(tilt_array==NULL && radius_array==NULL)
+               return;
+       
        last= nu->bezt+(nu->pntsu-1);
        
        /* returns a point */
@@ -1474,11 +1476,13 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
        for(a=0; a<resolu; a++, fac+= dfac) {
                if (tilt_array) {
                        if (nu->tilt_interp==3) { /* May as well support for tilt also 2.47 ease interp */
-                               tilt_array[a] = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
+                               *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
                        } else {
                                key_curve_position_weights(fac, t, nu->tilt_interp);
-                               tilt_array[a]= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa;
+                               *tilt_array= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa;
                        }
+                       
+                       tilt_array = (float *)(((char *)tilt_array) + stride); 
                }
                
                if (radius_array) {
@@ -1486,15 +1490,17 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
                                /* Support 2.47 ease interp
                                 * Note! - this only takes the 2 points into account,
                                 * giving much more localized results to changes in radius, sometimes you want that */
-                               radius_array[a] = prevbezt->radius + (bezt->radius - prevbezt->radius)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
+                               *radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
                        } else {
                                
                                /* reuse interpolation from tilt if we can */
                                if (tilt_array==NULL || nu->tilt_interp != nu->radius_interp) {
                                        key_curve_position_weights(fac, t, nu->radius_interp);
                                }
-                               radius_array[a]= t[0]*pprev->radius + t[1]*prevbezt->radius + t[2]*bezt->radius + t[3]*next->radius;
+                               *radius_array= t[0]*pprev->radius + t[1]*prevbezt->radius + t[2]*bezt->radius + t[3]*next->radius;
                        }
+                       
+                       radius_array = (float *)(((char *)radius_array) + stride); 
                }
        }
 }
@@ -1514,8 +1520,6 @@ void makeBevelList(Object *ob)
        BevList *bl, *blnew, *blnext;
        BevPoint *bevp, *bevp2, *bevp1 = NULL, *bevp0;
        float min, inp, x1, x2, y1, y2, vec[3], vec_prev[3], q[4], quat[4], quat_prev[4], cross[3];
-       float *coord_array, *tilt_array=NULL, *radius_array=NULL, *coord_fp, *tilt_fp=NULL, *radius_fp=NULL;
-       float *v1, *v2;
        struct bevelsort *sortdata, *sd, *sd1;
        int a, b, nr, poly, resolu, len=0;
        int do_tilt, do_radius;
@@ -1558,17 +1562,15 @@ void makeBevelList(Object *ob)
                                if(nu->flagu & CU_CYCLIC) bl->poly= 0;
                                else bl->poly= -1;
                                bl->nr= len;
-                               bl->flag= 0;
+                               bl->dupe_nr= 0;
                                bevp= (BevPoint *)(bl+1);
                                bp= nu->bp;
        
                                while(len--) {
-                                       bevp->x= bp->vec[0];
-                                       bevp->y= bp->vec[1];
-                                       bevp->z= bp->vec[2];
+                                       VECCOPY(bevp->vec, bp->vec);
                                        bevp->alfa= bp->alfa;
                                        bevp->radius= bp->radius;
-                                       bevp->f1= SELECT;
+                                       bevp->split_tag= TRUE;
                                        bevp++;
                                        bp++;
                                }
@@ -1594,88 +1596,52 @@ void makeBevelList(Object *ob)
                                        bezt++;
                                }
                                
-                               coord_array= coord_fp= MEM_mallocN(3*sizeof(float)*(resolu+1), "makeBevelCoords");
-                               
-                               if(do_tilt)
-                                       tilt_array= tilt_fp= MEM_callocN(sizeof(float)*(resolu+1), "makeBevelTilt");
-                               
-                               if (do_radius)
-                                       radius_array= radius_fp= MEM_callocN(sizeof(float)*(resolu+1), "nakeBevelRadius");
-                               
                                while(a--) {
                                        if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
-       
-                                               bevp->x= prevbezt->vec[1][0];
-                                               bevp->y= prevbezt->vec[1][1];
-                                               bevp->z= prevbezt->vec[1][2];
+
+                                               VECCOPY(bevp->vec, prevbezt->vec[1]);
                                                bevp->alfa= prevbezt->alfa;
                                                bevp->radius= prevbezt->radius;
-                                               bevp->f1= SELECT;
-                                               bevp->f2= 0;
+                                               bevp->split_tag= TRUE;
+                                               bevp->dupe_tag= FALSE;
                                                bevp++;
                                                bl->nr++;
-                                               bl->flag= 1;
+                                               bl->dupe_nr= 1;
                                        }
                                        else {
-                                               v1= prevbezt->vec[1];
-                                               v2= bezt->vec[0];
-                                               
                                                /* always do all three, to prevent data hanging around */
-                                               forward_diff_bezier(v1[0], v1[3], v2[0], v2[3], coord_array, resolu, 3);
-                                               forward_diff_bezier(v1[1], v1[4], v2[1], v2[4], coord_array+1, resolu, 3);
-                                               forward_diff_bezier(v1[2], v1[5], v2[2], v2[5], coord_array+2, resolu, 3);
+                                               int j;
+                                               
+                                               /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
+                                               for(j=0; j<3; j++) {
+                                                       forward_diff_bezier(    prevbezt->vec[1][j],    prevbezt->vec[2][j],
+                                                                                                       bezt->vec[0][j],                bezt->vec[1][j],
+                                                                                                       &(bevp->vec[j]), resolu, sizeof(BevPoint));
+                                               }
                                                
-                                               if (do_tilt || do_radius)
-                                                       alfa_bezpart(prevbezt, bezt, nu, tilt_array, radius_array, resolu);
+                                               /* if both arrays are NULL do nothiong */
+                                               alfa_bezpart(   prevbezt, bezt, nu,
+                                                                                do_tilt        ? &bevp->alfa : NULL,
+                                                                                do_radius      ? &bevp->radius : NULL,
+                                                                                resolu, sizeof(BevPoint));
                                                
                                                /* indicate with handlecodes double points */
                                                if(prevbezt->h1==prevbezt->h2) {
-                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= SELECT;
+                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
                                                }
                                                else {
-                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= SELECT;
-                                                       else if(prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->f1= SELECT;
-                                               }
-                                               
-                                               nr= resolu;
-                                               
-                                               coord_fp = coord_array;
-                                               tilt_fp = tilt_array;
-                                               radius_fp = radius_array;
-                                               
-                                               while(nr--) {
-                                                       bevp->x= coord_fp[0]; 
-                                                       bevp->y= coord_fp[1];
-                                                       bevp->z= coord_fp[2];
-                                                       coord_fp+=3;
-                                                       
-                                                       if (do_tilt) {
-                                                               bevp->alfa= *tilt_fp;
-                                                               tilt_fp++;
-                                                       }
-                                                       
-                                                       if (do_radius) {
-                                                               bevp->radius= *radius_fp;
-                                                               radius_fp++;
-                                                       }
-                                                       bevp++;
+                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
+                                                       else if(prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->split_tag= TRUE;
                                                }
                                                bl->nr+= resolu;
-       
+                                               bevp+= resolu;
                                        }
                                        prevbezt= bezt;
                                        bezt++;
                                }
                                
-                               MEM_freeN(coord_array);
-                               if (do_tilt)    MEM_freeN(tilt_array);
-                               if (do_radius)  MEM_freeN(radius_array);
-                               coord_array = tilt_array = radius_array = NULL;
-                               
                                if((nu->flagu & CU_CYCLIC)==0) {            /* not cyclic: endpoint */
-                                       bevp->x= prevbezt->vec[1][0];
-                                       bevp->y= prevbezt->vec[1][1];
-                                       bevp->z= prevbezt->vec[1][2];
+                                       VECCOPY(bevp->vec, prevbezt->vec[1]);
                                        bevp->alfa= prevbezt->alfa;
                                        bevp->radius= prevbezt->radius;
                                        bl->nr++;
@@ -1688,45 +1654,15 @@ void makeBevelList(Object *ob)
                                        bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3");
                                        BLI_addtail(&(cu->bev), bl);
                                        bl->nr= len;
-                                       bl->flag= 0;
+                                       bl->dupe_nr= 0;
                                        if(nu->flagu & CU_CYCLIC) bl->poly= 0;
                                        else bl->poly= -1;
                                        bevp= (BevPoint *)(bl+1);
-       
-                                       coord_array= coord_fp= MEM_callocN(3*sizeof(float)*len, "makeBevelCoords");    /* has to be zero-ed */
-                                       
-                                       if(do_tilt)
-                                               tilt_array= tilt_fp= MEM_callocN(sizeof(float)*len, "makeBevelTilt");
-                                       
-                                       if (do_radius)
-                                               radius_array= radius_fp= MEM_callocN(sizeof(float)*len, "nakeBevelRadius");
-                                       
-                                       makeNurbcurve(nu, coord_array, tilt_array, radius_array, resolu);
                                        
-                                       while(len--) {
-                                               bevp->x= coord_fp[0]; 
-                                               bevp->y= coord_fp[1];
-                                               bevp->z= coord_fp[2];
-                                               coord_fp+=3;
-                                               
-                                               if (do_tilt) {
-                                                       bevp->alfa= *tilt_fp;
-                                                       tilt_fp++;
-                                               }
-                                               
-                                               if (do_radius) {
-                                                       bevp->radius= *radius_fp;
-                                                       radius_fp++;
-                                               }
-                                               
-                                               
-                                               bevp->f1= bevp->f2= 0;
-                                               bevp++;
-                                       }
-                                       MEM_freeN(coord_array);
-                                       if (do_tilt)    MEM_freeN(tilt_array);
-                                       if (do_radius)  MEM_freeN(radius_array);
-                                       coord_array = tilt_array = radius_array = NULL;
+                                       makeNurbcurve(  nu, &bevp->vec[0],
+                                                                       do_tilt         ? &bevp->alfa : NULL,
+                                                                       do_radius       ? &bevp->radius : NULL,
+                                                                       resolu, sizeof(BevPoint));
                                }
                        }
                }
@@ -1742,11 +1678,11 @@ void makeBevelList(Object *ob)
                        bevp0= bevp1+(nr-1);
                        nr--;
                        while(nr--) {
-                               if( fabs(bevp0->x-bevp1->x)<0.00001 ) {
-                                       if( fabs(bevp0->y-bevp1->y)<0.00001 ) {
-                                               if( fabs(bevp0->z-bevp1->z)<0.00001 ) {
-                                                       bevp0->f2= SELECT;
-                                                       bl->flag++;
+                               if( fabs(bevp0->vec[0]-bevp1->vec[0])<0.00001 ) {
+                                       if( fabs(bevp0->vec[1]-bevp1->vec[1])<0.00001 ) {
+                                               if( fabs(bevp0->vec[2]-bevp1->vec[2])<0.00001 ) {
+                                                       bevp0->dupe_tag= TRUE;
+                                                       bl->dupe_nr++;
                                                }
                                        }
                                }
@@ -1759,8 +1695,8 @@ void makeBevelList(Object *ob)
        bl= cu->bev.first;
        while(bl) {
                blnext= bl->next;
-               if(bl->nr && bl->flag) {
-                       nr= bl->nr- bl->flag+1; /* +1 because vectorbezier sets flag too */
+               if(bl->nr && bl->dupe_nr) {
+                       nr= bl->nr- bl->dupe_nr+1;      /* +1 because vectorbezier sets flag too */
                        blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList4");
                        memcpy(blnew, bl, sizeof(BevList));
                        blnew->nr= 0;
@@ -1770,7 +1706,7 @@ void makeBevelList(Object *ob)
                        bevp1= (BevPoint *)(blnew+1);
                        nr= bl->nr;
                        while(nr--) {
-                               if(bevp0->f2==0) {
+                               if(bevp0->dupe_tag==0) {
                                        memcpy(bevp1, bevp0, sizeof(BevPoint));
                                        bevp1++;
                                        blnew->nr++;
@@ -1778,7 +1714,7 @@ void makeBevelList(Object *ob)
                                bevp0++;
                        }
                        MEM_freeN(bl);
-                       blnew->flag= 0;
+                       blnew->dupe_nr= 0;
                }
                bl= blnext;
        }
@@ -1807,8 +1743,8 @@ void makeBevelList(Object *ob)
                                bevp= (BevPoint *)(bl+1);
                                nr= bl->nr;
                                while(nr--) {
-                                       if(min>bevp->x) {
-                                               min= bevp->x;
+                                       if(min>bevp->vec[0]) {
+                                               min= bevp->vec[0];
                                                bevp1= bevp;
                                        }
                                        bevp++;
@@ -1823,8 +1759,7 @@ void makeBevelList(Object *ob)
                                if(bevp1== bevp) bevp2= (BevPoint *)(bl+1);
                                else bevp2= bevp1+1;
 
-                               inp= (bevp1->x- bevp0->x)*(bevp0->y- bevp2->y)
-                                   +(bevp0->y- bevp1->y)*(bevp0->x- bevp2->x);
+                               inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]);
 
                                if(inp>0.0) sd->dir= 1;
                                else sd->dir= 0;
@@ -1879,8 +1814,8 @@ void makeBevelList(Object *ob)
                        bevp2= (BevPoint *)(bl+1);
                        bevp1= bevp2+1;
 
-                       x1= bevp1->x- bevp2->x;
-                       y1= bevp1->y- bevp2->y;
+                       x1= bevp1->vec[0]- bevp2->vec[0];
+                       y1= bevp1->vec[1]- bevp2->vec[1];
 
                        calc_bevel_sin_cos(x1, y1, -x1, -y1, &(bevp1->sina), &(bevp1->cosa));
                        bevp2->sina= bevp1->sina;
@@ -1889,7 +1824,7 @@ void makeBevelList(Object *ob)
                        if(cu->flag & CU_3D) {  /* 3D */
                                float quat[4], q[4];
                        
-                               VecSubf(vec, &bevp1->x, &bevp2->x);
+                               VecSubf(vec, bevp1->vec, bevp2->vec);
                                
                                vectoquat(vec, 5, 1, quat);
                                
@@ -1924,7 +1859,7 @@ void makeBevelList(Object *ob)
                                while(nr--) {
        
                                        /* Normalizes */
-                                       VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x);
+                                       VecBisect3(vec, bevp0->vec, bevp1->vec, bevp2->vec);
 
                                        if(bl->nr==nr+1) { /* first time */
                                                vectoquat(vec, 5, 1, quat);
@@ -1976,7 +1911,7 @@ void makeBevelList(Object *ob)
                        nr= bl->nr;
                        while(nr--) {
 
-                               VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x);
+                               VecBisect3(vec, bevp0->vec, bevp1->vec, bevp2->vec);
 
                                quat_tmp1= (float *)bevp1->mat;
                                quat_tmp2= quat_tmp1+4;
@@ -1989,10 +1924,10 @@ void makeBevelList(Object *ob)
                                QuatToMat3(quat, bevp1->mat);
                                
                                /* generic */
-                               x1= bevp1->x- bevp0->x;
-                               x2= bevp1->x- bevp2->x;
-                               y1= bevp1->y- bevp0->y;
-                               y2= bevp1->y- bevp2->y;
+                               x1= bevp1->vec[0]- bevp0->vec[0];
+                               x2= bevp1->vec[0]- bevp2->vec[0];
+                               y1= bevp1->vec[1]- bevp0->vec[1];
+                               y2= bevp1->vec[1]- bevp2->vec[1];
                        
                                calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa));
                                
@@ -2014,7 +1949,7 @@ void makeBevelList(Object *ob)
                                if(cu->flag & CU_3D) {  /* 3D */
 
                                        /* Normalizes */
-                                       VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x);
+                                       VecBisect3(vec, bevp0->vec, bevp1->vec, bevp2->vec);
 
                                        if(bl->nr==nr+1 || !(cu->flag & CU_NO_TWIST)) { /* first time */
                                                vectoquat(vec, 5, 1, quat);
@@ -2039,10 +1974,10 @@ void makeBevelList(Object *ob)
                                        QuatToMat3(quat, bevp1->mat);
                                }
 
-                               x1= bevp1->x- bevp0->x;
-                               x2= bevp1->x- bevp2->x;
-                               y1= bevp1->y- bevp0->y;
-                               y2= bevp1->y- bevp2->y;
+                               x1= bevp1->vec[0]- bevp0->vec[0];
+                               x2= bevp1->vec[0]- bevp2->vec[0];
+                               y1= bevp1->vec[1]- bevp0->vec[1];
+                               y2= bevp1->vec[1]- bevp2->vec[1];
 
                                calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa));
 
index afc769b09663c055d56fbbd0a67bc02b5db923d5..c55dc8addb1d303b3bee101c4bab055d604c47b4 100644 (file)
@@ -804,7 +804,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
        DispList *dl;
        BezTriple *bezt, *prevbezt;
        BPoint *bp;
-       float *data, *v1, *v2;
+       float *data;
        int a, len, resolu;
        
        nu= nubase->first;
@@ -869,11 +869,15 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
                                                data+= 3;
                                        }
                                        else {
-                                               v1= prevbezt->vec[1];
-                                               v2= bezt->vec[0];
-                                               forward_diff_bezier(v1[0], v1[3], v2[0], v2[3], data, resolu, 3);
-                                               forward_diff_bezier(v1[1], v1[4], v2[1], v2[4], data+1, resolu, 3);
-                                               forward_diff_bezier(v1[2], v1[5], v2[2], v2[5], data+2, resolu, 3);
+                                               int j;
+                                               for(j=0; j<3; j++) {
+                                                       forward_diff_bezier(    prevbezt->vec[1][j],
+                                                                                                       prevbezt->vec[2][j],
+                                                                                                       bezt->vec[0][j],
+                                                                                                       bezt->vec[1][j],
+                                                                                                       data+j, resolu, 3*sizeof(float));
+                                               }
+                                               
                                                data+= 3*resolu;
                                        }
                                        
@@ -900,7 +904,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
                                data= dl->verts;
                                if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
                                else dl->type= DL_SEGM;
-                               makeNurbcurve(nu, data, NULL, NULL, resolu);
+                               makeNurbcurve(nu, data, NULL, NULL, resolu, 3*sizeof(float));
                        }
                        else if((nu->type & 7)==CU_POLY) {
                                len= nu->pntsu;
@@ -1397,7 +1401,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender, int forOrco
                                if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
                                else dl->type= DL_SEGM;
                                
-                               makeNurbcurve(nu, data, NULL, NULL, nu->resolu);
+                               makeNurbcurve(nu, data, NULL, NULL, nu->resolu, 3*sizeof(float));
                        }
                        else {
                                len= (nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv);
@@ -1508,9 +1512,9 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
                                                bevp= (BevPoint *)(bl+1);
                                                data= dl->verts;
                                                while(a--) {
-                                                       data[0]= bevp->x+widfac*bevp->sina;
-                                                       data[1]= bevp->y+widfac*bevp->cosa;
-                                                       data[2]= bevp->z;
+                                                       data[0]= bevp->vec[0]+widfac*bevp->sina;
+                                                       data[1]= bevp->vec[1]+widfac*bevp->cosa;
+                                                       data[2]= bevp->vec[2];
                                                        bevp++;
                                                        data+=3;
                                                }
@@ -1550,7 +1554,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
                                                                        fac = calc_taper(cu->taperobj, a, bl->nr);
                                                                }
                                                                
-                                                               if (bevp->f1) {
+                                                               if (bevp->split_tag) {
                                                                        dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
                                                                }
        
@@ -1566,14 +1570,14 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
                                                                                
                                                                                Mat3MulVecfl(bevp->mat, vec);
                                                                                
-                                                                               data[0]= bevp->x+ fac*vec[0];
-                                                                               data[1]= bevp->y+ fac*vec[1];
-                                                                               data[2]= bevp->z+ fac*vec[2];
+                                                                               data[0]= bevp->vec[0] + fac*vec[0];
+                                                                               data[1]= bevp->vec[1] + fac*vec[1];
+                                                                               data[2]= bevp->vec[2] + fac*vec[2];
                                                                        }
                                                                        else {
-                                                                               data[0]= bevp->x+ fac*(widfac+fp1[1])*bevp->sina;
-                                                                               data[1]= bevp->y+ fac*(widfac+fp1[1])*bevp->cosa;
-                                                                               data[2]= bevp->z+ fac*fp1[2];
+                                                                               data[0]= bevp->vec[0] + fac*(widfac+fp1[1])*bevp->sina;
+                                                                               data[1]= bevp->vec[1] + fac*(widfac+fp1[1])*bevp->cosa;
+                                                                               data[2]= bevp->vec[2] + fac*fp1[2];
                                                                        }
                                                                }
                                                        }
index 60dba9ce018126f167a7564ba3b6656a876d60a4..65d8cc6fbc6e02b3faf6206eb773cdca42447e1e 100644 (file)
@@ -60,7 +60,7 @@ typedef struct Path {
 #
 typedef struct BevList {
        struct BevList *next, *prev;
-       int nr, flag;
+       int nr, dupe_nr;
        short poly, hole;
 } BevList;
 
@@ -68,8 +68,8 @@ typedef struct BevList {
 #
 #
 typedef struct BevPoint {
-       float x, y, z, alfa, radius, sina, cosa, mat[3][3];
-       short f1, f2;
+       float vec[3], mat[3][3], alfa, radius, sina, cosa;
+       short split_tag, dupe_tag;
 } BevPoint;
 
 /* Keyframes on IPO curves and Points on Bezier Curves/Paths are generally BezTriples */
index e5679ea6ed702db7ee3ac01f4c22e188015416d3..4297453c91e9e6406bde21ead5fcdedd196f20e5 100644 (file)
@@ -509,7 +509,7 @@ static PyObject *M_Geometry_BezierInterp( PyObject * self, PyObject * args )
        
        coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "BezierInterp");
        for(i=0; i<dims; i++) {
-               forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, dims);
+               forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, dims*sizeof(float));
        }
        
        list= PyList_New(resolu);
index 973782d7463a4d10bcef69af6974739597f3b661..bc762bdb1a88aa85737ff554395e2057819398f5 100644 (file)
@@ -1514,8 +1514,8 @@ static void draw_ipocurves(int sel)
                                                                        
                                                                        correct_bezpart(v1, v2, v3, v4);
                                                                        
-                                                                       forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, 3);
-                                                                       forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data+1, resol, 3);
+                                                                       forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, 3*sizeof(float));
+                                                                       forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data+1, resol, 3*sizeof(float));
                                                                        
                                                                        fp= data;
                                                                        while(resol--) {
index fddbadac22d9de49a3e3df226c6b00b01c7e40da..22a9f277433c79980a0c727264f1db1710221d45 100644 (file)
@@ -3949,9 +3949,9 @@ static void drawnurb(Base *base, Nurb *nurb, int dt)
                                dz = fac*bevp->mat[2][2];
 
                                glBegin(GL_LINE_STRIP);
-                               glVertex3f(bevp->x - ox - dx, bevp->y - oy - dy, bevp->z - oz - dz);
-                               glVertex3f(bevp->x, bevp->y, bevp->z);
-                               glVertex3f(bevp->x + ox - dx, bevp->y + oy - dy, bevp->z + oz - dz);
+                               glVertex3f(bevp->vec[0] - ox - dx, bevp->vec[1] - oy - dy, bevp->vec[2] - oz - dz);
+                               glVertex3fv(bevp->vec);
+                               glVertex3f(bevp->vec[0] + ox - dx, bevp->vec[1] + oy - dy, bevp->vec[2] + oz - dz);
                                glEnd();
                                
                                bevp += skip+1;