style cleanup: follow style guide for formatting of if/for/while loops, and else...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 24 Mar 2012 06:18:31 +0000 (06:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 24 Mar 2012 06:18:31 +0000 (06:18 +0000)
116 files changed:
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/bmfont.c
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/booleanops_mesh.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/customdata_file.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/fmodifier.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/icons.c
source/blender/blenkernel/intern/idprop.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/image_gen.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/navmesh_conversion.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/ocean.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/property.c
source/blender/blenkernel/intern/report.c
source/blender/blenkernel/intern/sca.c
source/blender/blenkernel/intern/screen.c
source/blender/blenkernel/intern/seqcache.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/sketch.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/suggestions.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenkernel/intern/world.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenkernel/intern/writeframeserver.c
source/blender/blenlib/intern/BLI_args.c
source/blender/blenlib/intern/BLI_dynstr.c
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/BLI_kdtree.c
source/blender/blenlib/intern/BLI_linklist.c
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/callbacks.c
source/blender/blenlib/intern/dynlib.c
source/blender/blenlib/intern/fileops.c
source/blender/blenlib/intern/freetypefont.c
source/blender/blenlib/intern/graph.c
source/blender/blenlib/intern/gsqueue.c
source/blender/blenlib/intern/jitter.c
source/blender/blenlib/intern/listbase.c
source/blender/blenlib/intern/math_base.c
source/blender/blenlib/intern/math_base_inline.c
source/blender/blenlib/intern/math_color.c
source/blender/blenlib/intern/math_color_inline.c
source/blender/blenlib/intern/math_geom.c
source/blender/blenlib/intern/math_geom_inline.c
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/math_rotation.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/math_vector_inline.c
source/blender/blenlib/intern/noise.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenlib/intern/rand.c
source/blender/blenlib/intern/scanfill.c
source/blender/blenlib/intern/storage.c
source/blender/blenlib/intern/string.c
source/blender/blenlib/intern/string_utf8.c
source/blender/blenlib/intern/threads.c
source/blender/blenlib/intern/time.c
source/blender/blenlib/intern/winstuff.c
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/runtime.c
source/blender/blenloader/intern/undofile.c
source/blender/blenloader/intern/writefile.c

index 48dee60..f05ceb8 100644 (file)
@@ -173,7 +173,7 @@ static MVert *dm_dupVertArray(DerivedMesh *dm)
        MVert *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumVerts(dm),
                                                         "dm_dupVertArray tmp");
 
-       if(tmp) dm->copyVertArray(dm, tmp);
+       if (tmp) dm->copyVertArray(dm, tmp);
 
        return tmp;
 }
@@ -183,7 +183,7 @@ static MEdge *dm_dupEdgeArray(DerivedMesh *dm)
        MEdge *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumEdges(dm),
                                                         "dm_dupEdgeArray tmp");
 
-       if(tmp) dm->copyEdgeArray(dm, tmp);
+       if (tmp) dm->copyEdgeArray(dm, tmp);
 
        return tmp;
 }
@@ -193,7 +193,7 @@ static MFace *dm_dupFaceArray(DerivedMesh *dm)
        MFace *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumTessFaces(dm),
                                                         "dm_dupFaceArray tmp");
 
-       if(tmp) dm->copyTessFaceArray(dm, tmp);
+       if (tmp) dm->copyTessFaceArray(dm, tmp);
 
        return tmp;
 }
@@ -203,7 +203,7 @@ static MLoop *dm_dupLoopArray(DerivedMesh *dm)
        MLoop *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumLoops(dm),
                                                         "dm_dupLoopArray tmp");
 
-       if(tmp) dm->copyLoopArray(dm, tmp);
+       if (tmp) dm->copyLoopArray(dm, tmp);
 
        return tmp;
 }
@@ -213,7 +213,7 @@ static MPoly *dm_dupPolyArray(DerivedMesh *dm)
        MPoly *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumPolys(dm),
                                                         "dm_dupPolyArray tmp");
 
-       if(tmp) dm->copyPolyArray(dm, tmp);
+       if (tmp) dm->copyPolyArray(dm, tmp);
 
        return tmp;
 }
@@ -501,11 +501,11 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
        
        /* not all DerivedMeshes store their verts/edges/faces in CustomData, so
         * we set them here in case they are missing */
-       if(!CustomData_has_layer(&tmp.vdata, CD_MVERT))
+       if (!CustomData_has_layer(&tmp.vdata, CD_MVERT))
                CustomData_add_layer(&tmp.vdata, CD_MVERT, CD_ASSIGN, dm->dupVertArray(dm), totvert);
-       if(!CustomData_has_layer(&tmp.edata, CD_MEDGE))
+       if (!CustomData_has_layer(&tmp.edata, CD_MEDGE))
                CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN, dm->dupEdgeArray(dm), totedge);
-       if(!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
+       if (!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
                tmp.mloop = dm->dupLoopArray(dm);
                tmp.mpoly = dm->dupPolyArray(dm);
 
@@ -515,7 +515,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
 
        /* object had got displacement layer, should copy this layer to save sculpted data */
        /* NOTE: maybe some other layers should be copied? nazgul */
-       if(CustomData_has_layer(&me->ldata, CD_MDISPS)) {
+       if (CustomData_has_layer(&me->ldata, CD_MDISPS)) {
                if (totloop == me->totloop) {
                        MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
                        CustomData_add_layer(&tmp.ldata, CD_MDISPS, CD_DUPLICATE, mdisps, totloop);
@@ -536,9 +536,9 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
        /* ok, this should now use new CD shapekey data,
         * which shouuld be fed through the modifier
         * stack*/
-       if(tmp.totvert != me->totvert && !did_shapekeys && me->key) {
+       if (tmp.totvert != me->totvert && !did_shapekeys && me->key) {
                printf("YEEK! this should be recoded! Shape key loss!!!\n");
-               if(tmp.key) tmp.key->id.us--;
+               if (tmp.key) tmp.key->id.us--;
                tmp.key = NULL;
        }
 
@@ -551,16 +551,16 @@ void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
        float *fp;
        MVert *mvert;
        
-       if(totvert==0 || me->totvert==0 || me->totvert!=totvert) return;
+       if (totvert==0 || me->totvert==0 || me->totvert!=totvert) return;
        
-       if(kb->data) MEM_freeN(kb->data);
+       if (kb->data) MEM_freeN(kb->data);
        kb->data= MEM_callocN(me->key->elemsize*me->totvert, "kb->data");
        kb->totelem= totvert;
        
        fp= kb->data;
        mvert=dm->getVertDataArray(dm, CD_MVERT);
        
-       for(a=0; a<kb->totelem; a++, fp+=3, mvert++) {
+       for (a=0; a<kb->totelem; a++, fp+=3, mvert++) {
                copy_v3_v3(fp, mvert->co);
        }
 }
@@ -614,7 +614,7 @@ void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
 
 void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
 {
-       if(type == CD_MVERT)
+       if (type == CD_MVERT)
                return dm->getVertArray(dm);
 
        return CustomData_get_layer(&dm->vertData, type);
@@ -622,7 +622,7 @@ void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
 
 void *DM_get_edge_data_layer(DerivedMesh *dm, int type)
 {
-       if(type == CD_MEDGE)
+       if (type == CD_MEDGE)
                return dm->getEdgeArray(dm);
 
        return CustomData_get_layer(&dm->edgeData, type);
@@ -773,7 +773,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3])
 {
        DerivedMesh *dm = CDDM_from_mesh(me, ob);
        
-       if(!dm)
+       if (!dm)
                return NULL;
        
        if (vertCos)
@@ -814,7 +814,8 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
                        add_shapekey_layers(dm, me, ob);
                
                MEM_freeN(deformedVerts);
-       } else {
+       }
+       else {
                DerivedMesh *tdm = mesh_create_derived(me, ob, NULL);
 
                if (build_shapekey_layers)
@@ -822,7 +823,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
                
                dm = mti->applyModifier(md, ob, tdm, 0, 0);
 
-               if(tdm != dm) tdm->release(tdm);
+               if (tdm != dm) tdm->release(tdm);
        }
 
        return dm;
@@ -855,23 +856,23 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free
 {
        *free= 0;
 
-       if(layer == CD_ORCO) {
+       if (layer == CD_ORCO) {
                /* get original coordinates */
                *free= 1;
 
-               if(em)
+               if (em)
                        return (float(*)[3])get_editbmesh_orco_verts(em);
                else
                        return (float(*)[3])get_mesh_orco_verts(ob);
        }
-       else if(layer == CD_CLOTH_ORCO) {
+       else if (layer == CD_CLOTH_ORCO) {
                /* apply shape key for cloth, this should really be solved
                 * by a more flexible customdata system, but not simple */
-               if(!em) {
+               if (!em) {
                        ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
                        KeyBlock *kb= key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest);
 
-                       if(kb->data)
+                       if (kb->data)
                                return kb->data;
                }
 
@@ -887,14 +888,14 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
        float (*orco)[3];
        int free;
 
-       if(em) dm= CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
+       if (em) dm= CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
        else dm= CDDM_from_mesh(me, ob);
 
        orco= get_orco_coords_dm(ob, em, layer, &free);
 
-       if(orco) {
+       if (orco) {
                CDDM_apply_vert_coords(dm, orco);
-               if(free) MEM_freeN(orco);
+               if (free) MEM_freeN(orco);
        }
 
        CDDM_calc_normals(dm);
@@ -910,11 +911,11 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
 
        totvert= dm->getNumVerts(dm);
 
-       if(orcodm) {
+       if (orcodm) {
                orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco");
                free= 1;
 
-               if(orcodm->getNumVerts(orcodm) == totvert)
+               if (orcodm->getNumVerts(orcodm) == totvert)
                        orcodm->getVertCos(orcodm, orco);
                else
                        dm->getVertCos(dm, orco);
@@ -922,17 +923,17 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
        else
                orco= get_orco_coords_dm(ob, em, layer, &free);
 
-       if(orco) {
-               if(layer == CD_ORCO)
+       if (orco) {
+               if (layer == CD_ORCO)
                        transform_mesh_orco_verts(ob->data, orco, totvert, 0);
 
-               if(!(layerorco = DM_get_vert_data_layer(dm, layer))) {
+               if (!(layerorco = DM_get_vert_data_layer(dm, layer))) {
                        DM_add_vert_layer(dm, layer, CD_CALLOC, NULL);
                        layerorco = DM_get_vert_data_layer(dm, layer);
                }
 
                memcpy(layerorco, orco, sizeof(float)*3*totvert);
-               if(free) MEM_freeN(orco);
+               if (free) MEM_freeN(orco);
        }
 }
 
@@ -987,7 +988,7 @@ static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const flo
 {
        float colf[4];
 
-       if(coba) {
+       if (coba) {
                do_colorband(coba, input, colf);
        }
        else {
@@ -1149,7 +1150,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
 # else
 #if 0
        /* XXX We have to create a CD_PREVIEW_MCOL, else it might sigsev (after a SubSurf mod, eg)... */
-       if(!dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL))
+       if (!dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL))
                CustomData_add_layer(&dm->faceData, CD_PREVIEW_MCOL, CD_CALLOC, NULL, numFaces);
 #endif
 
@@ -1161,7 +1162,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
                        float *w = weights;
                        /* If indices is not NULL, it means we do not have weights for all vertices,
                         * so we must create them (and set them to zero)... */
-                       if(indices) {
+                       if (indices) {
                                w = MEM_callocN(sizeof(float)*numVerts, "Temp weight array DM_update_weight_mcol");
                                i = num;
                                while(i--)
@@ -1171,7 +1172,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
                        /* Convert float weights to colors. */
                        wtcol_v = calc_colors_from_weights_array(numVerts, w);
 
-                       if(indices)
+                       if (indices)
                                MEM_freeN(w);
                }
 
@@ -1277,7 +1278,8 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
                        for (j=0; j<dm->numVertData; j++, kbcos++, mvert++) {
                                copy_v3_v3(*kbcos, mvert->co);
                        }
-               } else {
+               }
+               else {
                        for (j=0; j<kb->totelem; j++, cos++, kbcos++) {
                                copy_v3_v3(*kbcos, *cos);
                        }
@@ -1374,16 +1376,16 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
        /* XXX Same as above... For now, only weights preview in WPaint mode. */
        const int do_mod_wmcol = do_init_wmcol;
 
-       if(mmd && !mmd->sculptlvl)
+       if (mmd && !mmd->sculptlvl)
                has_multires = 0;
 
-       if(!skipVirtualArmature) {
+       if (!skipVirtualArmature) {
                firstmd = modifiers_getVirtualModifierList(ob);
        }
        else {
                /* game engine exception */
                firstmd = ob->modifiers.first;
-               if(firstmd && firstmd->type == eModifierType_Armature)
+               if (firstmd && firstmd->type == eModifierType_Armature)
                        firstmd = firstmd->next;
        }
 
@@ -1391,13 +1393,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 
        modifiers_clearErrors(ob);
 
-       if(useRenderParams) required_mode = eModifierMode_Render;
+       if (useRenderParams) required_mode = eModifierMode_Render;
        else required_mode = eModifierMode_Realtime;
 
        datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode);
        curr = datamasks;
 
-       if(do_mod_wmcol || do_mod_mcol) {
+       if (do_mod_wmcol || do_mod_mcol) {
                /* Find the last active modifier generating a preview, or NULL if none. */
                /* XXX Currently, DPaint modifier just ignores this.
                 *     Needs a stupid hack...
@@ -1405,33 +1407,34 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                previewmd = modifiers_getLastPreview(scene, md, required_mode);
        }
 
-       if(deform_r) *deform_r = NULL;
+       if (deform_r) *deform_r = NULL;
        *final_r = NULL;
 
-       if(useDeform) {
-               if(inputVertexCos)
+       if (useDeform) {
+               if (inputVertexCos)
                        deformedVerts = inputVertexCos;
                
                /* Apply all leading deforming modifiers */
-               for(;md; md = md->next, curr = curr->next) {
+               for (;md; md = md->next, curr = curr->next) {
                        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                        md->scene= scene;
                        
-                       if(!modifier_isEnabled(scene, md, required_mode)) continue;
-                       if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+                       if (!modifier_isEnabled(scene, md, required_mode)) continue;
+                       if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
 
-                       if(mti->type == eModifierTypeType_OnlyDeform) {
-                               if(!deformedVerts)
+                       if (mti->type == eModifierTypeType_OnlyDeform) {
+                               if (!deformedVerts)
                                        deformedVerts = mesh_getVertexCos(me, &numVerts);
 
                                mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, useRenderParams, useDeform);
-                       } else {
+                       }
+                       else {
                                break;
                        }
                        
                        /* grab modifiers until index i */
-                       if((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
+                       if ((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
                                break;
                }
 
@@ -1445,14 +1448,15 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                        if (build_shapekey_layers)
                                add_shapekey_layers(dm, me, ob);
                        
-                       if(deformedVerts) {
+                       if (deformedVerts) {
                                CDDM_apply_vert_coords(*deform_r, deformedVerts);
                                CDDM_calc_normals(*deform_r);
                        }
                }
-       } else {
+       }
+       else {
                /* default behavior for meshes */
-               if(inputVertexCos)
+               if (inputVertexCos)
                        deformedVerts = inputVertexCos;
                else
                        deformedVerts = mesh_getVertexCos(me, &numVerts);
@@ -1466,41 +1470,41 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
        orcodm = NULL;
        clothorcodm = NULL;
 
-       for(;md; md = md->next, curr = curr->next) {
+       for (;md; md = md->next, curr = curr->next) {
                ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                md->scene= scene;
 
-               if(!modifier_isEnabled(scene, md, required_mode)) continue;
-               if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
-               if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
+               if (!modifier_isEnabled(scene, md, required_mode)) continue;
+               if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
+               if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
                        modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
                        continue;
                }
-               if(sculpt_mode && (!has_multires || multires_applied)) {
+               if (sculpt_mode && (!has_multires || multires_applied)) {
                        int unsupported= 0;
 
-                       if(scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
+                       if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
                                unsupported|= mti->type != eModifierTypeType_OnlyDeform;
 
                        unsupported|= md->type == eModifierType_Multires && ((MultiresModifierData*)md)->sculptlvl==0;
                        unsupported|= multires_applied;
 
-                       if(unsupported) {
+                       if (unsupported) {
                                modifier_setError(md, "%s", TIP_("Not supported in sculpt mode."));
                                continue;
                        }
                }
-               if(needMapping && !modifier_supportsMapping(md)) continue;
-               if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+               if (needMapping && !modifier_supportsMapping(md)) continue;
+               if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
 
                /* add an orco layer if needed by this modifier */
-               if(mti->requiredDataMask)
+               if (mti->requiredDataMask)
                        mask = mti->requiredDataMask(ob, md);
                else
                        mask = 0;
 
-               if(dm && (mask & CD_MASK_ORCO))
+               if (dm && (mask & CD_MASK_ORCO))
                        add_orco_dm(ob, NULL, dm, orcodm, CD_ORCO);
 
                /* How to apply modifier depends on (a) what we already have as
@@ -1508,10 +1512,10 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                 * deformed vertices) and (b) what type the modifier is.
                 */
 
-               if(mti->type == eModifierTypeType_OnlyDeform) {
+               if (mti->type == eModifierTypeType_OnlyDeform) {
                        /* No existing verts to deform, need to build them. */
-                       if(!deformedVerts) {
-                               if(dm) {
+                       if (!deformedVerts) {
+                               if (dm) {
                                        /* Deforming a derived mesh, read the vertex locations
                                         * out of the mesh and deform them. Once done with this
                                         * run of deformers verts will be written back.
@@ -1520,34 +1524,36 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                                        deformedVerts =
                                                MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
                                        dm->getVertCos(dm, deformedVerts);
-                               } else {
+                               }
+                               else {
                                        deformedVerts = mesh_getVertexCos(me, &numVerts);
                                }
                        }
 
                        /* if this is not the last modifier in the stack then recalculate the normals
                         * to avoid giving bogus normals to the next modifier see: [#23673] */
-                       if(isPrevDeform &&  mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+                       if (isPrevDeform &&  mti->dependsOnNormals && mti->dependsOnNormals(md)) {
                                /* XXX, this covers bug #23673, but we may need normal calc for other types */
-                               if(dm && dm->type == DM_TYPE_CDDM) {
+                               if (dm && dm->type == DM_TYPE_CDDM) {
                                        CDDM_apply_vert_coords(dm, deformedVerts);
                                        CDDM_calc_normals(dm);
                                }
                        }
 
                        mti->deformVerts(md, ob, dm, deformedVerts, numVerts, useRenderParams, useDeform);
-               } else {
+               }
+               else {
                        DerivedMesh *ndm;
 
                        /* determine which data layers are needed by following modifiers */
-                       if(curr->next)
+                       if (curr->next)
                                nextmask= (CustomDataMask)GET_INT_FROM_POINTER(curr->next->link);
                        else
                                nextmask= dataMask;
 
                        /* apply vertex coordinates or build a DerivedMesh as necessary */
-                       if(dm) {
-                               if(deformedVerts) {
+                       if (dm) {
+                               if (deformedVerts) {
                                        DerivedMesh *tdm = CDDM_copy(dm);
                                        dm->release(dm);
                                        dm = tdm;
@@ -1555,18 +1561,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                                        CDDM_apply_vert_coords(dm, deformedVerts);
                                        CDDM_calc_normals(dm);
                                }
-                       } else {
+                       }
+                       else {
                                dm = CDDM_from_mesh(me, ob);
 
                                if (build_shapekey_layers)
                                        add_shapekey_layers(dm, me, ob);
 
-                               if(deformedVerts) {
+                               if (deformedVerts) {
                                        CDDM_apply_vert_coords(dm, deformedVerts);
                                        CDDM_calc_normals(dm);
                                }
 
-                               if(do_init_wmcol)
+                               if (do_init_wmcol)
                                        DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
 
                                /* Constructive modifiers need to have an origindex
@@ -1576,7 +1583,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                                 * requests it, this way Mirror, Solidify etc will keep ORIGINDEX
                                 * data by using generic DM_copy_vert_data() functions.
                                 */
-                               if(needMapping || (nextmask & CD_MASK_ORIGINDEX)) {
+                               if (needMapping || (nextmask & CD_MASK_ORIGINDEX)) {
                                        /* calc */
                                        DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
                                        DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
@@ -1597,12 +1604,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                        DM_set_only_copy(dm, mask | (needMapping ? CD_MASK_ORIGINDEX : 0));
                        
                        /* add cloth rest shape key if need */
-                       if(mask & CD_MASK_CLOTH_ORCO)
+                       if (mask & CD_MASK_CLOTH_ORCO)
                                add_orco_dm(ob, NULL, dm, clothorcodm, CD_CLOTH_ORCO);
 
                        /* add an origspace layer if needed */
-                       if(((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE_MLOOP) {
-                               if(!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
+                       if (((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE_MLOOP) {
+                               if (!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
                                        DM_add_loop_layer(dm, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL);
                                        DM_init_origspace(dm);
                                }
@@ -1610,14 +1617,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 
                        ndm = mti->applyModifier(md, ob, dm, useRenderParams, useCache);
 
-                       if(ndm) {
+                       if (ndm) {
                                /* if the modifier returned a new dm, release the old one */
-                               if(dm && dm != ndm) dm->release(dm);
+                               if (dm && dm != ndm) dm->release(dm);
 
                                dm = ndm;
 
-                               if(deformedVerts) {
-                                       if(deformedVerts != inputVertexCos)
+                               if (deformedVerts) {
+                                       if (deformedVerts != inputVertexCos)
                                                MEM_freeN(deformedVerts);
 
                                        deformedVerts = NULL;
@@ -1625,33 +1632,33 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                        } 
 
                        /* create an orco derivedmesh in parallel */
-                       if(nextmask & CD_MASK_ORCO) {
-                               if(!orcodm)
+                       if (nextmask & CD_MASK_ORCO) {
+                               if (!orcodm)
                                        orcodm= create_orco_dm(ob, me, NULL, CD_ORCO);
 
                                nextmask &= ~CD_MASK_ORCO;
                                DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX);
                                ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0);
 
-                               if(ndm) {
+                               if (ndm) {
                                        /* if the modifier returned a new dm, release the old one */
-                                       if(orcodm && orcodm != ndm) orcodm->release(orcodm);
+                                       if (orcodm && orcodm != ndm) orcodm->release(orcodm);
                                        orcodm = ndm;
                                }
                        }
 
                        /* create cloth orco derivedmesh in parallel */
-                       if(nextmask & CD_MASK_CLOTH_ORCO) {
-                               if(!clothorcodm)
+                       if (nextmask & CD_MASK_CLOTH_ORCO) {
+                               if (!clothorcodm)
                                        clothorcodm= create_orco_dm(ob, me, NULL, CD_CLOTH_ORCO);
 
                                nextmask &= ~CD_MASK_CLOTH_ORCO;
                                DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
                                ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0);
 
-                               if(ndm) {
+                               if (ndm) {
                                        /* if the modifier returned a new dm, release the old one */
-                                       if(clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm);
+                                       if (clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm);
                                        clothorcodm = ndm;
                                }
                        }
@@ -1670,21 +1677,21 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform);
 
                /* grab modifiers until index i */
-               if((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
+               if ((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
                        break;
 
-               if(sculpt_mode && md->type == eModifierType_Multires)
+               if (sculpt_mode && md->type == eModifierType_Multires)
                        multires_applied = 1;
        }
 
-       for(md=firstmd; md; md=md->next)
+       for (md=firstmd; md; md=md->next)
                modifier_freeTemporaryData(md);
 
        /* Yay, we are done. If we have a DerivedMesh and deformed vertices
         * need to apply these back onto the DerivedMesh. If we have no
         * DerivedMesh then we need to build one.
         */
-       if(dm && deformedVerts) {
+       if (dm && deformedVerts) {
                finaldm = CDDM_copy(dm);
 
                dm->release(dm);
@@ -1694,46 +1701,48 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 
 #if 0 /* For later nice mod preview! */
                /* In case we need modified weights in CD_PREVIEW_MCOL, we have to re-compute it. */
-               if(do_final_wmcol)
+               if (do_final_wmcol)
                        DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
 #endif
-       } else if(dm) {
+       }
+       else if (dm) {
                finaldm = dm;
 
 #if 0 /* For later nice mod preview! */
                /* In case we need modified weights in CD_PREVIEW_MCOL, we have to re-compute it. */
-               if(do_final_wmcol)
+               if (do_final_wmcol)
                        DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
 #endif
-       } else {
+       }
+       else {
                int recalc_normals= 0;
 
                finaldm = CDDM_from_mesh(me, ob);
                
-               if(build_shapekey_layers) {
+               if (build_shapekey_layers) {
                        add_shapekey_layers(finaldm, me, ob);
                        recalc_normals= 1;
                }
                
-               if(deformedVerts) {
+               if (deformedVerts) {
                        CDDM_apply_vert_coords(finaldm, deformedVerts);
                        recalc_normals= 1;
                }
 
-               if(recalc_normals) {
+               if (recalc_normals) {
                        CDDM_calc_normals(finaldm);
                }
 
                /* In this case, we should never have weight-modifying modifiers in stack... */
-               if(do_init_wmcol)
+               if (do_init_wmcol)
                        DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
        }
 
        /* add an orco layer if needed */
-       if(dataMask & CD_MASK_ORCO) {
+       if (dataMask & CD_MASK_ORCO) {
                add_orco_dm(ob, NULL, finaldm, orcodm, CD_ORCO);
 
-               if(deform_r && *deform_r)
+               if (deform_r && *deform_r)
                        add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO);
        }
 
@@ -1806,12 +1815,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
 
        *final_r = finaldm;
 
-       if(orcodm)
+       if (orcodm)
                orcodm->release(orcodm);
-       if(clothorcodm)
+       if (clothorcodm)
                clothorcodm->release(clothorcodm);
 
-       if(deformedVerts && deformedVerts != inputVertexCos)
+       if (deformedVerts && deformedVerts != inputVertexCos)
                MEM_freeN(deformedVerts);
 
        BLI_linklist_free(datamasks, NULL);
@@ -1839,8 +1848,8 @@ int editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *d
        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
        int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
 
-       if(!modifier_isEnabled(scene, md, required_mode)) return 0;
-       if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
+       if (!modifier_isEnabled(scene, md, required_mode)) return 0;
+       if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
                modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
                return 0;
        }
@@ -1862,7 +1871,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
 
        modifiers_clearErrors(ob);
 
-       if(cage_r && cageIndex == -1) {
+       if (cage_r && cageIndex == -1) {
                *cage_r = getEditDerivedBMesh(em, ob, NULL);
        }
 
@@ -1872,18 +1881,18 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
        datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode);
 
        curr = datamasks;
-       for(i = 0; md; i++, md = md->next, curr = curr->next) {
+       for (i = 0; md; i++, md = md->next, curr = curr->next) {
                ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                md->scene= scene;
                
-               if(!editbmesh_modifier_is_enabled(scene, md, dm))
+               if (!editbmesh_modifier_is_enabled(scene, md, dm))
                        continue;
 
                /* add an orco layer if needed by this modifier */
-               if(dm && mti->requiredDataMask) {
+               if (dm && mti->requiredDataMask) {
                        mask = mti->requiredDataMask(ob, md);
-                       if(mask & CD_MASK_ORCO)
+                       if (mask & CD_MASK_ORCO)
                                add_orco_dm(ob, em, dm, orcodm, CD_ORCO);
                }
 
@@ -1892,10 +1901,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                 * deformed vertices) and (b) what type the modifier is.
                 */
 
-               if(mti->type == eModifierTypeType_OnlyDeform) {
+               if (mti->type == eModifierTypeType_OnlyDeform) {
                        /* No existing verts to deform, need to build them. */
-                       if(!deformedVerts) {
-                               if(dm) {
+                       if (!deformedVerts) {
+                               if (dm) {
                                        /* Deforming a derived mesh, read the vertex locations
                                         * out of the mesh and deform them. Once done with this
                                         * run of deformers verts will be written back.
@@ -1904,7 +1913,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                                        deformedVerts =
                                                MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
                                        dm->getVertCos(dm, deformedVerts);
-                               } else {
+                               }
+                               else {
                                        deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
                                }
                        }
@@ -1912,28 +1922,31 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                        if (mti->deformVertsEM)
                                mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
                        else mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0);
-               } else {
+               }
+               else {
                        DerivedMesh *ndm;
 
                        /* apply vertex coordinates or build a DerivedMesh as necessary */
-                       if(dm) {
-                               if(deformedVerts) {
+                       if (dm) {
+                               if (deformedVerts) {
                                        DerivedMesh *tdm = CDDM_copy(dm);
-                                       if(!(cage_r && dm == *cage_r)) dm->release(dm);
+                                       if (!(cage_r && dm == *cage_r)) dm->release(dm);
                                        dm = tdm;
 
                                        CDDM_apply_vert_coords(dm, deformedVerts);
                                        CDDM_calc_normals(dm);
-                               } else if(cage_r && dm == *cage_r) {
+                               }
+                               else if (cage_r && dm == *cage_r) {
                                        /* dm may be changed by this modifier, so we need to copy it
                                         */
                                        dm = CDDM_copy(dm);
                                }
 
-                       } else {
+                       }
+                       else {
                                dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
 
-                               if(deformedVerts) {
+                               if (deformedVerts) {
                                        CDDM_apply_vert_coords(dm, deformedVerts);
                                        CDDM_calc_normals(dm);
                                }
@@ -1941,8 +1954,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
 
                        /* create an orco derivedmesh in parallel */
                        mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
-                       if(mask & CD_MASK_ORCO) {
-                               if(!orcodm)
+                       if (mask & CD_MASK_ORCO) {
+                               if (!orcodm)
                                        orcodm= create_orco_dm(ob, ob->data, em, CD_ORCO);
 
                                mask &= ~CD_MASK_ORCO;
@@ -1953,9 +1966,9 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                                else
                                        ndm = mti->applyModifier(md, ob, orcodm, 0, 0);
 
-                               if(ndm) {
+                               if (ndm) {
                                        /* if the modifier returned a new dm, release the old one */
-                                       if(orcodm && orcodm != ndm) orcodm->release(orcodm);
+                                       if (orcodm && orcodm != ndm) orcodm->release(orcodm);
                                        orcodm = ndm;
                                }
                        }
@@ -1965,8 +1978,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
 
                        DM_set_only_copy(dm, mask | CD_MASK_ORIGINDEX);
 
-                       if(mask & CD_MASK_ORIGSPACE_MLOOP) {
-                               if(!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
+                       if (mask & CD_MASK_ORIGSPACE_MLOOP) {
+                               if (!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
                                        DM_add_loop_layer(dm, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL);
                                        DM_init_origspace(dm);
                                }
@@ -1978,7 +1991,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                                ndm = mti->applyModifier(md, ob, dm, 0, 0);
 
                        if (ndm) {
-                               if(dm && dm != ndm)
+                               if (dm && dm != ndm)
                                        dm->release(dm);
 
                                dm = ndm;
@@ -1990,13 +2003,15 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                        }
                }
 
-               if(cage_r && i == cageIndex) {
-                       if(dm && deformedVerts) {
+               if (cage_r && i == cageIndex) {
+                       if (dm && deformedVerts) {
                                *cage_r = CDDM_copy(dm);
                                CDDM_apply_vert_coords(*cage_r, deformedVerts);
-                       } else if(dm) {
+                       }
+                       else if (dm) {
                                *cage_r = dm;
-                       } else {
+                       }
+                       else {
                                *cage_r =
                                        getEditDerivedBMesh(em, ob,
                                                deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
@@ -2010,10 +2025,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
         * to apply these back onto the DerivedMesh. If we have no DerivedMesh
         * then we need to build one.
         */
-       if(dm && deformedVerts) {
+       if (dm && deformedVerts) {
                *final_r = CDDM_copy(dm);
 
-               if(!(cage_r && dm == *cage_r)) dm->release(dm);
+               if (!(cage_r && dm == *cage_r)) dm->release(dm);
 
                CDDM_apply_vert_coords(*final_r, deformedVerts);
                CDDM_calc_normals(*final_r); /* was CDDM_calc_normals_mapping - campbell */
@@ -2051,13 +2066,13 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
        /* --- */
 
        /* add an orco layer if needed */
-       if(dataMask & CD_MASK_ORCO)
+       if (dataMask & CD_MASK_ORCO)
                add_orco_dm(ob, em, *final_r, orcodm, CD_ORCO);
 
-       if(orcodm)
+       if (orcodm)
                orcodm->release(orcodm);
 
-       if(deformedVerts)
+       if (deformedVerts)
                MEM_freeN(deformedVerts);
 }
 
@@ -2088,7 +2103,7 @@ static void clear_mesh_caches(Object *ob)
                ob->derivedDeform= NULL;
        }
 
-       if(ob->sculpt) {
+       if (ob->sculpt) {
                object_sculpt_modifiers_changed(ob);
        }
 }
@@ -2113,7 +2128,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
        ob->derivedDeform->needsFree = 0;
        ob->lastDataMask = dataMask;
 
-       if((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
+       if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
                /* create PBVH immediately (would be created on the fly too,
                   but this avoids waiting on first stroke) */
                ob->sculpt->pbvh= ob->derivedFinal->getPBVH(ob, ob->derivedFinal);
@@ -2150,7 +2165,8 @@ void makeDerivedMesh(Scene *scene, Object *ob, BMEditMesh *em,
 {
        if (em) {
                editbmesh_build_data(scene, ob, em, dataMask);
-       } else {
+       }
+       else {
                mesh_build_data(scene, ob, dataMask, build_shapekey_layers);
        }
 }
@@ -2162,7 +2178,7 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask)
+       if (!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask)
                mesh_build_data(scene, ob, dataMask, 0);
 
        return ob->derivedFinal;
@@ -2173,7 +2189,7 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask)
+       if (!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask)
                mesh_build_data(scene, ob, dataMask, 0);
 
        return ob->derivedDeform;
@@ -2255,7 +2271,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit,
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!em->derivedCage ||
+       if (!em->derivedCage ||
           (em->lastDataMask & dataMask) != dataMask)
                editbmesh_build_data(scene, obedit, em, dataMask);
 
@@ -2268,7 +2284,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!em->derivedCage ||
+       if (!em->derivedCage ||
           (em->lastDataMask & dataMask) != dataMask)
                editbmesh_build_data(scene, obedit, em, dataMask);
 
@@ -2290,11 +2306,11 @@ static void make_vertexcosnos__mapFunc(void *userData, int index, float *co, flo
        vec+= 6*index;
 
        /* check if we've been here before (normal should not be 0) */
-       if(vec[3] || vec[4] || vec[5]) return;
+       if (vec[3] || vec[4] || vec[5]) return;
 
        copy_v3_v3(vec, co);
        vec+= 3;
-       if(no_f) {
+       if (no_f) {
                copy_v3_v3(vec, no_f);
        }
        else {
@@ -2314,20 +2330,20 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
        float *vertexcosnos;
        
        /* lets prevent crashing... */
-       if(ob->type!=OB_MESH || me->totvert==0)
+       if (ob->type!=OB_MESH || me->totvert==0)
                return NULL;
        
        dm= mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH|CD_MASK_ORIGINDEX);
        vertexcosnos= MEM_callocN(6*sizeof(float)*me->totvert, "vertexcosnos map");
        
-       if(dm->foreachMappedVert) {
+       if (dm->foreachMappedVert) {
                dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
        }
        else {
                float *fp= vertexcosnos;
                int a;
                
-               for(a=0; a< me->totvert; a++, fp+=6) {
+               for (a=0; a< me->totvert; a++, fp+=6) {
                        dm->getVertCo(dm, a, fp);
                        dm->getVertNo(dm, a, fp+3);
                }
@@ -2379,7 +2395,7 @@ static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[
        //assert(vert_index>=0 && vert_index<4);
        SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
 
-       if(pMesh->mtface!=NULL) {
+       if (pMesh->mtface!=NULL) {
                float * uv = pMesh->mtface[face_num].uv[vert_index];
                fUV[0]=uv[0]; fUV[1]=uv[1];
        }
@@ -2395,8 +2411,8 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
        SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
 
        const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
-       if(!smoothnormal) {     // flat
-               if(pMesh->precomputedFaceNormals) {
+       if (!smoothnormal) {    // flat
+               if (pMesh->precomputedFaceNormals) {
                        copy_v3_v3(fNorm, &pMesh->precomputedFaceNormals[3*face_num]);
                }
                else {
@@ -2405,7 +2421,7 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
                        float *p1= pMesh->mvert[mf->v2].co;
                        float *p2= pMesh->mvert[mf->v3].co;
 
-                       if(mf->v4) {
+                       if (mf->v4) {
                                float *p3 = pMesh->mvert[mf->v4].co;
                                normal_quad_v3(fNorm, p0, p1, p2, p3);
                        }
@@ -2443,7 +2459,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
        int i, j, len, mf_vi[4], totvert, totface, iCalcNewMethod;
        float *nors;
 
-       if(CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
+       if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
                return;
 
        nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
@@ -2456,9 +2472,9 @@ void DM_add_tangent_layer(DerivedMesh *dm)
        mface= dm->getTessFaceArray(dm);
        mtface= dm->getTessFaceDataArray(dm, CD_MTFACE);
 
-       if(!mtface) {
+       if (!mtface) {
                orco= dm->getVertDataArray(dm, CD_ORCO);
-               if(!orco)
+               if (!orco)
                        return;
        }
        
@@ -2473,7 +2489,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
 
        // new computation method
        iCalcNewMethod = 1;
-       if(iCalcNewMethod != 0) {
+       if (iCalcNewMethod != 0) {
                SGLSLMeshToTangent mesh2tangent= {0};
                SMikkTSpaceContext sContext= {0};
                SMikkTSpaceInterface sInterface= {0};
@@ -2499,9 +2515,9 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                iCalcNewMethod = genTangSpaceDefault(&sContext);
        }
 
-       if(!iCalcNewMethod) {
+       if (!iCalcNewMethod) {
                /* sum tangents at connected vertices */
-               for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) {
+               for (i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) {
                        v1= &mvert[mf->v1];
                        v2= &mvert[mf->v2];
                        v3= &mvert[mf->v3];
@@ -2515,7 +2531,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                                normal_tri_v3( fno,v3->co, v2->co, v1->co);
                        }
                
-                       if(mtface) {
+                       if (mtface) {
                                uv1= tf->uv[0];
                                uv2= tf->uv[1];
                                uv3= tf->uv[2];
@@ -2526,7 +2542,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                                map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
                                map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
                                map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
-                               if(v4)
+                               if (v4)
                                        map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
                        }
                
@@ -2535,7 +2551,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                        sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2);
                        sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3);
                
-                       if(mf->v4) {
+                       if (mf->v4) {
                                v4= &mvert[mf->v4];
                        
                                tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang);
@@ -2546,14 +2562,14 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                }
        
                /* write tangent to layer */
-               for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) {
+               for (i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) {
                        len= (mf->v4)? 4 : 3; 
 
-                       if(mtface == NULL) {
+                       if (mtface == NULL) {
                                map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
                                map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
                                map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
-                               if(len==4)
+                               if (len==4)
                                        map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
                        }
                
@@ -2562,7 +2578,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
                        mf_vi[2]= mf->v3;
                        mf_vi[3]= mf->v4;
                
-                       for(j=0; j<len; j++) {
+                       for (j=0; j<len; j++) {
                                vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]);
                                normalize_v3_v3(tangent[j], vtang);
                                ((float *) tangent[j])[3]=1.0f;
@@ -2583,7 +2599,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
        MFace * mface = dm->getTessFaceArray(dm);
        MTFace * mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);
 
-       if(mtface) {
+       if (mtface) {
                double dsum = 0.0;
                int nr_accumulated = 0;
                int f;
@@ -2603,7 +2619,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
 
                                // discard degenerate faces
                                is_degenerate = 0;
-                               if    equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) ||
+                               if (    equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) ||
                                        equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2]) )
                                {
                                        is_degenerate = 1;
@@ -2632,7 +2648,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
                                                        if (i == 0 ) {
                                                                is_signed = (signed_area < 0.0f) ? 1 : 0;
                                                        }
-                                                       else if((is_signed != 0) != (signed_area < 0.0f)) {
+                                                       else if ((is_signed != 0) != (signed_area < 0.0f)) {
                                                                is_degenerate = 1;
                                                        }
 
@@ -2657,10 +2673,10 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
                                                sub_v3_v3v3(vtmp, verts[3], verts[1]);
                                                pos_len_diag1 = dot_v3v3(vtmp, vtmp);
 
-                                               if(pos_len_diag1<pos_len_diag0) {
+                                               if (pos_len_diag1<pos_len_diag0) {
                                                        offs=1;         // alter split
                                                }
-                                               else if(pos_len_diag0==pos_len_diag1) { /* do UV check instead */
+                                               else if (pos_len_diag0==pos_len_diag1) { /* do UV check instead */
                                                        float tex_len_diag0, tex_len_diag1;
 
                                                        sub_v2_v2v2(vtmp, tex_coords[2], tex_coords[0]);
@@ -2733,25 +2749,25 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
        fdata = tfdata = dm->getTessFaceDataLayout(dm);
        
        /* calc auto bump scale if necessary */
-       if(dm->auto_bump_scale<=0.0f)
+       if (dm->auto_bump_scale<=0.0f)
                DM_calc_auto_bump_scale(dm);
 
        /* add a tangent layer if necessary */
-       for(b = 0; b < gattribs->totlayer; b++)
-               if(gattribs->layer[b].type == CD_TANGENT)
-                       if(CustomData_get_layer_index(fdata, CD_TANGENT) == -1)
+       for (b = 0; b < gattribs->totlayer; b++)
+               if (gattribs->layer[b].type == CD_TANGENT)
+                       if (CustomData_get_layer_index(fdata, CD_TANGENT) == -1)
                                DM_add_tangent_layer(dm);
 
-       for(b = 0; b < gattribs->totlayer; b++) {
-               if(gattribs->layer[b].type == CD_MTFACE) {
+       for (b = 0; b < gattribs->totlayer; b++) {
+               if (gattribs->layer[b].type == CD_MTFACE) {
                        /* uv coordinates */
-                       if(gattribs->layer[b].name[0])
+                       if (gattribs->layer[b].name[0])
                                layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE,
                                        gattribs->layer[b].name);
                        else
                                layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
 
-                       if(layer != -1) {
+                       if (layer != -1) {
                                a = attribs->tottface++;
 
                                attribs->tface[a].array = tfdata->layers[layer].data;
@@ -2765,7 +2781,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                                int player;
                                CustomData *pdata = dm->getPolyDataLayout(dm);
                                
-                               if(gattribs->layer[b].name[0])
+                               if (gattribs->layer[b].name[0])
                                        player = CustomData_get_named_layer_index(pdata, CD_MTEXPOLY,
                                                gattribs->layer[b].name);
                                else
@@ -2783,15 +2799,15 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                        }
 #endif
                }
-               else if(gattribs->layer[b].type == CD_MCOL) {
+               else if (gattribs->layer[b].type == CD_MCOL) {
                        /* vertex colors */
-                       if(gattribs->layer[b].name[0])
+                       if (gattribs->layer[b].name[0])
                                layer = CustomData_get_named_layer_index(tfdata, CD_MCOL,
                                        gattribs->layer[b].name);
                        else
                                layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
 
-                       if(layer != -1) {
+                       if (layer != -1) {
                                a = attribs->totmcol++;
 
                                attribs->mcol[a].array = tfdata->layers[layer].data;
@@ -2799,11 +2815,11 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                                attribs->mcol[a].glIndex = gattribs->layer[b].glindex;
                        }
                }
-               else if(gattribs->layer[b].type == CD_TANGENT) {
+               else if (gattribs->layer[b].type == CD_TANGENT) {
                        /* tangents */
                        layer = CustomData_get_layer_index(fdata, CD_TANGENT);
 
-                       if(layer != -1) {
+                       if (layer != -1) {
                                attribs->tottang = 1;
 
                                attribs->tang.array = fdata->layers[layer].data;
@@ -2811,11 +2827,11 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                                attribs->tang.glIndex = gattribs->layer[b].glindex;
                        }
                }
-               else if(gattribs->layer[b].type == CD_ORCO) {
+               else if (gattribs->layer[b].type == CD_ORCO) {
                        /* original coordinates */
                        layer = CustomData_get_layer_index(vdata, CD_ORCO);
 
-                       if(layer != -1) {
+                       if (layer != -1) {
                                attribs->totorco = 1;
 
                                attribs->orco.array = vdata->layers[layer].data;
@@ -2836,7 +2852,7 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
 
        dm->getMinMax(dm, min, max);
 
-       if(!ob->bb)
+       if (!ob->bb)
                ob->bb= MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
 
        boundbox_set_from_min_max(ob->bb, min, max);
@@ -2894,7 +2910,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
                DEBUG_VBO( "Using legacy code. drawNavMeshColored\n" );
                //glShadeModel(GL_SMOOTH);
                glBegin(glmode = GL_QUADS);
-               for(a = 0; a < dm->numTessFaceData; a++, mface++) {
+               for (a = 0; a < dm->numTessFaceData; a++, mface++) {
                        int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
                        int pi = polygonIdx[a];
                        if (pi <= 0) {
@@ -2904,7 +2920,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
                                navmesh_intToCol(pi, col);
                        }
 
-                       if(new_glmode != glmode) {
+                       if (new_glmode != glmode) {
                                glEnd();
                                glBegin(glmode = new_glmode);
                        }
@@ -2912,7 +2928,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
                        glVertex3fv(mvert[mface->v1].co);
                        glVertex3fv(mvert[mface->v2].co);
                        glVertex3fv(mvert[mface->v3].co);
-                       if(mface->v4) {
+                       if (mface->v4) {
                                glVertex3fv(mvert[mface->v4].co);
                        }
                }
index dcd4a71..b78a111 100644 (file)
@@ -415,7 +415,7 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name)
        if (ELEM(NULL, pose, name) || (name[0] == 0))
                return NULL;
        
-       if(pose->chanhash)
+       if (pose->chanhash)
                return BLI_ghash_lookup(pose->chanhash, (void *)name);
        
        return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
@@ -432,7 +432,7 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name)
        
        /* See if this channel exists */
        chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
-       if(chan) {
+       if (chan) {
                return chan;
        }
 
@@ -523,7 +523,7 @@ void copy_pose (bPose **dst, bPose *src, int copycon)
                        pchan->mpath= NULL; /* motion paths should not get copied yet... */
                }
                
-               if(pchan->prop) {
+               if (pchan->prop) {
                        pchan->prop= IDP_CopyProperty(pchan->prop);
                }
        }
@@ -570,18 +570,18 @@ void init_pose_ikparam(bPose *pose)
 
 void make_pose_channels_hash(bPose *pose) 
 {
-       if(!pose->chanhash) {
+       if (!pose->chanhash) {
                bPoseChannel *pchan;
 
                pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh");
-               for(pchan=pose->chanbase.first; pchan; pchan=pchan->next)
+               for (pchan=pose->chanbase.first; pchan; pchan=pchan->next)
                        BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
        }
 }
 
 void free_pose_channels_hash(bPose *pose) 
 {
-       if(pose->chanhash) {
+       if (pose->chanhash) {
                BLI_ghash_free(pose->chanhash, NULL, NULL);
                pose->chanhash= NULL;
        }
@@ -656,7 +656,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
        pchan->flag= chan->flag;
        
        con= chan->constraints.first;
-       for(pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) {
+       for (pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) {
                pcon->enforce= con->enforce;
                pcon->headtail= con->headtail;
        }
@@ -689,13 +689,13 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_
        copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE);
 
        /* id-properties */
-       if(pchan->prop) {
+       if (pchan->prop) {
                /* unlikely but possible it exists */
                IDP_FreeProperty(pchan->prop);
                MEM_freeN(pchan->prop);
                pchan->prop= NULL;
        }
-       if(pchan_from->prop) {
+       if (pchan_from->prop) {
                pchan->prop= IDP_CopyProperty(pchan_from->prop);
        }
 
@@ -727,19 +727,19 @@ void update_pose_constraint_flags(bPose *pose)
                                
                                pchan->constflag |= PCHAN_HAS_IK;
                                
-                               if(data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
+                               if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
                                        pchan->constflag |= PCHAN_HAS_TARGET;
                                
                                /* negative rootbone = recalc rootbone index. used in do_versions */
-                               if(data->rootbone<0) {
+                               if (data->rootbone<0) {
                                        data->rootbone= 0;
                                        
-                                       if(data->flag & CONSTRAINT_IK_TIP) parchan= pchan;
+                                       if (data->flag & CONSTRAINT_IK_TIP) parchan= pchan;
                                        else parchan= pchan->parent;
                                        
-                                       while(parchan) {
+                                       while (parchan) {
                                                data->rootbone++;
-                                               if((parchan->bone->flag & BONE_CONNECTED)==0)
+                                               if ((parchan->bone->flag & BONE_CONNECTED)==0)
                                                        break;
                                                parchan= parchan->parent;
                                        }
@@ -837,7 +837,7 @@ void pose_remove_group (Object *ob)
                /* now, remove it from the pose */
                BLI_freelinkN(&pose->agroups, grp);
                pose->active_group--;
-               if(pose->active_group < 0 || pose->agroups.first == NULL) {
+               if (pose->active_group < 0 || pose->agroups.first == NULL) {
                        pose->active_group= 0;
                }
        }
@@ -932,7 +932,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
        }       
        
        if (foundvert || foundmod) {
-               if(min==max) max+= 1.0f;
+               if (min==max) max+= 1.0f;
                *start= min;
                *end= max;
        }
@@ -1097,7 +1097,7 @@ void copy_pose_result(bPose *to, bPose *from)
 {
        bPoseChannel *pchanto, *pchanfrom;
        
-       if(to==NULL || from==NULL) {
+       if (to==NULL || from==NULL) {
                printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp
                return;
        }
@@ -1108,9 +1108,9 @@ void copy_pose_result(bPose *to, bPose *from)
        }
 
 
-       for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
+       for (pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
                pchanto= get_pose_channel(to, pchanfrom->name);
-               if(pchanto) {
+               if (pchanto) {
                        copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
                        copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
                        
@@ -1237,15 +1237,15 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
        /* matching offset bones */
        /* take dst offset, and put src on on that location */
        
-       if(strip->offs_bone[0]==0)
+       if (strip->offs_bone[0]==0)
                return;
        
        /* are we also blending with matching bones? */
-       if(strip->prev && strip->start>=strip->prev->start) {
+       if (strip->prev && strip->start>=strip->prev->start) {
                bPoseChannel *dpchan= get_pose_channel(dst, strip->offs_bone);
-               if(dpchan) {
+               if (dpchan) {
                        bPoseChannel *spchan= get_pose_channel(src, strip->offs_bone);
-                       if(spchan) {
+                       if (spchan) {
                                float vec[3];
                                
                                /* dst->ctime has the internal strip->prev action time */
@@ -1253,7 +1253,7 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
                                
                                float ctime= get_actionstrip_frame(strip, src->ctime, 1);
                                
-                               if( ctime > strip->prev->end) {
+                               if ( ctime > strip->prev->end) {
                                        bActionChannel *achan;
                                        
                                        /* add src to dest, minus the position of src on strip->prev->end */
@@ -1261,7 +1261,7 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
                                        ctime= get_actionstrip_frame(strip, strip->prev->end, 0);
                                        
                                        achan= get_action_channel(strip->act, strip->offs_bone);
-                                       if(achan && achan->ipo) {
+                                       if (achan && achan->ipo) {
                                                bPoseChannel pchan;
                                                /* Evaluates and sets the internal ipo value */
                                                calc_ipo(achan->ipo, ctime);
@@ -1302,19 +1302,19 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
        bActionChannel *achan= get_action_channel(act, name);
        int stride_axis= strip->stride_axis;
 
-       if(achan && achan->ipo) {
+       if (achan && achan->ipo) {
                IpoCurve *icu= NULL;
                float minx=0.0f, maxx=0.0f, miny=0.0f, maxy=0.0f;
                int foundvert= 0;
                
-               if(stride_axis==0) stride_axis= AC_LOC_X;
-               else if(stride_axis==1) stride_axis= AC_LOC_Y;
+               if (stride_axis==0) stride_axis= AC_LOC_X;
+               else if (stride_axis==1) stride_axis= AC_LOC_Y;
                else stride_axis= AC_LOC_Z;
                
                /* calculate the min/max */
                for (icu=achan->ipo->curve.first; icu; icu=icu->next) {
-                       if(icu->adrcode==stride_axis) {
-                               if(icu->totvert>1) {
+                       if (icu->adrcode==stride_axis) {
+                               if (icu->totvert>1) {
                                        foundvert= 1;
                                        minx= icu->bezt[0].vec[1][0];
                                        maxx= icu->bezt[icu->totvert-1].vec[1][0];
@@ -1326,7 +1326,7 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
                        }
                }
                
-               if(foundvert && miny!=maxy) {
+               if (foundvert && miny!=maxy) {
                        float stridelen= sizecorr*fabs(maxy-miny), striptime;
                        float actiondist, pdist, pdistNewNormalized, offs;
                        float vec1[4], vec2[4], dir[3];
@@ -1366,10 +1366,10 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
 static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float time)
 {
        /* only called when strip has cyclic, so >= 1.0f works... */
-       if(time >= 1.0f) {
+       if (time >= 1.0f) {
                bActionChannel *achan= get_action_channel(strip->act, strip->offs_bone);
 
-               if(achan && achan->ipo) {
+               if (achan && achan->ipo) {
                        IpoCurve *icu= NULL;
                        Bone *bone;
                        float min[3]={0.0f, 0.0f, 0.0f}, max[3]={0.0f, 0.0f, 0.0f};
@@ -1377,13 +1377,13 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
                        
                        /* calculate the min/max */
                        for (icu=achan->ipo->curve.first; icu; icu=icu->next) {
-                               if(icu->totvert>1) {
+                               if (icu->totvert>1) {
                                        
-                                       if(icu->adrcode==AC_LOC_X)
+                                       if (icu->adrcode==AC_LOC_X)
                                                index= 0;
-                                       else if(icu->adrcode==AC_LOC_Y)
+                                       else if (icu->adrcode==AC_LOC_Y)
                                                index= 1;
-                                       else if(icu->adrcode==AC_LOC_Z)
+                                       else if (icu->adrcode==AC_LOC_Z)
                                                index= 2;
                                        else
                                                continue;
@@ -1393,11 +1393,11 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
                                        max[index]= icu->bezt[icu->totvert-1].vec[1][1];
                                }
                        }
-                       if(foundvert) {
+                       if (foundvert) {
                                /* bring it into armature space */
                                sub_v3_v3v3(min, max, min);
                                bone= get_named_bone(ob->data, strip->offs_bone);       /* weak */
-                               if(bone) {
+                               if (bone) {
                                        mul_mat3_m4_v3(bone->arm_mat, min);
                                        
                                        /* dominant motion, cyclic_offset was cleared in rest_pose */
@@ -1405,10 +1405,11 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
                                                if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0];
                                                if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1];
                                                if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2];
-                                       } else {
-                                               if( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2]))
+                                       }
+                                       else {
+                                               if ( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2]))
                                                        pose->cyclic_offset[0]= time*min[0];
-                                               else if( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2]))
+                                               else if ( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2]))
                                                        pose->cyclic_offset[1]= time*min[1];
                                                else
                                                        pose->cyclic_offset[2]= time*min[2];
@@ -1425,12 +1426,12 @@ static Object *get_parent_path(Object *ob)
 {
        bConstraint *con;
        
-       if(ob->parent && ob->parent->type==OB_CURVE)
+       if (ob->parent && ob->parent->type==OB_CURVE)
                return ob->parent;
        
        for (con = ob->constraints.first; con; con=con->next) {
-               if(con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
-                       if(con->enforce>0.5f) {
+               if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
+                       if (con->enforce>0.5f) {
                                bFollowPathConstraint *data= con->data;
                                return data->tar;
                        }
@@ -1454,7 +1455,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
        float scene_cfra= BKE_curframe(scene);
        int     doit, dostride;
        
-       if(blocktype==ID_AR) {
+       if (blocktype==ID_AR) {
                copy_pose(&tpose, ob->pose, 1);
                rest_pose(ob->pose);            // potentially destroying current not-keyed pose
        }
@@ -1465,25 +1466,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
        /* check on extend to left or right, when no strip is hit by 'cfra' */
        for (strip=ob->nlastrips.first; strip; strip=strip->next) {
                /* escape loop on a hit */
-               if( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f)      /* note 0.1 comes back below */
+               if ( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f)     /* note 0.1 comes back below */
                        break;
-               if(scene_cfra < strip->start) {
-                       if(stripfirst==NULL)
+               if (scene_cfra < strip->start) {
+                       if (stripfirst==NULL)
                                stripfirst= strip;
-                       else if(stripfirst->start > strip->start)
+                       else if (stripfirst->start > strip->start)
                                stripfirst= strip;
                }
-               else if(scene_cfra > strip->end) {
-                       if(striplast==NULL)
+               else if (scene_cfra > strip->end) {
+                       if (striplast==NULL)
                                striplast= strip;
-                       else if(striplast->end < strip->end)
+                       else if (striplast->end < strip->end)
                                striplast= strip;
                }
        }
-       if(strip==NULL) {       /* extend */
-               if(striplast)
+       if (strip==NULL) {      /* extend */
+               if (striplast)
                        scene_cfra= striplast->end;
-               else if(stripfirst)
+               else if (stripfirst)
                        scene_cfra= stripfirst->start;
        }
        
@@ -1501,7 +1502,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
 
                        if (striptime>=0.0) {
                                
-                               if(blocktype==ID_AR) 
+                               if (blocktype==ID_AR) 
                                        rest_pose(tpose);
                                
                                /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */
@@ -1517,20 +1518,20 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                                                        
                                                        if (cu->flag & CU_PATH) {
                                                                /* Ensure we have a valid path */
-                                                               if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
-                                                               if(cu->path) {
+                                                               if (cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
+                                                               if (cu->path) {
                                                                        
                                                                        /* Find the position on the path */
                                                                        ctime= bsystem_time(scene, ob, scene_cfra, 0.0);
                                                                        
-                                                                       if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
+                                                                       if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
                                                                                /* correct for actions not starting on zero */
                                                                                ctime= (ctime - strip->actstart)/cu->pathlen;
                                                                                CLAMP(ctime, 0.0, 1.0);
                                                                        }
                                                                        pdist = ctime*cu->path->totdist;
                                                                        
-                                                                       if(tpose && strip->stridechannel[0]) {
+                                                                       if (tpose && strip->stridechannel[0]) {
                                                                                striptime= stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset);
                                                                        }                                                                       
                                                                        else {
@@ -1545,12 +1546,12 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                                                                        frametime = (striptime * actlength) + strip->actstart;
                                                                        frametime= bsystem_time(scene, ob, frametime, 0.0);
                                                                        
-                                                                       if(blocktype==ID_AR) {
+                                                                       if (blocktype==ID_AR) {
                                                                                extract_pose_from_action (tpose, strip->act, frametime);
                                                                        }
-                                                                       else if(blocktype==ID_OB) {
+                                                                       else if (blocktype==ID_OB) {
                                                                                extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
-                                                                               if(key)
+                                                                               if (key)
                                                                                        extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
                                                                        }
                                                                        doit=dostride= 1;
@@ -1562,25 +1563,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                                        else  {
                                                
                                                /* Mod to repeat */
-                                               if(strip->repeat!=1.0f) {
+                                               if (strip->repeat!=1.0f) {
                                                        float cycle= striptime*strip->repeat;
                                                        
                                                        striptime = (float)fmod (cycle, 1.0f + 0.1f/length);
                                                        cycle-= striptime;
                                                        
-                                                       if(blocktype==ID_AR)
+                                                       if (blocktype==ID_AR)
                                                                cyclic_offs_bone(ob, tpose, strip, cycle);
                                                }
 
                                                frametime = (striptime * actlength) + strip->actstart;
                                                frametime= nla_time(scene, frametime, (float)strip->repeat);
                                                        
-                                               if(blocktype==ID_AR) {
+                                               if (blocktype==ID_AR) {
                                                        extract_pose_from_action (tpose, strip->act, frametime);
                                                }
-                                               else if(blocktype==ID_OB) {
+                                               else if (blocktype==ID_OB) {
                                                        extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
-                                                       if(key)
+                                                       if (key)
                                                                extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
                                                }
                                                
@@ -1593,20 +1594,20 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                                                /* we want the strip to hold on the exact fraction of the repeat value */
                                                
                                                frametime = actlength * (strip->repeat-(int)strip->repeat);
-                                               if(frametime<=0.000001f) frametime= actlength;  /* rounding errors... */
+                                               if (frametime<=0.000001f) frametime= actlength; /* rounding errors... */
                                                frametime= bsystem_time(scene, ob, frametime+strip->actstart, 0.0);
                                                
-                                               if(blocktype==ID_AR)
+                                               if (blocktype==ID_AR)
                                                        extract_pose_from_action (tpose, strip->act, frametime);
-                                               else if(blocktype==ID_OB) {
+                                               else if (blocktype==ID_OB) {
                                                        extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
-                                                       if(key)
+                                                       if (key)
                                                                extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
                                                }
                                                
                                                /* handle cycle hold */
-                                               if(strip->repeat!=1.0f) {
-                                                       if(blocktype==ID_AR)
+                                               if (strip->repeat!=1.0f) {
+                                                       if (blocktype==ID_AR)
                                                                cyclic_offs_bone(ob, tpose, strip, strip->repeat-1.0f);
                                                }
                                                
@@ -1627,12 +1628,12 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                                        else
                                                blendfac = 1;
                                        
-                                       if(blocktype==ID_AR) {/* Blend this pose with the accumulated pose */
+                                       if (blocktype==ID_AR) {/* Blend this pose with the accumulated pose */
                                                /* offset bone, for matching cycles */
                                                blend_pose_offset_bone (strip, ob->pose, tpose, blendfac, strip->mode);
                                                
                                                blend_poses (ob->pose, tpose, blendfac, strip->mode);
-                                               if(dostride)
+                                               if (dostride)
                                                        blend_pose_strides (ob->pose, tpose, blendfac, strip->mode);
                                        }
                                        else {
@@ -1644,10 +1645,10 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
                }
        }
        
-       if(blocktype==ID_OB) {
+       if (blocktype==ID_OB) {
                execute_ipochannels(&chanbase);
        }
-       else if(blocktype==ID_AR) {
+       else if (blocktype==ID_AR) {
                /* apply stride offset to object */
                add_v3_v3(ob->obmat[3], ob->pose->stride_offset);
        }
@@ -1655,7 +1656,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
        /* free */
        if (tpose)
                free_pose(tpose);
-       if(chanbase.first)
+       if (chanbase.first)
                BLI_freelistN(&chanbase);
 }
 
index 48d8631..19c4a65 100644 (file)
@@ -456,7 +456,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
  */
 void free_path(Path *path)
 {
-       if(path->data) MEM_freeN(path->data);
+       if (path->data) MEM_freeN(path->data);
        MEM_freeN(path);
 }
 
@@ -479,29 +479,29 @@ void calc_curvepath(Object *ob)
        /* in a path vertices are with equal differences: path->len = number of verts */
        /* NOW WITH BEVELCURVE!!! */
        
-       if(ob==NULL || ob->type != OB_CURVE) return;
+       if (ob==NULL || ob->type != OB_CURVE) return;
        cu= ob->data;
 
        nurbs= BKE_curve_nurbs(cu);
        nu= nurbs->first;
 
-       if(cu->path) free_path(cu->path);
+       if (cu->path) free_path(cu->path);
        cu->path= NULL;
        
        bl= cu->bev.first;
-       if(bl==NULL || !bl->nr) return;
+       if (bl==NULL || !bl->nr) return;
 
        cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath");
        
        /* if POLY: last vertice != first vertice */
        cycl= (bl->poly!= -1);
        
-       if(cycl) tot= bl->nr;
+       if (cycl) tot= bl->nr;
        else tot= bl->nr-1;
        
        path->len= tot+1;
        /* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
-       if(path->len<nu->resolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu);
+       if (path->len<nu->resolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu);
        
        dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist");
 
@@ -509,9 +509,9 @@ void calc_curvepath(Object *ob)
        bevp= bevpfirst= (BevPoint *)(bl+1);
        fp= dist;
        *fp= 0;
-       for(a=0; a<tot; a++) {
+       for (a=0; a<tot; a++) {
                fp++;
-               if(cycl && a==tot-1)
+               if (cycl && a==tot-1)
                        sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
                else
                        sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec);
@@ -534,17 +534,17 @@ void calc_curvepath(Object *ob)
        fac= 1.0f/((float)path->len-1.0f);
                fac = fac * path->totdist;
        
-       for(a=0; a<path->len; a++) {
+       for (a=0; a<path->len; a++) {
                
                d= ((float)a)*fac;
                
                /* we're looking for location (distance) 'd' in the array */
-               while((d>= *fp) && fp<maxdist) {
+               while ((d>= *fp) && fp<maxdist) {
                        fp++;
-                       if(bevp<bevplast) bevp++;
+                       if (bevp<bevplast) bevp++;
                        bevpn= bevp+1;
-                       if(bevpn>bevplast) {
-                               if(cycl) bevpn= bevpfirst;
+                       if (bevpn>bevplast) {
+                               if (cycl) bevpn= bevpfirst;
                                else bevpn= bevplast;
                        }
                }
@@ -571,15 +571,15 @@ void calc_curvepath(Object *ob)
 /* is this only used internally?*/
 int interval_test(int min, int max, int p1, int cycl)
 {
-       if(cycl) {
-               if(p1 < min) 
+       if (cycl) {
+               if (p1 < min) 
                        p1=  ((p1 -min) % (max-min+1)) + max+1;
-               else if(p1 > max)
+               else if (p1 > max)
                        p1=  ((p1 -min) % (max-min+1)) + min;
        }
        else {
-               if(p1 < min) p1= min;
-               else if(p1 > max) p1= max;
+               if (p1 < min) p1= min;
+               else if (p1 > max) p1= max;
        }
        return p1;
 }
@@ -603,9 +603,9 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
        float data[4];
        int cycl=0, s0, s1, s2, s3;
 
-       if(ob==NULL || ob->type != OB_CURVE) return 0;
+       if (ob==NULL || ob->type != OB_CURVE) return 0;
        cu= ob->data;
-       if(cu->path==NULL || cu->path->data==NULL) {
+       if (cu->path==NULL || cu->path->data==NULL) {
                printf("no path!\n");
                return 0;
        }
@@ -616,7 +616,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
        bl= cu->bev.first;
        if (!bl) return 0;
        if (!bl->nr) return 0;
-       if(bl->poly> -1) cycl= 1;
+       if (bl->poly> -1) cycl= 1;
 
        ctime *= (path->len-1);
        
@@ -648,9 +648,9 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
        nu= cu->nurb.first;
 
        /* make sure that first and last frame are included in the vectors here  */
-       if(nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
-       else if(nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
-       else if(s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
+       if (nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
+       else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
+       else if (s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
        else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE);
 
        vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */
@@ -662,22 +662,22 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
                float totfac, q1[4], q2[4];
 
                totfac= data[0]+data[3];
-               if(totfac>FLT_EPSILON)  interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
+               if (totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
                else                                    copy_qt_qt(q1, p1->quat);
 
                totfac= data[1]+data[2];
-               if(totfac>FLT_EPSILON)  interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
+               if (totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
                else                                    copy_qt_qt(q2, p3->quat);
 
                totfac = data[0]+data[1]+data[2]+data[3];
-               if(totfac>FLT_EPSILON)  interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac);
+               if (totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac);
                else                                    copy_qt_qt(quat, q2);
        }
 
-       if(radius)
+       if (radius)
                *radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius;
 
-       if(weight)
+       if (weight)
                *weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight;
 
        return 1;
@@ -710,23 +710,23 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
        GroupObject *go;
        float mat[4][4], tmat[4][4];
        
-       if(ob->dup_group==NULL) return;
+       if (ob->dup_group==NULL) return;
        group= ob->dup_group;
        
        /* simple preventing of too deep nested groups */
-       if(level>MAX_DUPLI_RECUR) return;
+       if (level>MAX_DUPLI_RECUR) return;
        
        /* handles animated groups, and */
        /* we need to check update for objects that are not in scene... */
        group_handle_recalc_and_update(scene, ob, group);
        animated= animated || group_is_animated(ob, group);
        
-       for(go= group->gobject.first; go; go= go->next) {
+       for (go= group->gobject.first; go; go= go->next) {
                /* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
-               if(go->ob!=ob) {
+               if (go->ob!=ob) {
                        
                        /* group dupli offset, should apply after everything else */
-                       if(!is_zero_v3(group->dupli_ofs)) {
+                       if (!is_zero_v3(group->dupli_ofs)) {
                                copy_m4_m4(tmat, go->ob->obmat);
                                sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
                                mult_m4_m4m4(mat, ob->obmat, tmat);
@@ -738,7 +738,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
                        dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
 
                        /* check the group instance and object layers match, also that the object visible flags are ok. */
-                       if    (dob->origlay & group->layer)==0 ||
+                       if (    (dob->origlay & group->layer)==0 ||
                                (G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
                                (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)
                        ) {
@@ -748,7 +748,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
                                dob->no_draw= 0;
                        }
 
-                       if(go->ob->transflag & OB_DUPLI) {
+                       if (go->ob->transflag & OB_DUPLI) {
                                copy_m4_m4(dob->ob->obmat, dob->mat);
                                object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated);
                                copy_m4_m4(dob->ob->obmat, dob->omat);
@@ -854,11 +854,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
        copy_m4_m4(obmat, vdd->obmat);
        copy_v3_v3(obmat[3], vec);
        
-       if(vdd->par->transflag & OB_DUPLIROT) {
-               if(no_f) {
+       if (vdd->par->transflag & OB_DUPLIROT) {
+               if (no_f) {
                        vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2];
                }
-               else if(no_s) {
+               else if (no_s) {
                        vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2];
                }
                
@@ -876,10 +876,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
        /* restore the original layer so that each dupli will have proper dob->origlay */
        vdd->ob->lay = origlay;
 
-       if(vdd->orco)
+       if (vdd->orco)
                copy_v3_v3(dob->orco, vdd->orco[index]);
        
-       if(vdd->ob->transflag & OB_DUPLI) {
+       if (vdd->ob->transflag & OB_DUPLI) {
                float tmpmat[4][4];
                copy_m4_m4(tmpmat, vdd->ob->obmat);
                copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
@@ -906,16 +906,17 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
        copy_m4_m4(pmat, par->obmat);
        
        /* simple preventing of too deep nested groups */
-       if(level>MAX_DUPLI_RECUR) return;
+       if (level>MAX_DUPLI_RECUR) return;
        
        em = me->edit_btmesh;
        
-       if(em) {
+       if (em) {
                dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
-       } else
+       }
+       else
                dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
        
-       if(G.rendering) {
+       if (G.rendering) {
                vdd.orco= (float(*)[3])get_mesh_orco_verts(par);
                transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0);
        }
@@ -929,7 +930,8 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                sce = (Scene *)id;
                lay= sce->lay;
                base= sce->base.first;
-       } else {
+       }
+       else {
                group = (Group *)id;
                lay= group->layer;
                go = group->gobject.first;
@@ -940,15 +942,16 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                if (sce) {
                        ob_iter= base->object;
                        oblay = base->lay;
-               } else {
+               }
+               else {
                        ob_iter= go->ob;
                        oblay = ob_iter->lay;
                }
                
                if (lay & oblay && scene->obedit!=ob_iter) {
                        ob=ob_iter->parent;
-                       while(ob) {
-                               if(ob==par) {
+                       while (ob) {
+                               if (ob==par) {
                                        ob = ob_iter;
        /* End Scene/Group object loop, below is generic */
                                        
@@ -956,7 +959,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                        /* par_space_mat - only used for groups so we can modify the space dupli's are in
                                         * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                         */
-                                       if(par_space_mat)
+                                       if (par_space_mat)
                                                mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(vdd.obmat, ob->obmat);
@@ -971,20 +974,20 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                        copy_m4_m4(vdd.pmat, pmat);
                                        
                                        /* mballs have a different dupli handling */
-                                       if(ob->type!=OB_MBALL) ob->flag |= OB_DONE;     /* doesnt render */
+                                       if (ob->type!=OB_MBALL) ob->flag |= OB_DONE;    /* doesnt render */
 
-                                       if(me->edit_btmesh) {
+                                       if (me->edit_btmesh) {
                                                dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
                                        }
                                        else {
-                                               for(a=0; a<totvert; a++) {
+                                               for (a=0; a<totvert; a++) {
                                                        dm->getVertCo(dm, a, vec);
                                                        dm->getVertNo(dm, a, no);
                                                        
                                                        vertex_dupli__mapFunc(&vdd, a, vec, no, NULL);
                                                }
                                        }
-                                       if(sce) {
+                                       if (sce) {
                                                /* Set proper layer in case of scene looping,
                                                 * in case of groups the object layer will be
                                                 * changed when it's duplicated due to the
@@ -1002,7 +1005,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                else            go= go->next;           /* group loop */
        }
 
-       if(vdd.orco)
+       if (vdd.orco)
                MEM_freeN(vdd.orco);
        dm->release(dm);
 }
@@ -1027,12 +1030,12 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
        
        /* simple preventing of too deep nested groups */
-       if(level>MAX_DUPLI_RECUR) return;
+       if (level>MAX_DUPLI_RECUR) return;
        
        copy_m4_m4(pmat, par->obmat);
        em = me->edit_btmesh;
 
-       if(em) {
+       if (em) {
                dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
        }
        else {
@@ -1044,7 +1047,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        mloop= dm->getLoopArray(dm);
        mvert= dm->getVertArray(dm);
 
-       if(G.rendering) {
+       if (G.rendering) {
 
                orco= (float(*)[3])get_mesh_orco_verts(par);
                transform_mesh_orco_verts(me, orco, me->totvert, 0);
@@ -1060,7 +1063,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                sce = (Scene *)id;
                lay= sce->lay;
                base= sce->base.first;
-       } else {
+       }
+       else {
                group = (Group *)id;
                lay= group->layer;
                go = group->gobject.first;
@@ -1071,22 +1075,23 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                if (sce) {
                        ob_iter= base->object;
                        oblay = base->lay;
-               } else {
+               }
+               else {
                        ob_iter= go->ob;
                        oblay = ob_iter->lay;
                }
                
                if (lay & oblay && scene->obedit!=ob_iter) {
                        ob=ob_iter->parent;
-                       while(ob) {
-                               if(ob==par) {
+                       while (ob) {
+                               if (ob==par) {
                                        ob = ob_iter;
        /* End Scene/Group object loop, below is generic */
                                        
                                        /* par_space_mat - only used for groups so we can modify the space dupli's are in
                                         * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
                                         */
-                                       if(par_space_mat)
+                                       if (par_space_mat)
                                                mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
                                        else
                                                copy_m4_m4(ob__obmat, ob->obmat);
@@ -1094,9 +1099,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                        copy_m3_m4(imat, ob->parentinv);
                                                
                                        /* mballs have a different dupli handling */
-                                       if(ob->type!=OB_MBALL) ob->flag |= OB_DONE;     /* doesnt render */
+                                       if (ob->type!=OB_MBALL) ob->flag |= OB_DONE;    /* doesnt render */
 
-                                       for(a=0, mp= mpoly; a<totface; a++, mp++) {
+                                       for (a=0, mp= mpoly; a<totface; a++, mp++) {
                                                int mv1;
                                                int mv2;
                                                int mv3;
@@ -1140,7 +1145,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                quat_to_mat3( mat,quat);
                                                
                                                /* scale */
-                                               if(par->transflag & OB_DUPLIFACES_SCALE) {
+                                               if (par->transflag & OB_DUPLIFACES_SCALE) {
                                                        float size= mesh_calc_poly_area(mp, loopstart, mvert, NULL);
                                                        size= sqrtf(size) * par->dupfacesca;
                                                        mul_m3_fl(mat, size);
@@ -1153,17 +1158,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                mul_m4_m4m3(obmat, tmat, mat);
                                                
                                                dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated);
-                                               if(G.rendering) {
+                                               if (G.rendering) {
                                                        w= 1.0f / (float)mp->totloop;
 
-                                                       if(orco) {
+                                                       if (orco) {
                                                                int j;
                                                                for (j = 0; j < mpoly->totloop; j++) {
                                                                        madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w);
                                                                }
                                                        }
 
-                                                       if(mloopuv) {
+                                                       if (mloopuv) {
                                                                int j;
                                                                for (j = 0; j < mpoly->totloop; j++) {
                                                                        madd_v2_v2fl(dob->orco, mloopuv[loopstart[j].v].uv, w);
@@ -1171,7 +1176,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                        }
                                                }
                                                
-                                               if(ob->transflag & OB_DUPLI) {
+                                               if (ob->transflag & OB_DUPLI) {
                                                        float tmpmat[4][4];
                                                        copy_m4_m4(tmpmat, ob->obmat);
                                                        copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
@@ -1189,7 +1194,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                else            go= go->next;           /* group loop */
        }
 
-       if(orco)
+       if (orco)
                MEM_freeN(orco);
        
        dm->release(dm);
@@ -1214,20 +1219,20 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
        int no_draw_flag = PARS_UNEXIST;
 
-       if(psys==NULL) return;
+       if (psys==NULL) return;
        
        /* simple preventing of too deep nested groups */
-       if(level>MAX_DUPLI_RECUR) return;
+       if (level>MAX_DUPLI_RECUR) return;
        
        part=psys->part;
 
-       if(part==NULL)
+       if (part==NULL)
                return;
 
-       if(!psys_check_enabled(par, psys))
+       if (!psys_check_enabled(par, psys))
                return;
 
-       if(G.rendering == 0)
+       if (G.rendering == 0)
                no_draw_flag |= PARS_NO_DISP;
        
        ctime = BKE_curframe(scene); /* NOTE: in old animsys, used parent object's timeoffset... */
@@ -1237,7 +1242,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
        BLI_srandom(31415926 + psys->seed);
 
-       if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
+       if ((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
                ParticleSimulationData sim= {NULL};
                sim.scene= scene;
                sim.ob= par;
@@ -1247,24 +1252,24 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                invert_m4_m4(par->imat, par->obmat);
 
                /* first check for loops (particle system object used as dupli object) */
-               if(part->ren_as == PART_DRAW_OB) {
-                       if(ELEM(part->dup_ob, NULL, par))
+               if (part->ren_as == PART_DRAW_OB) {
+                       if (ELEM(part->dup_ob, NULL, par))
                                return;
                }
                else { /*PART_DRAW_GR */
-                       if(part->dup_group == NULL || part->dup_group->gobject.first == NULL)
+                       if (part->dup_group == NULL || part->dup_group->gobject.first == NULL)
                                return;
 
-                       for(go=part->dup_group->gobject.first; go; go=go->next)
-                               if(go->ob == par)
+                       for (go=part->dup_group->gobject.first; go; go=go->next)
+                               if (go->ob == par)
                                        return;
                }
 
                /* if we have a hair particle system, use the path cache */
-               if(part->type == PART_HAIR) {
-                       if(psys->flag & PSYS_HAIR_DONE)
+               if (part->type == PART_HAIR) {
+                       if (psys->flag & PSYS_HAIR_DONE)
                                hair= (totchild == 0 || psys->childcache) && psys->pathcache;
-                       if(!hair)
+                       if (!hair)
                                return;
                        
                        /* we use cache, update totchild according to cached data */
@@ -1277,15 +1282,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                psys->lattice = psys_get_lattice(&sim);
 
                /* gather list of objects or single object */
-               if(part->ren_as==PART_DRAW_GR) {
+               if (part->ren_as==PART_DRAW_GR) {
                        group_handle_recalc_and_update(scene, par, part->dup_group);
 
-                       if(part->draw & PART_DRAW_COUNT_GR) {
-                               for(dw=part->dupliweights.first; dw; dw=dw->next)
+                       if (part->draw & PART_DRAW_COUNT_GR) {
+                               for (dw=part->dupliweights.first; dw; dw=dw->next)
                                        totgroup += dw->count;
                        }
                        else {
-                               for(go=part->dup_group->gobject.first; go; go=go->next)
+                               for (go=part->dup_group->gobject.first; go; go=go->next)
                                        totgroup++;
                        }
 
@@ -1295,11 +1300,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                        obcopylist = MEM_callocN(totgroup*sizeof(Object), "dupgroup copy list");
 
                        
-                       if(part->draw & PART_DRAW_COUNT_GR && totgroup) {
+                       if (part->draw & PART_DRAW_COUNT_GR && totgroup) {
                                dw = part->dupliweights.first;
 
-                               for(a=0; a<totgroup; dw=dw->next) {
-                                       for(b=0; b<dw->count; b++, a++) {
+                               for (a=0; a<totgroup; dw=dw->next) {
+                                       for (b=0; b<dw->count; b++, a++) {
                                                oblist[a] = dw->ob;
                                                obcopylist[a] = *dw->ob;
                                        }
@@ -1307,7 +1312,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                        }
                        else {
                                go = part->dup_group->gobject.first;
-                               for(a=0; a<totgroup; a++, go=go->next) {
+                               for (a=0; a<totgroup; a++, go=go->next) {
                                        oblist[a] = go->ob;
                                        obcopylist[a] = *go->ob;
                                }
@@ -1318,15 +1323,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                        obcopy = *ob;
                }
 
-               if(totchild==0 || part->draw & PART_DRAW_PARENT)
+               if (totchild==0 || part->draw & PART_DRAW_PARENT)
                        a = 0;
                else
                        a = totpart;
 
-               for(pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) {
-                       if(a<totpart) {
+               for (pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) {
+                       if (a<totpart) {
                                /* handle parent particle */
-                               if(pa->flag & no_draw_flag)
+                               if (pa->flag & no_draw_flag)
                                        continue;
 
                                /* pa_num = pa->num; */ /* UNUSED */
@@ -1343,18 +1348,18 @@ 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 &&
+                       if (hair &&
                                ((a < totpart && psys->pathcache[a]->steps < 0) ||
                                (a >= totpart && psys->childcache[a-totpart]->steps < 0)))
                                continue;
 
-                       if(part->ren_as==PART_DRAW_GR) {
+                       if (part->ren_as==PART_DRAW_GR) {
                                /* prevent divide by zero below [#28336] */
-                               if(totgroup == 0)
+                               if (totgroup == 0)
                                        continue;
 
                                /* for groups, pick the object based on settings */
-                               if(part->draw&PART_DRAW_RAND_GR)
+                               if (part->draw&PART_DRAW_RAND_GR)
                                        b= BLI_rand() % totgroup;
                                else
                                        b= a % totgroup;
@@ -1368,9 +1373,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                oldobmat= obcopy.obmat;
                        }
 
-                       if(hair) {
+                       if (hair) {
                                /* hair we handle separate and compute transform based on hair keys */
-                               if(a < totpart) {
+                               if (a < totpart) {
                                        cache = psys->pathcache[a];
                                        psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale);
                                }
@@ -1386,7 +1391,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                        else {
                                /* first key */
                                state.time = ctime;
-                               if(psys_get_particle_state(&sim, a, &state, 0) == 0) {
+                               if (psys_get_particle_state(&sim, a, &state, 0) == 0) {
                                        continue;
                                }
                                else {
@@ -1398,11 +1403,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                }
                        }
 
-                       if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
-                               for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
+                       if (part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
+                               for (go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
 
                                        /* group dupli offset, should apply after everything else */
-                                       if(!is_zero_v3(part->dup_group->dupli_ofs)) {
+                                       if (!is_zero_v3(part->dup_group->dupli_ofs)) {
                                                copy_m4_m4(tmat, oblist[b]->obmat);
                                                sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
                                                mult_m4_m4m4(tmat, pamat, tmat);
@@ -1412,14 +1417,14 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        }
 
                                        mul_mat3_m4_fl(tmat, size*scale);
-                                       if(par_space_mat)
+                                       if (par_space_mat)
                                                mult_m4_m4m4(mat, par_space_mat, tmat);
                                        else
                                                copy_m4_m4(mat, tmat);
 
                                        dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
                                        copy_m4_m4(dob->omat, obcopylist[b].obmat);
-                                       if(G.rendering)
+                                       if (G.rendering)
                                                psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
                                }
                        }
@@ -1431,7 +1436,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
 
                                /* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
-                               if((part->draw & PART_DRAW_ROTATE_OB) == 0) {
+                               if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
                                        float xvec[3], q[4];
                                        xvec[0] = -1.f;
                                        xvec[1] = xvec[2] = 0;
@@ -1443,7 +1448,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                /* Normal particles and cached hair live in global space so we need to
                                 * remove the real emitter's transformation before 2nd order duplication.
                                 */
-                               if(par_space_mat && GS(id->name) != ID_GR)
+                               if (par_space_mat && GS(id->name) != ID_GR)
                                        mult_m4_m4m4(mat, psys->imat, pamat);
                                else
                                        copy_m4_m4(mat, pamat);
@@ -1451,24 +1456,24 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                mult_m4_m4m4(tmat, mat, obmat);
                                mul_mat3_m4_fl(tmat, size*scale);
 
-                               if(par_space_mat)
+                               if (par_space_mat)
                                        mult_m4_m4m4(mat, par_space_mat, tmat);
                                else
                                        copy_m4_m4(mat, tmat);
 
-                               if(part->draw & PART_DRAW_GLOBAL_OB)
+                               if (part->draw & PART_DRAW_GLOBAL_OB)
                                        add_v3_v3v3(mat[3], mat[3], vec);
 
                                dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
                                copy_m4_m4(dob->omat, oldobmat);
-                               if(G.rendering)
+                               if (G.rendering)
                                        psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
                        }
                }
 
                /* restore objects since they were changed in where_is_object_time */
-               if(part->ren_as==PART_DRAW_GR) {
-                       for(a=0; a<totgroup; a++)
+               if (part->ren_as==PART_DRAW_GR) {
+                       for (a=0; a<totgroup; a++)
                                *(oblist[a])= obcopylist[a];
                }
                else
@@ -1476,12 +1481,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
        }
 
        /* clean up */
-       if(oblist)
+       if (oblist)
                MEM_freeN(oblist);
-       if(obcopylist)
+       if (obcopylist)
                MEM_freeN(obcopylist);
 
-       if(psys->lattice) {
+       if (psys->lattice) {
                end_latt_deform(psys->lattice);
                psys->lattice = NULL;
        }
@@ -1492,14 +1497,14 @@ static Object *find_family_object(Object **obar, char *family, char ch)
        Object *ob;
        int flen;
        
-       if( obar[(int)ch] ) return obar[(int)ch];
+       if ( obar[(int)ch] ) return obar[(int)ch];
        
        flen= strlen(family);
        
        ob= G.main->object.first;
-       while(ob) {
-               if( ob->id.name[flen+2]==ch ) {
-                       if( strncmp(ob->id.name+2, family, flen)==0 ) break;
+       while (ob) {
+               if ( ob->id.name[flen+2]==ch ) {
+                       if ( strncmp(ob->id.name+2, family, flen)==0 ) break;
                }
                ob= ob->id.next;
        }
@@ -1519,14 +1524,14 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
        int slen, a;
        
        /* simple preventing of too deep nested groups */
-       if(level>MAX_DUPLI_RECUR) return;
+       if (level>MAX_DUPLI_RECUR) return;
        
        copy_m4_m4(pmat, par->obmat);
        
        /* in par the family name is stored, use this to find the other objects */
        
        chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI);
-       if(chartransdata==NULL) return;
+       if (chartransdata==NULL) return;
 
        cu= par->data;
        slen= strlen(cu->str);
@@ -1536,10 +1541,10 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
        
        ct= chartransdata;
        
-       for(a=0; a<slen; a++, ct++) {
+       for (a=0; a<slen; a++, ct++) {
                
                ob= find_family_object(obar, cu->family, cu->str[a]);
-               if(ob) {
+               if (ob) {
                        vec[0]= fsize*(ct->xof - xof);
                        vec[1]= fsize*(ct->yof - yof);
                        vec[2]= 0.0;
@@ -1560,7 +1565,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
 
 static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
 {      
-       if((ob->transflag & OB_DUPLI)==0)
+       if ((ob->transflag & OB_DUPLI)==0)
                return;
        
        /* Should the dupli's be generated for this object? - Respect restrict flags */
@@ -1568,43 +1573,45 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
                if (ob->restrictflag & OB_RESTRICT_RENDER) {
                        return;
                }
-       } else {
+       }
+       else {
                if (ob->restrictflag & OB_RESTRICT_VIEW) {
                        return;
                }
        }
 
-       if(ob->transflag & OB_DUPLIPARTS) {
+       if (ob->transflag & OB_DUPLIPARTS) {
                ParticleSystem *psys = ob->particlesystem.first;
-               for(; psys; psys=psys->next)
+               for (; psys; psys=psys->next)
                        new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated);
        }
-       else if(ob->transflag & OB_DUPLIVERTS) {
-               if(ob->type==OB_MESH) {
+       else if (ob->transflag & OB_DUPLIVERTS) {
+               if (ob->type==OB_MESH) {
                        vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
                }
-               else if(ob->type==OB_FONT) {
+               else if (ob->type==OB_FONT) {
                        if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
                                font_duplilist(duplilist, scene, ob, level+1, animated);
                        }
                }
        }
-       else if(ob->transflag & OB_DUPLIFACES) {
-               if(ob->type==OB_MESH)
+       else if (ob->transflag & OB_DUPLIFACES) {
+               if (ob->type==OB_MESH)
                        face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
        }
-       else if(ob->transflag & OB_DUPLIFRAMES) {
+       else if (ob->transflag & OB_DUPLIFRAMES) {
                if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
                        frames_duplilist(duplilist, scene, ob, level+1, animated);
                }
-       } else if(ob->transflag & OB_DUPLIGROUP) {
+       }
+       else if (ob->transflag & OB_DUPLIGROUP) {
                DupliObject *dob;
                
                group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */
 
                if (level==0) {
-                       for(dob= duplilist->first; dob; dob= dob->next)
-                               if(dob->type == OB_DUPLIGROUP)
+                       for (dob= duplilist->first; dob; dob= dob->next)
+                               if (dob->type == OB_DUPLIGROUP)
                                        copy_m4_m4(dob->ob->obmat, dob->mat);
                }
        }
@@ -1627,7 +1634,7 @@ void free_object_duplilist(ListBase *lb)
        /* loop in reverse order, if object is instanced multiple times
         * the original layer may not really be original otherwise, proper
         * solution is more complicated */
-       for(dob= lb->last; dob; dob= dob->prev) {
+       for (dob= lb->last; dob; dob= dob->prev) {
                dob->ob->lay= dob->origlay;
                copy_m4_m4(dob->ob->obmat, dob->omat);
        }
@@ -1638,17 +1645,17 @@ void free_object_duplilist(ListBase *lb)
 
 int count_duplilist(Object *ob)
 {
-       if(ob->transflag & OB_DUPLI) {
-               if(ob->transflag & OB_DUPLIVERTS) {
-                       if(ob->type==OB_MESH) {
-                               if(ob->transflag & OB_DUPLIVERTS) {
+       if (ob->transflag & OB_DUPLI) {
+               if (ob->transflag & OB_DUPLIVERTS) {
+                       if (ob->type==OB_MESH) {
+                               if (ob->transflag & OB_DUPLIVERTS) {
                                        ParticleSystem *psys = ob->particlesystem.first;
                                        int pdup=0;
 
-                                       for(; psys; psys=psys->next)
+                                       for (; psys; psys=psys->next)
                                                pdup += psys->totpart;
 
-                                       if(pdup==0) {
+                                       if (pdup==0) {
                                                Mesh *me= ob->data;
                                                return me->totvert;
                                        }
@@ -1657,7 +1664,7 @@ int count_duplilist(Object *ob)
                                }
                        }
                }
-               else if(ob->transflag & OB_DUPLIFRAMES) {
+               else if (ob->transflag & OB_DUPLIFRAMES) {
                        int tot= ob->dupend - ob->dupsta; 
                        tot/= (ob->dupon+ob->dupoff);
                        return tot*ob->dupon;
index 3a08120..a9267be 100644 (file)
@@ -1032,7 +1032,7 @@ void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp)
                return;
 
        /* free RNA-path info */
-       if(ksp->rna_path)
+       if (ksp->rna_path)
                MEM_freeN(ksp->rna_path);
 
        /* free path itself */
@@ -1194,7 +1194,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
                        /* as long as we don't do property update, we still tag datablock
                         * as having been updated. this flag does not cause any updates to
                         * be run, it's for e.g. render engines to synchronize data */
-                       if(new_ptr.id.data) {
+                       if (new_ptr.id.data) {
                                ID *id= new_ptr.id.data;
                                id->flag |= LIB_ID_RECALC;
                                DAG_id_type_tag(G.main, GS(id->name));
index 1bb6841..26c5912 100644 (file)
@@ -127,7 +127,7 @@ void initglobals(void)
 
        strcpy(G.ima, "//");
 
-       if(BLENDER_SUBVERSION)
+       if (BLENDER_SUBVERSION)
                BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
        else
                BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d", BLENDER_VERSION);
@@ -174,7 +174,7 @@ static void clean_paths(Main *main)
 
        bpath_traverse_main(main, clean_paths_visit_cb, BPATH_TRAVERSE_SKIP_MULTIFILE, NULL);
 
-       for(scene= main->scene.first; scene; scene= scene->id.next) {
+       for (scene= main->scene.first; scene; scene= scene->id.next) {
                BLI_clean(scene->r.pic);
        }
 }
@@ -193,21 +193,21 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        char mode;
 
        /* 'u' = undo save, 'n' = no UI load */
-       if(bfd->main->screen.first==NULL) mode= 'u';
-       else if(G.fileflags & G_FILE_NO_UI) mode= 'n';
+       if (bfd->main->screen.first==NULL) mode= 'u';
+       else if (G.fileflags & G_FILE_NO_UI) mode= 'n';
        else mode= 0;
 
        recover= (G.fileflags & G_FILE_RECOVER);
 
        /* Only make filepaths compatible when loading for real (not undo) */
-       if(mode != 'u') {
+       if (mode != 'u') {
                clean_paths(bfd->main);
        }
 
        /* XXX here the complex windowmanager matching */
        
        /* no load screens? */
-       if(mode) {
+       if (mode) {
                /* comes from readfile.c */
                extern void lib_link_screen_restore(Main *, bScreen *, Scene *);
                
@@ -219,9 +219,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
                curscreen= CTX_wm_screen(C);
                /* but use new Scene pointer */
                curscene= bfd->curscene;
-               if(curscene==NULL) curscene= bfd->main->scene.first;
+               if (curscene==NULL) curscene= bfd->main->scene.first;
                /* and we enforce curscene to be in current screen */
-               if(curscreen) curscreen->scene= curscene; /* can run in bgmode */
+               if (curscreen) curscreen->scene= curscene; /* can run in bgmode */
 
                /* clear_global will free G.main, here we can still restore pointers */
                lib_link_screen_restore(bfd->main, curscreen, curscene);
@@ -250,7 +250,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        }
        
        /* case G_FILE_NO_UI or no screens in file */
-       if(mode) {
+       if (mode) {
                /* leave entire context further unaltered? */
                CTX_data_scene_set(C, curscene);
        }
@@ -267,14 +267,14 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        }
        
        /* this can happen when active scene was lib-linked, and doesnt exist anymore */
-       if(CTX_data_scene(C)==NULL) {
+       if (CTX_data_scene(C)==NULL) {
                CTX_data_scene_set(C, bfd->main->scene.first);
                CTX_wm_screen(C)->scene= CTX_data_scene(C);
                curscene= CTX_data_scene(C);
        }
 
        /* special cases, override loaded flags: */
-       if(G.f != bfd->globalf) {
+       if (G.f != bfd->globalf) {
                const int flags_keep= (G_DEBUG | G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
                bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
        }
@@ -291,7 +291,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
        if (G.main->versionfile < 250)
                do_versions_ipos_to_animato(G.main);
        
-       if(recover && bfd->filename[0] && G.relbase_valid) {
+       if (recover && bfd->filename[0] && G.relbase_valid) {
                /* in case of autosave or quit.blend, use original filename instead
                 * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
                filepath= bfd->filename;
@@ -304,7 +304,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
 #endif
        
        /* these are the same at times, should never copy to the same location */
-       if(G.main->name != filepath)
+       if (G.main->name != filepath)
                BLI_strncpy(G.main->name, filepath, FILE_MAX);
 
        /* baseflags, groups, make depsgraph, etc */
@@ -317,7 +317,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
 
 static int handle_subversion_warning(Main *main, ReportList *reports)
 {
-       if(main->minversionfile > BLENDER_VERSION ||
+       if (main->minversionfile > BLENDER_VERSION ||
           (main->minversionfile == BLENDER_VERSION && 
                 main->minsubversionfile > BLENDER_SUBVERSION)) {
                BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
@@ -328,11 +328,11 @@ static int handle_subversion_warning(Main *main, ReportList *reports)
 
 static void keymap_item_free(wmKeyMapItem *kmi)
 {
-       if(kmi->properties) {
+       if (kmi->properties) {
                IDP_FreeProperty(kmi->properties);
                MEM_freeN(kmi->properties);
        }
-       if(kmi->ptr)
+       if (kmi->ptr)
                MEM_freeN(kmi->ptr);
 }
 
@@ -342,19 +342,19 @@ void BKE_userdef_free(void)
        wmKeyMapItem *kmi;
        wmKeyMapDiffItem *kmdi;
 
-       for(km=U.user_keymaps.first; km; km=km->next) {
-               for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
-                       if(kmdi->add_item) {
+       for (km=U.user_keymaps.first; km; km=km->next) {
+               for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       if (kmdi->add_item) {
                                keymap_item_free(kmdi->add_item);
                                MEM_freeN(kmdi->add_item);
                        }
-                       if(kmdi->remove_item) {
+                       if (kmdi->remove_item) {
                                keymap_item_free(kmdi->remove_item);
                                MEM_freeN(kmdi->remove_item);
                        }
                }
 
-               for(kmi=km->items.first; kmi; kmi=kmi->next)
+               for (kmi=km->items.first; kmi; kmi=kmi->next)
                        keymap_item_free(kmi);
 
                BLI_freelistN(&km->diff_items);
@@ -373,14 +373,14 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
        BlendFileData *bfd;
        int retval= BKE_READ_FILE_OK;
 
-       if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */
+       if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */
                printf("read blend: %s\n", filepath);
 
        bfd= BLO_read_from_file(filepath, reports);
        if (bfd) {
-               if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
+               if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
                
-               if(0==handle_subversion_warning(bfd->main, reports)) {
+               if (0==handle_subversion_warning(bfd->main, reports)) {
                        free_main(bfd->main);
                        MEM_freeN(bfd);
                        bfd= NULL;
@@ -474,7 +474,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
        fileflags= G.fileflags;
        G.fileflags |= G_FILE_NO_UI;
 
-       if(UNDO_DISK) 
+       if (UNDO_DISK) 
                success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
        else
                success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
@@ -483,7 +483,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
        BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
        G.fileflags= fileflags;
 
-       if(success) {
+       if (success) {
                /* important not to update time here, else non keyed tranforms are lost */
                DAG_on_visible_update(G.main, FALSE);
        }
@@ -498,11 +498,11 @@ void BKE_write_undo(bContext *C, const char *name)
        int nr /*, success */ /* UNUSED */;
        UndoElem *uel;
        
-       if( (U.uiflag & USER_GLOBALUNDO)==0) return;
-       if( U.undosteps==0) return;
+       if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
+       if ( U.undosteps==0) return;
        
        /* remove all undos after (also when curundo==NULL) */
-       while(undobase.last != curundo) {
+       while (undobase.last != curundo) {
                uel= undobase.last;
                BLI_remlink(&undobase, uel);
                BLO_free_memfile(&uel->memfile);
@@ -517,13 +517,13 @@ void BKE_write_undo(bContext *C, const char *name)
        /* and limit amount to the maximum */
        nr= 0;
        uel= undobase.last;
-       while(uel) {
+       while (uel) {
                nr++;
-               if(nr==U.undosteps) break;
+               if (nr==U.undosteps) break;
                uel= uel->prev;
        }
-       if(uel) {
-               while(undobase.first!=uel) {
+       if (uel) {
+               while (undobase.first!=uel) {
                        UndoElem *first= undobase.first;
                        BLI_remlink(&undobase, first);
                        /* the merge is because of compression */
@@ -534,7 +534,7 @@ void BKE_write_undo(bContext *C, const char *name)
 
 
        /* disk save version */
-       if(UNDO_DISK) {
+       if (UNDO_DISK) {
                static int counter= 0;
                char filepath[FILE_MAX];
                char numstr[32];
@@ -554,31 +554,31 @@ void BKE_write_undo(bContext *C, const char *name)
        else {
                MemFile *prevfile=NULL;
                
-               if(curundo->prev) prevfile= &(curundo->prev->memfile);
+               if (curundo->prev) prevfile= &(curundo->prev->memfile);
                
                memused= MEM_get_memory_in_use();
                /* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags);
                curundo->undosize= MEM_get_memory_in_use() - memused;
        }
 
-       if(U.undomemory != 0) {
+       if (U.undomemory != 0) {
                /* limit to maximum memory (afterwards, we can't know in advance) */
                totmem= 0;
                maxmem= ((uintptr_t)U.undomemory)*1024*1024;
 
                /* keep at least two (original + other) */
                uel= undobase.last;
-               while(uel && uel->prev) {
+               while (uel && uel->prev) {
                        totmem+= uel->undosize;
-                       if(totmem>maxmem) break;
+                       if (totmem>maxmem) break;
                        uel= uel->prev;
                }
 
-               if(uel) {
-                       if(uel->prev && uel->prev->prev)
+               if (uel) {
+                       if (uel->prev && uel->prev->prev)
                                uel= uel->prev;
 
-                       while(undobase.first!=uel) {
+                       while (undobase.first!=uel) {
                                UndoElem *first= undobase.first;
                                BLI_remlink(&undobase, first);
                                /* the merge is because of compression */
@@ -593,14 +593,14 @@ void BKE_write_undo(bContext *C, const char *name)
 void BKE_undo_step(bContext *C, int step)
 {
        
-       if(step==0) {
+       if (step==0) {
                read_undosave(C, curundo);
        }
-       else if(step==1) {
+       else if (step==1) {
                /* curundo should never be NULL, after restart or load file it should call undo_save */
-               if(curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
+               if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
                else {
-                       if(G.f & G_DEBUG) printf("undo %s\n", curundo->name);
+                       if (G.f & G_DEBUG) printf("undo %s\n", curundo->name);
                        curundo= curundo->prev;
                        read_undosave(C, curundo);
                }
@@ -609,11 +609,11 @@ void BKE_undo_step(bContext *C, int step)
                
                /* curundo has to remain current situation! */
                
-               if(curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available");
+               if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available");
                else {
                        read_undosave(C, curundo->next);
                        curundo= curundo->next;
-                       if(G.f & G_DEBUG) printf("redo %s\n", curundo->name);
+                       if (G.f & G_DEBUG) printf("redo %s\n", curundo->name);
                }
        }
 }
@@ -623,7 +623,7 @@ void BKE_reset_undo(void)
        UndoElem *uel;
        
        uel= undobase.first;
-       while(uel) {
+       while (uel) {
                BLO_free_memfile(&uel->memfile);
                uel= uel->next;
        }
@@ -644,7 +644,7 @@ void BKE_undo_name(bContext *C, const char *name)
 {
        UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
 
-       if(uel && uel->prev) {
+       if (uel && uel->prev) {
                curundo= uel->prev;
                BKE_undo_step(C, 0);
        }
@@ -653,7 +653,7 @@ void BKE_undo_name(bContext *C, const char *name)
 /* name optional */
 int BKE_undo_valid(const char *name)
 {
-       if(name) {
+       if (name) {
                UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
                return uel && uel->prev;
        }
@@ -667,10 +667,10 @@ const char *BKE_undo_get_name(int nr, int *active)
 {
        UndoElem *uel= BLI_findlink(&undobase, nr);
        
-       if(active) *active= 0;
+       if (active) *active= 0;
        
-       if(uel) {
-               if(active && uel==curundo)
+       if (uel) {
+               if (active && uel==curundo)
                        *active= 1;
                return uel->name;
        }
@@ -685,7 +685,7 @@ char *BKE_undo_menu_string(void)
 
        BLI_dynstr_append(ds, "Global Undo History %t");
        
-       for(uel= undobase.first; uel; uel= uel->next) {
+       for (uel= undobase.first; uel; uel= uel->next) {
                BLI_dynstr_append(ds, "|");
                BLI_dynstr_append(ds, uel->name);
        }
@@ -704,34 +704,34 @@ void BKE_undo_save_quit(void)
        int file;
        char str[FILE_MAX];
        
-       if( (U.uiflag & USER_GLOBALUNDO)==0) return;
+       if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
        
        uel= curundo;
-       if(uel==NULL) {
+       if (uel==NULL) {
                printf("No undo buffer to save recovery file\n");
                return;
        }
        
        /* no undo state to save */
-       if(undobase.first==undobase.last) return;
+       if (undobase.first==undobase.last) return;
                
        BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
 
        file = BLI_open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
-       if(file == -1) {
+       if (file == -1) {
                //XXX error("Unable to save %s, check you have permissions", str);
                return;
        }
 
        chunk= uel->memfile.chunks.first;
-       while(chunk) {
-               if( write(file, chunk->buf, chunk->size) != chunk->size) break;
+       while (chunk) {
+               if ( write(file, chunk->buf, chunk->size) != chunk->size) break;
                chunk= chunk->next;
        }
        
        close(file);
        
-       if(chunk) ; //XXX error("Unable to save %s, internal error", str);
+       if (chunk) ; //XXX error("Unable to save %s, internal error", str);
        else printf("Saved session recovery to %s\n", str);
 }
 
@@ -741,9 +741,9 @@ Main *BKE_undo_get_main(Scene **scene)
        Main *mainp= NULL;
        BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
        
-       if(bfd) {
+       if (bfd) {
                mainp= bfd->main;
-               if(scene)
+               if (scene)
                        *scene= bfd->curscene;
                
                MEM_freeN(bfd);
index 0211dcd..278dbe3 100644 (file)
@@ -163,7 +163,8 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step)
                        // we're going to fake alpha here:
                        calcAlpha(ibuf);
                }
-       } else {
+       }
+       else {
                printf("readBitmapFontVersion0: corrupted bitmapfont\n");
        }
 }
@@ -183,7 +184,8 @@ void detectBitmapFont(ImBuf *ibuf)
                                // printf("found 8bit font !\n");
                                // round y size down
                                // do the 8 bit font stuff. (not yet)
-                       } else {
+                       }
+                       else {
                                // we try all 4 possible combinations
                                for (i = 0; i < 4; i++) {
                                        if (rect[0] == 'B' && rect[4] == 'F' && rect[8] == 'N' && rect[12] == 'T') {
@@ -194,7 +196,8 @@ void detectBitmapFont(ImBuf *ibuf)
                                                
                                                if (version == 0) {
                                                        readBitmapFontVersion0(ibuf, rect, 4);
-                                               } else {
+                                               }
+                                               else {
                                                        printf("detectBitmapFont :Unsupported version %d\n", version);
                                                }
                                                
@@ -223,10 +226,12 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode)
 
                        if (bmfont->glyphs[current].unicode == unicode) {
                                break;
-                       } else if (bmfont->glyphs[current].unicode < unicode) {
+                       }
+                       else if (bmfont->glyphs[current].unicode < unicode) {
                                // have to move up
                                min = current;
-                       } else {
+                       }
+                       else {
                                // have to move down
                                max = current;
                        }
index 8fa0a46..993a33c 100644 (file)
@@ -83,15 +83,15 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
        pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
 
        /* first find out goal/predator with highest priority */
-       if(effectors) for(cur = effectors->first; cur; cur=cur->next) {
+       if (effectors) for(cur = effectors->first; cur; cur=cur->next) {
                Object *eob = cur->ob;
                PartDeflect *pd = cur->pd;
 
-               if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) {
-                       if(gabr->ob == eob) {
+               if (gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) {
+                       if (gabr->ob == eob) {
                                /* TODO: effectors with multiple points */
-                               if(get_effector_data(cur, &efd, &epoint, 0)) {
-                                       if(cur->pd && cur->pd->forcefield == PFIELD_BOID)
+                               if (get_effector_data(cur, &efd, &epoint, 0)) {
+                                       if (cur->pd && cur->pd->forcefield == PFIELD_BOID)
                                                priority = mul * pd->f_strength * effector_falloff(cur, &efd, &epoint, bbd->part->effector_weights);
                                        else
                                                priority = 1.0;
@@ -101,21 +101,21 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
                                break;
                        }
                }
-               else if(rule->type == eBoidRuleType_Goal && eob == bpa->ground)
+               else if (rule->type == eBoidRuleType_Goal && eob == bpa->ground)
                        ; /* skip current object */
-               else if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) {
+               else if (pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) {
                        float temp = mul * pd->f_strength * effector_falloff(cur, &cur_efd, &epoint, bbd->part->effector_weights);
 
-                       if(temp == 0.0f)
+                       if (temp == 0.0f)
                                ; /* do nothing */
-                       else if(temp > priority) {
+                       else if (temp > priority) {
                                priority = temp;
                                eff = cur;
                                efd = cur_efd;
                                len = efd.distance;
                        }
                        /* choose closest object with same priority */
-                       else if(temp == priority && efd.distance < len) {
+                       else if (temp == priority && efd.distance < len) {
                                eff = cur;
                                efd = cur_efd;
                                len = efd.distance;
@@ -124,7 +124,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
        }
 
        /* if the object doesn't have effector data we have to fake it */
-       if(eff == NULL && gabr->ob) {
+       if (eff == NULL && gabr->ob) {
                memset(&temp_eff, 0, sizeof(EffectorCache));
                temp_eff.ob = gabr->ob;
                temp_eff.scene = bbd->sim->scene;
@@ -134,12 +134,12 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
        }
 
        /* then use that effector */
-       if(priority > (rule->type==eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { /* with avoid, factor is "fear factor" */
+       if (priority > (rule->type==eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { /* with avoid, factor is "fear factor" */
                Object *eob = eff->ob;
                PartDeflect *pd = eff->pd;
                float surface = (pd && pd->shape == PFIELD_SHAPE_SURFACE) ? 1.0f : 0.0f;
 
-               if(gabr->options & BRULE_GOAL_AVOID_PREDICT) {
+               if (gabr->options & BRULE_GOAL_AVOID_PREDICT) {
                        /* estimate future location of target */
                        get_effector_data(eff, &efd, &epoint, 1);
 
@@ -149,14 +149,14 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
                        efd.distance = len_v3(efd.vec_to_point);
                }
 
-               if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
-                       if(!bbd->goal_ob || bbd->goal_priority < priority) {
+               if (rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
+                       if (!bbd->goal_ob || bbd->goal_priority < priority) {
                                bbd->goal_ob = eob;
                                copy_v3_v3(bbd->goal_co, efd.loc);
                                copy_v3_v3(bbd->goal_nor, efd.nor);
                        }
                }
-               else if(rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
+               else if (rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
                        priority > 2.0f * gabr->fear_factor) {
                        /* detach from surface and try to fly away from danger */
                        negate_v3_v3(efd.vec_to_point, bpa->gravity);
@@ -168,12 +168,12 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
                bbd->wanted_speed = val->max_speed * priority;
 
                /* with goals factor is approach velocity factor */
-               if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
+               if (rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
                        float len2 = 2.0f*len_v3(pa->prev_state.vel);
 
                        surface *= pa->size * boids->height;
 
-                       if(len2 > 0.0f && efd.distance - surface < len2) {
+                       if (len2 > 0.0f && efd.distance - surface < len2) {
                                len2 = (efd.distance - surface)/len2;
                                bbd->wanted_speed *= powf(len2, boids->landing_smoothness);
                        }
@@ -199,7 +199,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
        int ret = 0;
 
        //check deflector objects first
-       if(acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
+       if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
                ParticleCollision col;
                BVHTreeRayHit hit;
                float radius = val->personal_space * pa->size, ray_dir[3];
@@ -213,23 +213,23 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
                hit.dist = col.original_ray_length = len_v3(ray_dir);
 
                /* find out closest deflector object */
-               for(coll = bbd->sim->colliders->first; coll; coll=coll->next) {
+               for (coll = bbd->sim->colliders->first; coll; coll=coll->next) {
                        /* don't check with current ground object */
-                       if(coll->ob == bpa->ground)
+                       if (coll->ob == bpa->ground)
                                continue;
 
                        col.current = coll->ob;
                        col.md = coll->collmd;
 
-                       if(col.md && col.md->bvhtree)
+                       if (col.md && col.md->bvhtree)
                                BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
                }
                /* then avoid that object */
-               if(hit.index>=0) {
+               if (hit.index>=0) {
                        t = hit.dist/col.original_ray_length;
 
                        /* avoid head-on collision */
-                       if(dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) {
+                       if (dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) {
                                /* don't know why, but uneven range [0.0,1.0] */
                                /* works much better than even [-1.0,1.0] */
                                bbd->wanted_co[0] = BLI_frand();
@@ -252,7 +252,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
        //check boids in own system
        if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
                neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
-               if(neighbors > 1) for(n=1; n<neighbors; n++) {
+               if (neighbors > 1) for(n=1; n<neighbors; n++) {
                        copy_v3_v3(co1, pa->prev_state.co);
                        copy_v3_v3(vel1, pa->prev_state.vel);
                        copy_v3_v3(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co);
@@ -265,10 +265,10 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
                        inp = dot_v3v3(vec,vec);
 
                        /* velocities not parallel */
-                       if(inp != 0.0f) {
+                       if (inp != 0.0f) {
                                t = -dot_v3v3(loc, vec)/inp;
                                /* cpa is not too far in the future so investigate further */
-                               if(t > 0.0f && t < t_min) {
+                               if (t > 0.0f && t < t_min) {
                                        madd_v3_v3fl(co1, vel1, t);
                                        madd_v3_v3fl(co2, vel2, t);
                                        
@@ -277,7 +277,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
                                        len = normalize_v3(vec);
 
                                        /* distance of cpa is close enough */
-                                       if(len < 2.0f * val->personal_space * pa->size) {
+                                       if (len < 2.0f * val->personal_space * pa->size) {
                                                t_min = t;
 
                                                mul_v3_fl(vec, len_v3(vel1));
@@ -293,12 +293,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
        if (ptn) { MEM_freeN(ptn); ptn=NULL; }
 
        /* check boids in other systems */
-       for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+       for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
                ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
 
-               if(epsys) {
+               if (epsys) {
                        neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
-                       if(neighbors > 0) for(n=0; n<neighbors; n++) {
+                       if (neighbors > 0) for(n=0; n<neighbors; n++) {
                                copy_v3_v3(co1, pa->prev_state.co);
                                copy_v3_v3(vel1, pa->prev_state.vel);
                                copy_v3_v3(co2, (epsys->particles + ptn[n].index)->prev_state.co);
@@ -311,10 +311,10 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
                                inp = dot_v3v3(vec,vec);
 
                                /* velocities not parallel */
-                               if(inp != 0.0f) {
+                               if (inp != 0.0f) {
                                        t = -dot_v3v3(loc, vec)/inp;
                                        /* cpa is not too far in the future so investigate further */
-                                       if(t > 0.0f && t < t_min) {
+                                       if (t > 0.0f && t < t_min) {
                                                madd_v3_v3fl(co1, vel1, t);
                                                madd_v3_v3fl(co2, vel2, t);
                                                
@@ -323,7 +323,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
                                                len = normalize_v3(vec);
 
                                                /* distance of cpa is close enough */
-                                               if(len < 2.0f * val->personal_space * pa->size) {
+                                               if (len < 2.0f * val->personal_space * pa->size) {
                                                        t_min = t;
 
                                                        mul_v3_fl(vec, len_v3(vel1));
@@ -341,7 +341,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
        }
 
 
-       if(ptn && nearest==0)
+       if (ptn && nearest==0)
                MEM_freeN(ptn);
 
        return ret;
@@ -355,7 +355,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
        int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
        int ret = 0;
 
-       if(neighbors > 1 && ptn[1].dist!=0.0f) {
+       if (neighbors > 1 && ptn[1].dist!=0.0f) {
                sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
                mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
                add_v3_v3(bbd->wanted_co, vec);
@@ -366,13 +366,13 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
        if (ptn) { MEM_freeN(ptn); ptn=NULL; }
 
        /* check other boid systems */
-       for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+       for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
                ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
 
-               if(epsys) {
+               if (epsys) {
                        neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
                        
-                       if(neighbors > 0 && ptn[0].dist < len) {
+                       if (neighbors > 0 && ptn[0].dist < len) {
                                sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
                                mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
                                add_v3_v3(bbd->wanted_co, vec);
@@ -394,8 +394,8 @@ static int rule_flock(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UN
        int n;
        int ret = 0;
 
-       if(neighbors > 1) {
-               for(n=1; n<neighbors; n++) {
+       if (neighbors > 1) {
+               for (n=1; n<neighbors; n++) {
                        add_v3_v3(loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
                        add_v3_v3(vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
                }
@@ -422,7 +422,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
        int n = (flbr->queue_size <= 1) ? bbd->sim->psys->totpart : flbr->queue_size;
        int i, ret = 0, p = pa - bbd->sim->psys->particles;
 
-       if(flbr->ob) {
+       if (flbr->ob) {
                float vec2[3], t;
 
                /* first check we're not blocking the leader*/
@@ -434,10 +434,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                mul = dot_v3v3(vec, vec);
 
                /* leader is not moving */
-               if(mul < 0.01f) {
+               if (mul < 0.01f) {
                        len = len_v3(loc);
                        /* too close to leader */
-                       if(len < 2.0f * val->personal_space * pa->size) {
+                       if (len < 2.0f * val->personal_space * pa->size) {
                                copy_v3_v3(bbd->wanted_co, loc);
                                bbd->wanted_speed = val->max_speed;
                                return 1;
@@ -447,7 +447,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                        t = dot_v3v3(loc, vec)/mul;
 
                        /* possible blocking of leader in near future */
-                       if(t > 0.0f && t < 3.0f) {
+                       if (t > 0.0f && t < 3.0f) {
                                copy_v3_v3(vec2, vec);
                                mul_v3_fl(vec2, t);
 
@@ -455,7 +455,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
 
                                len = len_v3(vec2);
 
-                               if(len < 2.0f * val->personal_space * pa->size) {
+                               if (len < 2.0f * val->personal_space * pa->size) {
                                        copy_v3_v3(bbd->wanted_co, vec2);
                                        bbd->wanted_speed = val->max_speed * (3.0f - t)/3.0f;
                                        return 1;
@@ -464,7 +464,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                }
 
                /* not blocking so try to follow leader */
-               if(p && flbr->options & BRULE_LEADER_IN_LINE) {
+               if (p && flbr->options & BRULE_LEADER_IN_LINE) {
                        copy_v3_v3(vec, bbd->sim->psys->particles[p-1].prev_state.vel);
                        copy_v3_v3(loc, bbd->sim->psys->particles[p-1].prev_state.co);
                }
@@ -482,11 +482,11 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                        
                ret = 1;
        }
-       else if(p % n) {
+       else if (p % n) {
                float vec2[3], t, t_min = 3.0f;
 
                /* first check we're not blocking any leaders */
-               for(i = 0; i< bbd->sim->psys->totpart; i+=n) {
+               for (i = 0; i< bbd->sim->psys->totpart; i+=n) {
                        copy_v3_v3(vec, bbd->sim->psys->particles[i].prev_state.vel);
 
                        sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
@@ -494,10 +494,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                        mul = dot_v3v3(vec, vec);
 
                        /* leader is not moving */
-                       if(mul < 0.01f) {
+                       if (mul < 0.01f) {
                                len = len_v3(loc);
                                /* too close to leader */
-                               if(len < 2.0f * val->personal_space * pa->size) {
+                               if (len < 2.0f * val->personal_space * pa->size) {
                                        copy_v3_v3(bbd->wanted_co, loc);
                                        bbd->wanted_speed = val->max_speed;
                                        return 1;
@@ -507,7 +507,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                                t = dot_v3v3(loc, vec)/mul;
 
                                /* possible blocking of leader in near future */
-                               if(t > 0.0f && t < t_min) {
+                               if (t > 0.0f && t < t_min) {
                                        copy_v3_v3(vec2, vec);
                                        mul_v3_fl(vec2, t);
 
@@ -515,7 +515,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
 
                                        len = len_v3(vec2);
 
-                                       if(len < 2.0f * val->personal_space * pa->size) {
+                                       if (len < 2.0f * val->personal_space * pa->size) {
                                                t_min = t;
                                                copy_v3_v3(bbd->wanted_co, loc);
                                                bbd->wanted_speed = val->max_speed * (3.0f - t)/3.0f;
@@ -525,10 +525,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                        }
                }
 
-               if(ret) return 1;
+               if (ret) return 1;
 
                /* not blocking so try to follow leader */
-               if(flbr->options & BRULE_LEADER_IN_LINE) {
+               if (flbr->options & BRULE_LEADER_IN_LINE) {
                        copy_v3_v3(vec, bbd->sim->psys->particles[p-1].prev_state.vel);
                        copy_v3_v3(loc, bbd->sim->psys->particles[p-1].prev_state.co);
                }
@@ -554,7 +554,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
        BoidRuleAverageSpeed *asbr = (BoidRuleAverageSpeed*)rule;
        float vec[3] = {0.0f, 0.0f, 0.0f};
 
-       if(asbr->wander > 0.0f) {
+       if (asbr->wander > 0.0f) {
                /* abuse pa->r_ave for wandering */
                bpa->wander[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
                bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
@@ -573,7 +573,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                add_v3_v3(bbd->wanted_co, vec);
 
                /* leveling */
-               if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
+               if (asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
                        project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity);
                        mul_v3_fl(vec, asbr->level);
                        sub_v3_v3(bbd->wanted_co, vec);
@@ -583,14 +583,14 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
                copy_v3_v3(bbd->wanted_co, pa->prev_state.ave);
 
                /* may happen at birth */
-               if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
+               if (dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
                        bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand());
                        bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand());
                        bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand());
                }
                
                /* leveling */
-               if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
+               if (asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
                        project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity);
                        mul_v3_fl(vec, asbr->level);
                        sub_v3_v3(bbd->wanted_co, vec);
@@ -618,7 +618,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
 
        /* calculate own group strength */
        int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn);
-       for(n=0; n<neighbors; n++) {
+       for (n=0; n<neighbors; n++) {
                bpa = bbd->sim->psys->particles[ptn[n].index].boid;
                health += bpa->data.health;
        }
@@ -628,39 +628,39 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
        if (ptn) { MEM_freeN(ptn); ptn=NULL; }
 
        /* add other friendlies and calculate enemy strength and find closest enemy */
-       for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+       for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
                ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
-               if(epsys) {
+               if (epsys) {
                        epars = epsys->particles;
 
                        neighbors = BLI_kdtree_range_search(epsys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn);
                        
                        health = 0.0f;
 
-                       for(n=0; n<neighbors; n++) {
+                       for (n=0; n<neighbors; n++) {
                                bpa = epars[ptn[n].index].boid;
                                health += bpa->data.health;
 
-                               if(n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) {
+                               if (n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) {
                                        copy_v3_v3(closest_enemy, ptn[n].co);
                                        closest_dist = ptn[n].dist;
                                        enemy_pa = epars + ptn[n].index;
                                }
                        }
-                       if(pt->mode==PTARGET_MODE_ENEMY)
+                       if (pt->mode==PTARGET_MODE_ENEMY)
                                e_strength += epsys->part->boids->strength * health;
-                       else if(pt->mode==PTARGET_MODE_FRIEND)
+                       else if (pt->mode==PTARGET_MODE_FRIEND)
                                f_strength += epsys->part->boids->strength * health;
 
                        if (ptn) { MEM_freeN(ptn); ptn=NULL; }
                }
        }
        /* decide action if enemy presence found */
-       if(e_strength > 0.0f) {
+       if (e_strength > 0.0f) {
                sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co);
 
                /* attack if in range */
-               if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
+               if (closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
                        float damage = BLI_frand();
                        float enemy_dir[3];
 
@@ -670,7 +670,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
                        bbd->wanted_speed = 0.0f;
 
                        /* must face enemy to fight */
-                       if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
+                       if (dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
                                bpa = enemy_pa->boid;
                                bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
                        }
@@ -682,9 +682,9 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
 
                /* check if boid doesn't want to fight */
                bpa = pa->boid;
-               if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
+               if (bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
                        /* decide to flee */
-                       if(closest_dist < fbr->flee_distance * fbr->distance) {
+                       if (closest_dist < fbr->flee_distance * fbr->distance) {
                                negate_v3(bbd->wanted_co);
                                bbd->wanted_speed = val->max_speed;
                        }
@@ -722,7 +722,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
 {
        BoidParticle *bpa = pa->boid;
 
-       if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
+       if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
                val->max_speed = boids->land_max_speed * bpa->data.health/boids->health;
                val->max_acc = boids->land_max_acc * val->max_speed;
                val->max_ave = boids->land_max_ave * (float)M_PI * bpa->data.health/boids->health;
@@ -744,7 +744,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
 {
        BoidParticle *bpa = pa->boid;
 
-       if(bpa->data.mode == eBoidMode_Climbing) {
+       if (bpa->data.mode == eBoidMode_Climbing) {
                SurfaceModifierData *surmd = NULL;
                float x[3], v[3];
                
@@ -766,7 +766,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
                BVHTreeRayHit hit;
                float radius = 0.0f, t, ray_dir[3];
 
-               if(!bbd->sim->colliders)
+               if (!bbd->sim->colliders)
                        return NULL;
 
                /* first try to find below boid */
@@ -778,16 +778,16 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
                hit.dist = col.original_ray_length = len_v3(ray_dir);
                col.pce.inside = 0;
 
-               for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
+               for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
                        col.current = coll->ob;
                        col.md = coll->collmd;
                        col.fac1 = col.fac2 = 0.f;
 
-                       if(col.md && col.md->bvhtree)
+                       if (col.md && col.md->bvhtree)
                                BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
                }
                /* then use that object */
-               if(hit.index>=0) {
+               if (hit.index>=0) {
                        t = hit.dist/col.original_ray_length;
                        interp_v3_v3v3(ground_co, col.co1, col.co2, t);
                        normalize_v3_v3(ground_nor, col.pce.nor);
@@ -803,15 +803,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
                hit.index = -1;
                hit.dist = col.original_ray_length = len_v3(ray_dir);
 
-               for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
+               for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
                        col.current = coll->ob;
                        col.md = coll->collmd;
 
-                       if(col.md && col.md->bvhtree)
+                       if (col.md && col.md->bvhtree)
                                BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
                }
                /* then use that object */
-               if(hit.index>=0) {
+               if (hit.index>=0) {
                        t = hit.dist/col.original_ray_length;
                        interp_v3_v3v3(ground_co, col.co1, col.co2, t);
                        normalize_v3_v3(ground_nor, col.pce.nor);
@@ -830,13 +830,13 @@ static int boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), Boid
 {
        BoidParticle *bpa = pa->boid;
 
-       if(rule==NULL)
+       if (rule==NULL)
                return 0;
        
-       if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
+       if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
                return 1;
        
-       if(bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
+       if (bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
                return 1;
 
        return 0;
@@ -845,12 +845,12 @@ void boids_precalc_rules(ParticleSettings *part, float cfra)
 {
        BoidState *state = part->boids->states.first;
        BoidRule *rule;
-       for(; state; state=state->next) {
-               for(rule = state->rules.first; rule; rule=rule->next) {
-                       if(rule->type==eBoidRuleType_FollowLeader) {
+       for (; state; state=state->next) {
+               for (rule = state->rules.first; rule; rule=rule->next) {
+                       if (rule->type==eBoidRuleType_FollowLeader) {
                                BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*) rule;
 
-                               if(flbr->ob && flbr->cfra != cfra) {
+                               if (flbr->ob && flbr->cfra != cfra) {
                                        /* save object locations for velocity calculations */
                                        copy_v3_v3(flbr->oloc, flbr->loc);
                                        copy_v3_v3(flbr->loc, flbr->ob->obmat[3]);
@@ -889,16 +889,16 @@ static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_n
 /* wanted_co is relative to boid location */
 static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
 {
-       if(rule==NULL)
+       if (rule==NULL)
                return 0;
 
-       if(boid_rule_applies(pa, bbd->part->boids, rule)==0)
+       if (boid_rule_applies(pa, bbd->part->boids, rule)==0)
                return 0;
 
-       if(boid_rules[rule->type](rule, bbd, val, pa)==0)
+       if (boid_rules[rule->type](rule, bbd, val, pa)==0)
                return 0;
 
-       if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
+       if (fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
                return 1;
        else
                return 0;
@@ -908,14 +908,14 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
        BoidState *state = boids->states.first;
        BoidParticle *bpa = pa->boid;
 
-       for(; state; state=state->next) {
-               if(state->id==bpa->data.state_id)
+       for (; state; state=state->next) {
+               if (state->id==bpa->data.state_id)
                        return state;
        }
 
        /* for some reason particle isn't at a valid state */
        state = boids->states.first;
-       if(state)
+       if (state)
                bpa->data.state_id = state->id;
 
        return state;
@@ -937,7 +937,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
        int rand;
        //BoidCondition *cond;
 
-       if(bpa->data.health <= 0.0f) {
+       if (bpa->data.health <= 0.0f) {
                pa->alive = PARS_DYING;
                pa->dietime = bbd->cfra;
                return;
@@ -946,7 +946,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
        //planned for near future
        //cond = state->conditions.first;
        //for(; cond; cond=cond->next) {
-       //      if(boid_condition_is_true(cond)) {
+       //      if (boid_condition_is_true(cond)) {
        //              pa->boid->state_id = cond->state_id;
        //              state = get_boid_state(boids, pa);
        //              break; /* only first true condition is used */
@@ -965,8 +965,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
        switch(state->ruleset_type) {
                case eBoidRulesetType_Fuzzy:
                {
-                       for(rule = state->rules.first; rule; rule = rule->next) {
-                               if(apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))
+                       for (rule = state->rules.first; rule; rule = rule->next) {
+                               if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))
                                        break; /* only first nonzero rule that comes through fuzzy rule is applied */
                        }
                        break;
@@ -982,8 +982,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
                {
                        float wanted_co[3] = {0.0f, 0.0f, 0.0f}, wanted_speed = 0.0f;
                        int n = 0;
-                       for(rule = state->rules.first; rule; rule=rule->next) {
-                               if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
+                       for (rule = state->rules.first; rule; rule=rule->next) {
+                               if (apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
                                        add_v3_v3(wanted_co, bbd->wanted_co);
                                        wanted_speed += bbd->wanted_speed;
                                        n++;
@@ -991,7 +991,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
                                }
                        }
 
-                       if(n > 1) {
+                       if (n > 1) {
                                mul_v3_fl(wanted_co, 1.0f/(float)n);
                                wanted_speed /= (float)n;
                        }
@@ -1004,11 +1004,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
        }
 
        /* decide on jumping & liftoff */
-       if(bpa->data.mode == eBoidMode_OnLand) {
+       if (bpa->data.mode == eBoidMode_OnLand) {
                /* fuzziness makes boids capable of misjudgement */
                float mul = 1.0f + state->rule_fuzziness;
                
-               if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
+               if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
                        float cvel[3], dir[3];
 
                        copy_v3_v3(dir, pa->prev_state.ave);
@@ -1017,15 +1017,15 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
                        copy_v3_v3(cvel, bbd->wanted_co);
                        normalize_v2(cvel);
 
-                       if(dot_v2v2(cvel, dir) > 0.95f / mul)
+                       if (dot_v2v2(cvel, dir) > 0.95f / mul)
                                bpa->data.mode = eBoidMode_Liftoff;
                }
-               else if(val.jump_speed > 0.0f) {
+               else if (val.jump_speed > 0.0f) {
                        float jump_v[3];
                        int jump = 0;
 
                        /* jump to get to a location */
-                       if(bbd->wanted_co[2] > 0.0f) {
+                       if (bbd->wanted_co[2] > 0.0f) {
                                float cvel[3], dir[3];
                                float z_v, ground_v, cur_v;
                                float len;
@@ -1040,7 +1040,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
 
                                /* first of all, are we going in a suitable direction? */
                                /* or at a suitably slow speed */
-                               if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
+                               if (dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
                                        /* try to reach goal at highest point of the parabolic path */
                                        cur_v = len_v2(pa->prev_state.vel);
                                        z_v = sasqrt(-2.0f * bbd->sim->scene->physics_settings.gravity[2] * bbd->wanted_co[2]);
@@ -1048,7 +1048,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
 
                                        len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v);
 
-                                       if(len < val.jump_speed * mul || bbd->part->boids->options & BOID_ALLOW_FLIGHT) {
+                                       if (len < val.jump_speed * mul || bbd->part->boids->options & BOID_ALLOW_FLIGHT) {
                                                jump = 1;
 
                                                len = MIN2(len, val.jump_speed);
@@ -1065,11 +1065,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
                        }
 
                        /* jump to go faster */
-                       if(jump == 0 && val.jump_speed > val.max_speed && bbd->wanted_speed > val.max_speed) {
+                       if (jump == 0 && val.jump_speed > val.max_speed && bbd->wanted_speed > val.max_speed) {
                                
                        }
 
-                       if(jump) {
+                       if (jump) {
                                copy_v3_v3(pa->prev_state.vel, jump_v);
                                bpa->data.mode = eBoidMode_Falling;
                        }
@@ -1098,14 +1098,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
        /* make sure there's something in new velocity, location & rotation */
        copy_particle_key(&pa->state,&pa->prev_state,0);
 
-       if(bbd->part->flag & PART_SIZEMASS)
+       if (bbd->part->flag & PART_SIZEMASS)
                pa_mass*=pa->size;
 
        /* if boids can't fly they fall to the ground */
-       if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && psys_uses_gravity(bbd->sim))
+       if ((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && psys_uses_gravity(bbd->sim))
                bpa->data.mode = eBoidMode_Falling;
 
-       if(bpa->data.mode == eBoidMode_Falling) {
+       if (bpa->data.mode == eBoidMode_Falling) {
                /* Falling boids are only effected by gravity. */
                acc[2] = bbd->sim->scene->physics_settings.gravity[2];
        }
@@ -1115,11 +1115,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                float level = landing_level + 1.0f;
                float new_vel[3];
 
-               if(bpa->data.mode == eBoidMode_Liftoff) {
+               if (bpa->data.mode == eBoidMode_Liftoff) {
                        bpa->data.mode = eBoidMode_InAir;
                        bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
                }
-               else if(bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
+               else if (bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
                        /* auto-leveling & landing if close to ground */
 
                        bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
@@ -1129,13 +1129,13 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
 
                        landing_level = - boids->landing_smoothness * pa->prev_state.vel[2] * pa_mass;
 
-                       if(pa->prev_state.vel[2] < 0.0f) {
-                               if(level < 1.0f) {
+                       if (pa->prev_state.vel[2] < 0.0f) {
+                               if (level < 1.0f) {
                                        bbd->wanted_co[0] = bbd->wanted_co[1] = bbd->wanted_co[2] = 0.0f;
                                        bbd->wanted_speed = 0.0f;
                                        bpa->data.mode = eBoidMode_Falling;
                                }
-                               else if(level < landing_level) {
+                               else if (level < landing_level) {
                                        bbd->wanted_speed *= (level - 1.0f)/landing_level;
                                        bbd->wanted_co[2] *= (level - 1.0f)/landing_level;
                                }
@@ -1146,7 +1146,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                new_speed = normalize_v3_v3(wanted_dir, bbd->wanted_co);
 
                /* first check if we have valid direction we want to go towards */
-               if(new_speed == 0.0f) {
+               if (new_speed == 0.0f) {
                        copy_v3_v3(new_dir, old_dir);
                }
                else {
@@ -1158,7 +1158,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
 
                        /* choose random direction to turn if wanted velocity */
                        /* is directly behind regardless of z-coordinate */
-                       if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
+                       if (dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
                                wanted_dir[0] = 2.0f*(0.5f - BLI_frand());
                                wanted_dir[1] = 2.0f*(0.5f - BLI_frand());
                                wanted_dir[2] = 2.0f*(0.5f - BLI_frand());
@@ -1185,7 +1185,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                /* constrain speed with maximum acceleration */
                old_speed = len_v3(pa->prev_state.vel);
                
-               if(bbd->wanted_speed < old_speed)
+               if (bbd->wanted_speed < old_speed)
                        new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
                else
                        new_speed = MIN2(bbd->wanted_speed, old_speed + val.max_acc);
@@ -1195,7 +1195,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                mul_v3_fl(new_vel, new_speed);
 
                /* maintain minimum flying velocity if not landing */
-               if(level >= landing_level) {
+               if (level >= landing_level) {
                        float len2 = dot_v2v2(new_vel,new_vel);
                        float root;
 
@@ -1224,7 +1224,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
        pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
        pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL);
 
-       if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
+       if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
                float length = normalize_v3(force);
 
                length = MAX2(0.0f, length - boids->land_stick_force);
@@ -1268,7 +1268,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                        grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
 
                        /* don't take forward acceleration into account (better banking) */
-                       if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
+                       if (dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
                                project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
                                sub_v3_v3v3(dvec, bpa->data.acc, dvec);
                        }
@@ -1281,21 +1281,21 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                        normalize_v3(bpa->gravity);
 
                        /* stick boid on goal when close enough */
-                       if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+                       if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
                                bpa->data.mode = eBoidMode_Climbing;
                                bpa->ground = bbd->goal_ob;
                                boid_find_ground(bbd, pa, ground_co, ground_nor);
                                boid_climb(boids, pa, ground_co, ground_nor);
                        }
-                       else if(pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
+                       else if (pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
                                /* land boid when below ground */
-                               if(boids->options & BOID_ALLOW_LAND) {
+                               if (boids->options & BOID_ALLOW_LAND) {
                                        pa->state.co[2] = ground_co[2] + pa->size * boids->height;
                                        pa->state.vel[2] = 0.0f;
                                        bpa->data.mode = eBoidMode_OnLand;
                                }
                                /* fly above ground */
-                               else if(bpa->ground) {
+                               else if (bpa->ground) {
                                        pa->state.co[2] = ground_co[2] + pa->size * boids->height;
                                        pa->state.vel[2] = 0.0f;
                                }
@@ -1315,22 +1315,22 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                        madd_v3_v3fl(bpa->gravity, grav, dtime);
                        normalize_v3(bpa->gravity);
 
-                       if(boids->options & BOID_ALLOW_LAND) {
+                       if (boids->options & BOID_ALLOW_LAND) {
                                /* stick boid on goal when close enough */
-                               if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+                               if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
                                        bpa->data.mode = eBoidMode_Climbing;
                                        bpa->ground = bbd->goal_ob;
                                        boid_find_ground(bbd, pa, ground_co, ground_nor);
                                        boid_climb(boids, pa, ground_co, ground_nor);
                                }
                                /* land boid when really near ground */
-                               else if(pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height) {
+                               else if (pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height) {
                                        pa->state.co[2] = ground_co[2] + pa->size * boids->height;
                                        pa->state.vel[2] = 0.0f;
                                        bpa->data.mode = eBoidMode_OnLand;
                                }
                                /* if we're falling, can fly and want to go upwards lets fly */
-                               else if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
+                               else if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
                                        bpa->data.mode = eBoidMode_InAir;
                        }
                        else
@@ -1359,14 +1359,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                case eBoidMode_OnLand:
                {
                        /* stick boid on goal when close enough */
-                       if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+                       if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
                                bpa->data.mode = eBoidMode_Climbing;
                                bpa->ground = bbd->goal_ob;
                                boid_find_ground(bbd, pa, ground_co, ground_nor);
                                boid_climb(boids, pa, ground_co, ground_nor);
                        }
                        /* ground is too far away so boid falls */
-                       else if(pa->state.co[2]-ground_co[2] > 1.1f * pa->size * boids->height)
+                       else if (pa->state.co[2]-ground_co[2] > 1.1f * pa->size * boids->height)
                                bpa->data.mode = eBoidMode_Falling;
                        else {
                                /* constrain to surface */
@@ -1374,7 +1374,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
                                pa->state.vel[2] = 0.0f;
                        }
 
-                       if(boids->banking > 0.0f) {
+                       if (boids->banking > 0.0f) {
                                float grav[3];
                                /* Don't take gravity's strength in to account, */
                                /* otherwise amount of banking is hard to control. */
@@ -1398,18 +1398,18 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
 
        /* save direction to state.ave unless the boid is falling */
        /* (boids can't effect their direction when falling) */
-       if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1f*pa->size) {
+       if (bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1f*pa->size) {
                copy_v3_v3(pa->state.ave, pa->state.vel);
                pa->state.ave[2] *= bbd->part->boids->pitch;
                normalize_v3(pa->state.ave);
        }
 
        /* apply damping */
-       if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
+       if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
                mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
 
        /* calculate rotation matrix based on forward & down vectors */
-       if(bpa->data.mode == eBoidMode_InAir) {
+       if (bpa->data.mode == eBoidMode_InAir) {
                copy_v3_v3(mat[0], pa->state.ave);
 
                project_v3_v3v3(dvec, bpa->gravity, pa->state.ave);
@@ -1434,7 +1434,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
 BoidRule *boid_new_rule(int type)
 {
        BoidRule *rule = NULL;
-       if(type <= 0)
+       if (type <= 0)
                return NULL;
 
        switch(type) {
@@ -1501,7 +1501,7 @@ BoidState *boid_new_state(BoidSettings *boids)
        BoidState *state = MEM_callocN(sizeof(BoidState), "BoidState");
 
        state->id = boids->last_state_id++;
-       if(state->id)
+       if (state->id)
                BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
        else
                strcpy(state->name, "State");
@@ -1527,10 +1527,10 @@ BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state)
 }
 void boid_free_settings(BoidSettings *boids)
 {
-       if(boids) {
+       if (boids) {
                BoidState *state = boids->states.first;
 
-               for(; state; state=state->next) {
+               for (; state; state=state->next) {
                        BLI_freelistN(&state->rules);
                        BLI_freelistN(&state->conditions);
                        BLI_freelistN(&state->actions);
@@ -1545,7 +1545,7 @@ BoidSettings *boid_copy_settings(BoidSettings *boids)
 {
        BoidSettings *nboids = NULL;
 
-       if(boids) {
+       if (boids) {
                BoidState *state;
                BoidState *nstate;
 
@@ -1555,7 +1555,7 @@ BoidSettings *boid_copy_settings(BoidSettings *boids)
 
                state = boids->states.first;
                nstate = nboids->states.first;
-               for(; state; state=state->next, nstate=nstate->next) {
+               for (; state; state=state->next, nstate=nstate->next) {
                        BLI_duplicatelist(&nstate->rules, &state->rules);
                        BLI_duplicatelist(&nstate->conditions, &state->conditions);
                        BLI_duplicatelist(&nstate->actions, &state->actions);
@@ -1568,8 +1568,8 @@ BoidState *boid_get_current_state(BoidSettings *boids)
 {
        BoidState *state = boids->states.first;
 
-       for(; state; state=state->next) {
-               if(state->flag & BOIDSTATE_CURRENT)
+       for (; state; state=state->next) {
+               if (state->flag & BOIDSTATE_CURRENT)
                        break;
        }
 
index ea626df..31c90d5 100644 (file)
@@ -208,7 +208,8 @@ CSG_PerformOp(
                        mesh2->m_vertex_iterator,               
                        InterpFaceVertexData    
                );
-       } else {
+       }
+       else {
                success = 
                CSG_PerformBooleanOperation(
                        bool_op,
index c178bf6..e7ba09d 100644 (file)
@@ -197,23 +197,23 @@ void make_local_brush(Brush *brush)
        Scene *scene;
        int is_local= FALSE, is_lib= FALSE;
 
-       if(brush->id.lib==NULL) return;
+       if (brush->id.lib==NULL) return;
 
-       if(brush->clone.image) {
+       if (brush->clone.image) {
                /* special case: ima always local immediately. Clone image should only
                 * have one user anyway. */
                id_clear_lib_data(bmain, &brush->clone.image->id);
                extern_local_brush(brush);
        }
 
-       for(scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) {
-               if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
-                       if(scene->id.lib) is_lib= TRUE;
+       for (scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) {
+               if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
+                       if (scene->id.lib) is_lib= TRUE;
                        else is_local= TRUE;
                }
        }
 
-       if(is_local && is_lib == FALSE) {
+       if (is_local && is_lib == FALSE) {
                id_clear_lib_data(bmain, &brush->id);
                extern_local_brush(brush);
 
@@ -223,7 +223,7 @@ void make_local_brush(Brush *brush)
                        brush->id.us++;
                }
        }
-       else if(is_local && is_lib) {
+       else if (is_local && is_lib) {
                Brush *brush_new= copy_brush(brush);
                brush_new->id.us= 1; /* only keep fake user */
                brush_new->id.flag |= LIB_FAKEUSER;
@@ -231,9 +231,9 @@ void make_local_brush(Brush *brush)
                /* Remap paths of new ID using old library as base. */
                BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
                
-               for(scene= bmain->scene.first; scene; scene=scene->id.next) {
-                       if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
-                               if(scene->id.lib==NULL) {
+               for (scene= bmain->scene.first; scene; scene=scene->id.next) {
+                       if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
+                               if (scene->id.lib==NULL) {
                                        paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
                                }
                        }
@@ -248,13 +248,13 @@ void brush_debug_print_state(Brush *br)
        brush_set_defaults(&def);
        
 #define BR_TEST(field, t)                                      \
-       if(br->field != def.field)                              \
+       if (br->field != def.field)                             \
                printf("br->" #field " = %" #t ";\n", br->field)
 
 #define BR_TEST_FLAG(_f)                               \
-       if((br->flag & _f) && !(def.flag & _f))         \
+       if ((br->flag & _f) && !(def.flag & _f))                \
                printf("br->flag |= " #_f ";\n");       \
-       else if(!(br->flag & _f) && (def.flag & _f))    \
+       else if (!(br->flag & _f) && (def.flag & _f))   \
                printf("br->flag &= ~" #_f ";\n")
        
 
@@ -412,7 +412,7 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset)
 {
        CurveMap *cm = NULL;
 
-       if(!b->curve)
+       if (!b->curve)
                b->curve = curvemapping_add(1, 0, 0, 1, 1);
 
        cm = b->curve->cm;
@@ -430,12 +430,12 @@ int brush_texture_set_nr(Brush *brush, int nr)
        id= (ID *)brush->mtex.tex;
 
        idtest= (ID*)BLI_findlink(&G.main->tex, nr-1);
-       if(idtest==NULL) { /* new tex */
-               if(id) idtest= (ID *)copy_texture((Tex *)id);
+       if (idtest==NULL) { /* new tex */
+               if (id) idtest= (ID *)copy_texture((Tex *)id);
                else idtest= (ID *)add_texture("Tex");
                idtest->us--;
        }
-       if(idtest!=id) {
+       if (idtest!=id) {
                brush_texture_delete(brush);
 
                brush->mtex.tex= (Tex*)idtest;
@@ -449,7 +449,7 @@ int brush_texture_set_nr(Brush *brush, int nr)
 
 int brush_texture_delete(Brush *brush)
 {
-       if(brush->mtex.tex)
+       if (brush->mtex.tex)
                brush->mtex.tex->id.us--;
 
        return 1;
@@ -457,10 +457,10 @@ int brush_texture_delete(Brush *brush)
 
 int brush_clone_image_set_nr(Brush *brush, int nr)
 {
-       if(brush && nr > 0) {
+       if (brush && nr > 0) {
                Image *ima= (Image*)BLI_findlink(&G.main->image, nr-1);
 
-               if(ima) {
+               if (ima) {
                        brush_clone_image_delete(brush);
                        brush->clone.image= ima;
                        id_us_plus(&ima->id);
@@ -717,7 +717,7 @@ void brush_scale_unprojected_radius(float *unprojected_radius,
 {
        float scale = new_brush_size;
        /* avoid division by zero */
-       if(old_brush_size != 0)
+       if (old_brush_size != 0)
                scale /= (float)old_brush_size;
        (*unprojected_radius) *= scale;
 }
@@ -729,7 +729,7 @@ void brush_scale_size(int *brush_size,
 {
        float scale = new_unprojected_radius;
        /* avoid division by zero */
-       if(old_unprojected_radius != 0)
+       if (old_unprojected_radius != 0)
                scale /= new_unprojected_radius;
        (*brush_size)= (int)((float)(*brush_size) * scale);
 }
@@ -1077,7 +1077,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
        int totpaintops= 0;
 
        if (pressure == 0.0f) {
-               if(painter->lastpressure) // XXX - hack, operator misses
+               if (painter->lastpressure) // XXX - hack, operator misses
                        pressure= painter->lastpressure;
                else
                        pressure = 1.0f;        /* zero pressure == not using tablet */
@@ -1172,7 +1172,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
                                painter->accumdistance -= spacing;
                                startdistance -= spacing;
                        }
-               } else {
+               }
+               else {
                        brush_jitter_pos(scene, brush, pos, finalpos);
 
                        if (painter->cache.enabled)
@@ -1230,19 +1231,19 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
 /* Uses the brush curve control to find a strength value between 0 and 1 */
 float brush_curve_strength_clamp(Brush *br, float p, const float len)
 {
-       if(p >= len)    return 0;
+       if (p >= len)   return 0;
        else                    p= p/len;
 
        p= curvemapping_evaluateF(br->curve, 0, p);
-       if(p < 0.0f)            p= 0.0f;
-       else if(p > 1.0f)       p= 1.0f;
+       if (p < 0.0f)           p= 0.0f;
+       else if (p > 1.0f)      p= 1.0f;
        return p;
 }
 /* same as above but can return negative values if the curve enables
  * used for sculpt only */
 float brush_curve_strength(Brush *br, float p, const float len)
 {
-       if(p >= len)
+       if (p >= len)
                p= 1.0f;
        else
                p= p/len;
@@ -1259,7 +1260,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
        int hasrgb, ix, iy;
        int side = half_side * 2;
        
-       if(mtex->tex) {
+       if (mtex->tex) {
                float x, y, step = 2.0 / side, co[3];
 
                texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache");
@@ -1280,7 +1281,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
                                 * intensity, so calculate one (formula from do_material_tex).
                                 * if the texture didn't give an RGB value, copy the intensity across
                                 */
-                               if(hasrgb & TEX_RGB)
+                               if (hasrgb & TEX_RGB)
                                        texres.tin = (0.35f * texres.tr + 0.45f *
                                                                  texres.tg + 0.2f * texres.tb);
 
@@ -1309,17 +1310,17 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
        im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect");
        im->x = im->y = side;
 
-       for(i=0; i<side; ++i) {
-               for(j=0; j<side; ++j) {
+       for (i=0; i<side; ++i) {
+               for (j=0; j<side; ++j) {
                        float magn= sqrt(pow(i - half, 2) + pow(j - half, 2));
                        im->rect_float[i*side + j]= brush_curve_strength_clamp(br, magn, half);
                }
        }
 
        /* Modulate curve with texture */
-       if(texcache) {
-               for(i=0; i<side; ++i) {
-                       for(j=0; j<side; ++j) {
+       if (texcache) {
+               for (i=0; i<side; ++i) {
+                       for (j=0; j<side; ++j) {
                                const int col= texcache[i*side+j];
                                im->rect_float[i*side+j]*= (((char*)&col)[0]+((char*)&col)[1]+((char*)&col)[2])/3.0f/255.0f;
                        }
index 90cdb7b..d7c7a9a 100644 (file)
@@ -51,7 +51,7 @@ float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_d
 {
        float dist;
 
-       if(isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
+       if (isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
                return dist;
 
        return FLT_MAX;
@@ -121,7 +121,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
                                                lv = 1;
                                        }
                                        else {
-                                               if(fabsf(A00) > FLT_EPSILON)
+                                               if (fabsf(A00) > FLT_EPSILON)
                                                        S = -B0/A00;
                                                else
                                                        S = 0.0f;
@@ -142,7 +142,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
                                                lv = 2;
                                        }
                                        else {
-                                               if(fabsf(A11) > FLT_EPSILON)
+                                               if (fabsf(A11) > FLT_EPSILON)
                                                        T = -B1 / A11;
                                                else
                                                        T = 0.0f;
@@ -164,7 +164,7 @@ float nearest