diff options
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 830 |
1 files changed, 415 insertions, 415 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 04e559388ca..d74a688f121 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -81,11 +81,11 @@ void freedisplist(ListBase *lb) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { BLI_remlink(lb, dl); free_disp_elem(dl); - dl= lb->first; + dl = lb->first; } } @@ -93,14 +93,14 @@ DispList *find_displist_create(ListBase *lb, int type) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) return dl; + dl = dl->next; } - dl= MEM_callocN(sizeof(DispList), "find_disp"); - dl->type= type; + dl = MEM_callocN(sizeof(DispList), "find_disp"); + dl->type = type; BLI_addtail(lb, dl); return dl; @@ -110,10 +110,10 @@ DispList *find_displist(ListBase *lb, int type) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) return dl; + dl = dl->next; } return NULL; @@ -122,7 +122,7 @@ DispList *find_displist(ListBase *lb, int type) int displist_has_faces(ListBase *lb) { DispList *dl; - for (dl= lb->first; dl; dl= dl->next) { + for (dl = lb->first; dl; dl = dl->next) { if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { return 1; } @@ -136,21 +136,21 @@ void copy_displist(ListBase *lbn, ListBase *lb) freedisplist(lbn); - dl= lb->first; + dl = lb->first; while (dl) { - dln= MEM_dupallocN(dl); + dln = MEM_dupallocN(dl); BLI_addtail(lbn, dln); - dln->verts= MEM_dupallocN(dl->verts); - dln->nors= MEM_dupallocN(dl->nors); - dln->index= MEM_dupallocN(dl->index); - dln->col1= MEM_dupallocN(dl->col1); - dln->col2= MEM_dupallocN(dl->col2); + dln->verts = MEM_dupallocN(dl->verts); + dln->nors = MEM_dupallocN(dl->nors); + dln->index = MEM_dupallocN(dl->index); + dln->col1 = MEM_dupallocN(dl->col1); + dln->col2 = MEM_dupallocN(dl->col2); if (dl->bevelSplitFlag) - dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag); + dln->bevelSplitFlag = MEM_dupallocN(dl->bevelSplitFlag); - dl= dl->next; + dl = dl->next; } } @@ -163,38 +163,38 @@ void addnormalsDispList(ListBase *lb) int a, b, p1, p2, p3, p4; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==DL_INDEX3) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3, "dlnors"); - if (dl->verts[2] < 0.0f) dl->nors[2]= -1.0f; - else dl->nors[2]= 1.0f; + if (dl->type == DL_INDEX3) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); + if (dl->verts[2] < 0.0f) dl->nors[2] = -1.0f; + else dl->nors[2] = 1.0f; } } - else if (dl->type==DL_SURF) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors"); + else if (dl->type == DL_SURF) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors"); - vdata= dl->verts; - ndata= dl->nors; + vdata = dl->verts; + ndata = dl->nors; - for (a=0; a<dl->parts; a++) { + for (a = 0; a < dl->parts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - v1= vdata+ 3*p1; - n1= ndata+ 3*p1; - v2= vdata+ 3*p2; - n2= ndata+ 3*p2; - v3= vdata+ 3*p3; - n3= ndata+ 3*p3; - v4= vdata+ 3*p4; - n4= ndata+ 3*p4; + v1 = vdata + 3 * p1; + n1 = ndata + 3 * p1; + v2 = vdata + 3 * p2; + n2 = ndata + 3 * p2; + v3 = vdata + 3 * p3; + n3 = ndata + 3 * p3; + v4 = vdata + 3 * p4; + n4 = ndata + 3 * p4; - for (; b<dl->nr; b++) { + for (; b < dl->nr; b++) { normal_quad_v3(nor, v1, v3, v4, v2); @@ -203,21 +203,21 @@ void addnormalsDispList(ListBase *lb) add_v3_v3(n3, nor); add_v3_v3(n4, nor); - v2= v1; v1+= 3; - v4= v3; v3+= 3; - n2= n1; n1+= 3; - n4= n3; n3+= 3; + v2 = v1; v1 += 3; + v4 = v3; v3 += 3; + n2 = n1; n1 += 3; + n4 = n3; n3 += 3; } } - a= dl->parts*dl->nr; - v1= ndata; + a = dl->parts * dl->nr; + v1 = ndata; while (a--) { normalize_v3(v1); - v1+= 3; + v1 += 3; } } } - dl= dl->next; + dl = dl->next; } } @@ -225,52 +225,52 @@ void count_displist(ListBase *lb, int *totvert, int *totface) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { switch (dl->type) { case DL_SURF: - *totvert+= dl->nr*dl->parts; - *totface+= (dl->nr-1)*(dl->parts-1); + *totvert += dl->nr * dl->parts; + *totface += (dl->nr - 1) * (dl->parts - 1); break; case DL_INDEX3: case DL_INDEX4: - *totvert+= dl->nr; - *totface+= dl->parts; + *totvert += dl->nr; + *totface += dl->parts; break; case DL_POLY: case DL_SEGM: - *totvert+= dl->nr*dl->parts; + *totvert += dl->nr * dl->parts; } - dl= dl->next; + dl = dl->next; } } int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) { - if ((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) { + if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) { return 0; } if (dl->flag & DL_CYCL_U) { - (*p1)= dl->nr*a; - (*p2)= (*p1)+ dl->nr-1; - (*p3)= (*p1)+ dl->nr; - (*p4)= (*p2)+ dl->nr; - (*b)= 0; + (*p1) = dl->nr * a; + (*p2) = (*p1) + dl->nr - 1; + (*p3) = (*p1) + dl->nr; + (*p4) = (*p2) + dl->nr; + (*b) = 0; } else { - (*p2)= dl->nr*a; - (*p1)= (*p2)+1; - (*p4)= (*p2)+ dl->nr; - (*p3)= (*p1)+ dl->nr; - (*b)= 1; + (*p2) = dl->nr * a; + (*p1) = (*p2) + 1; + (*p4) = (*p2) + dl->nr; + (*p3) = (*p1) + dl->nr; + (*b) = 1; } - if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { - (*p3)-= dl->nr*dl->parts; - (*p4)-= dl->nr*dl->parts; + if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + (*p3) -= dl->nr * dl->parts; + (*p4) -= dl->nr * dl->parts; } return 1; @@ -287,70 +287,70 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i float *data; int a, len, resolu; - nu= nubase->first; + nu = nubase->first; while (nu) { - if (nu->hide==0) { + if (nu->hide == 0) { - if (forRender && cu->resolu_ren!=0) - resolu= cu->resolu_ren; + if (forRender && cu->resolu_ren != 0) + resolu = cu->resolu_ren; else - resolu= nu->resolu; + resolu = nu->resolu; - if (!BKE_nurb_check_valid_u(nu)); + if (!BKE_nurb_check_valid_u(nu)) ; else if (nu->type == CU_BEZIER) { /* count */ - len= 0; - a= nu->pntsu-1; + len = 0; + a = nu->pntsu - 1; if (nu->flagu & CU_NURB_CYCLIC) a++; - prevbezt= nu->bezt; - bezt= prevbezt+1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; while (a--) { - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt; + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) bezt = nu->bezt; - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++; - else len+= resolu; + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) len++; + else len += resolu; - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++; + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) len++; - prevbezt= bezt; + prevbezt = bezt; bezt++; } - dl= MEM_callocN(sizeof(DispList), "makeDispListbez"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbez"); /* len+1 because of 'forward_diff_bezier' function */ - dl->verts= MEM_callocN((len+1)*3*sizeof(float), "dlverts"); + dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; - data= dl->verts; + data = dl->verts; if (nu->flagu & CU_NURB_CYCLIC) { - dl->type= DL_POLY; - a= nu->pntsu; + dl->type = DL_POLY; + a = nu->pntsu; } else { - dl->type= DL_SEGM; - a= nu->pntsu-1; + dl->type = DL_SEGM; + a = nu->pntsu - 1; } - prevbezt= nu->bezt; - bezt= prevbezt+1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; while (a--) { - if (a==0 && dl->type== DL_POLY) bezt= nu->bezt; + if (a == 0 && dl->type == DL_POLY) bezt = nu->bezt; - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) { + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(data, prevbezt->vec[1]); - data+= 3; + data += 3; } else { int j; - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], @@ -358,58 +358,58 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i data + j, resolu, 3 * sizeof(float)); } - data+= 3*resolu; + data += 3 * resolu; } - if (a==0 && dl->type==DL_SEGM) { + if (a == 0 && dl->type == DL_SEGM) { copy_v3_v3(data, bezt->vec[1]); } - prevbezt= bezt; + prevbezt = bezt; bezt++; } } else if (nu->type == CU_NURBS) { - len= (resolu*SEGMENTSU(nu)); + len = (resolu * SEGMENTSU(nu)); - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; + dl->parts = 1; - dl->nr= len; - dl->col= nu->mat_nr; + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else if (nu->type == CU_POLY) { - len= nu->pntsu; - dl= MEM_callocN(sizeof(DispList), "makeDispListpoly"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + len = nu->pntsu; + dl = MEM_callocN(sizeof(DispList), "makeDispListpoly"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; - a= len; - bp= nu->bp; + a = len; + bp = nu->bp; while (a--) { copy_v3_v3(data, bp->vec); bp++; - data+= 3; + data += 3; } } } - nu= nu->next; + nu = nu->next; } } @@ -419,99 +419,99 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) ScanFillContext sf_ctx; ScanFillVert *eve, *v1, *vlast; ScanFillFace *efa; - DispList *dlnew=NULL, *dl; + DispList *dlnew = NULL, *dl; float *f1; - int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; + int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0; intptr_t totvert; - if (dispbase==NULL) return; - if (dispbase->first==NULL) return; + if (dispbase == NULL) return; + if (dispbase->first == NULL) return; while (cont) { - cont= 0; - totvert= 0; - nextcol= 0; + cont = 0; + totvert = 0; + nextcol = 0; BLI_scanfill_begin(&sf_ctx); - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_POLY) { - if (charidx<dl->charidx) cont= 1; - else if (charidx==dl->charidx) { /* character with needed index */ - if (colnr==dl->col) { + if (dl->type == DL_POLY) { + if (charidx < dl->charidx) cont = 1; + else if (charidx == dl->charidx) { /* character with needed index */ + if (colnr == dl->col) { /* make editverts and edges */ - f1= dl->verts; - a= dl->nr; - eve= v1= NULL; + f1 = dl->verts; + a = dl->nr; + eve = v1 = NULL; while (a--) { - vlast= eve; + vlast = eve; eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; - if (vlast==NULL) v1= eve; + if (vlast == NULL) v1 = eve; else { BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } - f1+=3; + f1 += 3; } - if (eve!=NULL && v1!=NULL) { + if (eve != NULL && v1 != NULL) { BLI_scanfill_edge_add(&sf_ctx, eve, v1); } } - else if (colnr<dl->col) { + else if (colnr < dl->col) { /* got poly with next material at current char */ - cont= 1; - nextcol= 1; + cont = 1; + nextcol = 1; } } } - dl= dl->next; + dl = dl->next; } - if (totvert && (tot= BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { + if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { if (tot) { - dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); - dlnew->type= DL_INDEX3; - dlnew->col= colnr; - dlnew->nr= totvert; - dlnew->parts= tot; - - dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex"); - dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts"); + dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); + dlnew->type = DL_INDEX3; + dlnew->col = colnr; + dlnew->nr = totvert; + dlnew->parts = tot; + + dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); + dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); /* vert data */ - f1= dlnew->verts; - totvert= 0; - eve= sf_ctx.fillvertbase.first; + f1 = dlnew->verts; + totvert = 0; + eve = sf_ctx.fillvertbase.first; while (eve) { copy_v3_v3(f1, eve->co); - f1+= 3; + f1 += 3; /* index number */ eve->tmp.l = totvert; totvert++; - eve= eve->next; + eve = eve->next; } /* index data */ efa = sf_ctx.fillfacebase.first; - index= dlnew->index; + index = dlnew->index; while (efa) { - index[0]= (intptr_t)efa->v1->tmp.l; - index[1]= (intptr_t)efa->v2->tmp.l; - index[2]= (intptr_t)efa->v3->tmp.l; + index[0] = (intptr_t)efa->v1->tmp.l; + index[1] = (intptr_t)efa->v2->tmp.l; + index[2] = (intptr_t)efa->v3->tmp.l; if (flipnormal) SWAP(int, index[0], index[2]); - index+= 3; - efa= efa->next; + index += 3; + efa = efa->next; } } @@ -527,7 +527,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) else { /* switch to next char and start filling from first material */ charidx++; - colnr= 0; + colnr = 0; } } @@ -542,55 +542,55 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) float *fp, *fp1; int a, dpoly; - front.first= front.last= back.first= back.last= NULL; + front.first = front.last = back.first = back.last = NULL; - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_SURF) { - if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) { + if (dl->type == DL_SURF) { + if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&front, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; dlnew->charidx = dl->charidx; - fp= dl->verts; - dpoly= 3*dl->nr; + fp = dl->verts; + dpoly = 3 * dl->nr; - a= dl->parts; + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&back, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; - dlnew->charidx= dl->charidx; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; + dlnew->charidx = dl->charidx; - fp= dl->verts+3*(dl->nr-1); - dpoly= 3*dl->nr; + fp = dl->verts + 3 * (dl->nr - 1); + dpoly = 3 * dl->nr; - a= dl->parts; + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } } } - dl= dl->next; + dl = dl->next; } filldisplist(&front, dispbase, 1); @@ -607,7 +607,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis { if (cu->flag & CU_3D) return; - if (dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) { + if (dispbase->first && ((DispList *) dispbase->first)->type == DL_SURF) { bevels_to_filledpoly(cu, dispbase); } else { @@ -624,37 +624,37 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { DispList *dl; - if (taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; + if (taperobj == NULL || taperobj->type != OB_CURVE) return 1.0; - dl= taperobj->disp.first; - if (dl==NULL) { + dl = taperobj->disp.first; + if (dl == NULL) { makeDispListCurveTypes(scene, taperobj, 0); - dl= taperobj->disp.first; + dl = taperobj->disp.first; } if (dl) { - float fac= ((float)cur)/(float)(tot-1); + float fac = ((float)cur) / (float)(tot - 1); float minx, dx, *fp; int a; /* horizontal size */ - minx= dl->verts[0]; - dx= dl->verts[3*(dl->nr-1)] - minx; + minx = dl->verts[0]; + dx = dl->verts[3 * (dl->nr - 1)] - minx; if (dx > 0.0f) { - fp= dl->verts; - for (a=0; a<dl->nr; a++, fp+=3) { - if ( (fp[0]-minx)/dx >= fac) { + fp = dl->verts; + for (a = 0; a < dl->nr; a++, fp += 3) { + if ( (fp[0] - minx) / dx >= fac) { /* interpolate with prev */ - if (a>0) { - float fac1= (fp[-3]-minx)/dx; - float fac2= (fp[0]-minx)/dx; - if (fac1!=fac2) - return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2); + if (a > 0) { + float fac1 = (fp[-3] - minx) / dx; + float fac2 = (fp[0] - minx) / dx; + if (fac1 != fac2) + return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2); } return fp[1]; } } - return fp[-2]; // last y coord + return fp[-2]; // last y coord } } @@ -663,7 +663,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) void makeDispListMBall(Scene *scene, Object *ob) { - if (!ob || ob->type!=OB_MBALL) return; + if (!ob || ob->type != OB_MBALL) return; // XXX: mball stuff uses plenty of global variables // while this is unchanged updating during render is unsafe @@ -671,8 +671,8 @@ void makeDispListMBall(Scene *scene, Object *ob) freedisplist(&(ob->disp)); - if (ob->type==OB_MBALL) { - if (ob==BKE_metaball_basis_find(scene, ob)) { + if (ob->type == OB_MBALL) { + if (ob == BKE_metaball_basis_find(scene, ob)) { BKE_metaball_polygonize(scene, ob, &ob->disp); BKE_metaball_texspace_calc(ob); @@ -703,7 +703,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo if (editmode) required_mode |= eModifierMode_Editmode; pretessellatePoint = NULL; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (!modifier_isEnabled(scene, md, required_mode)) continue; @@ -717,7 +717,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo * for incformation button in modifier's header */ md->mode |= eModifierMode_ApplyOnSpline; } - else if (md->mode&eModifierMode_ApplyOnSpline) { + else if (md->mode & eModifierMode_ApplyOnSpline) { pretessellatePoint = md; } } @@ -729,13 +729,13 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int numVerts = 0; int editmode = (!forRender && cu->editnurb); float (*originalVerts)[3] = NULL; float (*deformedVerts)[3] = NULL; - float *keyVerts= NULL; + float *keyVerts = NULL; int required_mode; if (forRender) required_mode = eModifierMode_Render; @@ -745,29 +745,29 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl if (editmode) required_mode |= eModifierMode_Editmode; - if (cu->editnurb==NULL) { - keyVerts= do_ob_key(scene, ob); + if (cu->editnurb == NULL) { + keyVerts = do_ob_key(scene, ob); if (keyVerts) { /* split coords from key data, the latter also includes * tilts, which is passed through in the modifier stack. * this is also the reason curves do not use a virtual * shape key modifier yet. */ - deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); - originalVerts= MEM_dupallocN(deformedVerts); + deformedVerts = BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); + originalVerts = MEM_dupallocN(deformedVerts); numVerts = BKE_nurbList_verts_count_without_handles(nurb); } } if (pretessellatePoint) { - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform) continue; + if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!deformedVerts) { deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts); @@ -776,7 +776,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode); - if (md==pretessellatePoint) + if (md == pretessellatePoint) break; } } @@ -794,22 +794,22 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl *numVerts_r = numVerts; } -static float (*displist_get_allverts (ListBase *dispbase, int *totvert))[3] +static float (*displist_get_allverts(ListBase * dispbase, int *totvert))[3] { DispList *dl; float (*allverts)[3], *fp; - *totvert= 0; + *totvert = 0; - for (dl=dispbase->first; dl; dl=dl->next) - *totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + for (dl = dispbase->first; dl; dl = dl->next) + *totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr; - allverts= MEM_mallocN((*totvert)*sizeof(float)*3, "displist_get_allverts allverts"); - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts"); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; + fp += offs; } return allverts; @@ -820,24 +820,24 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) DispList *dl; float *fp; - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(dl->verts, fp, sizeof(float) * offs); - fp+= offs; + fp += offs; } } static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) + DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); - DerivedMesh *dm= NULL, *ndm; + DerivedMesh *dm = NULL, *ndm; float (*vertCos)[3] = NULL; int useCache = !forRender; @@ -853,19 +853,19 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } if (derivedFinal && *derivedFinal) { - (*derivedFinal)->release (*derivedFinal); + (*derivedFinal)->release(*derivedFinal); } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; if (mti->type == eModifierTypeType_OnlyDeform || - (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { + (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { if (dm) { if (!vertCos) { totvert = dm->getNumVerts(dm); @@ -877,7 +877,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } else { if (!vertCos) { - vertCos= displist_get_allverts(dispbase, &totvert); + vertCos = displist_get_allverts(dispbase, &totvert); } mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode); @@ -910,7 +910,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba curve_to_filledpoly(cu, nurb, dispbase); } - dm= CDDM_from_curve_customDB(ob, dispbase); + dm = CDDM_from_curve_customDB(ob, dispbase); CDDM_calc_normals_mapping(dm); } @@ -918,7 +918,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if (vertCos) { /* Vertex coordinates were applied to necessary data, could free it */ MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } ndm = mti->applyModifier(md, ob, dm, forRender, useCache); @@ -927,7 +927,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba /* Modifier returned a new derived mesh */ if (dm && dm != ndm) /* Modifier */ - dm->release (dm); + dm->release(dm); dm = ndm; } } @@ -946,12 +946,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba else { displist_apply_allverts(dispbase, vertCos); MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } } if (derivedFinal) { - if (dm) DM_ensure_tessface(dm); /* needed for drawing */ + if (dm) DM_ensure_tessface(dm); /* needed for drawing */ (*derivedFinal) = dm; } @@ -967,25 +967,25 @@ static void displist_surf_indices(DispList *dl) int a, b, p1, p2, p3, p4; int *index; - dl->totindex= 0; + dl->totindex = 0; - index=dl->index= MEM_mallocN(4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs"); + index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs"); - for (a=0; a<dl->parts; a++) { + for (a = 0; a < dl->parts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - for (; b<dl->nr; b++, index+=4) { - index[0]= p1; - index[1]= p2; - index[2]= p4; - index[3]= p3; + for (; b < dl->nr; b++, index += 4) { + index[0] = p1; + index[1] = p2; + index[2] = p4; + index[3] = p3; dl->totindex++; - p2= p1; p1++; - p4= p3; p3++; + p2 = p1; p1++; + p4 = p3; p3++; } } @@ -995,11 +995,11 @@ static void displist_surf_indices(DispList *dl) static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) { DerivedMesh *dm; - ListBase disp= {NULL, NULL}; + ListBase disp = {NULL, NULL}; /* OrcoDM should be created from underformed disp lists */ makeDispListCurveTypes_forOrco(scene, ob, &disp); - dm= CDDM_from_curve_customDB(ob, &disp); + dm = CDDM_from_curve_customDB(ob, &disp); freedisplist(&disp); @@ -1010,12 +1010,12 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * { float (*orco)[3], (*layerorco)[3]; int totvert, a; - Curve *cu= ob->data; + Curve *cu = ob->data; - totvert= dm->getNumVerts(dm); + totvert = dm->getNumVerts(dm); if (orcodm) { - orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco"); + orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco"); if (orcodm->getNumVerts(orcodm) == totvert) orcodm->getVertCos(orcodm, orco); @@ -1023,18 +1023,18 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * dm->getVertCos(dm, orco); } else { - orco= (float(*)[3])BKE_curve_make_orco(scene, ob); + orco = (float(*)[3])BKE_curve_make_orco(scene, ob); } - for (a=0; a<totvert; a++) { + for (a = 0; a < totvert; a++) { float *co = orco[a]; - co[0] = (co[0]-cu->loc[0])/cu->size[0]; - co[1] = (co[1]-cu->loc[1])/cu->size[1]; - co[2] = (co[2]-cu->loc[2])/cu->size[2]; + co[0] = (co[0] - cu->loc[0]) / cu->size[0]; + co[1] = (co[1] - cu->loc[1]) / cu->size[1]; + co[2] = (co[2] - cu->loc[2]) / cu->size[2]; } if ((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) { - memcpy(layerorco, orco, sizeof(float)*totvert); + memcpy(layerorco, orco, sizeof(float) * totvert); MEM_freeN(orco); } else @@ -1048,10 +1048,10 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; + Curve *cu = ob->data; int required_mode; int editmode = (!forRender && cu->editnurb); - DerivedMesh *ndm, *orcodm= NULL; + DerivedMesh *ndm, *orcodm = NULL; if (forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -1064,17 +1064,17 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina md = pretessellatePoint->next; } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_Constructive) continue; + if (mti->type != eModifierTypeType_Constructive) continue; if (!orcodm) - orcodm= create_orco_dm(scene, ob); + orcodm = create_orco_dm(scene, ob); ndm = mti->applyModifier(md, ob, orcodm, forRender, 0); @@ -1095,7 +1095,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina } void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1108,65 +1108,65 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, float (*deformedVerts)[3]; if (!forRender && cu->editnurb) - nubase= BKE_curve_editNurbs_get(cu); + nubase = BKE_curve_editNurbs_get(cu); else - nubase= &cu->nurb; + nubase = &cu->nurb; if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); - for (nu=nubase->first; nu; nu=nu->next) { - if (forRender || nu->hide==0) { - int resolu= nu->resolu, resolv= nu->resolv; + for (nu = nubase->first; nu; nu = nu->next) { + if (forRender || nu->hide == 0) { + int resolu = nu->resolu, resolv = nu->resolv; if (forRender) { - if (cu->resolu_ren) resolu= cu->resolu_ren; - if (cu->resolv_ren) resolv= cu->resolv_ren; + if (cu->resolu_ren) resolu = cu->resolu_ren; + if (cu->resolv_ren) resolv = cu->resolv_ren; } - if (nu->pntsv==1) { - len= SEGMENTSU(nu)*resolu; + if (nu->pntsv == 1) { + len = SEGMENTSU(nu) * resolu; - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else { - len= (nu->pntsu*resolu) * (nu->pntsv*resolv); + len = (nu->pntsu * resolu) * (nu->pntsv * resolv); - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - dl->type= DL_SURF; + data = dl->verts; + dl->type = DL_SURF; - dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */ - dl->nr= (nu->pntsv*resolv); - if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ - if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V; + dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */ + dl->nr = (nu->pntsv * resolv); + if (nu->flagv & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_U; /* reverse too! */ + if (nu->flagu & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_V; BKE_nurb_makeFaces(nu, data, 0, resolu, resolv); @@ -1187,7 +1187,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, - forRender, originalVerts, deformedVerts); + forRender, originalVerts, deformedVerts); } static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r) @@ -1196,24 +1196,24 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid int b; fp = dlb->verts; - for (b = 0; b<dlb->nr; b++, fp += 3, data += 3) { + for (b = 0; b < dlb->nr; b++, fp += 3, data += 3) { if (cu->flag & CU_3D) { float vec[3]; - vec[0] = fp[1]+widfac; + vec[0] = fp[1] + widfac; vec[1] = fp[2]; - vec[2 ]= 0.0; + vec[2] = 0.0; mul_qt_v3(bevp->quat, vec); - data[0] = bevp->vec[0] + fac*vec[0]; - data[1] = bevp->vec[1] + fac*vec[1]; - data[2] = bevp->vec[2] + 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->vec[0] + fac*(widfac+fp[1])*bevp->sina; - data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa; - data[2] = bevp->vec[2] + fac*fp[2]; + data[0] = bevp->vec[0] + fac * (widfac + fp[1]) * bevp->sina; + data[1] = bevp->vec[1] + fac * (widfac + fp[1]) * bevp->cosa; + data[2] = bevp->vec[2] + fac * fp[2]; } } @@ -1226,19 +1226,19 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp float *data; int b; - dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbev2"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr, "dlverts"); - dl->type= DL_POLY; + dl->type = DL_POLY; - dl->parts= 1; - dl->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3) copy_v3_v3(data, prev_fp); @@ -1247,14 +1247,14 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp } static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco) { Curve *cu = ob->data; /* we do allow duplis... this is only displist on curve level */ if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; - if (ob->type==OB_SURF) { + if (ob->type == OB_SURF) { makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { @@ -1264,14 +1264,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - nubase= BKE_curve_nurbs_get(cu); + nubase = BKE_curve_nurbs_get(cu); BLI_freelistN(&(cu->bev)); if (cu->path) free_path(cu->path); - cu->path= NULL; + cu->path = NULL; - if (ob->type==OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0); + if (ob->type == OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0); if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); @@ -1281,15 +1281,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba BKE_curve_bevel_make(scene, ob, &dlbev, forRender); /* no bevel or extrude, and no width correction? */ - if (!dlbev.first && cu->width==1.0f) { + if (!dlbev.first && cu->width == 1.0f) { curve_to_displist(cu, nubase, dispbase, forRender); } else { - float widfac= cu->width - 1.0f; - BevList *bl= cu->bev.first; - Nurb *nu= nubase->first; + float widfac = cu->width - 1.0f; + BevList *bl = cu->bev.first; + Nurb *nu = nubase->first; - for (; bl && nu; bl=bl->next, nu=nu->next) { + for (; bl && nu; bl = bl->next, nu = nu->next) { DispList *dl; float *data; BevPoint *bevp; @@ -1298,34 +1298,34 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (bl->nr) { /* blank bevel lists can happen */ /* 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"); + 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->poly!= -1) dl->type= DL_POLY; - else dl->type= DL_SEGM; + 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); + 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->parts = 1; + dl->nr = bl->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - a= dl->nr; - bevp= (BevPoint *)(bl+1); - data= dl->verts; + a = dl->nr; + bevp = (BevPoint *)(bl + 1); + data = dl->verts; while (a--) { - data[0]= bevp->vec[0]+widfac*bevp->sina; - data[1]= bevp->vec[1]+widfac*bevp->cosa; - data[2]= bevp->vec[2]; + data[0] = bevp->vec[0] + widfac * bevp->sina; + data[1] = bevp->vec[1] + widfac * bevp->cosa; + data[2] = bevp->vec[2]; bevp++; - data+=3; + data += 3; } } else { @@ -1333,7 +1333,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase bottom_capbase = {NULL, NULL}; ListBase top_capbase = {NULL, NULL}; - for (dlb=dlbev.first; dlb; dlb=dlb->next) { + 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; @@ -1341,10 +1341,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba 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)); + 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; @@ -1352,35 +1352,35 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } /* 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 = MEM_callocN(sizeof(DispList), "makeDispListbev1"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts"); BLI_addtail(dispbase, dl); - dl->type= DL_SURF; + 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; + 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->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = steps; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag"); + dl->bevelSplitFlag = MEM_callocN(sizeof(*dl->col2) * ((steps + 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++) { - float fac=1.0; + bevp = (BevPoint *)(bl + 1) + start; + for (i = start, a = 0; a < steps; i++, bevp++, a++) { + float fac = 1.0; float *cur_data = data; - if (cu->taperobj==NULL) { - if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) + if (cu->taperobj == NULL) { + if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { @@ -1388,14 +1388,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (bevp->split_tag) { - dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); + dl->bevelSplitFlag[a >> 5] |= 1 << (a & 0x1F); } /* 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; + 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) { @@ -1416,7 +1416,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { if (a == 1) - fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase); + fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase); if (a == steps - 1) fillBevelCap(nu, dlb, cur_data, &top_capbase); } @@ -1464,7 +1464,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) { - Curve *cu= ob->data; + Curve *cu = ob->data; ListBase *dispbase; /* The same check for duplis as in do_makeDispListCurveTypes. @@ -1473,7 +1473,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; freedisplist(&(ob->disp)); - dispbase= &(ob->disp); + dispbase = &(ob->disp); freedisplist(dispbase); /* free displist used for textspace */ @@ -1482,21 +1482,21 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { - DM_set_object_boundbox (ob, ob->derivedFinal); + DM_set_object_boundbox(ob, ob->derivedFinal); } else { - boundbox_displist (ob); + boundbox_displist(ob); /* if there is no derivedMesh, object's boundbox is unneeded */ if (ob->bb) { MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; } } } void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forOrco) + DerivedMesh **derivedFinal, int forOrco) { do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); } @@ -1512,16 +1512,16 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int float *orco; if (derivedFinal == NULL) - derivedFinal= ob->derivedFinal; + derivedFinal = ob->derivedFinal; if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) { curve_calc_orcodm(scene, ob, derivedFinal, forRender); } - orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); + orco = derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); if (orco) { - orco= MEM_dupallocN(orco); + orco = MEM_dupallocN(orco); } return orco; @@ -1530,34 +1530,34 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int /* this is confusing, there's also min_max_object, appplying the obmat... */ static void boundbox_displist(Object *ob) { - BoundBox *bb=NULL; + BoundBox *bb = NULL; float min[3], max[3]; DispList *dl; float *vert; - int a, tot=0; + int a, tot = 0; INIT_MINMAX(min, max); if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - Curve *cu= ob->data; - int doit= 0; + Curve *cu = ob->data; + int doit = 0; - if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= cu->bb; + if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = cu->bb; - dl= ob->disp.first; + dl = ob->disp.first; while (dl) { - if (dl->type==DL_INDEX3) tot= dl->nr; - else tot= dl->nr*dl->parts; + if (dl->type == DL_INDEX3) tot = dl->nr; + else tot = dl->nr * dl->parts; - vert= dl->verts; - for (a=0; a<tot; a++, vert+=3) { - doit= 1; + vert = dl->verts; + for (a = 0; a < tot; a++, vert += 3) { + doit = 1; DO_MINMAX(vert, min, max); } - dl= dl->next; + dl = dl->next; } if (!doit) { |