From f7de9efb7441ec14eb89a3f7ab33b97400911fe9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 17 Apr 2014 16:22:25 +0200 Subject: BI: cleanup in autosmooth area. --- .../blender/render/intern/source/convertblender.c | 47 ++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 5204799932b..a9e2e1c2daf 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -500,32 +500,29 @@ static int as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr) { ASface *asf; int a = -1; - - if (v1 == NULL) return a; - - if (asv->faces.first==NULL) { - asf= MEM_callocN(sizeof(ASface), "asface"); - BLI_addtail(&asv->faces, asf); - } - - asf= asv->faces.last; - for (a=0; a<4; a++) { - if (asf->vlr[a]==NULL) { - asf->vlr[a]= vlr; - asv->totface++; - break; + + if (v1 == NULL) + return a; + + asf = asv->faces.last; + if (asf) { + for (a = 0; a < 4 && asf->vlr[a]; a++) { } } - + else { + a = 4; + } + /* new face struct */ - if (a==4) { + if (a == 4) { a = 0; - asf= MEM_callocN(sizeof(ASface), "asface"); + asf = MEM_callocN(sizeof(ASface), "asface"); BLI_addtail(&asv->faces, asf); - asf->vlr[a]= vlr; - asv->totface++; } + asf->vlr[a] = vlr; + asv->totface++; + return a; } @@ -628,14 +625,14 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], shor } /* free */ - for (a=0; atotvert; a++) { - ver= RE_findOrAddVert(obr, a); + for (a = 0; a < obr->totvert; a++) { + ver = RE_findOrAddVert(obr, a); mul_m4_v3(mat, ver->co); if (lnors) { mul_mat3_m4_v3(mat, ver->n); @@ -643,9 +640,9 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], shor normalize_v3(ver->n); } } - for (a=0; atotvlak; a++) { - vlr= RE_findOrAddVlak(obr, a); - + for (a = 0; a < obr->totvlak; a++) { + vlr = RE_findOrAddVlak(obr, a); + /* skip wire faces */ if (vlr->v2 != vlr->v3) { if (vlr->v4) -- cgit v1.2.3