diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/armature/meshlaplacian.c | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/armature/meshlaplacian.c')
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 450 |
1 files changed, 225 insertions, 225 deletions
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index de9b4a890cb..4c1315e847e 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -142,7 +142,7 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2) { void **p = BLI_edgehash_lookup_p(edgehash, v1, v2); - if(p) + if (p) *p = (void*)((intptr_t)*p + (intptr_t)1); else BLI_edgehash_insert(edgehash, v1, v2, (void*)(intptr_t)1); @@ -184,8 +184,8 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3 t3= cotan_weight(v3, v1, v2); if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse= 1; - else if(angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; - else if(angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; + else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; + else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; if (obtuse > 0) { area= area_tri_v3(v1, v2, v3); @@ -237,7 +237,7 @@ static void laplacian_triangle_weights(LaplacianSystem *sys, int f, int i1, int nlMatrixAdd(i3, i1, -t2*varea[i3]); nlMatrixAdd(i1, i3, -t2*varea[i1]); - if(sys->storeweights) { + if (sys->storeweights) { sys->fweights[f][0]= t1*varea[i1]; sys->fweights[f][1]= t2*varea[i2]; sys->fweights[f][2]= t3*varea[i3]; @@ -263,7 +263,7 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac /* create opennl context */ nlNewContext(); nlSolverParameteri(NL_NB_VARIABLES, totvert); - if(lsq) + if (lsq) nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); sys->context= nlGetCurrent(); @@ -296,39 +296,39 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) sys->varea= MEM_callocN(sizeof(float)*totvert, "LaplacianSystemVarea"); sys->edgehash= BLI_edgehash_new(); - for(a=0, face=sys->faces; a<sys->totface; a++, face++) { + for (a=0, face=sys->faces; a<sys->totface; a++, face++) { laplacian_increase_edge_count(sys->edgehash, (*face)[0], (*face)[1]); laplacian_increase_edge_count(sys->edgehash, (*face)[1], (*face)[2]); laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]); } - if(sys->areaweights) - for(a=0, face=sys->faces; a<sys->totface; a++, face++) + if (sys->areaweights) + for (a=0, face=sys->faces; a<sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - for(a=0; a<totvert; a++) { - if(sys->areaweights) { - if(sys->varea[a] != 0.0f) + for (a=0; a<totvert; a++) { + if (sys->areaweights) { + if (sys->varea[a] != 0.0f) sys->varea[a]= 0.5f/sys->varea[a]; } else sys->varea[a]= 1.0f; /* for heat weighting */ - if(sys->heat.H) + if (sys->heat.H) nlMatrixAdd(a, a, sys->heat.H[a]); } - if(sys->storeweights) + if (sys->storeweights) sys->fweights= MEM_callocN(sizeof(float)*3*totface, "LaplacianFWeight"); - for(a=0, face=sys->faces; a<totface; a++, face++) + for (a=0, face=sys->faces; a<totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); MEM_freeN(sys->faces); sys->faces= NULL; - if(sys->varea) { + if (sys->varea) { MEM_freeN(sys->varea); sys->varea= NULL; } @@ -339,11 +339,11 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) static void laplacian_system_delete(LaplacianSystem *sys) { - if(sys->verts) MEM_freeN(sys->verts); - if(sys->varea) MEM_freeN(sys->varea); - if(sys->vpinned) MEM_freeN(sys->vpinned); - if(sys->faces) MEM_freeN(sys->faces); - if(sys->fweights) MEM_freeN(sys->fweights); + if (sys->verts) MEM_freeN(sys->verts); + if (sys->varea) MEM_freeN(sys->varea); + if (sys->vpinned) MEM_freeN(sys->vpinned); + if (sys->faces) MEM_freeN(sys->faces); + if (sys->fweights) MEM_freeN(sys->fweights); nlDeleteContext(sys->context); MEM_freeN(sys); @@ -356,9 +356,9 @@ void laplacian_begin_solve(LaplacianSystem *sys, int index) if (!sys->nlbegun) { nlBegin(NL_SYSTEM); - if(index >= 0) { - for(a=0; a<sys->totvert; a++) { - if(sys->vpinned[a]) { + if (index >= 0) { + for (a=0; a<sys->totvert; a++) { + if (sys->vpinned[a]) { nlSetVariable(0, a, sys->verts[a][index]); nlLockVariable(a); } @@ -415,9 +415,9 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray mul_v3_v3fl(dir, data->vec, hit->dist); - if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) { + if (isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) { normal_tri_v3(n, verts[mf->v1], verts[mf->v2], verts[mf->v3]); - if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + if (lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { hit->index = index; hit->dist *= lambda; } @@ -425,9 +425,9 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray mul_v3_v3fl(dir, data->vec, hit->dist); - if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) { + if (isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) { normal_tri_v3(n, verts[mf->v1], verts[mf->v3], verts[mf->v4]); - if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + if (lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { hit->index = index; hit->dist *= lambda; } @@ -446,7 +446,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6); sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces"); - for(a=0; a<totface; a++) { + for (a=0; a<totface; a++) { MFace *mf = mface+a; float bb[6]; @@ -454,7 +454,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) DO_MINMAX(verts[mf->v1], bb, bb+3); DO_MINMAX(verts[mf->v2], bb, bb+3); DO_MINMAX(verts[mf->v3], bb, bb+3); - if(mf->v4) { + if (mf->v4) { DO_MINMAX(verts[mf->v4], bb, bb+3); } @@ -464,7 +464,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) sys->heat.vface[mf->v1]= mf; sys->heat.vface[mf->v2]= mf; sys->heat.vface[mf->v3]= mf; - if(mf->v4) sys->heat.vface[mf->v4]= mf; + if (mf->v4) sys->heat.vface[mf->v4]= mf; } BLI_bvhtree_balance(sys->heat.bvhtree); @@ -479,13 +479,13 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) int visible; mface= sys->heat.vface[vertex]; - if(!mface) + if (!mface) return 1; data.sys= sys; copy_v3_v3(data.start, sys->heat.verts[vertex]); - if(sys->heat.root) /* bone */ + if (sys->heat.root) /* bone */ closest_to_line_segment_v3(end, data.start, sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ @@ -509,7 +509,7 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) float closest[3], d[3], dist, cosine; /* compute euclidian distance */ - if(sys->heat.root) /* bone */ + if (sys->heat.root) /* bone */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ @@ -530,8 +530,8 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) dist= heat_source_distance(sys, vertex, source); - if(dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) - if(heat_ray_source_visible(sys, vertex, source)) + if (dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) + if (heat_ray_source_visible(sys, vertex, source)) return 1; return 0; @@ -545,24 +545,24 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) mindist= 1e10; /* compute minimum distance */ - for(j=0; j<sys->heat.numsource; j++) { + for (j=0; j<sys->heat.numsource; j++) { dist= heat_source_distance(sys, vertex, j); - if(dist < mindist) + if (dist < mindist) mindist= dist; } sys->heat.mindist[vertex]= mindist; /* count number of sources with approximately this minimum distance */ - for(j=0; j<sys->heat.numsource; j++) - if(heat_source_closest(sys, vertex, j)) + for (j=0; j<sys->heat.numsource; j++) + if (heat_source_closest(sys, vertex, j)) numclosest++; sys->heat.p[vertex]= (numclosest > 0)? 1.0f/numclosest: 0.0f; /* compute H entry */ - if(numclosest > 0) { + if (numclosest > 0) { mindist= maxf(mindist, 1e-4f); h= numclosest*C_WEIGHT/(mindist*mindist); } @@ -579,7 +579,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) sys->heat.vnors= MEM_callocN(sizeof(float)*3*sys->totvert, "HeatVNors"); - for(a=0, face=sys->faces; a<sys->totface; a++, face++) { + for (a=0, face=sys->faces; a<sys->totface; a++, face++) { v1= (*face)[0]; v2= (*face)[1]; v3= (*face)[2]; @@ -591,7 +591,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) add_v3_v3(sys->heat.vnors[v3], fnor); } - for(a=0; a<sys->totvert; a++) + for (a=0; a<sys->totvert; a++) normalize_v3(sys->heat.vnors[a]); } @@ -608,19 +608,19 @@ static void heat_laplacian_create(LaplacianSystem *sys) sys->heat.p= MEM_callocN(sizeof(float)*totvert, "HeatP"); /* add verts and faces to laplacian */ - for(a=0; a<totvert; a++) + for (a=0; a<totvert; a++) laplacian_add_vertex(sys, sys->heat.verts[a], 0); - for(a=0, mf=mface; a<totface; a++, mf++) { + for (a=0, mf=mface; a<totface; a++, mf++) { laplacian_add_triangle(sys, mf->v1, mf->v2, mf->v3); - if(mf->v4) + if (mf->v4) laplacian_add_triangle(sys, mf->v1, mf->v3, mf->v4); } /* for distance computation in set_H */ heat_calc_vnormals(sys); - for(a=0; a<totvert; a++) + for (a=0; a<totvert; a++) heat_set_H(sys, a); } @@ -639,10 +639,10 @@ static float heat_limit_weight(float weight) { float t; - if(weight < WEIGHT_LIMIT_END) { + if (weight < WEIGHT_LIMIT_END) { return 0.0f; } - else if(weight < WEIGHT_LIMIT_START) { + else if (weight < WEIGHT_LIMIT_START) { t= (weight - WEIGHT_LIMIT_END)/(WEIGHT_LIMIT_START - WEIGHT_LIMIT_END); return t*WEIGHT_LIMIT_START; } @@ -667,15 +667,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str= NULL; /* count triangles and create mask */ - if( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + if ( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) || (use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask"); } - for(a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { + for (a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ - if(use_vert_sel) { + if (use_vert_sel) { for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { if (use_vert_sel) { mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; @@ -694,9 +694,9 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* bone heat needs triangulated faces */ BKE_mesh_tessface_ensure(me); - for(tottri = 0, a = 0, mf = me->mface; a < me->totface; mf++, a++) { + for (tottri = 0, a = 0, mf = me->mface; a < me->totface; mf++, a++) { tottri++; - if(mf->v4) tottri++; + if (mf->v4) tottri++; } /* create laplacian */ @@ -715,15 +715,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, laplacian_system_construct_end(sys); - if(dgroupflip) { + if (dgroupflip) { vertsflipped = MEM_callocN(sizeof(int)*me->totvert, "vertsflipped"); - for(a=0; a<me->totvert; a++) + for (a=0; a<me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, a); } /* compute weights per bone */ - for(j=0; j<numsource; j++) { - if(!selected[j]) + for (j=0; j<numsource; j++) { + if (!selected[j]) continue; firstsegment= (j == 0 || dgrouplist[j-1] != dgrouplist[j]); @@ -731,13 +731,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, bbone= !(firstsegment && lastsegment); /* clear weights */ - if(bbone && firstsegment) { - for(a=0; a<me->totvert; a++) { - if(mask && !mask[a]) + if (bbone && firstsegment) { + for (a=0; a<me->totvert; a++) { + if (mask && !mask[a]) continue; ED_vgroup_vert_remove(ob, dgrouplist[j], a); - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } } @@ -745,28 +745,28 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* fill right hand side */ laplacian_begin_solve(sys, -1); - for(a=0; a<me->totvert; a++) - if(heat_source_closest(sys, a, j)) + for (a=0; a<me->totvert; a++) + if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, sys->heat.H[a]*sys->heat.p[a]); /* solve */ - if(laplacian_system_solve(sys)) { + if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for(a=0; a<me->totvert; a++) { - if(mask && !mask[a]) + for (a=0; a<me->totvert; a++) { + if (mask && !mask[a]) continue; solution= laplacian_system_get_solution(a); - if(bbone) { - if(solution > 0.0f) + if (bbone) { + if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, WEIGHT_ADD); } else { weight= heat_limit_weight(solution); - if(weight > 0.0f) + if (weight > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, WEIGHT_REPLACE); else @@ -774,15 +774,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } /* do same for mirror */ - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { - if(bbone) { - if(solution > 0.0f) + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { + if (bbone) { + if (solution > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], solution, WEIGHT_ADD); } else { weight= heat_limit_weight(solution); - if(weight > 0.0f) + if (weight > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], weight, WEIGHT_REPLACE); else @@ -791,26 +791,26 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } } - else if(*err_str == NULL) { + else if (*err_str == NULL) { *err_str= "Bone Heat Weighting: failed to find solution for one or more bones"; break; } /* remove too small vertex weights */ - if(bbone && lastsegment) { - for(a=0; a<me->totvert; a++) { - if(mask && !mask[a]) + if (bbone && lastsegment) { + for (a=0; a<me->totvert; a++) { + if (mask && !mask[a]) continue; weight= ED_vgroup_vert_weight(ob, dgrouplist[j], a); weight= heat_limit_weight(weight); - if(weight <= 0.0f) + if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgrouplist[j], a); - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { weight= ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); weight= heat_limit_weight(weight); - if(weight <= 0.0f) + if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } } @@ -818,8 +818,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } /* free */ - if(vertsflipped) MEM_freeN(vertsflipped); - if(mask) MEM_freeN(mask); + if (vertsflipped) MEM_freeN(vertsflipped); + if (mask) MEM_freeN(mask); heat_system_free(sys); @@ -903,7 +903,7 @@ void rigid_deform_iteration() EditFace *efa; int a, i; - if(!sys) + if (!sys) return; nlMakeCurrent(sys->context); @@ -913,12 +913,12 @@ void rigid_deform_iteration() memset(sys->rigid.R, 0, sizeof(float)*3*3*sys->totvert); memset(sys->rigid.rhs, 0, sizeof(float)*3*sys->totvert); - for(a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { rigid_add_edge_to_R(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_R(sys, efa->v3, efa->v1, sys->fweights[a][1]); - if(efa->v4) { + if (efa->v4) { a++; rigid_add_edge_to_R(sys, efa->v1, efa->v3, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v3, efa->v4, sys->fweights[a][0]); @@ -926,18 +926,18 @@ void rigid_deform_iteration() } } - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { rigid_orthogonalize_R(sys->rigid.R[a]); eve->tmp.l= a; } /* compute right hand sides for solving */ - for(a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { rigid_add_edge_to_rhs(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v1, sys->fweights[a][1]); - if(efa->v4) { + if (efa->v4) { a++; rigid_add_edge_to_rhs(sys, efa->v1, efa->v3, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v4, sys->fweights[a][0]); @@ -946,19 +946,19 @@ void rigid_deform_iteration() } /* solve for positions, for X,Y and Z separately */ - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { laplacian_begin_solve(sys, i); - for(a=0; a<sys->totvert; a++) - if(!sys->vpinned[a]) + for (a=0; a<sys->totvert; a++) + if (!sys->vpinned[a]) laplacian_add_right_hand_side(sys, a, sys->rigid.rhs[a][i]); - if(laplacian_system_solve(sys)) { - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) + if (laplacian_system_solve(sys)) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) eve->co[i]= laplacian_system_get_solution(a); } else { - if(!sys->rigid.thrownerror) { + if (!sys->rigid.thrownerror) { error("RigidDeform: failed to find solution"); sys->rigid.thrownerror= 1; } @@ -975,15 +975,15 @@ static void rigid_laplacian_create(LaplacianSystem *sys) int a; /* add verts and faces to laplacian */ - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { laplacian_add_vertex(sys, eve->co, eve->pinned); eve->tmp.l= a; } - for(efa=em->faces.first; efa; efa=efa->next) { + for (efa=em->faces.first; efa; efa=efa->next) { laplacian_add_triangle(sys, efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); - if(efa->v4) + if (efa->v4) laplacian_add_triangle(sys, efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); } @@ -997,12 +997,12 @@ void rigid_deform_begin(EditMesh *em) int a, totvert, totface; /* count vertices, triangles */ - for(totvert=0, eve=em->verts.first; eve; eve=eve->next) + for (totvert=0, eve=em->verts.first; eve; eve=eve->next) totvert++; - for(totface=0, efa=em->faces.first; efa; efa=efa->next) { + for (totface=0, efa=em->faces.first; efa; efa=efa->next) { totface++; - if(efa->v4) totface++; + if (efa->v4) totface++; } /* create laplacian */ @@ -1013,7 +1013,7 @@ void rigid_deform_begin(EditMesh *em) sys->rigid.rhs = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformRHS"); sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) copy_v3_v3(sys->rigid.origco[a], eve->co); sys->areaweights= 0; @@ -1030,19 +1030,19 @@ void rigid_deform_end(int cancel) { LaplacianSystem *sys = RigidDeformSystem; - if(sys) { + if (sys) { EditMesh *em = sys->rigid.mesh; EditVert *eve; int a; - if(cancel) - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) - if(!eve->pinned) + if (cancel) + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + if (!eve->pinned) copy_v3_v3(eve->co, sys->rigid.origco[a]); - if(sys->rigid.R) MEM_freeN(sys->rigid.R); - if(sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); - if(sys->rigid.origco) MEM_freeN(sys->rigid.origco); + if (sys->rigid.R) MEM_freeN(sys->rigid.R); + if (sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); + if (sys->rigid.origco) MEM_freeN(sys->rigid.origco); /* free */ laplacian_system_delete(sys); @@ -1176,10 +1176,10 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* check if it is within the length of the line segment */ sub_v3_v3v3(isectdir, isectco, orig); - if(dot_v3v3(dir, isectdir) < -EPSILON) + if (dot_v3v3(dir, isectdir) < -EPSILON) return 0; - if(dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir)) + if (dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir)) return 0; return 1; @@ -1198,16 +1198,16 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) add_v3_v3v3(end, isec->start, isec->vec); - for(f=0; f<totface; f++, mface++) { + for (f=0; f<totface; f++, mface++) { copy_v3_v3(face[0], mdb->cagecos[mface->v1]); copy_v3_v3(face[1], mdb->cagecos[mface->v2]); copy_v3_v3(face[2], mdb->cagecos[mface->v3]); - if(mface->v4) { + if (mface->v4) { copy_v3_v3(face[3], mdb->cagecos[mface->v4]); hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); - if(hit) { + if (hit) { normal_tri_v3( nor,face[0], face[1], face[2]); } else { @@ -1220,9 +1220,9 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) normal_tri_v3( nor,face[0], face[1], face[2]); } - if(hit) { + if (hit) { len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); - if(len < isec->labda) { + if (len < isec->labda) { isec->labda= len; isec->face = mface; isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f); @@ -1251,7 +1251,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float add_v3_v3v3(end, co2, epsilon); sub_v3_v3v3(isec.vec, end, isec.start); - if(meshdeform_intersect(mdb, &isec)) { + if (meshdeform_intersect(mdb, &isec)) { len= isec.labda; mface=(MFace*)isec.face; @@ -1264,7 +1264,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float isect->co[2]= co1[2] + isec.vec[2]*len; isect->len= len_v3v3(co1, isect->co); - if(isect->len < MESHDEFORM_LEN_THRESHOLD) + if (isect->len < MESHDEFORM_LEN_THRESHOLD) isect->len= MESHDEFORM_LEN_THRESHOLD; isect->v[0]= mface->v1; @@ -1280,7 +1280,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float copy_v3_v3(vert[0], cagecos[mface->v1]); copy_v3_v3(vert[1], cagecos[mface->v2]); copy_v3_v3(vert[2], cagecos[mface->v3]); - if(mface->v4) copy_v3_v3(vert[3], cagecos[mface->v4]); + if (mface->v4) copy_v3_v3(vert[3], cagecos[mface->v4]); interp_weights_poly_v3( isect->uvw,vert, isect->nvert, isect->co); return isect; @@ -1295,7 +1295,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) float outside[3], start[3], dir[3]; int i; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0]; outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; @@ -1305,7 +1305,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) normalize_v3(dir); isect = meshdeform_ray_tree_intersect(mdb, start, outside); - if(isect && !isect->facing) + if (isect && !isect->facing) return 1; } @@ -1322,11 +1322,11 @@ static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; - if(x < 0 || x >= mdb->size) + if (x < 0 || x >= mdb->size) return -1; - if(y < 0 || y >= mdb->size) + if (y < 0 || y >= mdb->size) return -1; - if(z < 0 || z >= mdb->size) + if (z < 0 || z >= mdb->size) return -1; return x + y*size + z*size*size; @@ -1353,14 +1353,14 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int meshdeform_cell_center(mdb, x, y, z, 0, center); /* check each outgoing edge for intersection */ - for(i=1; i<=6; i++) { - if(meshdeform_index(mdb, x, y, z, i) == -1) + for (i=1; i<=6; i++) { + if (meshdeform_index(mdb, x, y, z, i) == -1) continue; meshdeform_cell_center(mdb, x, y, z, i, ncenter); isect= meshdeform_ray_tree_intersect(mdb, center, ncenter); - if(isect) { + if (isect) { mdb->boundisect[a][i-1]= isect; mdb->tag[a]= MESHDEFORM_TAG_BOUNDARY; } @@ -1380,18 +1380,18 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) stacksize= 1; /* floodfill exterior tag */ - while(stacksize > 0) { + while (stacksize > 0) { a= stack[--stacksize]; xyz[2]= a/(size*size); xyz[1]= (a - xyz[2]*size*size)/size; xyz[0]= a - xyz[1]*size - xyz[2]*size*size; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { b= meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); - if(b != -1) { - if(tag[b] == MESHDEFORM_TAG_UNTYPED || + if (b != -1) { + if (tag[b] == MESHDEFORM_TAG_UNTYPED || (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i-1])) { tag[b]= MESHDEFORM_TAG_EXTERIOR; stack[stacksize++]= b; @@ -1401,23 +1401,23 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) } /* other cells are interior */ - for(a=0; a<size*size*size; a++) - if(tag[a]==MESHDEFORM_TAG_UNTYPED) + for (a=0; a<size*size*size; a++) + if (tag[a]==MESHDEFORM_TAG_UNTYPED) tag[a]= MESHDEFORM_TAG_INTERIOR; #if 0 { int tb, ti, te, ts; tb= ti= te= ts= 0; - for(a=0; a<size*size*size; a++) - if(tag[a]==MESHDEFORM_TAG_BOUNDARY) + for (a=0; a<size*size*size; a++) + if (tag[a]==MESHDEFORM_TAG_BOUNDARY) tb++; - else if(tag[a]==MESHDEFORM_TAG_INTERIOR) + else if (tag[a]==MESHDEFORM_TAG_INTERIOR) ti++; - else if(tag[a]==MESHDEFORM_TAG_EXTERIOR) { + else if (tag[a]==MESHDEFORM_TAG_EXTERIOR) { te++; - if(mdb->semibound[a]) + if (mdb->semibound[a]) ts++; } @@ -1432,8 +1432,8 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect { int a; - for(a=0; a<isect->nvert; a++) - if(isect->v[a] == cagevert) + for (a=0; a<isect->nvert; a++) + if (isect->v[a] == cagevert) return isect->uvw[a]; return 0.0f; @@ -1445,19 +1445,19 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNU float weight, totweight= 0.0f; int i, a, x, y, z; - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { ivec[i]= (int)gridvec[i]; dvec[i]= gridvec[i] - ivec[i]; } - for(i=0; i<8; i++) { - if(i & 1) { x= ivec[0]+1; wx= dvec[0]; } + for (i=0; i<8; i++) { + if (i & 1) { x= ivec[0]+1; wx= dvec[0]; } else { x= ivec[0]; wx= 1.0f-dvec[0]; } - if(i & 2) { y= ivec[1]+1; wy= dvec[1]; } + if (i & 2) { y= ivec[1]+1; wy= dvec[1]; } else { y= ivec[1]; wy= 1.0f-dvec[1]; } - if(i & 4) { z= ivec[2]+1; wz= dvec[2]; } + if (i & 4) { z= ivec[2]+1; wz= dvec[2]; } else { z= ivec[2]; wz= 1.0f-dvec[2]; } CLAMP(x, 0, mdb->size-1); @@ -1470,7 +1470,7 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNU totweight += weight; } - if(totweight > 0.0f) + if (totweight > 0.0f) result /= totweight; return result; @@ -1481,11 +1481,11 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z) int i, a; a= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) return; - for(i=1; i<=6; i++) - if(mdb->boundisect[a][i-1]) + for (i=1; i<=6; i++) + if (mdb->boundisect[a][i-1]) mdb->semibound[a]= 1; } @@ -1497,13 +1497,13 @@ static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, a= meshdeform_index(mdb, x, y, z, 0); /* count weight for neighbor cells */ - for(i=1; i<=6; i++) { - if(meshdeform_index(mdb, x, y, z, i) == -1) + for (i=1; i<=6; i++) { + if (meshdeform_index(mdb, x, y, z, i) == -1) continue; - if(mdb->boundisect[a][i-1]) + if (mdb->boundisect[a][i-1]) weight= 1.0f/mdb->boundisect[a][i-1]->len; - else if(!mdb->semibound[a]) + else if (!mdb->semibound[a]) weight= 1.0f/mdb->width[0]; else weight= 0.0f; @@ -1521,15 +1521,15 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, int x, int y, int z) int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) + if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) continue; isect= mdb->boundisect[acenter][i-1]; @@ -1547,13 +1547,13 @@ static void meshdeform_matrix_add_rhs(MeshDeformBind *mdb, int x, int y, int z, int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a == -1) + if (a == -1) continue; isect= mdb->boundisect[acenter][i-1]; @@ -1573,13 +1573,13 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int int i, a; a= meshdeform_index(mdb, x, y, z, 0); - if(!mdb->semibound[a]) + if (!mdb->semibound[a]) return; mdb->phi[a]= 0.0f; totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { isect= mdb->boundisect[a][i-1]; if (isect) { @@ -1596,21 +1596,21 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) + if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) return; phi= 0.0f; totweight= 0.0f; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a != -1 && mdb->semibound[a]) { + if (a != -1 && mdb->semibound[a]) { phi += mdb->phi[a]; totweight += 1.0f; } } - if(totweight != 0.0f) + if (totweight != 0.0f) mdb->phi[acenter]= phi/totweight; } @@ -1623,10 +1623,10 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind /* setup variable indices */ mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx"); - for(a=0, totvar=0; a<mdb->size3; a++) + for (a=0, totvar=0; a<mdb->size3; a++) mdb->varidx[a]= (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)? -1: totvar++; - if(totvar == 0) { + if (totvar == 0) { MEM_freeN(mdb->varidx); return; } @@ -1645,22 +1645,22 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlBegin(NL_MATRIX); /* build matrix */ - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_cell(mdb, x, y, z); /* solve for each cage vert */ - for(a=0; a<mdb->totcagevert; a++) { - if(a != 0) { + for (a=0; a<mdb->totcagevert; a++) { + if (a != 0) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } /* fill in right hand side and solve */ - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_rhs(mdb, x, y, z, a); nlEnd(NL_MATRIX); @@ -1670,27 +1670,27 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlPrintMatrix(); #endif - if(nlSolveAdvanced(NULL, NL_TRUE)) { - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + if (nlSolveAdvanced(NULL, NL_TRUE)) { + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a); - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a); - for(b=0; b<mdb->size3; b++) { - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) + for (b=0; b<mdb->size3; b++) { + if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) mdb->phi[b]= nlGetVariable(0, mdb->varidx[b]); mdb->totalphi[b] += mdb->phi[b]; } - if(mdb->weights) { + if (mdb->weights) { /* static bind : compute weights for each vertex */ - for(b=0; b<mdb->totvert; b++) { - if(mdb->inside[b]) { + for (b=0; b<mdb->totvert; b++) { + if (mdb->inside[b]) { copy_v3_v3(vec, mdb->vertexcos[b]); gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; @@ -1704,8 +1704,8 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind MDefBindInfluence *inf; /* dynamic bind */ - for(b=0; b<mdb->size3; b++) { - if(mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { + for (b=0; b<mdb->size3; b++) { + if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { inf= BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); inf->vertex= a; inf->weight= mdb->phi[b]; @@ -1727,9 +1727,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind #if 0 /* sanity check */ - for(b=0; b<mdb->size3; b++) - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) - if(fabs(mdb->totalphi[b] - 1.0f) > 1e-4) + for (b=0; b<mdb->size3; b++) + if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) + if (fabs(mdb->totalphi[b] - 1.0f) > 1e-4) printf("totalphi deficiency [%s|%d] %d: %.10f\n", (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR)? "interior": "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif @@ -1751,7 +1751,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* compute bounding box of the cage mesh */ INIT_MINMAX(mdb->min, mdb->max); - for(a=0; a<mdb->totcagevert; a++) + for (a=0; a<mdb->totcagevert; a++) DO_MINMAX(mdb->cagecos[a], mdb->min, mdb->max); /* allocate memory */ @@ -1765,7 +1765,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa mdb->inside= MEM_callocN(sizeof(int)*mdb->totvert, "MDefInside"); - if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) + if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) mdb->dyngrid= MEM_callocN(sizeof(MDefBindInfluence*)*mdb->size3, "MDefDynGrid"); else mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); @@ -1776,11 +1776,11 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* make bounding box equal size in all directions, add padding, and compute * width of the cells */ maxwidth = -1.0f; - for(a=0; a<3; a++) - if(mdb->max[a]-mdb->min[a] > maxwidth) + for (a=0; a<3; a++) + if (mdb->max[a]-mdb->min[a] > maxwidth) maxwidth= mdb->max[a]-mdb->min[a]; - for(a=0; a<3; a++) { + for (a=0; a<3; a++) { center[a]= (mdb->min[a]+mdb->max[a])*0.5f; mdb->min[a]= center[a] - maxwidth*0.5f; mdb->max[a]= center[a] + maxwidth*0.5f; @@ -1796,10 +1796,10 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa progress_bar(0, "Setting up mesh deform system"); totinside= 0; - for(a=0; a<mdb->totvert; a++) { + for (a=0; a<mdb->totvert; a++) { copy_v3_v3(vec, mdb->vertexcos[a]); mdb->inside[a]= meshdeform_inside_cage(mdb, vec); - if(mdb->inside[a]) + if (mdb->inside[a]) totinside++; } @@ -1808,53 +1808,53 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); /* start with all cells untyped */ - for(a=0; a<mdb->size3; a++) + for (a=0; a<mdb->size3; a++) mdb->tag[a]= MESHDEFORM_TAG_UNTYPED; /* detect intersections and tag boundary cells */ - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_add_intersections(mdb, x, y, z); /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_check_semibound(mdb, x, y, z); /* solve */ meshdeform_matrix_solve(mmd, mdb); /* assign results */ - if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { + if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { mmd->totinfluence= 0; - for(a=0; a<mdb->size3; a++) - for(inf=mdb->dyngrid[a]; inf; inf=inf->next) + for (a=0; a<mdb->size3; a++) + for (inf=mdb->dyngrid[a]; inf; inf=inf->next) mmd->totinfluence++; /* convert MDefBindInfluences to smaller MDefInfluences */ mmd->dyngrid= MEM_callocN(sizeof(MDefCell)*mdb->size3, "MDefDynGrid"); mmd->dyninfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefInfluence"); offset= 0; - for(a=0; a<mdb->size3; a++) { + for (a=0; a<mdb->size3; a++) { cell= &mmd->dyngrid[a]; cell->offset= offset; totweight= 0.0f; mdinf= mmd->dyninfluences + cell->offset; - for(inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { + for (inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { mdinf->weight= inf->weight; mdinf->vertex= inf->vertex; totweight += mdinf->weight; cell->totinfluence++; } - if(totweight > 0.0f) { + if (totweight > 0.0f) { mdinf= mmd->dyninfluences + cell->offset; - for(b=0; b<cell->totinfluence; b++, mdinf++) + for (b=0; b<cell->totinfluence; b++, mdinf++) mdinf->weight /= totweight; } @@ -1893,9 +1893,9 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); /* count triangles */ - for(tottri=0, a=0, mf=mface; a<totface; a++, mf++) { + for (tottri=0, a=0, mf=mface; a<totface; a++, mf++) { tottri++; - if(mf->v4) tottri++; + if (mf->v4) tottri++; } /* create laplacian */ @@ -1914,27 +1914,27 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie laplacian_system_construct_end(sys); /* compute weights per bone */ - for(j=0; j<mdb->totcagevert; j++) { + for (j=0; j<mdb->totcagevert; j++) { /* fill right hand side */ laplacian_begin_solve(sys, -1); - for(a=0; a<totvert; a++) - if(heat_source_closest(sys, a, j)) + for (a=0; a<totvert; a++) + if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, sys->heat.H[a]*sys->heat.p[a]); /* solve */ - if(laplacian_system_solve(sys)) { + if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for(a=0; a<totvert; a++) { + for (a=0; a<totvert; a++) { solution= laplacian_system_get_solution(a); weight= heat_limit_weight(solution); - if(weight > 0.0f) + if (weight > 0.0f) mdb->weights[a*mdb->totcagevert + j] = weight; } } - else if(!thrownerror) { + else if (!thrownerror) { error("Mesh Deform Heat Weighting:" " failed to find solution for one or more vertices"); thrownerror= 1; @@ -1971,14 +1971,14 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco copy_m4_m4(mdb.cagemat, cagemat); mvert= mdb.cagedm->getVertArray(mdb.cagedm); - for(a=0; a<mdb.totcagevert; a++) + for (a=0; a<mdb.totcagevert; a++) copy_v3_v3(mdb.cagecos[a], mvert[a].co); - for(a=0; a<mdb.totvert; a++) + for (a=0; a<mdb.totvert; a++) mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a*3); /* solve */ #if 0 - if(mmd->mode == MOD_MDEF_VOLUME) + if (mmd->mode == MOD_MDEF_VOLUME) harmonic_coordinates_bind(scene, mmd, &mdb); else heat_weighting_bind(scene, dm, mmd, &mdb); @@ -1993,7 +1993,7 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco copy_m4_m4(mmd->bindmat, mmd->object->obmat); /* transform bindcagecos to world space */ - for(a=0; a<mdb.totcagevert; a++) + for (a=0; a<mdb.totcagevert; a++) mul_m4_v3(mmd->object->obmat, mmd->bindcagecos+a*3); /* free */ |