From 5da2135eef39ac042a8c4babcac7be375e6903d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 21:35:04 +0000 Subject: code cleanup: double promotion & some style cleanup --- source/blender/modifiers/intern/MOD_boolean_util.c | 10 +++--- source/blender/modifiers/intern/MOD_cloth.c | 2 +- source/blender/modifiers/intern/MOD_collision.c | 6 ++-- source/blender/modifiers/intern/MOD_decimate.c | 4 +-- source/blender/modifiers/intern/MOD_displace.c | 2 +- source/blender/modifiers/intern/MOD_edgesplit.c | 2 +- source/blender/modifiers/intern/MOD_hook.c | 16 +++++----- source/blender/modifiers/intern/MOD_mask.c | 4 ++- source/blender/modifiers/intern/MOD_meshdeform.c | 36 +++++++++++----------- source/blender/modifiers/intern/MOD_mirror.c | 6 ++-- source/blender/modifiers/intern/MOD_solidify.c | 21 +++++++------ source/blender/modifiers/intern/MOD_warp.c | 9 +++--- .../modifiers/intern/MOD_weightvgproximity.c | 14 ++++----- 13 files changed, 69 insertions(+), 63 deletions(-) (limited to 'source/blender/modifiers/intern') diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 711c7e6e4ff..8d6295ee6d4 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -113,7 +113,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) static void VertexIt_Step(CSG_IteratorPtr it) { VertexIt * iterator = (VertexIt *)it; - iterator->pos ++; + iterator->pos++; } static void VertexIt_Reset(CSG_IteratorPtr it) @@ -207,7 +207,7 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) static void FaceIt_Step(CSG_IteratorPtr it) { FaceIt * face_it = (FaceIt *)it; - face_it->pos ++; + face_it->pos++; } static void FaceIt_Reset(CSG_IteratorPtr it) @@ -441,7 +441,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mat_nr = 0; for (a = 0; a < ob1->totcol; a++) { - if (give_current_material(ob1, a+1) == orig_mat) { + if (give_current_material(ob1, a + 1) == orig_mat) { mat_nr = a; break; } @@ -601,7 +601,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) dm_select = mesh_create_derived_view(scene, ob_select, 0); // no modifiers in editmode ?? maxmat= ob->totcol + ob_select->totcol; - mat= (Material**)MEM_mallocN(sizeof(Material*)*maxmat, "NewBooleanMeshMat"); + mat = (Material **)MEM_mallocN(sizeof(Material *) * maxmat, "NewBooleanMeshMat"); /* put some checks in for nice user feedback */ if (dm == NULL || dm_select == NULL) { @@ -632,7 +632,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) /* add materials to object */ for (a = 0; a < totmat; a++) - assign_material(ob_new, mat[a], a+1); + assign_material(ob_new, mat[a], a + 1); MEM_freeN(mat); diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index d5d8439c749..1bc23ab5040 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -113,7 +113,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Ob CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); if (coll_clmd) { DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Cloth Collision"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Cloth Collision"); } } } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 83a366815de..9636104cb06 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -117,7 +117,7 @@ static void deformVerts(ModifierData *md, Object *ob, /* if possible use/create DerivedMesh */ if (derivedData) dm = CDDM_copy(derivedData); - else if (ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); + else if (ob->type == OB_MESH) dm = CDDM_from_mesh(ob->data, ob); if (!ob->pd) { printf("CollisionModifier deformVerts: Should not happen!\n"); @@ -138,7 +138,7 @@ static void deformVerts(ModifierData *md, Object *ob, numverts = dm->getNumVerts (dm); - if ((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics())) { + if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; // check if mesh has changed @@ -148,7 +148,7 @@ static void deformVerts(ModifierData *md, Object *ob, if (collmd->time_xnew == -1000) { /* first time */ collmd->x = dm->dupVertArray(dm); // frame start position - for ( i = 0; i < numverts; i++ ) { + for (i = 0; i < numverts; i++) { // we save global positions mul_m4_v3(ob->obmat, collmd->x[i].co); } diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index f55faf9c183..e1a8e221476 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -140,7 +140,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), /* we assume the decim_faces tells how much to reduce */ while (lod.face_num > numTris*dmd->percent) { - if ( LOD_CollapseEdge(&lod)==0) break; + if ( LOD_CollapseEdge(&lod) == 0) break; } if (lod.vertex_num>2) { @@ -160,7 +160,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), if (lod.vertex_num>2) { mface = CDDM_get_tessfaces(result); - for (a=0; av1 = tri[0]; diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 70294588fd4..4d9b8de061e 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -189,7 +189,7 @@ static void displaceModifier_do( modifier_init_texture(dmd->modifier.scene, dmd->texture); - for (i = 0; i < numVerts; ++i) { + for (i = 0; i < numVerts; i++) { TexResult texres; float delta = 0, strength = dmd->strength; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index def02081be8..3e399707040 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -64,7 +64,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj BMEditMesh *em; BMIter iter; BMEdge *e; - float threshold = cos((emd->split_angle + 0.00001) * M_PI / 180.0); + float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f); em = DM_to_editbmesh(dm, NULL, FALSE); bm = em->bm; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index b115e5bb244..ef3a6d8217e 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -122,7 +122,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, DagNode *curNode = dag_get_node(forest, hmd->object); if (hmd->subtarget[0]) - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier"); + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Hook Modifier"); else dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier"); } @@ -195,9 +195,9 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, for (j = 0; j < numVerts; j++) { if (origindex_ar[j] == *index_pt) { float *co = vertexCos[j]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if (dvert) - fac *= defvert_find_weight(dvert+j, defgrp_index); + fac *= defvert_find_weight(dvert + j, defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); @@ -210,12 +210,12 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } else { /* missing dm or ORIGINDEX */ - for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { + for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { float *co = vertexCos[*index_pt]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if (dvert) - fac *= defvert_find_weight(dvert+(*index_pt), defgrp_index); + fac *= defvert_find_weight(dvert + (*index_pt), defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); @@ -227,13 +227,13 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } else if (dvert) { /* vertex group hook */ - const float fac_orig= hmd->force; + const float fac_orig = hmd->force; for (i = 0; i < max_dvert; i++, dvert++) { float fac; float *co = vertexCos[i]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { fac *= defvert_find_weight(dvert, defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 32376acc553..a8f5f008e0c 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -407,7 +407,9 @@ ModifierTypeInfo modifierType_Mask = { /* structName */ "MaskModifierData", /* structSize */ sizeof(MaskModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_SupportsMapping|eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index aee8dd21903..1bcafc2918e 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -142,24 +142,24 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 size= mmd->dyngridsize; for (i=0; i<3; i++) { - gridvec[i]= (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; - ivec[i]= (int)gridvec[i]; - dvec[i]= gridvec[i] - ivec[i]; + gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; + 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]; } - else { x= ivec[0]; wx= 1.0f-dvec[0]; } + 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]; } - else { y= ivec[1]; wy= 1.0f-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]; } - else { z= ivec[2]; wz= 1.0f-dvec[2]; } + if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } - CLAMP(x, 0, size-1); - CLAMP(y, 0, size-1); - CLAMP(z, 0, size-1); + CLAMP(x, 0, size - 1); + CLAMP(y, 0, size - 1); + CLAMP(z, 0, size - 1); a= x + y*size + z*size*size; weight= wx*wy*wz; @@ -314,7 +314,7 @@ static void meshdeformModifier_do( totweight= 0.0f; zero_v3(co); - for (a=offsets[b]; a 0.0f) { - mul_v3_fl(co, fac/totweight); + mul_v3_fl(co, fac / totweight); mul_m3_v3(icagemat, co); if (G.rt != 527) add_v3_v3(vertexCos[b], co); @@ -394,8 +394,8 @@ void modifier_mdef_compact_influences(ModifierData *md) } /* allocate bind influences */ - mmd->bindinfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefBindInfluence"); - mmd->bindoffsets= MEM_callocN(sizeof(int)*(totvert+1), "MDefBindOffset"); + mmd->bindinfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->totinfluence, "MDefBindInfluence"); + mmd->bindoffsets = MEM_callocN(sizeof(int) * (totvert + 1), "MDefBindOffset"); /* write influences */ totinfluence= 0; @@ -417,8 +417,8 @@ void modifier_mdef_compact_influences(ModifierData *md) weight= weights[a + b*totcagevert]; if (weight > MESHDEFORM_MIN_INFLUENCE) { - mmd->bindinfluences[totinfluence].weight= weight/totweight; - mmd->bindinfluences[totinfluence].vertex= a; + mmd->bindinfluences[totinfluence].weight = weight / totweight; + mmd->bindinfluences[totinfluence].vertex = a; totinfluence++; } } diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 09924b5b0a4..2df0bd17eaf 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -231,10 +231,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, ml2 = ml + mp->loopstart + maxLoops; e = ml2[0].e; - for (j = 0; j < mp->totloop-1; j++) { - ml2[j].e = ml2[j+1].e; + for (j = 0; j < mp->totloop - 1; j++) { + ml2[j].e = ml2[j + 1].e; } - ml2[mp->totloop-1].e = e; + ml2[mp->totloop - 1].e = e; mp->loopstart += maxLoops; } diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index d3e54651eea..71839312cf5 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -478,7 +478,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, sub_v3_v3v3(e1, mvert[ml_next->v].co, mvert[ml->v].co); sub_v3_v3v3(e2, mvert[ml_prev->v].co, mvert[ml->v].co); - angle = M_PI - angle_normalized_v3v3(e1, e2); + angle = (float)M_PI - angle_normalized_v3v3(e1, e2); BLI_array_append(face_angles, angle); } @@ -644,13 +644,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, ml[j].v = ed->v1+numVerts; ml[j++].e = eidx+numEdges; - ml[j].v = ed->v2+numVerts; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v2]; + ml[j].v = ed->v2 + numVerts; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2]; } if (edge_origIndex) { - edge_origIndex[ml[j-3].e] = ORIGINDEX_NONE; - edge_origIndex[ml[j-1].e] = ORIGINDEX_NONE; + edge_origIndex[ml[j - 3].e] = ORIGINDEX_NONE; + edge_origIndex[ml[j - 1].e] = ORIGINDEX_NONE; } /* use the next material index if option enabled */ @@ -667,13 +667,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (crease_inner) { /* crease += crease_inner; without wrapping */ - unsigned char *cr= (unsigned char *)&(medge[numEdges + eidx].crease); - int tcr= *cr + crease_inner; - *cr= tcr > 255 ? 255 : tcr; + unsigned char *cr = (unsigned char *)&(medge[numEdges + eidx].crease); + int tcr = *cr + crease_inner; + *cr = tcr > 255 ? 255 : tcr; } #ifdef SOLIDIFY_SIDE_NORMALS - normal_quad_v3(nor, mvert[ml[j-4].v].co, mvert[ml[j-3].v].co, mvert[ml[j-2].v].co, mvert[ml[j-1].v].co); + normal_quad_v3(nor, mvert[ml[j - 4].v].co, + mvert[ml[j - 3].v].co, + mvert[ml[j - 2].v].co, + mvert[ml[j - 1].v].co); add_v3_v3(edge_vert_nos[ed->v1], nor); add_v3_v3(edge_vert_nos[ed->v2], nor); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 38a93091700..5ee8103630d 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -192,7 +192,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index); - if (wmd->curfalloff==NULL) /* should never happen, but bad lib linking could cause it */ + if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */ wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); invert_m4_m4(obinv, ob->obmat); @@ -229,9 +229,10 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, for (i = 0; i < numVerts; i++) { float *co = vertexCos[i]; - if (wmd->falloff_type==eWarp_Falloff_None || - ((fac=len_v3v3(co, mat_from[3])) < wmd->falloff_radius && (fac=(wmd->falloff_radius-fac)/wmd->falloff_radius)) ) { - + if (wmd->falloff_type == eWarp_Falloff_None || + ((fac = len_v3v3(co, mat_from[3])) < wmd->falloff_radius && + (fac = (wmd->falloff_radius-fac) / wmd->falloff_radius))) + { /* skip if no vert group found */ if (dvert && defgrp_index >= 0) { dv = &dvert[i]; diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index bcfdced4ffd..31cd20e7f97 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -112,7 +112,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], dist_f,loc2trgt) \ schedule(static) #endif - for (i = 0; i < numVerts; ++i) { + for (i = 0; i < numVerts; i++) { float tmp_co[3]; /* Convert the vertex to tree coordinates. */ @@ -319,12 +319,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) { curNode = dag_get_node(forest, wmd->mask_tex_map_obj); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGProximity Modifier"); } if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) - dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGProximity Modifier"); } @@ -546,10 +546,10 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* structName */ "WeightVGProximityModifierData", /* structSize */ sizeof(WeightVGProximityModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - |eModifierTypeFlag_SupportsMapping - |eModifierTypeFlag_SupportsEditmode - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, -- cgit v1.2.3