diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 10:31:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 10:31:57 +0400 |
commit | b340f930ec5639f24e7e2d47fab221fb752b61dd (patch) | |
tree | 0e880a36bb528d133af6d10701fc090716b3b7f8 /source/blender/blenkernel/intern | |
parent | 09dc600839904a198ab4ba3fad62ce58c2d3aa07 (diff) |
style cleanup: changes to brace placement / newlines - for/while/if/switch
Diffstat (limited to 'source/blender/blenkernel/intern')
55 files changed, 778 insertions, 1184 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index f5718974f9f..53e4a973cd4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1272,7 +1272,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV if (f->numVerts != numVerts || memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) + { topologyChanged = 1; + } } if (!f || topologyChanged) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c28958d5b0d..511b4603791 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2279,8 +2279,10 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, * the data we need, rebuild the derived mesh */ if (!em->derivedCage || - (em->lastDataMask & dataMask) != dataMask) + (em->lastDataMask & dataMask) != dataMask) + { editbmesh_build_data(scene, obedit, em, dataMask); + } *final_r = em->derivedFinal; return em->derivedCage; @@ -2292,8 +2294,10 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh * the data we need, rebuild the derived mesh */ if (!em->derivedCage || - (em->lastDataMask & dataMask) != dataMask) + (em->lastDataMask & dataMask) != dataMask) + { editbmesh_build_data(scene, obedit, em, dataMask); + } return em->derivedCage; } @@ -2701,8 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) if (nr_tris_to_pile==1 || nr_tris_to_pile==2) { const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 }; int t; - for ( t=0; t<nr_tris_to_pile; t++ ) - { + for ( t=0; t<nr_tris_to_pile; t++ ) { float f2x_area_uv; float * p0 = verts[indices[t*3+0]]; float * p1 = verts[indices[t*3+1]]; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1ec9f7d8a10..05171a5d9f5 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1350,9 +1350,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* some hair paths might be non-existent so they can't be used for duplication */ if (hair && - ((a < totpart && psys->pathcache[a]->steps < 0) || - (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + ((a < totpart && psys->pathcache[a]->steps < 0) || + (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + { continue; + } if (part->ren_as==PART_DRAW_GR) { /* prevent divide by zero below [#28336] */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 75b9ae59e26..be53e3ddcba 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1250,8 +1250,7 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe FCurve *fcu; /* calculate then execute each curve */ - for (fcu= list->first; fcu; fcu= fcu->next) - { + for (fcu= list->first; fcu; fcu= fcu->next) { /* check if this F-Curve doesn't belong to a muted group */ if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) { /* check if this curve should be skipped */ @@ -1274,8 +1273,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if * the depsgraph requested that this driver be evaluated... */ - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) - { + for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { ChannelDriver *driver= fcu->driver; short ok= 0; @@ -1351,8 +1349,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup return; /* calculate then execute each curve */ - for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) - { + for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) { /* check if this curve should be skipped */ if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) { calculate_fcurve(fcu, ctime); @@ -1968,8 +1965,7 @@ void nladata_flush_channels (ListBase *channels) float value= nec->value; /* write values - see animsys_write_rna_setting() to sync the code */ - switch (RNA_property_type(prop)) - { + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_length(ptr, prop)) RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value)); @@ -2217,7 +2213,9 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c * or be layered on top of existing animation data. * - Drivers should be in the appropriate order to be evaluated without problems... */ - if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated + if ((recalc & ADT_RECALC_DRIVERS) + /* XXX for now, don't check yet, as depsgraph hasn't been updated */ + /* && (adt->recalc & ADT_RECALC_DRIVERS)*/) { animsys_evaluate_drivers(&id_ptr, adt, ctime); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0f3e27a9b6e..931aa2d6242 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1372,7 +1372,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[] /* same as object_mat3_to_rot() */ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) { - switch(pchan->rotmode) { + switch (pchan->rotmode) { case ROT_MODE_QUAT: mat3_to_quat(pchan->quat, mat); break; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a556c99dc7d..fbcabccd2b9 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -962,7 +962,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) set_boid_values(&val, bbd->part->boids, pa); /* go through rules */ - switch(state->ruleset_type) { + switch (state->ruleset_type) { case eBoidRulesetType_Fuzzy: { for (rule = state->rules.first; rule; rule = rule->next) { @@ -1258,7 +1258,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ - switch(bpa->data.mode) { + switch (bpa->data.mode) { case eBoidMode_InAir: { float grav[3]; @@ -1437,7 +1437,7 @@ BoidRule *boid_new_rule(int type) if (type <= 0) return NULL; - switch(type) { + switch (type) { case eBoidRuleType_Goal: case eBoidRuleType_Avoid: rule = MEM_callocN(sizeof(BoidRuleGoalAvoid), "BoidRuleGoalAvoid"); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e7ba09d3959..3df6de2fd24 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -337,7 +337,7 @@ void brush_reset_sculpt(Brush *br) brush_set_defaults(br); brush_curve_preset(br, CURVE_PRESET_SMOOTH); - switch(br->sculpt_tool) { + switch (br->sculpt_tool) { case SCULPT_TOOL_CLAY: br->flag |= BRUSH_FRONTFACE; break; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 009b7ca7f99..df80ce6e87c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -649,8 +649,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES); //Not in cache - if (tree == NULL) - { + if (tree == NULL) { int i; int numEdges= mesh->getNumEdges(mesh); MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); @@ -675,8 +674,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float } } } - else - { + else { // printf("BVHTree is already build, using cached tree\n"); } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index a0c273cf962..97baaad430b 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -191,8 +191,7 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps bvhtree = BLI_bvhtree_new(cloth->numverts, epsilon, 4, 6); // fill tree - for (i = 0; i < cloth->numverts; i++, verts++) - { + for (i = 0; i < cloth->numverts; i++, verts++) { copy_v3_v3(&co[0*3], verts->xold); BLI_bvhtree_insert(bvhtree, i, co, 1); @@ -232,8 +231,7 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26); // fill tree - for (i = 0; i < cloth->numfaces; i++, mfaces++) - { + for (i = 0; i < cloth->numfaces; i++, mfaces++) { copy_v3_v3(&co[0*3], verts[mfaces->v1].xold); copy_v3_v3(&co[1*3], verts[mfaces->v2].xold); copy_v3_v3(&co[2*3], verts[mfaces->v3].xold); @@ -266,10 +264,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving) mfaces = cloth->mfaces; // update vertex position in bvh tree - if (verts && mfaces) - { - for (i = 0; i < cloth->numfaces; i++, mfaces++) - { + if (verts && mfaces) { + for (i = 0; i < cloth->numfaces; i++, mfaces++) { copy_v3_v3(&co[0*3], verts[mfaces->v1].txold); copy_v3_v3(&co[1*3], verts[mfaces->v2].txold); copy_v3_v3(&co[2*3], verts[mfaces->v3].txold); @@ -278,8 +274,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving) copy_v3_v3(&co[3*3], verts[mfaces->v4].txold); // copy new locations into array - if (moving) - { + if (moving) { // update moving positions copy_v3_v3(&co_moving[0*3], verts[mfaces->v1].tx); copy_v3_v3(&co_moving[1*3], verts[mfaces->v2].tx); @@ -319,15 +314,12 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) mfaces = cloth->mfaces; // update vertex position in bvh tree - if (verts && mfaces) - { - for (i = 0; i < cloth->numverts; i++, verts++) - { + if (verts && mfaces) { + for (i = 0; i < cloth->numverts; i++, verts++) { copy_v3_v3(&co[0*3], verts->txold); // copy new locations into array - if (moving) - { + if (moving) { // update moving positions copy_v3_v3(&co_moving[0*3], verts->tx); @@ -558,11 +550,9 @@ void cloth_free_modifier(ClothModifierData *clmd ) cloth = clmd->clothObject; - if ( cloth ) - { + if ( cloth ) { // If our solver provides a free function, call it - if ( solvers [clmd->sim_parms->solver_type].free ) - { + if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); } @@ -574,11 +564,9 @@ void cloth_free_modifier(ClothModifierData *clmd ) cloth->numverts = 0; // Free the springs. - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -628,14 +616,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd ) cloth = clmd->clothObject; - if ( cloth ) - { + if ( cloth ) { if (G.rt > 0) printf("cloth_free_modifier_extern in\n"); // If our solver provides a free function, call it - if ( solvers [clmd->sim_parms->solver_type].free ) - { + if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); } @@ -647,11 +633,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd ) cloth->numverts = 0; // Free the springs. - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -708,8 +692,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte /* inverse matrix is not uptodate... */ invert_m4_m4(ob->imat, ob->obmat); - for (i = 0; i < cloth->numverts; i++) - { + for (i = 0; i < cloth->numverts; i++) { copy_v3_v3 (vertexCos[i], cloth->verts[i].x); mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */ } @@ -749,17 +732,12 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) verts = clothObj->verts; - if (cloth_uses_vgroup(clmd)) - { - for ( i = 0; i < numverts; i++, verts++ ) - { + if (cloth_uses_vgroup(clmd)) { + for ( i = 0; i < numverts; i++, verts++ ) { dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT ); - if ( dvert ) - { - for ( j = 0; j < dvert->totweight; j++ ) - { - if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) - { + if ( dvert ) { + for ( j = 0; j < dvert->totweight; j++ ) { + if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) { verts->goal = dvert->dw [j].weight; /* goalfac= 1.0f; */ /* UNUSED */ @@ -769,22 +747,18 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) */ verts->goal = ( float ) pow ( verts->goal , 4.0f ); - if ( verts->goal >=SOFTGOALSNAP ) - { + if ( verts->goal >=SOFTGOALSNAP ) { verts->flags |= CLOTH_VERT_FLAG_PINNED; } } - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) - { - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) - { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) { + if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) { verts->struct_stiff = dvert->dw [j].weight; verts->shear_stiff = dvert->dw [j].weight; } - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) - { + if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) { verts->bend_stiff = dvert->dw [j].weight; } } @@ -812,8 +786,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d float maxdist = 0; // If we have a clothObject, free it. - if ( clmd->clothObject != NULL ) - { + if ( clmd->clothObject != NULL ) { cloth_free_modifier ( clmd ); if (G.rt > 0) printf("cloth_free_modifier cloth_from_object\n"); @@ -821,8 +794,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d // Allocate a new cloth object. clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" ); - if ( clmd->clothObject ) - { + if ( clmd->clothObject ) { clmd->clothObject->old_solver_type = 255; // clmd->clothObject->old_collision_type = 255; cloth = clmd->clothObject; @@ -851,10 +823,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d verts = clmd->clothObject->verts; // set initial values - for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) - { - if (first) - { + for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) { + if (first) { copy_v3_v3( verts->x, mvert[i].co ); mul_m4_v3( ob->obmat, verts->x ); @@ -891,18 +861,15 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d // has to be happen before springs are build! cloth_apply_vgroup (clmd, dm); - if ( !cloth_build_springs ( clmd, dm ) ) - { + if ( !cloth_build_springs ( clmd, dm ) ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs.")); printf("cloth_free_modifier cloth_build_springs\n"); return 0; } - for ( i = 0; i < dm->getNumVerts(dm); i++) - { - if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) - { + for ( i = 0; i < dm->getNumVerts(dm); i++) { + if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) { cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL); } } @@ -917,8 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) ); - for (i = 0; i < dm->getNumVerts(dm); i++) - { + for (i = 0; i < dm->getNumVerts(dm); i++) { maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f)); } @@ -937,8 +903,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) /* Allocate our vertices. */ clmd->clothObject->numverts = numverts; clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" ); - if ( clmd->clothObject->verts == NULL ) - { + if ( clmd->clothObject->verts == NULL ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts.")); printf("cloth_free_modifier clmd->clothObject->verts\n"); @@ -948,8 +913,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) // save face information clmd->clothObject->numfaces = numfaces; clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" ); - if ( clmd->clothObject->mfaces == NULL ) - { + if ( clmd->clothObject->mfaces == NULL ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces.")); printf("cloth_free_modifier clmd->clothObject->mfaces\n"); @@ -977,8 +941,7 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in Cloth *cloth = clmd->clothObject; ClothSpring *spring = NULL; - if (cloth) - { + if (cloth) { // TODO: look if this spring is already there spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); @@ -1006,11 +969,9 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li { unsigned int i = 0; - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -1021,10 +982,8 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li cloth->springs = NULL; } - if (edgelist) - { - for ( i = 0; i < cloth->numverts; i++ ) - { + if (edgelist) { + for ( i = 0; i < cloth->numverts; i++ ) { BLI_linklist_free ( edgelist[i],NULL ); } @@ -1062,8 +1021,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (!edgelist) return 0; - for ( i = 0; i < numverts; i++ ) - { + for ( i = 0; i < numverts; i++ ) { edgelist[i] = NULL; } @@ -1074,12 +1032,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) edgehash = BLI_edgehash_new(); // structural springs - for ( i = 0; i < numedges; i++ ) - { + for ( i = 0; i < numedges; i++ ) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if ( spring ) - { + if ( spring ) { spring->ij = MIN2(medge[i].v1, medge[i].v2); spring->kl = MAX2(medge[i].v2, medge[i].v1); spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest); @@ -1104,22 +1060,19 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (struct_springs > 0) clmd->sim_parms->avg_spring_len /= struct_springs; - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count); } // shear springs - for ( i = 0; i < numfaces; i++ ) - { + for ( i = 0; i < numfaces; i++ ) { // triangle faces already have shear springs due to structural geometry if ( !mface[i].v4 ) continue; spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1140,8 +1093,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // if ( mface[i].v4 ) --> Quad face spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1162,15 +1114,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (numfaces) { // bending springs search2 = cloth->springs; - for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) - { + for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) { if ( !search2 ) break; tspring2 = search2->link; search = edgelist[tspring2->kl]; - while ( search ) - { + while ( search ) { tspring = search->link; index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) ); @@ -1181,8 +1131,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1212,16 +1161,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) /* of the strands. -jahka */ search = cloth->springs; search2 = search->next; - while (search && search2) - { + while (search && search2) { tspring = search->link; tspring2 = search2->link; if (tspring->ij == tspring2->kl) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1242,13 +1189,12 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) } /* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */ - for ( i = 0; i < numedges; i++ ) // struct springs + for (i = 0; i < numedges; i++) { /* struct springs */ BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL ); - - for ( i = 0; i < numfaces; i++ ) // edge springs - { - if (mface[i].v4) - { + } + + for (i = 0; i < numfaces; i++) { /* edge springs */ + if (mface[i].v4) { BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL ); BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL ); @@ -1258,10 +1204,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) cloth->numsprings = struct_springs + shear_springs + bend_springs; - if ( edgelist ) - { - for ( i = 0; i < numverts; i++ ) - { + if ( edgelist ) { + for ( i = 0; i < numverts; i++ ) { BLI_linklist_free ( edgelist[i],NULL ); } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 5b03f73e120..264a251c317 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -80,8 +80,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev float tv[3] = {0, 0, 0}; unsigned int i = 0; - for ( i = 0; i < collmd->numverts; i++ ) - { + for ( i = 0; i < collmd->numverts; i++ ) { sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co ); VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep ); VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step ); @@ -101,8 +100,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 ); // fill tree - for ( i = 0; i < numfaces; i++, tface++ ) - { + for ( i = 0; i < numfaces; i++, tface++ ) { copy_v3_v3 ( &co[0*3], x[tface->v1].co ); copy_v3_v3 ( &co[1*3], x[tface->v2].co ); copy_v3_v3 ( &co[2*3], x[tface->v3].co ); @@ -128,10 +126,8 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, if ( !bvhtree ) return; - if ( x ) - { - for ( i = 0; i < numfaces; i++, mfaces++ ) - { + if ( x ) { + for ( i = 0; i < numfaces; i++, mfaces++ ) { copy_v3_v3 ( &co[0*3], x[mfaces->v1].co ); copy_v3_v3 ( &co[1*3], x[mfaces->v2].co ); copy_v3_v3 ( &co[2*3], x[mfaces->v3].co ); @@ -139,8 +135,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, copy_v3_v3 ( &co[3*3], x[mfaces->v4].co ); // copy new locations into array - if ( moving && xnew ) - { + if ( moving && xnew ) { // update moving positions copy_v3_v3 ( &co_moving[0*3], xnew[mfaces->v1].co ); copy_v3_v3 ( &co_moving[1*3], xnew[mfaces->v2].co ); @@ -150,8 +145,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, ret = BLI_bvhtree_update_node ( bvhtree, i, co, co_moving, ( mfaces->v4 ? 4 : 3 ) ); } - else - { + else { ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) ); } @@ -465,8 +459,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3 d = ( a * c - b * b ); - if ( ABS ( d ) < (double)ALMOST_ZERO ) - { + if ( ABS ( d ) < (double)ALMOST_ZERO ) { *w1 = *w2 = *w3 = 1.0 / 3.0; return; } @@ -504,8 +497,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { // only handle static collisions here if ( collpair->flag & COLLISION_IN_FUTURE ) continue; @@ -540,8 +532,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM // TODO // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -558,8 +549,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * @@ -587,8 +577,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; - if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -685,10 +674,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -699,10 +686,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, bp2 = face2->v2; bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -717,10 +702,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, continue; } } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -735,10 +718,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, continue; } } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -847,8 +828,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { if (!(collpair->flag & COLLISION_IS_EDGES)) continue; @@ -865,8 +845,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -885,8 +864,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; @@ -906,8 +884,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = collpair->distance; - if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) - { + if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -949,8 +926,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { if (collpair->flag & COLLISION_IS_EDGES) continue; @@ -967,8 +943,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -985,8 +960,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; // 2.0 * @@ -1006,8 +980,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; - if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -1034,8 +1007,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -1052,8 +1024,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; // 2.0 * @@ -1072,8 +1043,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; - if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -1202,10 +1172,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -1216,10 +1184,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree bp2 = face2->v2; bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -1234,10 +1200,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree continue; } } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -1252,10 +1216,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree continue; } } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -1417,10 +1379,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v2; @@ -1431,10 +1391,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, collpair->bp2 = face2->v2; collpair->bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v4; @@ -1448,10 +1406,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, else i++; } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v2; @@ -1465,10 +1421,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, else break; } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v4; @@ -1513,8 +1467,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO ); #endif - if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) - { + if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { normalize_v3_v3( collpair->normal, collpair->vector ); collpair->distance = distance; @@ -2283,14 +2236,12 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis #ifdef WITH_ELTOPO machine_epsilon_offset(clmd->clothObject); - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt, tri_visithash, arena ); } - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, visithash, arena ); } @@ -2298,8 +2249,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis BLI_ghash_free(tri_visithash, NULL, NULL); BLI_memarena_free(arena); #else /* WITH_ELTOPO */ - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt ); } @@ -2323,12 +2273,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision // process all collisions (calculate impulses, TODO: also repulses if distance too short) result = 1; - for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence - { + for ( j = 0; j < 5; j++ ) { /* 5 is just a value that ensures convergence */ result = 0; - if ( collmd->bvhtree ) - { + if ( collmd->bvhtree ) { #ifdef WITH_ELTOPO result += cloth_collision_response_moving(clmd, collmd, collisions, collisions_index); result += cloth_edge_collision_response_moving(clmd, collmd, collisions, collisions_index); @@ -2339,14 +2287,11 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision { #else // apply impulses in parallel - if ( result ) - { + if (result) { #endif - for ( i = 0; i < numverts; i++ ) - { + for (i = 0; i < numverts; i++) { // calculate "velocities" (just xnew = xold + v; no dt in v) - if ( verts[i].impulse_count ) - { + if (verts[i].impulse_count) { VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count ); copy_v3_v3 ( verts[i].impulse, tnull ); verts[i].impulse_count = 0; @@ -2402,8 +2347,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair"); // check all collision objects - for (i = 0; i < numcollobj; i++) - { + for (i = 0; i < numcollobj; i++) { Object *collob= collobjs[i]; CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision); BVHTreeOverlap *overlap = NULL; @@ -2435,8 +2379,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl } rounds++; - for (i = 0; i < numcollobj; i++) - { + for (i = 0; i < numcollobj; i++) { if ( collisions[i] ) MEM_freeN ( collisions[i] ); } @@ -2449,12 +2392,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // verts come from clmd - for ( i = 0; i < numverts; i++ ) - { - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) - { - if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) - { + for ( i = 0; i < numverts; i++ ) { + if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { + if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { continue; } } @@ -2467,10 +2407,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // Test on *simple* selfcollisions //////////////////////////////////////////////////////////// - if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) - { - for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) - { + if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { + for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) { // TODO: add coll quality rounds again BVHTreeOverlap *overlap = NULL; unsigned int result = 0; @@ -2483,14 +2421,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl verts = cloth->verts; - if ( cloth->bvhselftree ) - { - // search for overlapping collision pairs + if ( cloth->bvhselftree ) { + // search for overlapping collision pairs overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result ); // #pragma omp parallel for private(k, i, j) schedule(static) - for ( k = 0; k < result; k++ ) - { + for ( k = 0; k < result; k++ ) { float temp[3]; float length = 0; float mindistance; @@ -2500,8 +2436,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len ); - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) - { + if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) ) { @@ -2514,29 +2449,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue; // check for adjacent points (i must be smaller j) - if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) - { + if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) { continue; } length = normalize_v3( temp ); - if ( length < mindistance ) - { + if ( length < mindistance ) { float correction = mindistance - length; - if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) - { + if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { mul_v3_fl( temp, -correction ); VECADD ( verts[j].tx, verts[j].tx, temp ); } - else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) - { + else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) { mul_v3_fl( temp, correction ); VECADD ( verts[i].tx, verts[i].tx, temp ); } - else - { + else { mul_v3_fl( temp, correction * -0.5 ); VECADD ( verts[j].tx, verts[j].tx, temp ); @@ -2560,12 +2490,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // SELFCOLLISIONS: update velocities //////////////////////////////////////////////////////////// - if ( ret2 ) - { - for ( i = 0; i < cloth->numverts; i++ ) - { - if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) - { + if ( ret2 ) { + for ( i = 0; i < cloth->numverts; i++ ) { + if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) { sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold ); } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 25391a34689..2d5631509b4 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -202,7 +202,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) if (cuma->curve) MEM_freeN(cuma->curve); - switch(preset) { + switch (preset) { case CURVE_PRESET_LINE: cuma->totpoint= 2; break; case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; @@ -214,7 +214,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); - switch(preset) { + switch (preset) { case CURVE_PRESET_LINE: cuma->curve[0].x= clipr->xmin; cuma->curve[0].y= clipr->ymax; @@ -252,10 +252,9 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) case CURVE_PRESET_MID9: { int i; - for (i=0; i < cuma->totpoint; i++) - { - cuma->curve[i].x= i / ((float)cuma->totpoint-1); - cuma->curve[i].y= 0.5; + for (i = 0; i < cuma->totpoint; i++) { + cuma->curve[i].x = i / ((float)cuma->totpoint - 1); + cuma->curve[i].y = 0.5; } } break; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0a6e8a163cc..82a908eaf57 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3439,8 +3439,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr { bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; - if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) - { + if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) { int fail = FALSE; float co[3] = {0.0f, 0.0f, 0.0f}; float no[3] = {0.0f, 0.0f, 0.0f}; @@ -3461,12 +3460,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr unit_m4(ct->matrix); - if (target != NULL) - { + if (target != NULL) { space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat); - switch(scon->shrinkType) - { + switch (scon->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: case MOD_SHRINKWRAP_NEAREST_VERTEX: @@ -3475,8 +3472,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr else bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6); - if (treeData.tree == NULL) - { + if (treeData.tree == NULL) { fail = TRUE; break; } @@ -3506,14 +3502,12 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6); - if (treeData.tree == NULL) - { + if (treeData.tree == NULL) { fail = TRUE; break; } - if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) - { + if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) { fail = TRUE; break; } @@ -3542,8 +3536,7 @@ static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, L bConstraintTarget *ct= targets->first; /* only evaluate if there is a target */ - if (VALID_CONS_TARGET(ct)) - { + if (VALID_CONS_TARGET(ct)) { copy_v3_v3(cob->matrix[3], ct->matrix[3]); } } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index e9dd4d01b0e..7a5b4ef9b24 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -777,7 +777,7 @@ int CTX_data_mode_enum(const bContext *C) Object *obedit= CTX_data_edit_object(C); if (obedit) { - switch(obedit->type) { + switch (obedit->type) { case OB_MESH: return CTX_MODE_EDIT_MESH; case OB_CURVE: diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 9232fe8ec04..e5b2e5f69c7 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -636,7 +636,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s float k; int a; - switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { + switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { case CU_NURB_ENDPOINT: k= 0.0; for (a=1; a <= pnts_order; a++) { @@ -2038,7 +2038,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) { - switch(twist_mode) { + switch (twist_mode) { case CU_TWIST_TANGENT: make_bevel_list_3D_tangent(bl); break; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1514716d717..ee8e57d5a3e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2337,7 +2337,10 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n) const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); if (typeInfo->equal && typeInfo->add && typeInfo->multiply && - typeInfo->initminmax && typeInfo->dominmax) return 1; + typeInfo->initminmax && typeInfo->dominmax) + { + return 1; + } return 0; } @@ -2684,7 +2687,9 @@ int CustomData_verify_versions(struct CustomData *data, int index) if (!typeInfo->defaultname && (index > 0) && data->layers[index-1].type == layer->type) + { keeplayer = 0; /* multiple layers of which we only support one */ + } } if (!keeplayer) { diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 1232177fa10..3e0c947ff4a 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -479,7 +479,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ /* first case; separator . - _ with extensions r R l L */ if (is_char_sep(name[len - 2]) ) { - switch(name[len - 1]) { + switch (name[len - 1]) { case 'l': prefix[len - 1] = 0; strcpy(replace, "r"); @@ -500,7 +500,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ } /* case; beginning with r R l L , with separator after it */ else if (is_char_sep(name[1]) ) { - switch(name[0]) { + switch (name[0]) { case 'l': strcpy(replace, "r"); BLI_strncpy(suffix, name + 1, sizeof(suffix)); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index aa6d42977ca..246c973169e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -462,7 +462,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->parent) { node2 = dag_get_node(dag,ob->parent); - switch(ob->partype) { + switch (ob->partype) { case PARSKEL: dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; @@ -2245,7 +2245,7 @@ static void dag_object_time_update_flags(Object *ob) Curve *cu; Lattice *lt; - switch(ob->type) { + switch (ob->type) { case OB_MESH: me= ob->data; if (me->key) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 01d5d6ef2ad..fcd80698d5c 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -228,7 +228,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface) dl= lb->first; while (dl) { - switch(dl->type) { + switch (dl->type) { case DL_SURF: *totvert+= dl->nr*dl->parts; *totface+= (dl->nr-1)*(dl->parts-1); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 9ce4d68eeed..31544dd5ca0 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -231,13 +231,22 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface) /* checks whether surface's format/type has realtime preview */ int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface) { - if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0; + if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) { + return 0; + } else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 0; - else return 1; + surface->type == MOD_DPAINT_SURFACE_T_WAVE) + { + return 0; + } + else { + return 1; + } + } + else { + return 1; } - else return 1; } /* get currently active surface (in user interface) */ @@ -393,11 +402,15 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface) static int surface_totalSamples(DynamicPaintSurface *surface) { if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ && - surface->flags & MOD_DPAINT_ANTIALIAS) - return (surface->data->total_points*5); + surface->flags & MOD_DPAINT_ANTIALIAS) + { + return (surface->data->total_points * 5); + } if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX && - surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data) + surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data) + { return (surface->data->total_points+surface->data->adj_data->total_targets); + } return surface->data->total_points; } @@ -548,8 +561,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) else base = scene->base.first; - while (base || go) - { + while (base || go) { brushObj = NULL; /* select object */ @@ -559,8 +571,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) else brushObj = base->object; - if (!brushObj) - { + if (!brushObj) { if (surface->brush_group) go = go->next; else base= base->next; continue; @@ -572,12 +583,10 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) base= base->next; md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); - if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { + if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) { DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md; - if (pmd2->brush) - { + if (pmd2->brush) { DynamicPaintBrushSettings *brush = pmd2->brush; if (brush->flags & MOD_DPAINT_USES_VELOCITY) @@ -888,8 +897,10 @@ void surface_freeUnusedData(DynamicPaintSurface *surface) /* free bakedata if not active or surface is baked */ if (!(surface->flags & MOD_DPAINT_ACTIVE) || - (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) + (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) + { free_bakeData(surface->data); + } } void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface) @@ -1219,9 +1230,13 @@ static int surface_usesAdjData(DynamicPaintSurface *surface) { if (surface_usesAdjDistance(surface)) return 1; if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX && - surface->flags & MOD_DPAINT_ANTIALIAS) return 1; - - return 0; + surface->flags & MOD_DPAINT_ANTIALIAS) + { + return 1; + } + else { + return 0; + } } /* initialize surface adjacency data */ @@ -1294,10 +1309,12 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for /* now check if total number of edges+faces for * each vertex is even, if not -> vertex is on mesh edge */ for (i=0; i<sData->total_points; i++) { - if ((temp_data[i]%2) || - temp_data[i] < 4) + if ((temp_data[i] % 2) || + (temp_data[i] < 4)) + { ad->flags[i] |= ADJ_ON_MESH_EDGE; - + } + /* reset temp data */ temp_data[i] = 0; } @@ -1863,8 +1880,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene /* restore canvas derivedmesh if required */ if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE && - surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) + surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) + { canvas_copyDerivedMesh(canvas, dm); + } BKE_ptcache_validate(cache, surface->current_frame); BKE_ptcache_write(&pid, surface->current_frame); @@ -2042,9 +2061,12 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh //printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]); if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) && - (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) || - ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) && - (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) return ((px+neighX[n_index]) + w*(py+neighY[n_index])); + (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) || + ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) && + (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) + { + return ((px+neighX[n_index]) + w*(py+neighY[n_index])); + } /* * Find a point that is relatively at same edge position @@ -2185,11 +2207,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) */ if (!error) { #pragma omp parallel for schedule(static) - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int i, sample; int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2257,8 +2277,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* If collision wasn't found but the face is a quad * do another check for the second half */ - if ((!isInside) && mface[i].v4) - { + if ((!isInside) && mface[i].v4) { /* change d2 to test the other half */ sub_v2_v2v2(d2, tface[i].uv[3], tface[i].uv[0]); // uv3 - uv0 @@ -2330,11 +2349,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) * (To avoid seams on uv island edges) */ #pragma omp parallel for schedule(static) - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2408,11 +2425,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) * When base loop is over convert found neighbor indexes to real ones * Also count the final number of active surface points */ - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2440,11 +2455,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) if (sData->adj_data) { PaintAdjData *ed = sData->adj_data; unsigned int n_pos = 0; - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int i, index = tx+w*ty; if (tempPoints[index].face_index != -1) { @@ -2576,8 +2589,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;} #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */ /* Set values of preferred type */ @@ -2759,8 +2771,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay { float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); - if (dist >= 0 && dist < hit->dist) - { + if (dist >= 0 && dist < hit->dist) { hit->index = index; hit->dist = dist; hit->no[0] = (quad) ? 1.0f : 0.0f; @@ -2799,8 +2810,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float * int vertex, edge; dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, nearest_tmp); - if (dist < nearest->dist) - { + if (dist < nearest->dist) { nearest->index = index; nearest->dist = dist; copy_v3_v3(nearest->co, nearest_tmp); @@ -3188,8 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* check bounding box collision */ if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius)) /* Build a bvh tree from transformed vertices */ - if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) - { + if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) { int c_index; int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2]; @@ -3203,8 +3212,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* loop through cell points and process brush */ #pragma omp parallel for schedule(static) - for (id = 0; id < grid->s_num[c_index]; id++) - { + for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; int ss, samples = bData->s_num[index]; float total_sample = (float)samples; @@ -3220,8 +3228,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, total_sample = gaussianTotal; /* Supersampling */ - for (ss=0; ss<samples; ss++) - { + for (ss=0; ss<samples; ss++) { float ray_start[3], ray_dir[3]; float sample_factor = 0.0f; @@ -3263,8 +3270,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* Check volume collision */ if (brush->collision == MOD_DPAINT_COL_VOLUME || brush->collision == MOD_DPAINT_COL_VOLDIST) - if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) - { + if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) { /* We hit a triangle, now check if collision point normal is facing the point */ /* For optimization sake, hit point normal isn't calculated in ray cast loop */ @@ -3277,8 +3283,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* If ray and hit face normal are facing same direction * hit point is inside a closed mesh. */ - if (dot>=0) - { + if (dot>=0) { float dist = hit.dist; int f_index = hit.index; @@ -3342,8 +3347,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, hit.dist = brush_radius; /* Do a face normal directional raycast, and use that distance */ - if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) - { + if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) { proxDist = hit.dist; madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */ hQuad = (hit.no[0] == 1.0f); @@ -3446,8 +3450,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* * Process hit color and alpha */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) - { + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { float sampleColor[3]; float alpha_factor = 1.0f; @@ -3589,8 +3592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, BLI_begin_threaded_malloc(); /* only continue if particle bb is close enough to canvas bb */ - if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) - { + if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) { int c_index; int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2]; @@ -3603,13 +3605,14 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* check cell bounding box */ if (!grid->s_num[c_index] || - !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range)) + !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range)) + { continue; + } /* loop through cell points */ #pragma omp parallel for schedule(static) - for (id = 0; id < grid->s_num[c_index]; id++) - { + for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; float disp_intersect = 0.0f; float radius = 0.0f; @@ -3714,8 +3717,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, } } - if (strength > 0.001f) - { + if (strength > 0.001f) { float paintColor[4] = {0.0f}; float depth = 0.0f; @@ -3781,8 +3783,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po * Loop through every surface point */ #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v); float colorband[4] = {0.0f}; float strength; @@ -3891,8 +3892,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int if (!bNeighs) return; #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = adj_data->n_num[index]; @@ -3911,8 +3911,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int /* calculate average values (single thread) */ bData->average_dist = 0.0f; - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = adj_data->n_num[index]; @@ -4080,8 +4079,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s if (*force) { #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { float forc[3] = {0}; /* apply force fields */ @@ -4121,8 +4119,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s } /* calculate average values (single thread) */ - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { average_force += (*force)[index*4+3]; } average_force /= sData->total_points; @@ -4171,8 +4168,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index]; @@ -4214,8 +4210,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; float totalAlpha = 0.0f; @@ -4256,8 +4251,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* * Drip Effect */ - if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) - { + if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) { float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*timescale/2.0f; /* Copy current surface to the previous points array to read unmodified values */ memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); @@ -4335,8 +4329,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) if (!prevPoint) return; /* calculate average neigh distance (single thread) */ - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; @@ -4435,8 +4428,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time int index; #pragma omp parallel for schedule(static) - for (index=0; index<sData->total_points; index++) - { + for (index=0; index<sData->total_points; index++) { /* Do drying dissolve effects */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index]; @@ -4651,8 +4643,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc * Prepare each surface point for a new step */ #pragma omp parallel for schedule(static) - for (index=0; index<sData->total_points; index++) - { + for (index=0; index<sData->total_points; index++) { float prev_point[3] = {0.0f, 0.0f, 0.0f}; if (do_velocity_data && !new_bdata) { copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v); @@ -4796,8 +4787,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su else base = scene->base.first; - while (base || go) - { + while (base || go) { brushObj = NULL; /* select object */ if (surface->brush_group) { @@ -4821,12 +4811,10 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* check if target has an active dp modifier */ md = modifiers_findByType(brushObj, eModifierType_DynamicPaint); - if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { + if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) { DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md; /* make sure we're dealing with a brush */ - if (pmd2->brush) - { + if (pmd2->brush) { DynamicPaintBrushSettings *brush = pmd2->brush; BrushMaterials bMats = {0}; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 4f320b41184..c275d4ef0ac 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -129,7 +129,7 @@ PartDeflect *object_add_collision_fields(int type) pd->f_damp = 1.0f; /* set sensible defaults based on type */ - switch(type) { + switch (type) { case PFIELD_VORTEX: pd->shape = PFIELD_SHAPE_PLANE; break; @@ -419,8 +419,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect len = normalize_v3(norm); // check all collision objects - for (col = colls->first; col; col = col->next) - { + for (col = colls->first; col; col = col->next) { CollisionModifierData *collmd = col->collmd; if (col->ob == eff->ob) @@ -506,7 +505,8 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU falloff=0.0f; else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f) falloff=0.0f; - else switch(eff->pd->falloff) { + else { + switch (eff->pd->falloff) { case PFIELD_FALL_SPHERE: falloff*= falloff_func_dist(eff->pd, efd->distance); break; @@ -529,6 +529,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU falloff*= falloff_func_rad(eff->pd, r_fac); break; + } } return falloff; @@ -835,7 +836,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected copy_v3_v3(force, efd->vec_to_point); - switch(pd->forcefield) { + switch (pd->forcefield) { case PFIELD_WIND: copy_v3_v3(force, efd->nor); mul_v3_fl(force, strength * efd->falloff); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index bb8cfe37a88..806d795cc9d 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1655,8 +1655,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) { driver->curval= 0.0f; } - else - { + else { /* this evaluates the expression using Python,and returns its result: * - on errors it reports, then returns 0.0f */ diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index ed5cf5e7924..0b722aabd4c 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -318,8 +318,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* get function pointer to the func to use: * WARNING: must perform special argument validation hereto guard against crashes */ - switch (data->type) - { + switch (data->type) { /* simple ones */ case FCM_GENERATOR_FN_SIN: /* sine wave */ fn= sin; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index b2759f18e9b..cdc923600d7 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -68,8 +68,7 @@ void free_vfont(struct VFont *vf) if (vf == NULL) return; if (vf->data) { - while (vf->data->characters.first) - { + while (vf->data->characters.first) { VChar *che = vf->data->characters.first; while (che->nurbsbase.first) { @@ -136,8 +135,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont) // Try finding the font from font list tmpfnt = ttfdata.first; - while (tmpfnt) - { + while (tmpfnt) { if (tmpfnt->vfont == vfont) break; tmpfnt = tmpfnt->next; @@ -280,7 +278,7 @@ VFont *load_vfont(Main *bmain, const char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); case CU_CHINFO_ITALIC: @@ -397,8 +395,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo nu1 = che->nurbsbase.first; // Create the character - while (nu1) - { + while (nu1) { bezt1 = nu1->bezt; if (bezt1) { nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb"); @@ -822,10 +819,15 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } } else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { - float curofs= 0.0f; - for (i=0; i<=slen; i++) { - for (j=i; (mem[j]) && (mem[j]!='\n') && - (mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++); + float curofs = 0.0f; + for (i = 0; i <= slen; i++) { + for (j=i; (mem[j]) && (mem[j]!='\n') && + (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen); + j++) + { + /* pass */ + } + if ((mem[j]!='\r') && (mem[j]!='\n') && ((chartransdata[j].dobreak!=0))) { if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr]; @@ -833,7 +835,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0; ct++; - } + } } } @@ -950,7 +952,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0); else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr); else { - switch(mode) { + switch (mode) { case FO_CURSUP: lnr= ct->linenr-1; break; case FO_CURSDOWN: lnr= ct->linenr+1; break; case FO_PAGEUP: lnr= ct->linenr-10; break; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index bb51325a6ef..dfe73ae20db 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -581,8 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself) static void IDP_FreeGroup(IDProperty *prop) { IDProperty *loop; - for (loop=prop->data.group.first; loop; loop=loop->next) - { + for (loop=prop->data.group.first; loop; loop=loop->next) { IDP_FreeProperty(loop); } BLI_freelistN(&prop->data.group); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 6e0330f5316..5c9c942cc6c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -578,7 +578,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; - switch(uvtestgrid) { + switch (uvtestgrid) { case 1: BKE_image_buf_fill_checker(rect, rect_float, width, height); break; @@ -929,7 +929,7 @@ char BKE_ftype_to_imtype(const int ftype) int BKE_imtype_is_movie(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_AVIRAW: case R_IMF_IMTYPE_AVIJPEG: case R_IMF_IMTYPE_AVICODEC: @@ -946,7 +946,7 @@ int BKE_imtype_is_movie(const char imtype) int BKE_imtype_supports_zbuf(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_IRIZ: case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ return 1; @@ -956,7 +956,7 @@ int BKE_imtype_supports_zbuf(const char imtype) int BKE_imtype_supports_compress(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_PNG: return 1; } @@ -965,7 +965,7 @@ int BKE_imtype_supports_compress(const char imtype) int BKE_imtype_supports_quality(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_JPEG90: case R_IMF_IMTYPE_JP2: case R_IMF_IMTYPE_AVIJPEG: @@ -979,7 +979,7 @@ char BKE_imtype_valid_channels(const char imtype) char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */ /* alpha */ - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_TARGA: case R_IMF_IMTYPE_IRIS: case R_IMF_IMTYPE_PNG: @@ -995,7 +995,7 @@ char BKE_imtype_valid_channels(const char imtype) } /* bw */ - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_PNG: case R_IMF_IMTYPE_JPEG90: case R_IMF_IMTYPE_TARGA: @@ -1110,8 +1110,11 @@ int BKE_add_image_extension(char *string, const char imtype) } #ifdef WITH_TIFF else if (imtype==R_IMF_IMTYPE_TIFF) { - if (!BLI_testextensie(string, ".tif") && - !BLI_testextensie(string, ".tiff")) extension= ".tif"; + if (!BLI_testextensie(string, ".tif") && + !BLI_testextensie(string, ".tiff")) + { + extension= ".tif"; + } } #endif #ifdef WITH_OPENEXR @@ -1791,7 +1794,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (ima==NULL) return; - switch(signal) { + switch (signal) { case IMA_SIGNAL_FREE: image_free_buffers(ima); if (iuser) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 675c0771140..1441bd7b12b 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -169,12 +169,10 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int hue_step= power_of_2_max_i(width / 8); if (hue_step < 8) hue_step= 8; - for (y= 0; y < height; y++) - { + for (y= 0; y < height; y++) { val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */ - for (x= 0; x < width; x++) - { + for (x= 0; x < width; x++) { hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step); hsv_to_rgb(hue, sat, val, &r, &g, &b); @@ -291,12 +289,10 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_buffer(mono, rect_float, rect, width, height, 4); - for (y= 0; y < height; y+=step) - { + for (y= 0; y < height; y+=step) { text[1]= '1'; - for (x= 0; x < width; x+=step) - { + for (x= 0; x < width; x+=step) { /* hard coded offset */ pen_x = x + 33; pen_y = y + 44; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index a4edc1e531a..b593419db9f 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -178,8 +178,7 @@ static void print_fvector(float m3[3]) DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts) { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { print_fvector(fLongVector[i]); } } @@ -193,8 +192,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts) /* delete long vector */ DO_INLINE void del_lfvector(float (*fLongVector)[3]) { - if (fLongVector != NULL) - { + if (fLongVector != NULL) { MEM_freeN (fLongVector); // cloth_aligned_free(&MEMORY_BASE, fLongVector); } @@ -208,8 +206,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts) DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts) { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { copy_v3_v3(fLongVector[i], vector); } } @@ -223,8 +220,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { mul_fvector_S(to[i], fLongVector[i], scalar); } } @@ -233,8 +229,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts) { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { VECSUBMUL(to[i], fLongVector[i], scalar); } } @@ -258,8 +253,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { VECADD(to[i], fLongVectorA[i], fLongVectorB[i]); } @@ -269,8 +263,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS); } @@ -280,8 +273,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS); } } @@ -289,8 +281,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts) { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS); } @@ -300,8 +291,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f { unsigned int i = 0; - for (i = 0; i < verts; i++) - { + for (i = 0; i < verts; i++) { sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]); } @@ -350,15 +340,12 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3]) unsigned int i, j; float d; - if ((d=det_fmatrix(from))==0) - { + if ((d=det_fmatrix(from)) == 0) { printf("can't build inverse"); exit(0); } - for (i=0;i<3;i++) - { - for (j=0;j<3;j++) - { + for (i=0;i<3;i++) { + for (j=0;j<3;j++) { int i1=(i+1)%3; int i2=(i+2)%3; int j1=(j+1)%3; @@ -535,8 +522,7 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs) /* delete big matrix */ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix) { - if (matrix != NULL) - { + if (matrix != NULL) { MEM_freeN (matrix); } } @@ -554,8 +540,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3]) { unsigned int i; - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { cp_fmatrix(matrix[i].m, m3); } } @@ -567,12 +552,10 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3]) unsigned int i,j; float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; - for (i = 0; i < matrix[0].vcount; i++) - { + for (i = 0; i < matrix[0].vcount; i++) { cp_fmatrix(matrix[i].m, m3); } - for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) - { + for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++) { cp_fmatrix(matrix[j].m, tmatrix); } } @@ -581,8 +564,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3]) DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar) { unsigned int i = 0; - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { mul_fmatrix_S(matrix[i].m, scalar); } } @@ -601,15 +583,13 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector { #pragma omp section { - for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) - { + for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) { muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]); } } #pragma omp section { - for (i = 0; i < from[0].vcount+from[0].scount; i++) - { + for (i = 0; i < from[0].vcount+from[0].scount; i++) { muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]); } } @@ -627,8 +607,7 @@ DO_INLINE void mul_prevfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVec { unsigned int i = 0; - for (i = 0; i < from[0].vcount; i++) - { + for (i = 0; i < from[0].vcount; i++) { mul_fmatrix_fvector(to[from[i].r], from[i].m, fLongVector[from[i].c]); } } @@ -639,8 +618,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } @@ -651,8 +629,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } @@ -663,8 +640,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } @@ -675,8 +651,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } @@ -687,8 +662,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3 unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount; i++) - { + for (i = 0; i < matrix[0].vcount; i++) { sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m); } @@ -699,8 +673,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } @@ -713,8 +686,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo unsigned int i = 0; /* process diagonal elements */ - for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) - { + for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS); } @@ -772,12 +744,10 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) id->dV = create_lfvector(cloth->numverts); id->z = create_lfvector(cloth->numverts); - for (i=0;i<cloth->numverts;i++) - { + for (i=0;i<cloth->numverts;i++) { id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = id->M[i].r = id->M[i].c = i; - if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) - { + if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) { id->S[pinned].pinned = 1; id->S[pinned].c = id->S[pinned].r = i; pinned++; @@ -791,8 +761,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) // init springs search = cloth->springs; - for (i=0;i<cloth->numsprings;i++) - { + for (i=0;i<cloth->numsprings;i++) { spring = search->link; // dFdV_start[i].r = big_I[i].r = big_zero[i].r = @@ -810,8 +779,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) initdiag_bfmatrix(id->bigI, I); - for (i = 0; i < cloth->numverts; i++) - { + for (i = 0; i < cloth->numverts; i++) { copy_v3_v3(id->X[i], verts[i].x); } @@ -823,12 +791,10 @@ int implicit_free (ClothModifierData *clmd) Cloth *cloth; cloth = (Cloth *)clmd->clothObject; - if (cloth) - { + if (cloth) { id = cloth->implicit; - if (id) - { + if (id) { del_bfmatrix(id->A); del_bfmatrix(id->dFdV); del_bfmatrix(id->dFdX); @@ -886,12 +852,10 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb) float tempfb = kb * fb(length, L); float fbstar = cb * (length - L); - if (tempfb < fbstar) - { + if (tempfb < fbstar) { return cb; } - else - { + else { return kb * fbderiv(length, L); } } @@ -900,8 +864,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S) { unsigned int i=0; - for (i=0;i<S[0].vcount;i++) - { + for (i = 0; i < S[0].vcount; i++) { mul_fvector_fmatrix(V[S[i].r], V[S[i].r], S[i].m); } } @@ -936,8 +899,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z s = dot_lfvector(r, r, numverts); starget = s * sqrt(conjgrad_epsilon); - while (s>starget && conjgrad_loopcount < conjgrad_looplimit) - { + while (s>starget && conjgrad_loopcount < conjgrad_looplimit) { // Mul(q,A,d); // q = A*d; mul_bfmatrix_lfvector(q, lA, d); @@ -979,8 +941,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv) // Take only the diagonal blocks of A // #pragma omp parallel for private(i) if (lA[0].vcount > CLOTH_OPENMP_LIMIT) - for (i = 0; i<lA[0].vcount; i++) - { + for (i = 0; i<lA[0].vcount; i++) { // block diagonalizer cp_fmatrix(P[i].m, lA[i].m); inverse_fmatrix(Pinv[i].m, P[i].m); @@ -1255,8 +1216,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, s->flags &= ~CLOTH_SPRING_FLAG_NEEDED; - if (length > ALMOST_ZERO) - { + if (length > ALMOST_ZERO) { /* if (length>L) { @@ -1270,16 +1230,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, */ mul_fvector_S(dir, extent, 1.0f/length); } - else - { + else { mul_fvector_S(dir, extent, 0.0f); } // calculate force of structural + shear springs - if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) - { - if (length > L || no_compress) - { + if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) { + if (length > L || no_compress) { s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->structural; @@ -1337,10 +1294,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, // dfdx_spring(s->dfdx, dir, length, 0.0, k); // dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0))); } - else // calculate force of bending springs - { - if (length < L) - { + else { /* calculate force of bending springs */ + if (length < L) { s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->bending; @@ -1358,10 +1313,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX) { - if (s->flags & CLOTH_SPRING_FLAG_NEEDED) - { - if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) - { + if (s->flags & CLOTH_SPRING_FLAG_NEEDED) { + if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) { sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv); sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv); add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv); @@ -1486,8 +1439,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec } /* gather colliders */ - if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next) - { + if (colliders && collfac > 0.0f) for (col = colliders->first; col; col = col->next) { MVert *loc0 = col->collmd->x; MVert *loc1 = col->collmd->xnew; float vel[3]; @@ -1593,8 +1545,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec /* multiply lF with mass matrix * force = mass * acceleration (in this case: gravity) */ - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { float temp[3]; copy_v3_v3(temp, lF[i]); mul_fmatrix_fvector(lF[i], M[i].m, temp); @@ -1603,8 +1554,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec submul_lfvectorS(lF, lV, spring_air, numverts); /* handle external forces like wind */ - if (effectors) - { + if (effectors) { // 0 = force, 1 = normalized force winvec = create_lfvector(cloth->numverts); @@ -1612,14 +1562,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec printf("winvec: out of memory in implicit.c\n"); // precalculate wind forces - for (i = 0; i < cloth->numverts; i++) - { + for (i = 0; i < cloth->numverts; i++) { pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint); pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL); } - for (i = 0; i < cloth->numfaces; i++) - { + for (i = 0; i < cloth->numfaces; i++) { float trinormal[3]={0,0,0}; // normalized triangle normal float triunnormal[3]={0,0,0}; // not-normalized-triangle normal float tmp[3]={0,0,0}; @@ -1650,8 +1598,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor); // add wind from v4 - if (mfaces[i].v4) - { + if (mfaces[i].v4) { copy_v3_v3(tmp, trinormal); mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal)); VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor); @@ -1692,8 +1639,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec // calculate spring forces search = cloth->springs; - while (search) - { + while (search) { // only handle active springs // if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) {} cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time); @@ -1703,8 +1649,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec // apply spring forces search = cloth->springs; - while (search) - { + while (search) { // only handle active springs // if (((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX); @@ -1836,21 +1781,17 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase Implicit_Data *id = cloth->implicit; int do_extra_solve; - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */ - { - for (i = 0; i < numverts; i++) - { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */ + for (i = 0; i < numverts; i++) { // update velocities with constrained velocities from pinned verts - if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) - { + if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) { sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold); // mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame); } } } - while (step < tf) - { + while (step < tf) { // damping velocity for artistic reasons mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts); @@ -1864,13 +1805,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts); /* move pinned verts to correct position */ - for (i = 0; i < numverts; i++) - { - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) - { - if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) - { - float tvect[3] = {.0,.0,.0}; + for (i = 0; i < numverts; i++) { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { + if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { + float tvect[3] = {0.0f, 0.0f, 0.0f}; sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold); mul_fvector_S(tvect, tvect, step+dt); VECADD(tvect, tvect, verts[i].xold); @@ -1881,14 +1819,12 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase copy_v3_v3(verts[i].txold, id->X[i]); } - if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) - { + if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) { // collisions // itstart(); // update verts to current positions - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { copy_v3_v3(verts[i].tx, id->Xnew[i]); sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold); @@ -1904,8 +1840,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); // copy corrected positions back to simulation - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { // correct velocity again, just to be sure we had to change it due to adaptive collisions sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]); } @@ -1913,11 +1848,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase //if (do_extra_solve) // cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { - if (do_extra_solve) - { + if (do_extra_solve) { if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) continue; @@ -1933,8 +1866,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase // if there were collisions, advance the velocity from v_n+1/2 to v_n+1 - if (do_extra_solve) - { + if (do_extra_solve) { // V = Vnew; cp_lfvector(id->V, id->Vnew, numverts); @@ -1944,8 +1876,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI); } } - else - { + else { // X = Xnew; cp_lfvector(id->X, id->Xnew, numverts); } @@ -1959,16 +1890,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase step += dt; } - for (i = 0; i < numverts; i++) - { - if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) - { + for (i = 0; i < numverts; i++) { + if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) { copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x copy_v3_v3(verts[i].x, verts[i].xconst); copy_v3_v3(verts[i].v, id->V[i]); } - else - { + else { copy_v3_v3(verts[i].txold, id->X[i]); copy_v3_v3(verts[i].x, id->X[i]); copy_v3_v3(verts[i].v, id->V[i]); @@ -1987,8 +1915,7 @@ void implicit_set_positions (ClothModifierData *clmd) unsigned int numverts = cloth->numverts, i; Implicit_Data *id = cloth->implicit; - for (i = 0; i < numverts; i++) - { + for (i = 0; i < numverts; i++) { copy_v3_v3(id->X[i], verts[i].x); copy_v3_v3(id->V[i], verts[i].v); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 7e756e853b1..07839b10ef1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -182,7 +182,7 @@ int id_make_local(ID *id, int test) if (id->flag & LIB_INDIRECT) return 0; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_SCE: return 0; /* not implemented */ case ID_LI: @@ -279,7 +279,7 @@ int id_copy(ID *id, ID **newid, int test) /* conventions: * - make shallow copy, only this ID block * - id.us of the new ID is set to 1 */ - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_SCE: return 0; /* can't be copied from here */ case ID_LI: @@ -368,7 +368,7 @@ int id_unlink(ID *id, int test) Main *mainlib= G.main; ListBase *lb; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_TXT: if (test) return 1; unlink_text(mainlib, (Text*)id); @@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) ListBase *which_libbase(Main *mainlib, short type) { - switch( type ) { + switch ( type ) { case ID_SCE: return &(mainlib->scene); case ID_LI: @@ -589,7 +589,7 @@ static ID *alloc_libblock_notest(short type) { ID *id= NULL; - switch( type ) { + switch ( type ) { case ID_SCE: id= MEM_callocN(sizeof(Scene), "scene"); break; @@ -796,7 +796,7 @@ void free_libblock(ListBase *lb, void *idv) BPY_id_release(id); #endif - switch( GS(id->name) ) { /* GetShort from util.h */ + switch ( GS(id->name) ) { /* GetShort from util.h */ case ID_SCE: free_scene((Scene *)id); break; @@ -1010,8 +1010,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor BLI_dynstr_append(pupds, numstr); /* icon */ - switch(GS(id->name)) - { + switch (GS(id->name)) { case ID_MA: /* fall through */ case ID_TE: /* fall through */ case ID_IM: /* fall through */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 6d44282c60a..21a91b34e8d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -493,7 +493,7 @@ short *give_totcolp(Object *ob) /* same as above but for ID's */ Material ***give_matarar_id(ID *id) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->mat); break; @@ -509,7 +509,7 @@ Material ***give_matarar_id(ID *id) short *give_totcolp_id(ID *id) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->totcol); break; @@ -525,7 +525,7 @@ short *give_totcolp_id(ID *id) static void data_delete_material_index_id(ID *id, short index) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: mesh_delete_material_index((Mesh *)id, index); break; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index c06d796d562..60ccfa2a7cb 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -204,7 +204,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type) ml->s= 2.0; ml->flag= MB_SCALE_RAD; - switch(type) { + switch (type) { case MB_BALL: ml->type = MB_BALL; ml->expx= ml->expy= ml->expz= 1.0; @@ -853,7 +853,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb) count++; } if (count>2) { - switch(count) { + switch (count) { case 3: accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); break; @@ -1179,10 +1179,13 @@ int getedge (EDGELIST *table[], k2=t; } q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)]; - for (; q != NULL; q = q->next) + for (; q != NULL; q = q->next) { if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && q->i2 == i2 && q->j2 == j2 && q->k2 == k2) + { return q->vid; + } + } return -1; } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 59dd7db43da..7509260d503 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -128,18 +128,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 CustomDataLayer *l1, *l2; int i, i1=0, i2=0, tot, j; - for (i=0; i<c1->totlayer; i++) { - if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + for (i = 0; i < c1->totlayer; i++) { + if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i1++; + } } - - for (i=0; i<c2->totlayer; i++) { - if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + + for (i = 0; i < c2->totlayer; i++) { + if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i2++; + } } - + if (i1 != i2) return MESHCMP_CDLAYERS_MISMATCH; @@ -148,12 +152,16 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 i1 = 0; i2 = 0; for (i=0; i < tot; i++) { while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i1++, l1++; + } - while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i2++, l2++; + } if (l1->type == CD_MVERT) { MVert *v1 = l1->data; @@ -3054,10 +3062,13 @@ void mesh_flush_hidden_from_verts(const MVert *mvert, for (i = 0; i < totedge; i++) { MEdge *e = &medge[i]; if (mvert[e->v1].flag & ME_HIDE || - mvert[e->v2].flag & ME_HIDE) + mvert[e->v2].flag & ME_HIDE) + { e->flag |= ME_HIDE; - else + } + else { e->flag &= ~ME_HIDE; + } } for (i = 0; i < totpoly; i++) { MPoly *p = &mpoly[i]; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 9a640bcb8eb..f23578e07d7 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -517,7 +517,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in *height = ibuf->y; if (clip->flag & MCLIP_USE_PROXY) { - switch(user->render_size) { + switch (user->render_size) { case MCLIP_PROXY_RENDER_SIZE_25: (*width) *= 4; (*height) *= 4; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 7580f2eee4d..e2142c393a5 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1017,7 +1017,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm column_vectors_to_mat3(mat, tx, ty, no); - switch(op) { + switch (op) { case APPLY_DISPLACEMENTS: /* Convert displacement to object space * and add to grid points */ diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index 34e0be1de92..23d2f50c3f7 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -57,8 +57,7 @@ BLI_INLINE int left(const float* a, const float* b, const float* c) int polyNumVerts(const unsigned short* p, const int vertsPerPoly) { int i, nv = 0; - for (i=0; i<vertsPerPoly; i++) - { + for (i=0; i<vertsPerPoly; i++) { if (p[i]==0xffff) break; nv++; @@ -71,8 +70,7 @@ int polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* v int j, nv = polyNumVerts(p, vertsPerPoly); if (nv<3) return 0; - for (j=0; j<nv; j++) - { + for (j=0; j<nv; j++) { const float* v = &verts[3*p[j]]; const float* v_next = &verts[3*p[(j+1)%nv]]; const float* v_prev = &verts[3*p[(nv+j-1)%nv]]; @@ -119,8 +117,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, MFace *faces; nverts = dm->getNumVerts(dm); - if (nverts>=0xffff) - { + if (nverts>=0xffff) { printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff); return 0; } @@ -128,8 +125,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, dm->getVertCos(dm, (float(*)[3])verts); //flip coordinates - for (vi=0; vi<nverts; vi++) - { + for (vi=0; vi<nverts; vi++) { SWAP(float, verts[3*vi+1], verts[3*vi+2]); } @@ -137,8 +133,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, nfaces = dm->getNumTessFaces(dm); faces = dm->getTessFaceArray(dm); ntris = nfaces; - for (fi=0; fi<nfaces; fi++) - { + for (fi=0; fi<nfaces; fi++) { MFace* face = &faces[fi]; if (face->v4) ntris++; @@ -149,15 +144,13 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris"); tri = tris; triIdx = 0; - for (fi=0; fi<nfaces; fi++) - { + for (fi=0; fi<nfaces; fi++) { MFace* face = &faces[fi]; tri[3*triIdx+0] = (unsigned short) face->v1; tri[3*triIdx+1] = (unsigned short) face->v3; tri[3*triIdx+2] = (unsigned short) face->v2; trisToFacesMap[triIdx++]=fi; - if (face->v4) - { + if (face->v4) { tri[3*triIdx+0] = (unsigned short) face->v1; tri[3*triIdx+1] = (unsigned short) face->v4; tri[3*triIdx+2] = (unsigned short) face->v3; @@ -187,8 +180,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly"); memset(newPoly, 0xff, sizeof(unsigned short)*capacity); - for (polyidx=0; polyidx<npolys; polyidx++) - { + for (polyidx=0; polyidx<npolys; polyidx++) { size_t i; int j, k; int nv = 0; @@ -202,22 +194,18 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, int adjustedNv; int allBorderTraversed; - for (j=0; j<dtrisNum && btri==-1;j++) - { + for (j=0; j<dtrisNum && btri==-1;j++) { int curpolytri = dtrisBase+j; - for (k=0; k<3; k++) - { + for (k=0; k<3; k++) { unsigned short neighbortri = dtris[curpolytri*3*2+3+k]; - if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) - { + if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) { btri = curpolytri; bedge = k; break; } } } - if (btri==-1 || bedge==-1) - { + if (btri==-1 || bedge==-1) { //can't find triangle with border edge MEM_freeN(traversedTris); MEM_freeN(newPoly); @@ -229,13 +217,10 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, tri = btri; edge = (bedge+1)%3; traversedTris[tri-dtrisBase] = 1; - while (tri!=btri || edge!=bedge) - { + while (tri != btri || edge != bedge) { int neighbortri = dtris[tri*3*2+3+edge]; - if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) - { - if (nv==capacity) - { + if (neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) { + if (nv==capacity) { unsigned short* newPolyBig; capacity += vertsPerPoly; newPolyBig = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPolyBig"); @@ -251,16 +236,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, else { //move to next tri int twinedge = -1; - for (k=0; k<3; k++) - { - if (dtris[neighbortri*3*2+3+k] == tri) - { + for (k=0; k<3; k++) { + if (dtris[neighbortri*3*2+3+k] == tri) { twinedge = k; break; } } - if (twinedge==-1) - { + if (twinedge==-1) { printf("Converting navmesh: Error! Can't find neighbor edge - invalid adjacency info\n"); MEM_freeN(traversedTris); goto returnLabel; @@ -273,8 +255,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, adjustedPoly = MEM_callocN(sizeof(unsigned short)*nv, "buildPolygonsByDetailedMeshes adjustedPoly"); adjustedNv = 0; - for (i=0; i<nv; i++) - { + for (i=0; i<nv; i++) { unsigned short prev = newPoly[(nv+i-1)%nv]; unsigned short cur = newPoly[i]; unsigned short next = newPoly[(i+1)%nv]; @@ -288,17 +269,13 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, nv = adjustedNv; allBorderTraversed = 1; - for (i=0; i<dtrisNum; i++) - { - if (traversedTris[i]==0) - { + for (i=0; i<dtrisNum; i++) { + if (traversedTris[i]==0) { //check whether it has border edges int curpolytri = dtrisBase+i; - for (k=0; k<3; k++) - { + for (k=0; k<3; k++) { unsigned short neighbortri = dtris[curpolytri*3*2+3+k]; - if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) - { + if ( neighbortri==0xffff || dtrisToPolysMap[neighbortri]!=polyidx+1) { allBorderTraversed = 0; break; } @@ -306,10 +283,8 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, } } - if (nv<=vertsPerPoly && allBorderTraversed) - { - for (i=0; i<nv; i++) - { + if (nv<=vertsPerPoly && allBorderTraversed) { + for (i=0; i<nv; i++) { polys[polyidx*vertsPerPoly*2+i] = newPoly[i]; } } @@ -353,8 +328,7 @@ int buildNavMeshData(const int nverts, const float* verts, unsigned short *dtris, *dmeshes, *polys; int *dtrisToPolysMap, *dtrisToTrisMap; - if (!recastData) - { + if (!recastData) { printf("Converting navmesh: Error! Can't find recast custom data\n"); return 0; } @@ -370,17 +344,14 @@ int buildNavMeshData(const int nverts, const float* verts, //search first valid triangle - triangle of convex polygon validTriStart = -1; - for (i=0; i< ntris; i++) - { - if (recastData[trisToFacesMap[trisMapping[i]]]>0) - { + for (i=0; i< ntris; i++) { + if (recastData[trisToFacesMap[trisMapping[i]]]>0) { validTriStart = i; break; } } - if (validTriStart<0) - { + if (validTriStart<0) { printf("Converting navmesh: Error! No valid polygons in mesh\n"); MEM_freeN(trisMapping); return 0; @@ -396,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts, //and reserve memory for adjacency info dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris"); memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris); - for (i=0; i<ndtris; i++) - { + for (i=0; i<ndtris; i++) { memcpy(dtris+3*2*i, tris+3*dtrisToTrisMap[i], sizeof(unsigned short)*3); } @@ -405,11 +375,9 @@ int buildNavMeshData(const int nverts, const float* verts, prevPolyIdx = -1; newPolyIdx = 0; dtrisToPolysMap = MEM_callocN(sizeof(int)*ndtris, "buildNavMeshData dtrisToPolysMap"); - for (i=0; i<ndtris; i++) - { + for (i=0; i<ndtris; i++) { curPolyIdx = recastData[trisToFacesMap[dtrisToTrisMap[i]]]; - if (curPolyIdx!=prevPolyIdx) - { + if (curPolyIdx!=prevPolyIdx) { newPolyIdx++; prevPolyIdx=curPolyIdx; } @@ -426,13 +394,10 @@ int buildNavMeshData(const int nverts, const float* verts, memset(dmeshes, 0, npolys*4*sizeof(unsigned short)); dmesh = NULL; prevpolyidx = 0; - for (i=0; i<ndtris; i++) - { + for (i=0; i<ndtris; i++) { int curpolyidx = dtrisToPolysMap[i]; - if (curpolyidx!=prevpolyidx) - { - if (curpolyidx!=prevpolyidx+1) - { + if (curpolyidx!=prevpolyidx) { + if (curpolyidx!=prevpolyidx+1) { printf("Converting navmesh: Error! Wrong order of detailed mesh faces\n"); return 0; } @@ -476,8 +441,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly, unsigned short *tris=NULL; res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData); - if (!res) - { + if (!res) { printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n"); goto exit; } @@ -485,8 +449,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly, res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap, ndtris, dtris, npolys, dmeshes,polys, vertsPerPoly, dtrisToPolysMap, dtrisToTrisMap); - if (!res) - { + if (!res) { printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n"); goto exit; } @@ -501,12 +464,10 @@ exit: int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx) { int i, res = -1; - for (i=0; i<vertsPerPoly; i++) - { + for (i=0; i<vertsPerPoly; i++) { if (p[i]==0xffff) break; - if (p[i]==vertexIdx) - { + if (p[i] == vertexIdx) { res = i; break; } diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 56fec119cce..5dfeb37b2ee 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -357,7 +357,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) strip->end = (float)ceil((double)info.length * FPS); } - else + else #endif { strip->end = 10.0f; @@ -373,7 +373,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */ /* strip should be referenced as-is */ - strip->scale= 1.0f; + strip->scale = 1.0f; strip->repeat = 1.0f; /* return this strip */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bc9411b7e02..6d3cce6ccfc 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1483,7 +1483,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { - switch(ob->rotmode) { + switch (ob->rotmode) { case ROT_MODE_QUAT: { float dquat[4]; @@ -2025,7 +2025,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); - switch(ob->partype & PARTYPE) { + switch (ob->partype & PARTYPE) { case PAROBJECT: ok= 0; if (par->type==OB_CURVE) { @@ -2260,7 +2260,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) int a; short change= FALSE; - switch(ob->type) { + switch (ob->type) { case OB_CURVE: case OB_FONT: case OB_SURF: @@ -2568,7 +2568,7 @@ void object_handle_update(Scene *scene, Object *ob) } /* includes all keys and modifiers */ - switch(ob->type) { + switch (ob->type) { case OB_MESH: { #if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' @@ -2784,8 +2784,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 int result = 0; int i; - for (i = 0; i < 12 && result == 0; i++) - { + for (i = 0; i < 12 && result == 0; i++) { float lambda; int v1, v2, v3; v1 = triangle_indexes[i][0]; @@ -2812,8 +2811,7 @@ int object_insert_ptcache(Object *ob) BLI_sortlist(&ob->pc_ids, pc_cmp); - for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) - { + for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) { int index = GET_INT_FROM_POINTER(link->data); if (i < index) diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 907de7888cb..5ba1b3d86c3 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -196,15 +196,13 @@ static float Ph(struct Ocean* o, float kx,float kz ) float tmp; float k2 = kx*kx + kz*kz; - if (k2 == 0.0f) - { + if (k2 == 0.0f) { return 0.0f; // no DC component } // damp out the waves going in the direction opposite the wind tmp = (o->_wx * kx + o->_wz * kz)/sqrtf(k2); - if (tmp < 0) - { + if (tmp < 0) { tmp *= o->_damp_reflections; } @@ -421,18 +419,15 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u frac_z) { - if (oc->_do_disp_y) - { + if (oc->_do_disp_y) { ocr->disp[1] = INTERP(oc->_disp_y); } - if (oc->_do_normals) - { + if (oc->_do_normals) { ocr->normal[0] = INTERP(oc->_N_x); ocr->normal[1] = oc->_N_y/*INTERP(oc->_N_y) (MEM01)*/; ocr->normal[2] = INTERP(oc->_N_z); } - if (oc->_do_chop) - { + if (oc->_do_chop) { ocr->disp[0] = INTERP(oc->_disp_x); ocr->disp[2] = INTERP(oc->_disp_z); } @@ -441,8 +436,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u ocr->disp[2] = 0.0; } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz)); } } @@ -474,8 +468,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i*oc->_N+j] : 0.0f; - if (oc->_do_chop) - { + if (oc->_do_chop) { ocr->disp[0] = oc->_disp_x[i*oc->_N+j]; ocr->disp[2] = oc->_disp_z[i*oc->_N+j]; } @@ -484,8 +477,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) ocr->disp[2] = 0.0f; } - if (oc->_do_normals) - { + if (oc->_do_normals) { ocr->normal[0] = oc->_N_x[i*oc->_N+j]; ocr->normal[1] = oc->_N_y/*oc->_N_y[i*oc->_N+j] (MEM01)*/; ocr->normal[2] = oc->_N_z[i*oc->_N+j]; @@ -493,8 +485,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) normalize_v3(ocr->normal); } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]); } @@ -511,12 +502,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount // compute a new htilda #pragma omp parallel for private(i, j) - for (i = 0 ; i < o->_M ; ++i) - { + for (i = 0 ; i < o->_M ; ++i) { // note the <= _N/2 here, see the fftw doco about // the mechanics of the complex->real fft storage - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex exp_param1; fftw_complex exp_param2; fftw_complex conj_param; @@ -541,8 +530,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_disp_y) - { + if (o->_do_disp_y) { // y displacement fftw_execute(o->_disp_y_plan); } @@ -550,13 +538,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_chop) - { + if (o->_do_chop) { // x displacement - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; fftw_complex minus_i; @@ -575,13 +560,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_chop) - { + if (o->_do_chop) { // z displacement - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; fftw_complex minus_i; @@ -600,13 +582,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jxx - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -620,10 +599,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount } fftw_execute(o->_Jxx_plan); - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j < o->_N ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j < o->_N ; ++j) { o->_Jxx[i*o->_N+j] += 1.0; } } @@ -632,13 +609,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jzz - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -651,10 +625,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount } } fftw_execute(o->_Jzz_plan); - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j < o->_N ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j < o->_N ; ++j) { o->_Jzz[i*o->_N+j] += 1.0; } } @@ -663,13 +635,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jxz - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -688,12 +657,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { // fft normals - if (o->_do_normals) - { - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + if (o->_do_normals) { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; init_complex(mul_param, 0.0, -1.0); @@ -709,12 +675,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_normals) - { - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + if (o->_do_normals) { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; init_complex(mul_param, 0.0, -1.0); @@ -757,12 +720,9 @@ static void set_height_normalize_factor(struct Ocean *oc) BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ); - for (i = 0; i < oc->_M; ++i) - { - for (j = 0; j < oc->_N; ++j) - { - if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) - { + for (i = 0; i < oc->_M; ++i) { + for (j = 0; j < oc->_N; ++j) { + if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) { max_h = fabsf(oc->_disp_y[i*oc->_N+j]); } } @@ -851,10 +811,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f /*srand(seed);*/ BLI_srand(seed); - for (i = 0 ; i < o->_M ; ++i) - { - for (j = 0 ; j < o->_N ; ++j) - { + for (i = 0 ; i < o->_M ; ++i) { + for (j = 0 ; j < o->_N ; ++j) { float r1 = gaussRand(); float r2 = gaussRand(); @@ -921,14 +879,12 @@ void BKE_free_ocean_data(struct Ocean *oc) BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE); - if (oc->_do_disp_y) - { + if (oc->_do_disp_y) { fftw_destroy_plan(oc->_disp_y_plan); MEM_freeN(oc->_disp_y); } - if (oc->_do_normals) - { + if (oc->_do_normals) { MEM_freeN(oc->_fft_in_nx); MEM_freeN(oc->_fft_in_nz); fftw_destroy_plan(oc->_N_x_plan); @@ -938,8 +894,7 @@ void BKE_free_ocean_data(struct Ocean *oc) MEM_freeN(oc->_N_z); } - if (oc->_do_chop) - { + if (oc->_do_chop) { MEM_freeN(oc->_fft_in_x); MEM_freeN(oc->_fft_in_z); fftw_destroy_plan(oc->_disp_x_plan); @@ -948,8 +903,7 @@ void BKE_free_ocean_data(struct Ocean *oc) MEM_freeN(oc->_disp_z); } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { MEM_freeN(oc->_fft_in_jxx); MEM_freeN(oc->_fft_in_jzz); MEM_freeN(oc->_fft_in_jxz); @@ -1002,7 +956,7 @@ static void cache_filename(char *string, const char *path, const char *relbase, char cachepath[FILE_MAX]; const char *fname; - switch(type) { + switch (type) { case CACHE_TYPE_FOAM: fname= "foam_"; break; @@ -1043,8 +997,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) if (!och) return; if (och->ibufs_disp) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_disp[f]) { IMB_freeImBuf(och->ibufs_disp[f]); } @@ -1053,8 +1006,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) } if (och->ibufs_foam) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_foam[f]) { IMB_freeImBuf(och->ibufs_foam[f]); } @@ -1063,8 +1015,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) } if (och->ibufs_norm) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_norm[f]) { IMB_freeImBuf(och->ibufs_norm[f]); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index b55033b8493..e0c61fbcc90 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -72,7 +72,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence) if (pf) { oldseek = pf->seek; - switch(whence) { + switch (whence) { case SEEK_CUR: seek = oldseek + offset; break; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 27f5f7d9eb1..f417f9b79fb 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -59,7 +59,7 @@ Paint *paint_get_active(Scene *sce) ToolSettings *ts = sce->toolsettings; if (sce->basact && sce->basact->object) { - switch(sce->basact->object->mode) { + switch (sce->basact->object->mode) { case OB_MODE_SCULPT: return &ts->sculpt->paint; case OB_MODE_VERTEX_PAINT: diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a154a1f8926..febe4277010 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1572,7 +1572,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int if (values==0 || index==-1) return 0.0; - switch(from) { + switch (from) { case PART_FROM_VERT: return values[index]; case PART_FROM_FACE: @@ -1936,7 +1936,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float copy_v3_v3(result, state->co); sub_v3_v3v3(par_vec, par->co, state->co); - switch(type) { + switch (type) { case PART_KINK_CURL: { negate_v3(par_vec); @@ -2846,7 +2846,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache { float cosangle, angle, tangent[3], normal[3], q[4]; - switch(i) { + switch (i) { case 0: /* start from second key */ break; @@ -3778,7 +3778,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; - switch(texco) { + switch (texco) { case TEXCO_GLOB: copy_v3_v3(texvec, par->state.co); break; @@ -3846,7 +3846,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; - switch(texco) { + switch (texco) { case TEXCO_GLOB: copy_v3_v3(texvec, pa->state.co); break; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4ce24953c89..d3644657de7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch pa->num = i = ctx->index[p]; mface = dm->getTessFaceData(dm,i,CD_MFACE); - switch(distr) { + switch (distr) { case PART_DISTR_JIT: if (ctx->jitlevel == 1) { if (mface->v4) @@ -855,13 +855,15 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch } if (intersect==0) pa->foffset=0.0; - else switch(distr) { - case PART_DISTR_JIT: - pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)]; - break; - case PART_DISTR_RAND: - pa->foffset*=BLI_frand(); - break; + else { + switch (distr) { + case PART_DISTR_JIT: + pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)]; + break; + case PART_DISTR_RAND: + pa->foffset *= BLI_frand(); + break; + } } } } @@ -1575,7 +1577,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec) { - switch(avemode) { + switch (avemode) { case PART_AVE_VELOCITY: copy_v3_v3(vec, state->vel); break; @@ -1779,7 +1781,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P if (part->rotmode) { /* create vector into which rotation is aligned */ - switch(part->rotmode) { + switch (part->rotmode) { case PART_ROT_NOR: copy_v3_v3(rot_vec, nor); break; @@ -2141,7 +2143,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) integrator = PART_INT_EULER; - switch(integrator) { + switch (integrator) { case PART_INT_EULER: steps=1; break; @@ -2175,7 +2177,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d /* calculate next state */ add_v3_v3(states[i].vel, impulse); - switch(integrator) { + switch (integrator) { case PART_INT_EULER: madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime); madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime); @@ -2193,7 +2195,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d } break; case PART_INT_RK4: - switch(i) { + switch (i) { case 0: copy_v3_v3(dx[0], states->vel); mul_v3_fl(dx[0], dtime); @@ -2859,7 +2861,7 @@ static float collision_point_distance_with_normal(float p[3], ParticleCollisionE if (fac >= 0.f) collision_interpolate_element(pce, 0.f, fac, col); - switch(pce->tot) { + switch (pce->tot) { case 1: { sub_v3_v3v3(nor, p, pce->x0); @@ -2884,7 +2886,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce { collision_interpolate_element(pce, 0.f, fac, col); - switch(pce->tot) { + switch (pce->tot) { case 1: { sub_v3_v3v3(co, p, pce->x0); @@ -3833,7 +3835,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL); /* initialize physics type specific stuff */ - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_BOIDS: { ParticleTarget *pt = psys->targets.first; @@ -3908,7 +3910,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) pa->state.time = -1.f; } - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_NEWTON: { LOOP_DYNAMIC_PARTICLES { @@ -4499,7 +4501,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) /* setup necessary physics type dependent additional data if it doesn't yet exist */ psys_prepare_physics(&sim); - switch(part->type) { + switch (part->type) { case PART_HAIR: { /* nothing to do so bail out early */ @@ -4551,7 +4553,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) } default: { - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_NO: case PART_PHYS_KEYED: { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 2812592c69a..39293084dc0 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -433,7 +433,7 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS PTCacheExtra *extra = pm->extradata.first; for (; extra; extra=extra->next) { - switch(extra->type) { + switch (extra->type) { case BPHYS_EXTRA_FLUID_SPRINGS: { if (psys->fluid_springs) @@ -690,14 +690,20 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v) /* cache type */ ptcache_file_write(pf, &surface->type, 1, sizeof(int)); - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) - in_len = sizeof(PaintPoint)*total_points; + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + in_len = sizeof(PaintPoint) * total_points; + } else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) - in_len = sizeof(float)*total_points; - else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) - in_len = sizeof(PaintWavePoint)*total_points; - else return 0; + surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + { + in_len = sizeof(float) * total_points; + } + else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { + in_len = sizeof(PaintWavePoint) * total_points; + } + else { + return 0; + } out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); @@ -727,14 +733,20 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) return 0; /* read surface data */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { data_len = sizeof(PaintPoint); + } else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + { data_len = sizeof(float); - else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) + } + else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { data_len = sizeof(PaintWavePoint); - else return 0; + } + else { + return 0; + } ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points); @@ -989,8 +1001,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } else if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; - if (smd->type & MOD_SMOKE_TYPE_DOMAIN) - { + if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md); BLI_addtail(lb, pid); @@ -998,8 +1009,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } else if (md->type == eModifierType_DynamicPaint) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - if (pmd->canvas) - { + if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; for (; surface; surface=surface->next) { @@ -1205,8 +1215,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); #endif #ifdef WITH_LZMA - if (compressed == 2) - { + if (compressed == 2) { size_t sizeOfIt; size_t leni = in_len, leno = len; ptcache_file_read(pf, &size, 1, sizeof(unsigned int)); @@ -1270,8 +1279,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns else ptcache_file_write(pf, in, in_len, sizeof(unsigned char)); - if (compressed == 2) - { + if (compressed == 2) { unsigned int size = sizeOfIt; ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int)); ptcache_file_write(pf, props, size, sizeof(unsigned char)); @@ -2505,16 +2513,14 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) } if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; - if (smd->type & MOD_SMOKE_TYPE_DOMAIN) - { + if (smd->type & MOD_SMOKE_TYPE_DOMAIN) { BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } } if (md->type == eModifierType_DynamicPaint) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - if (pmd->canvas) - { + if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; for (; surface; surface=surface->next) { @@ -2813,8 +2819,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker) PTCacheID *pid2; BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR); for (pid2=pidlist2.first; pid2; pid2=pid2->next) { - if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) - { + if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) { if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) { if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED) BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0); @@ -3246,8 +3251,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) } if (cache->flag & PTCACHE_DISK_CACHE) { - if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) - { + if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) { int totpoint = pid->totpoint(pid->calldata, 0); if (cache->totpoint > totpoint) diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 066de61575d..e7247be7f51 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -99,7 +99,7 @@ void init_property(bProperty *prop) prop->data= 0; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: case GPROP_FLOAT: @@ -206,7 +206,7 @@ int compare_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ float fvalue, ftest; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: if (BLI_strcasecmp(str, "true")==0) { if (prop->data==1) return 0; @@ -242,7 +242,7 @@ void set_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: if (BLI_strcasecmp(str, "true")==0) prop->data= 1; else if (BLI_strcasecmp(str, "false")==0) prop->data= 0; @@ -266,7 +266,7 @@ void add_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: prop->data+= atoi(str); @@ -288,7 +288,7 @@ void set_property_valstr(bProperty *prop, char *str) if (str == NULL) return; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: sprintf(str, "%d", prop->data); diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index b3e288dfc74..a7df6b10f06 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -43,7 +43,7 @@ static const char *report_type_str(int type) { - switch(type) { + switch (type) { case RPT_DEBUG: return "Debug"; case RPT_INFO: return "Info"; case RPT_OPERATOR: return "Operator"; diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 8123cbf3f0b..b5bb6b76c61 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -110,7 +110,7 @@ void init_sensor(bSensor *sens) sens->data= NULL; sens->pulse = 0; - switch(sens->type) { + switch (sens->type) { case SENS_ALWAYS: sens->pulse = 0; break; @@ -272,7 +272,7 @@ void init_controller(bController *cont) if (cont->data) MEM_freeN(cont->data); cont->data= NULL; - switch(cont->type) { + switch (cont->type) { case CONT_EXPRESSION: cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont"); break; @@ -400,7 +400,7 @@ void init_actuator(bActuator *act) if (act->data) MEM_freeN(act->data); act->data= NULL; - switch(act->type) { + switch (act->type) { case ACT_ACTION: case ACT_SHAPEACTION: act->data= MEM_callocN(sizeof(bActionActuator), "actionact"); @@ -647,7 +647,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) sens= obt->sensors.first; while (sens) { - switch(sens->type) { + switch (sens->type) { case SENS_MESSAGE: ms= sens->data; if (ms->fromObject==ob) ms->fromObject= NULL; @@ -657,7 +657,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) act= obt->actuators.first; while (act) { - switch(act->type) { + switch (act->type) { case ACT_CAMERA: ca= act->data; if (ca->ob==ob) ca->ob= NULL; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 8015e53e4c9..d3eade834e6 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2112,7 +2112,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out yt += (yo / 2.0f); //interpolate - switch(interpolation) { + switch (interpolation) { case 0: neareast_interpolation(ibuf1,out, xt,yt,xi,yi); break; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2d4397d16cd..1c06f1da018 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3099,13 +3099,17 @@ int seqbase_isolated_sel_check(ListBase *seqbase) if ( (seq->seq1 && (seq->seq1->flag & SELECT) == 0) || (seq->seq2 && (seq->seq2->flag & SELECT) == 0) || (seq->seq3 && (seq->seq3->flag & SELECT) == 0) ) + { return FALSE; + } } else { if ( (seq->seq1 && (seq->seq1->flag & SELECT)) || (seq->seq2 && (seq->seq2->flag & SELECT)) || (seq->seq3 && (seq->seq3->flag & SELECT)) ) + { return FALSE; + } } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 4006837efd6..e201209ec3f 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -146,8 +146,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6)); - if (treeData.tree == NULL) - { + if (treeData.tree == NULL) { OUT_OF_MEMORY(); return; } @@ -158,8 +157,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static) #endif - for (i = 0; i<calc->numVerts; ++i) - { + for (i = 0; i<calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -189,8 +187,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) //Found the nearest vertex - if (nearest.index != -1) - { + if (nearest.index != -1) { //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position float dist = sasqrt(nearest.dist); if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist; @@ -224,8 +221,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa memcpy( &hit_tmp, hit, sizeof(hit_tmp) ); //Apply space transform (TODO readjust dist) - if (transf) - { + if (transf) { copy_v3_v3( tmp_co, vert ); space_transform_apply( transf, tmp_co ); co = tmp_co; @@ -298,8 +294,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) //Prepare data to retrieve the direction in which we should project each vertex - if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) - { + if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { if (calc->vert == NULL) return; } else { @@ -316,8 +311,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) return; } - if (calc->smd->auxTarget) - { + if (calc->smd->auxTarget) { auxMesh = object_get_derived_final(calc->smd->auxTarget); if (!auxMesh) return; @@ -332,16 +326,14 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for private(i,hit) schedule(static) #endif - for (i = 0; i<calc->numVerts; ++i) - { + for (i = 0; i<calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3], tmp_no[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); if (weight == 0.0f) continue; - if (calc->vert) - { + if (calc->vert) { /* calc->vert contains verts from derivedMesh */ /* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */ /* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */ @@ -364,8 +356,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that //Project over positive direction of axis - if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) - { + if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) { if (auxData.tree) normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); @@ -374,8 +365,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } //Project over negative direction of axis - if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) - { + if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) { float inv_no[3]; negate_v3_v3(inv_no, tmp_no); @@ -386,8 +376,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } - if (hit.index != -1) - { + if (hit.index != -1) { madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist); interp_v3_v3v3(co, co, hit.co, weight); } @@ -414,8 +403,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) //Create a bvh-tree of the given target BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6)); - if (treeData.tree == NULL) - { + if (treeData.tree == NULL) { OUT_OF_MEMORY(); return; } @@ -429,8 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) #endif - for (i = 0; i<calc->numVerts; ++i) - { + for (i = 0; i<calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -458,10 +445,8 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData); //Found the nearest vertex - if (nearest.index != -1) - { - if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) - { + if (nearest.index != -1) { + if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) { //Make the vertex stay on the front side of the face madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist); } @@ -511,8 +496,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM } - if (smd->target) - { + if (smd->target) { calc.target = object_get_derived_final(smd->target); //TODO there might be several "bugs" on non-uniform scales matrixs @@ -528,28 +512,24 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name); - if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) - { + if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) { //Setup arrays to get vertexs positions, normals and deform weights calc.vert = dm->getVertDataArray(dm, CD_MVERT); calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); //Using vertexs positions/normals as if a subsurface was applied - if (smd->subsurfLevels) - { + if (smd->subsurfLevels) { SubsurfModifierData ssmd= {{NULL}}; ssmd.subdivType = ME_CC_SUBSURF; //catmull clark ssmd.levels = smd->subsurfLevels; //levels ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT)); - if (ss_mesh) - { + if (ss_mesh) { calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); - if (calc.vert) - { - //TRICKY: this code assumes subsurface will have the transformed original vertices - //in their original order at the end of the vert array. + if (calc.vert) { + /* TRICKY: this code assumes subsurface will have the transformed original vertices + * in their original order at the end of the vert array. */ calc.vert = calc.vert + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm); } } @@ -562,8 +542,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM //Projecting target defined - lets work! if (calc.target) { - switch(smd->shrinkType) - { + switch (smd->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: BENCH(shrinkwrap_calc_nearest_surface_point(&calc)); break; diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 71ea85de716..32681c3a041 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -44,8 +44,7 @@ void freeSketch(SK_Sketch *sketch) { SK_Stroke *stk, *next; - for (stk = sketch->strokes.first; stk; stk = next) - { + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; sk_freeStroke(stk); @@ -119,8 +118,7 @@ SK_Stroke* sk_createStroke(void) void sk_shrinkStrokeBuffer(SK_Stroke *stk) { - if (stk->nb_points < stk->buf_size) - { + if (stk->nb_points < stk->buf_size) { SK_Point *old_points = stk->points; stk->buf_size = stk->nb_points; @@ -135,8 +133,7 @@ void sk_shrinkStrokeBuffer(SK_Stroke *stk) void sk_growStrokeBuffer(SK_Stroke *stk) { - if (stk->nb_points == stk->buf_size) - { + if (stk->nb_points == stk->buf_size) { SK_Point *old_points = stk->points; stk->buf_size *= 2; @@ -151,12 +148,10 @@ void sk_growStrokeBuffer(SK_Stroke *stk) void sk_growStrokeBufferN(SK_Stroke *stk, int n) { - if (stk->nb_points + n > stk->buf_size) - { + if (stk->nb_points + n > stk->buf_size) { SK_Point *old_points = stk->points; - while (stk->nb_points + n > stk->buf_size) - { + while (stk->nb_points + n > stk->buf_size) { stk->buf_size *= 2; } @@ -202,8 +197,7 @@ void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, in sk_growStrokeBufferN(stk, len - size); - if (len != size) - { + if (len != size) { int tail_size = stk->nb_points - end + 1; memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point)); @@ -218,8 +212,7 @@ void sk_trimStroke(SK_Stroke *stk, int start, int end) { int size = end - start + 1; - if (start > 0) - { + if (start > 0) { memmove(stk->points, stk->points + start, size * sizeof(SK_Point)); } @@ -253,8 +246,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */ sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */ - for (i = 1; i < total; i++) - { + for (i = 1; i < total; i++) { float delta = (float)i / (float)total; float *p = stk->points[start + 1 + i].p; @@ -269,30 +261,23 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) int i; /* find first exact points outside of range */ - for (;start > 0; start--) - { - if (stk->points[start].type == PT_EXACT) - { + for (;start > 0; start--) { + if (stk->points[start].type == PT_EXACT) { break; } } - for (;end < stk->nb_points - 1; end++) - { - if (stk->points[end].type == PT_EXACT) - { + for (;end < stk->nb_points - 1; end++) { + if (stk->points[end].type == PT_EXACT) { break; } } offset = start + 1; - for (i = start + 1; i < end; i++) - { - if (stk->points[i].type == PT_EXACT) - { - if (offset != i) - { + for (i = start + 1; i < end; i++) { + if (stk->points[i].type == PT_EXACT) { + if (offset != i) { memcpy(stk->points + offset, stk->points + i, sizeof(SK_Point)); } @@ -301,8 +286,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) } /* some points were removes, move end of array */ - if (offset < end) - { + if (offset < end) { int size = stk->nb_points - end; memmove(stk->points + offset, stk->points + end, size * sizeof(SK_Point)); stk->nb_points = offset + size; @@ -323,8 +307,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) project_v3_v3v3(normal, distance, normal); limit = normalize_v3(normal); - for (i = 1; i < total - 1; i++) - { + for (i = 1; i < total - 1; i++) { float d = limit * i / total; float offset[3]; float *p = stk->points[start + i].p; @@ -342,8 +325,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk) { - if (sketch->active_stroke == stk) - { + if (sketch->active_stroke == stk) { sketch->active_stroke = NULL; } @@ -358,8 +340,7 @@ void sk_reverseStroke(SK_Stroke *stk) sk_allocStrokeBuffer(stk); - for (i = 0; i < stk->nb_points; i++) - { + for (i = 0; i < stk->nb_points; i++) { sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i); } @@ -376,8 +357,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) char work; int i; - if (start == -1) - { + if (start == -1) { start = 0; end = stk->nb_points - 1; } @@ -386,8 +366,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) stk->nb_points = 0; /* adding points before range */ - for (i = 0; i < start; i++) - { + for (i = 0; i < start; i++) { sk_appendStrokePoint(stk, old_points + i); } @@ -398,8 +377,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) work = 1; /* while still reducing */ - while (work) - { + while (work) { int ls, le; work = 0; @@ -407,15 +385,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) le = start+1; /* while not over interval */ - while (ls < end) - { + while (ls < end) { int max_i = 0; short v1[2]; float max_dist = 16; /* more than 4 pixels */ /* find the next marked point */ - while (marked[le] == 0) - { + while (marked[le] == 0) { le++; } @@ -424,8 +400,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1]; - for ( i = ls + 1; i < le; i++ ) - { + for ( i = ls + 1; i < le; i++ ) { float mul; float dist; short v2[2]; @@ -433,8 +408,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) v2[0] = old_points[i].p2d[0] - old_points[ls].p2d[0]; v2[1] = old_points[i].p2d[1] - old_points[ls].p2d[1]; - if (v2[0] == 0 && v2[1] == 0) - { + if (v2[0] == 0 && v2[1] == 0) { continue; } @@ -442,15 +416,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) dist = mul * mul * (v2[0]*v2[0] + v2[1]*v2[1]); - if (dist > max_dist) - { + if (dist > max_dist) { max_dist = dist; max_i = i; } } - if (max_i != 0) - { + if (max_i != 0) { work = 1; marked[max_i] = 1; } @@ -462,10 +434,8 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) /* adding points after range */ - for (i = start; i <= end; i++) - { - if (marked[i]) - { + for (i = start; i <= end; i++) { + if (marked[i]) { sk_appendStrokePoint(stk, old_points + i); } } @@ -473,8 +443,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) MEM_freeN(marked); /* adding points after range */ - for (i = end + 1; i < nb_points; i++) - { + for (i = end + 1; i < nb_points; i++) { sk_appendStrokePoint(stk, old_points + i); } @@ -490,13 +459,11 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk) end = stk->nb_points -1; - for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) - { + for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) { /* nothing to do here*/ } - if (end - start > 1) - { + if (end - start > 1) { sk_filterStroke(stk, start, end); } } @@ -505,8 +472,7 @@ SK_Point *sk_lastStrokePoint(SK_Stroke *stk) { SK_Point *pt = NULL; - if (stk->nb_points > 0) - { + if (stk->nb_points > 0) { pt = stk->points + (stk->nb_points - 1); } @@ -520,8 +486,7 @@ void sk_endContinuousStroke(SK_Stroke *stk) void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk) { - if (stk) - { + if (stk) { memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point)); } } @@ -529,8 +494,7 @@ void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk) int sk_stroke_filtermval(SK_DrawData *dd) { int retval = 0; - if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) - { + if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) { retval = 1; } @@ -551,12 +515,10 @@ void sk_deleteSelectedStrokes(SK_Sketch *sketch) { SK_Stroke *stk, *next; - for (stk = sketch->strokes.first; stk; stk = next) - { + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; - if (stk->selected == 1) - { + if (stk->selected == 1) { sk_removeStroke(sketch, stk); } } @@ -566,31 +528,26 @@ void sk_selectAllSketch(SK_Sketch *sketch, int mode) { SK_Stroke *stk = NULL; - if (mode == -1) - { - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + if (mode == -1) { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = 0; } } else if (mode == 0) { - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = 1; } } else if (mode == 1) { int selected = 1; - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { selected &= stk->selected; } selected ^= 1; - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = selected; } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e3a309fc945..d0eca731a1a 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -402,7 +402,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) if (!cmd->numverts || !cmd->numfaces) return; if ((pccd_M->totvert != cmd->numverts) || - (pccd_M->totface != cmd->numfaces)) return; + (pccd_M->totface != cmd->numfaces)) + { + return; + } pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; @@ -1388,8 +1391,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) } bf = sb->scratch->bodyface; for (a=0; a<sb->scratch->totface; a++, bf++) { - if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) - { + if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) { sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke); sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke); @@ -1935,8 +1937,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } } - if ((deflected < 2)&& (G.rt != 444)) // we did not hit a face until now - { // see if 'outer' hits an edge + if ((deflected < 2)&& (G.rt != 444)) { /* we did not hit a face until now */ + /* see if 'outer' hits an edge */ float dist; closest_to_line_segment_v3(ve, opco, nv1, nv2); @@ -2831,8 +2833,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa nlEnd(NL_MATRIX); nlEnd(NL_SYSTEM); - if ((G.rt == 32) && (nl_flags & NLF_BUILD)) - { + if ((G.rt == 32) && (nl_flags & NLF_BUILD)) { printf("####MEE#####\n"); nlPrintMatrix(); } @@ -3230,8 +3231,7 @@ static void springs_from_mesh(Object *ob) float scale =1.0f; sb= ob->soft; - if (me && sb) - { + if (me && sb) { /* using bp->origS as a container for spring calcualtions here ** will be overwritten sbObjectStep() to receive ** actual modifier stack positions @@ -3307,8 +3307,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) this enables per vertex *mass painting* */ - if (sb->namedVG_Mass[0]) - { + if (sb->namedVG_Mass[0]) { int grp= defgroup_name_index (ob,sb->namedVG_Mass); /* printf("VGN %s %d\n",sb->namedVG_Mass,grp); */ if (grp > -1) { @@ -3321,8 +3320,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* first set the default */ bp->springweight = 1.0f; - if (sb->namedVG_Spring_K[0]) - { + if (sb->namedVG_Spring_K[0]) { int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); //printf("VGN %s %d\n",sb->namedVG_Spring_K,grp); if (grp > -1) { @@ -3639,8 +3637,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) } } - if (totspring) - { + if (totspring) { build_bps_springlist(ob); /* link bps to springs */ if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} } @@ -3896,7 +3893,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int SB_estimate_transform(ob,NULL,NULL,NULL); SB_estimate_transform(ob,NULL,NULL,NULL); } - switch(ob->type) { + switch (ob->type) { case OB_MESH: if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob); break; @@ -3952,8 +3949,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) if (sb->solver_ID>0) mid_flags |= MID_PRESERVE; forcetime = forcetimemax; /* hope for integrating in one step */ - while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) - { + while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) { /* set goals in time */ interpolate_exciter(ob,200,(int)(200.0f*(timedone/dtime))); @@ -4021,12 +4017,11 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) } } - else if (sb->solver_ID == 2) - {/* do semi "fake" implicit euler */ + else if (sb->solver_ID == 2) { + /* do semi "fake" implicit euler */ //removed }/*SOLVER SELECT*/ - else if (sb->solver_ID == 4) - { + else if (sb->solver_ID == 4) { /* do semi "fake" implicit euler */ }/*SOLVER SELECT*/ else if (sb->solver_ID == 3) { @@ -4083,7 +4078,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if (sb->bpoint == NULL || ((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) { - switch(ob->type) { + switch (ob->type) { case OB_MESH: mesh_to_softbody(scene, ob); break; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index c2dbb518837..28ce95ea8d1 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -95,8 +95,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) sound_load(bmain, sound); - if (!sound->playback_handle) - { + if (!sound->playback_handle) { free_libblock(&bmain->sound, sound); sound = NULL; } @@ -106,22 +105,19 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) void sound_free(struct bSound* sound) { - if (sound->packedfile) - { + if (sound->packedfile) { freePackedFile(sound->packedfile); sound->packedfile = NULL; } #ifdef WITH_AUDASPACE - if (sound->handle) - { + if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; } - if (sound->cache) - { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } @@ -141,10 +137,8 @@ static void sound_sync_callback(void* data, int mode, float time) struct Scene* scene; scene = bmain->scene.first; - while (scene) - { - if (scene->audio.flag & AUDIO_SYNC) - { + while (scene) { + if (scene->audio.flag & AUDIO_SYNC) { if (mode) sound_play_scene(scene); else @@ -282,8 +276,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa void sound_delete(struct Main *bmain, struct bSound* sound) { - if (sound) - { + if (sound) { sound_free(sound); free_libblock(&bmain->sound, sound); @@ -312,8 +305,7 @@ void sound_cache_notifying(struct Main* main, struct bSound* sound) void sound_delete_cache(struct bSound* sound) { sound->flags &= ~SOUND_FLAGS_CACHING; - if (sound->cache) - { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; sound->playback_handle = sound->handle; @@ -322,16 +314,13 @@ void sound_delete_cache(struct bSound* sound) void sound_load(struct Main *bmain, struct bSound* sound) { - if (sound) - { - if (sound->cache) - { + if (sound) { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } - if (sound->handle) - { + if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; @@ -341,7 +330,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) // XXX unused currently #if 0 - switch(sound->type) + switch (sound->type) { case SOUND_TYPE_FILE: #endif @@ -376,15 +365,13 @@ void sound_load(struct Main *bmain, struct bSound* sound) break; } #endif - if (sound->flags & SOUND_FLAGS_MONO) - { + if (sound->flags & SOUND_FLAGS_MONO) { void* handle = AUD_monoSound(sound->handle); AUD_unload(sound->handle); sound->handle = handle; } - if (sound->flags & SOUND_FLAGS_CACHING) - { + if (sound->flags & SOUND_FLAGS_CACHING) { sound->cache = AUD_bufferSound(sound->handle); } @@ -557,14 +544,12 @@ void sound_play_scene(struct Scene *scene) if (status == AUD_STATUS_INVALID) sound_start_play_scene(scene); - if (!scene->sound_scene_handle) - { + if (!scene->sound_scene_handle) { AUD_unlock(); return; } - if (status != AUD_STATUS_PLAYING) - { + if (status != AUD_STATUS_PLAYING) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_resume(scene->sound_scene_handle); } @@ -577,8 +562,7 @@ void sound_play_scene(struct Scene *scene) void sound_stop_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - { + if (scene->sound_scene_handle) { AUD_pause(scene->sound_scene_handle); if (scene->audio.flag & AUDIO_SYNC) @@ -596,12 +580,10 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID; - if (status == AUD_STATUS_INVALID) - { + if (status == AUD_STATUS_INVALID) { sound_start_play_scene(scene); - if (!scene->sound_scene_handle) - { + if (!scene->sound_scene_handle) { AUD_unlock(); return; } @@ -616,10 +598,8 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) } } - if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) - { - if (scene->audio.flag & AUDIO_SYNC) - { + if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) { + if (scene->audio.flag & AUDIO_SYNC) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); } @@ -648,8 +628,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) float sound_sync_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - { + if (scene->sound_scene_handle) { if (scene->audio.flag & AUDIO_SYNC) return AUD_getSequencerPosition(scene->sound_scene_handle); else @@ -668,8 +647,7 @@ int sound_scene_playing(struct Scene *scene) void sound_free_waveform(struct bSound* sound) { - if (sound->waveform) - { + if (sound->waveform) { MEM_freeN(((SoundWaveform*)sound->waveform)->data); MEM_freeN(sound->waveform); } @@ -683,8 +661,7 @@ void sound_read_waveform(struct bSound* sound) info = AUD_getInfo(sound->playback_handle); - if (info.length > 0) - { + if (info.length > 0) { SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; @@ -709,23 +686,16 @@ void sound_update_scene(struct Scene* scene) void* handle; float quat[4]; - for (SETLOOPER(scene, sce_it, base)) - { + for (SETLOOPER(scene, sce_it, base)) { ob = base->object; - if (ob->type == OB_SPEAKER) - { - if (ob->adt) - { - for (track = ob->adt->nla_tracks.first; track; track = track->next) - { - for (strip = track->strips.first; strip; strip = strip->next) - { - if (strip->type == NLASTRIP_TYPE_SOUND) - { + if (ob->type == OB_SPEAKER) { + if (ob->adt) { + for (track = ob->adt->nla_tracks.first; track; track = track->next) { + for (strip = track->strips.first; strip; strip = strip->next) { + if (strip->type == NLASTRIP_TYPE_SOUND) { speaker = (Speaker*)ob->data; - if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) - { + if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (speaker->sound) AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); else { @@ -734,15 +704,13 @@ void sound_update_scene(struct Scene* scene) } } else { - if (speaker->sound) - { + if (speaker->sound) { strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0); AUD_setRelativeSequence(strip->speaker_handle, 0); } } - if (strip->speaker_handle) - { + if (strip->speaker_handle) { AUD_addSet(new_set, strip->speaker_handle); AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max, speaker->volume_min, speaker->distance_max, @@ -765,13 +733,11 @@ void sound_update_scene(struct Scene* scene) } } - while ((handle = AUD_getSet(scene->speaker_handles))) - { + while ((handle = AUD_getSet(scene->speaker_handles))) { AUD_removeSequence(scene->sound_scene, handle); } - if (scene->camera) - { + if (scene->camera) { mat4_to_quat(quat, scene->camera->obmat); AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1); AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 83a24f6afdc..83225163ea3 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2423,7 +2423,9 @@ static void ccgDM_release(DerivedMesh *dm) /* Check that mmd still exists */ if (!ccgdm->multires.local_mmd && BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0) + { ccgdm->multires.mmd = NULL; + } if (ccgdm->multires.mmd) { if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 1197ec23907..cb7369476c0 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1193,9 +1193,11 @@ void txt_order_cursors(Text *text) if (!text->sell) return; /* Flip so text->curl is before text->sell */ - if (txt_get_span(text->curl, text->sell)<0 || - (text->curl==text->sell && text->curc>text->selc)) + if ((txt_get_span(text->curl, text->sell) < 0) || + (text->curl == text->sell && text->curc > text->selc)) + { txt_curs_swap(text); + } } int txt_has_sel(Text *text) @@ -2018,7 +2020,7 @@ void txt_do_undo(Text *text) undoing= 1; - switch(op) { + switch (op) { case UNDO_CLEFT: txt_move_right(text, 0); break; @@ -2245,7 +2247,7 @@ void txt_do_redo(Text *text) undoing= 1; - switch(op) { + switch (op) { case UNDO_CLEFT: txt_move_left(text, 0); break; @@ -2832,8 +2834,7 @@ void txt_indent(Text *text) } num = 0; - while (TRUE) - { + while (TRUE) { tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string"); text->curc = 0; @@ -2851,8 +2852,7 @@ void txt_indent(Text *text) txt_make_dirty(text); txt_clean_text(text); - if (text->curl == text->sell) - { + if (text->curl == text->sell) { text->selc = text->sell->len; break; } @@ -2862,14 +2862,12 @@ void txt_indent(Text *text) } } text->curc = 0; - while ( num > 0 ) - { + while ( num > 0 ) { text->curl = text->curl->prev; num--; } - if (!undoing) - { + if (!undoing) { txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); } } @@ -2893,12 +2891,10 @@ void txt_unindent(Text *text) indent = spaceslen; } - while (TRUE) - { + while (TRUE) { int i = 0; - if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) - { + if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) { while (i< text->curl->len) { text->curl->line[i]= text->curl->line[i+indent]; i++; @@ -2909,8 +2905,7 @@ void txt_unindent(Text *text) txt_make_dirty(text); txt_clean_text(text); - if (text->curl == text->sell) - { + if (text->curl == text->sell) { text->selc = text->sell->len; break; } @@ -2921,14 +2916,12 @@ void txt_unindent(Text *text) } text->curc = 0; - while ( num > 0 ) - { + while ( num > 0 ) { text->curl = text->curl->prev; num--; } - if (!undoing) - { + if (!undoing) { txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); } } @@ -2944,8 +2937,7 @@ void txt_comment(Text *text) if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one num = 0; - while (TRUE) - { + while (TRUE) { tmp= MEM_mallocN(text->curl->len+2, "textline_string"); text->curc = 0; @@ -2963,8 +2955,7 @@ void txt_comment(Text *text) txt_make_dirty(text); txt_clean_text(text); - if (text->curl == text->sell) - { + if (text->curl == text->sell) { text->selc = text->sell->len; break; } @@ -2974,14 +2965,12 @@ void txt_comment(Text *text) } } text->curc = 0; - while ( num > 0 ) - { + while ( num > 0 ) { text->curl = text->curl->prev; num--; } - if (!undoing) - { + if (!undoing) { txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); } } @@ -2995,12 +2984,10 @@ void txt_uncomment(Text *text) if (!text->curl) return; if (!text->sell) return; - while (TRUE) - { + while (TRUE) { int i = 0; - if (text->curl->line[i] == remove) - { + if (text->curl->line[i] == remove) { while (i< text->curl->len) { text->curl->line[i]= text->curl->line[i+1]; i++; @@ -3012,8 +2999,7 @@ void txt_uncomment(Text *text) txt_make_dirty(text); txt_clean_text(text); - if (text->curl == text->sell) - { + if (text->curl == text->sell) { text->selc = text->sell->len; break; } @@ -3024,14 +3010,12 @@ void txt_uncomment(Text *text) } text->curc = 0; - while ( num > 0 ) - { + while ( num > 0 ) { text->curl = text->curl->prev; num--; } - if (!undoing) - { + if (!undoing) { txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc); } } @@ -3047,27 +3031,23 @@ int setcurr_tab_spaces (Text *text, int space) if (!text) return 0; if (!text->curl) return 0; - while (text->curl->line[i] == indent) - { + while (text->curl->line[i] == indent) { //we only count those tabs/spaces that are before any text or before the curs; - if (i == text->curc) - { + if (i == text->curc) { return i; } else { i++; } } - if (strstr(text->curl->line, word)) - { + if (strstr(text->curl->line, word)) { /* if we find a ':' on this line, then add a tab but not if it is: * 1) in a comment * 2) within an identifier * 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414] */ int a, is_indent = 0; - for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) - { + for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { char ch= text->curl->line[a]; if (ch=='#') { break; @@ -3084,13 +3064,10 @@ int setcurr_tab_spaces (Text *text, int space) } } - for (test=0; back_words[test]; test++) - { + for (test=0; back_words[test]; test++) { /* if there are these key words then remove a tab because we are done with the block */ - if (strstr(text->curl->line, back_words[test]) && i > 0) - { - if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) - { + if (strstr(text->curl->line, back_words[test]) && i > 0) { + if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) { i -= space; } } @@ -3139,14 +3116,16 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en for (marker=text->markers.first; marker; marker=next) { next= marker->next; - if (group && marker->group != group) continue; + if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; + else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->start<end && marker->end>start)) + (marker->start<end && marker->end>start)) + { return marker; + } } return NULL; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 23d818369a2..29b9505f449 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -663,7 +663,7 @@ void default_tex(Tex *tex) void tex_set_type(Tex *tex, int type) { - switch(type) { + switch (type) { case TEX_VOXELDATA: if (tex->vd == NULL) @@ -1180,7 +1180,7 @@ Tex *give_current_material_texture(Material *ma) int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_MA: *mtex_ar= ((Material *)id)->mtex; if (act) *act= (((Material *)id)->texact); @@ -1211,7 +1211,7 @@ void set_active_mtex(ID *id, short act) if (act<0) act= 0; else if (act>=MAX_MTEX) act= MAX_MTEX-1; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_MA: ((Material *)id)->texact= act; break; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 59c38117858..079bde0afec 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -120,19 +120,17 @@ static int write_audio_frame(void) audio_time += (double) audio_input_samples / (double) c->sample_rate; pkt.size = avcodec_encode_audio(c, audio_output_buffer, - audio_outbuf_size, - (short*) audio_input_buffer); + audio_outbuf_size, + (short *)audio_input_buffer); - if (pkt.size < 0) - { + if (pkt.size < 0) { // XXX error("Error writing audio packet"); return -1; } pkt.data = audio_output_buffer; - if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) - { + if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_stream->time_base); fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); @@ -175,7 +173,7 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height) * first is always desired guess_format parameter */ static const char** get_file_extensions(int format) { - switch(format) { + switch (format) { case FFMPEG_DV: { static const char * rv[] = { ".dv", NULL }; return rv; @@ -372,7 +370,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) *param++ = 0; } - switch(prop->type) { + switch (prop->type) { case IDP_STRING: fprintf(stderr, "%s.\n", IDP_String(prop)); av_set_string3(c, prop->name, IDP_String(prop), 1, &rv); @@ -717,7 +715,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report BLI_snprintf(of->filename, sizeof(of->filename), "%s", name); /* set the codec to the user's selection */ - switch(ffmpeg_type) { + switch (ffmpeg_type) { case FFMPEG_AVI: case FFMPEG_MOV: case FFMPEG_MKV: @@ -929,8 +927,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo success = start_ffmpeg_impl(rd, rectx, recty, reports); #ifdef WITH_AUDASPACE - if (audio_stream) - { + if (audio_stream) { AVCodecContext* c = audio_stream->codec; AUD_DeviceSpecs specs; specs.channels = c->channels; @@ -974,8 +971,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r // why is this done before writing the video frame and again at end_ffmpeg? // write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base)); - if (video_stream) - { + if (video_stream) { avframe= generate_video_frame((unsigned char*) pixels, reports); success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports)); @@ -1172,10 +1168,12 @@ static const AVOption *my_av_find_opt(void *v, const char *name, const AVOption *o= c->option; for (;o && o->name; o++) { - if (!strcmp(o->name, name) && - (!unit || (o->unit && !strcmp(o->unit, unit))) && - (o->flags & mask) == flags ) + if (!strcmp(o->name, name) && + (!unit || (o->unit && !strcmp(o->unit, unit))) && + (o->flags & mask) == flags) + { return o; + } } return NULL; } |