svn merge ^/trunk/blender -r46300:46330
[blender.git] / source / blender / blenkernel / intern / displist.c
index ebcebaedd2dee01373175d724ca72c7497c594fc..7bd95dfa7dd38f2d7e58bf5a734543c6cc6b28e2 100644 (file)
@@ -1220,11 +1220,10 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid
        *data_r = data;
 }
 
-static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *dispbase)
+static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, ListBase *dispbase)
 {
        DispList *dl;
        float *data;
-       int b;
 
        dl= MEM_callocN(sizeof(DispList), "makeDispListbev2");
        dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts");
@@ -1240,8 +1239,7 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp
        /* CU_2D conflicts with R_NOPUNOFLIP */
        dl->rt= nu->flag & ~CU_2D;
 
-       for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3)
-               copy_v3_v3(data, prev_fp);
+       rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
 
        BLI_addtail(dispbase, dl);
 }
@@ -1334,26 +1332,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                                                ListBase top_capbase = {NULL, NULL};
 
                                                for (dlb=dlbev.first; dlb; dlb=dlb->next) {
-                                                       int i, start, steps;
-                                                       float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2);
-                                                       float firstblend = 0.0f, lastblend = 0.0f;
-
-                                                       if (cu->bevfac1 - cu->bevfac2 == 0.0f)
-                                                               continue;
-
-                                                       start = (int)(bevfac1*(bl->nr-1));
-                                                       steps = 2+(int)((bevfac2)*(bl->nr-1)) - start;
-                                                       firstblend = 1.0f - ((float)bevfac1*(bl->nr-1) - (int)((float)bevfac1*(bl->nr-1)));
-                                                       lastblend  = (float)bevfac2*(bl->nr-1) - (int)((float)bevfac2*(bl->nr-1));
-
-                                                       if (steps > bl->nr) {
-                                                               steps = bl->nr;
-                                                               lastblend = 1.0f;
-                                                       }
-
                                                        /* 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*steps, "dlverts");
+                                                       dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts");
                                                        BLI_addtail(dispbase, dl);
        
                                                        dl->type= DL_SURF;
@@ -1361,8 +1342,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                                                        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= steps;
+                                                       
+                                                       dl->parts= bl->nr;
                                                        dl->nr= dlb->nr;
                                                        dl->col= nu->mat_nr;
                                                        dl->charidx= nu->charidx;
@@ -1371,20 +1352,18 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                                                        /* CU_2D conflicts with R_NOPUNOFLIP */
                                                        dl->rt= nu->flag & ~CU_2D;
 
-                                                       dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag");
+                                                       dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag");
        
                                                        /* for each point of poly make a bevel piece */
-                                                       bevp= (BevPoint *)(bl+1) + start;
-                                                       for (i=start, a=0; a<steps; i++,bevp++,a++) {
+                                                       bevp= (BevPoint *)(bl+1);
+                                                       for (a=0; a<bl->nr; a++, bevp++) {
                                                                float fac=1.0;
-                                                               float *cur_data = data;
-
                                                                if (cu->taperobj==NULL) {
                                                                        if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
                                                                                fac = bevp->radius;
                                                                }
                                                                else {
-                                                                       fac = calc_taper(scene, cu->taperobj, i, bl->nr);
+                                                                       fac = calc_taper(scene, cu->taperobj, a, bl->nr);
                                                                }
 
                                                                if (bevp->split_tag) {
@@ -1394,31 +1373,11 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                                                                /* rotate bevel piece and write in data */
                                                                rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
 
-                                                               if (a == 1 || a == steps - 1) {
-                                                                       float *cur_fp = cur_data, *prev_fp = cur_data - 3*dlb->nr;
-                                                                       int b;
-
-                                                                       for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) {
-                                                                               float cur[3], prev[3];
-
-                                                                               copy_v3_v3(cur, cur_fp);
-                                                                               copy_v3_v3(prev, prev_fp);
-
-                                                                               if (a == 1)
-                                                                                       interp_v3_v3v3(prev, cur_fp, prev_fp, firstblend);
-                                                                               if (a == steps - 1)
-                                                                                       interp_v3_v3v3(cur, prev_fp, cur_fp, lastblend);
-
-                                                                               copy_v3_v3(cur_fp, cur);
-                                                                               copy_v3_v3(prev_fp, prev);
-                                                                       }
-                                                               }
-
                                                                if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) {
-                                                                       if (a == 1) 
-                                                                               fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase);
-                                                                       if (a == steps - 1)
-                                                                               fillBevelCap(nu, dlb, cur_data, &top_capbase);
+                                                                       if (a == 0)
+                                                                               fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &bottom_capbase);
+                                                                       else if (a == bl->nr - 1)
+                                                                               fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &top_capbase);
                                                                }
                                                        }