bugfix, curve radius would display incorrectly when there were single point's before...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 3 Dec 2007 22:42:48 +0000 (22:42 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 3 Dec 2007 22:42:48 +0000 (22:42 +0000)
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/lattice.c
source/blender/src/drawobject.c

index 87bba6abca8439fc2f897d90d907e80a0376290b..ab17366163f4f591be19ded1a2b34d071c4088ad 100644 (file)
@@ -105,7 +105,7 @@ void calc_curvepath(Object *ob)
        cu->path= NULL;
        
        bl= cu->bev.first;
-       if(bl==NULL) return;
+       if(bl==NULL || !bl->nr) return;
 
        cu->path=path= MEM_callocN(sizeof(Path), "path");
        
@@ -227,6 +227,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir)  /* returns OK
        
        /* test for cyclic */
        bl= cu->bev.first;
+       if (!bl->nr) return 0;
        if(bl && bl->poly> -1) cycl= 1;
 
        ctime *= (path->len-1);
index fcf44fb07752466c08dc6e1d88cbb805219506aa..c50374388a93d6f208827bcf4ba3d686cab7e940 100644 (file)
@@ -1479,7 +1479,11 @@ void makeBevelList(Object *ob)
        else nu= cu->nurb.first;
        
        while(nu) {
-               if(nu->pntsu>1) {
+               if(nu->pntsu<=1) {
+                       bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
+                       BLI_addtail(&(cu->bev), bl);
+                       bl->nr= 0;
+               } else {
                        if(G.rendering && cu->resolu_ren!=0) 
                                resolu= cu->resolu_ren;
                        else
@@ -1637,28 +1641,30 @@ void makeBevelList(Object *ob)
        /* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */
        bl= cu->bev.first;
        while(bl) {
-               nr= bl->nr;
-               bevp1= (BevPoint *)(bl+1);
-               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 (bl->nr) { /* null bevel items come from single points */
+                       nr= bl->nr;
+                       bevp1= (BevPoint *)(bl+1);
+                       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++;
+                                               }
                                        }
                                }
+                               bevp0= bevp1;
+                               bevp1++;
                        }
-                       bevp0= bevp1;
-                       bevp1++;
                }
                bl= bl->next;
        }
        bl= cu->bev.first;
        while(bl) {
                blnext= bl->next;
-               if(bl->flag) {
+               if(bl->nr && bl->flag) {
                        nr= bl->nr- bl->flag+1; /* +1 because vectorbezier sets flag too */
                        blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList");
                        memcpy(blnew, bl, sizeof(BevList));
@@ -1686,7 +1692,7 @@ void makeBevelList(Object *ob)
        bl= cu->bev.first;
        poly= 0;
        while(bl) {
-               if(bl->poly>=0) {
+               if(bl->nr && bl->poly>=0) {
                        poly++;
                        bl->poly= poly;
                        bl->gat= 0;     /* 'gat' is dutch for hole */
index 6248e01432eb0baefd6dab4eec456bbf531674a9..82a108a20eb0df7ced3d6bdfcf5acdf168fcabde 100644 (file)
@@ -1426,99 +1426,102 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
                                BevPoint *bevp;
                                int a,b;
                                
-                               /* exception handling; curve without bevel or extrude, with width correction */
-                               if(dlbev.first==NULL) {
-                                       dl= MEM_callocN(sizeof(DispList), "makeDispListbev");
-                                       dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts");
-                                       BLI_addtail(dispbase, dl);
+                               if (bl->nr) { /* blank bevel lists can happen */
                                        
-                                       if(bl->poly!= -1) dl->type= DL_POLY;
-                                       else dl->type= DL_SEGM;
-                                       
-                                       if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
-                                       
-                                       dl->parts= 1;
-                                       dl->nr= bl->nr;
-                                       dl->col= nu->mat_nr;
-                                       dl->charidx= nu->charidx;
-                                       dl->rt= nu->flag;
-                                       
-                                       a= dl->nr;
-                                       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;
-                                               bevp++;
-                                               data+=3;
-                                       }
-                               }
-                               else {
-                                       DispList *dlb;
-                                       
-                                       for (dlb=dlbev.first; dlb; dlb=dlb->next) {
-
-                                                       /* for each part of the bevel use a separate displblock */
-                                               dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
-                                               dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts");
+                                       /* exception handling; curve without bevel or extrude, with width correction */
+                                       if(dlbev.first==NULL) {
+                                               dl= MEM_callocN(sizeof(DispList), "makeDispListbev");
+                                               dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts");
                                                BLI_addtail(dispbase, dl);
-
-                                               dl->type= DL_SURF;
                                                
-                                               dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE);
-                                               if(dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
-                                               if(bl->poly>=0) dl->flag |= DL_CYCL_V;
+                                               if(bl->poly!= -1) dl->type= DL_POLY;
+                                               else dl->type= DL_SEGM;
+                                               
+                                               if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
                                                
-                                               dl->parts= bl->nr;
-                                               dl->nr= dlb->nr;
+                                               dl->parts= 1;
+                                               dl->nr= bl->nr;
                                                dl->col= nu->mat_nr;
                                                dl->charidx= nu->charidx;
                                                dl->rt= nu->flag;
-                                               dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2");
-                                               bevp= (BevPoint *)(bl+1);
-
-                                                       /* for each point of poly make a bevel piece */
+                                               
+                                               a= dl->nr;
                                                bevp= (BevPoint *)(bl+1);
-                                               for(a=0; a<bl->nr; a++,bevp++) {
-                                                       float fac=1.0;
-                                                       if (cu->taperobj==NULL) {
-                                                               if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
-                                                               fac = calc_curve_subdiv_radius(cu, nu, a);
-                                                       } else {
-                                                               fac = calc_taper(cu->taperobj, a, bl->nr);
-                                                       }
+                                               data= dl->verts;
+                                               while(a--) {
+                                                       data[0]= bevp->x+widfac*bevp->sina;
+                                                       data[1]= bevp->y+widfac*bevp->cosa;
+                                                       data[2]= bevp->z;
+                                                       bevp++;
+                                                       data+=3;
+                                               }
+                                       }
+                                       else {
+                                               DispList *dlb;
+                                               
+                                               for (dlb=dlbev.first; dlb; dlb=dlb->next) {
+       
+                                                               /* for each part of the bevel use a separate displblock */
+                                                       dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
+                                                       dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts");
+                                                       BLI_addtail(dispbase, dl);
+       
+                                                       dl->type= DL_SURF;
                                                        
-                                                       if (bevp->f1) {
-                                                               dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
-                                                       }
-
-                                                               /* rotate bevel piece and write in data */
-                                                       fp1= dlb->verts;
-                                                       for (b=0; b<dlb->nr; b++,fp1+=3,data+=3) {
-                                                               if(cu->flag & CU_3D) {
-                                                                       float vec[3];
-
-                                                                       vec[0]= fp1[1]+widfac;
-                                                                       vec[1]= fp1[2];
-                                                                       vec[2]= 0.0;
-                                                                       
-                                                                       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];
+                                                       dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE);
+                                                       if(dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
+                                                       if(bl->poly>=0) dl->flag |= DL_CYCL_V;
+                                                       
+                                                       dl->parts= bl->nr;
+                                                       dl->nr= dlb->nr;
+                                                       dl->col= nu->mat_nr;
+                                                       dl->charidx= nu->charidx;
+                                                       dl->rt= nu->flag;
+                                                       dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2");
+                                                       bevp= (BevPoint *)(bl+1);
+       
+                                                               /* for each point of poly make a bevel piece */
+                                                       bevp= (BevPoint *)(bl+1);
+                                                       for(a=0; a<bl->nr; a++,bevp++) {
+                                                               float fac=1.0;
+                                                               if (cu->taperobj==NULL) {
+                                                                       if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
+                                                                       fac = calc_curve_subdiv_radius(cu, nu, a);
+                                                               } else {
+                                                                       fac = calc_taper(cu->taperobj, a, bl->nr);
+                                                               }
+                                                               
+                                                               if (bevp->f1) {
+                                                                       dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
                                                                }
-                                                               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];
+       
+                                                                       /* rotate bevel piece and write in data */
+                                                               fp1= dlb->verts;
+                                                               for (b=0; b<dlb->nr; b++,fp1+=3,data+=3) {
+                                                                       if(cu->flag & CU_3D) {
+                                                                               float vec[3];
+       
+                                                                               vec[0]= fp1[1]+widfac;
+                                                                               vec[1]= fp1[2];
+                                                                               vec[2]= 0.0;
+                                                                               
+                                                                               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];
+                                                                       }
+                                                                       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];
+                                                                       }
                                                                }
                                                        }
+                                                       
+                                                       /* gl array drawing: using indices */
+                                                       displist_surf_indices(dl);
                                                }
-                                               
-                                               /* gl array drawing: using indices */
-                                               displist_surf_indices(dl);
                                        }
                                }
 
index 64c081c27a66203ed6d8bc4662bd6f598bb3a883..2b815c28cc52acba870de674c473af36e5d9c6a0 100644 (file)
@@ -483,6 +483,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir)
        
        /* test for cyclic */
        bl= cu->bev.first;
+       if (!bl->nr) return 0;
        if(bl && bl->poly> -1) cycl= 1;
 
        if(cycl==0) {
index 790db21374470824cb9cb4da8fbd00cdf8b2c86b..e0b09d6d812278ae0bf6d9b8e34959a47ec6190a 100644 (file)
@@ -3949,7 +3949,7 @@ static void drawnurb(Base *base, Nurb *nurb, int dt)
                        int skip= nu->resolu/16;
                        float fac;
                        
-                       while (nr-->0) {
+                       while (nr-->0) { /* accounts for empty bevel lists */
                                float ox,oy,oz; // Offset perpendicular to the curve
                                float dx,dy,dz; // Delta along the curve