style cleanup: whitespace
authorCampbell Barton <ideasman42@gmail.com>
Sat, 12 May 2012 16:11:34 +0000 (16:11 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 12 May 2012 16:11:34 +0000 (16:11 +0000)
14 files changed:
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/customdata_file.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/idcode.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/report.c
source/blender/blenkernel/intern/sketch.c
source/blender/blenkernel/intern/suggestions.c
source/blender/blenkernel/intern/writeavi.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/quicktime/apple/quicktime_export.c
source/blender/quicktime/apple/quicktime_import.c

index 42c9fa8..7676a64 100644 (file)
@@ -416,10 +416,10 @@ struct CCGSubSurf {
 static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++) {
-               if(a[i] != b[i])
+       for (i = 0; i < ss->meshIFC.numLayers; i++) {
+               if (a[i] != b[i])
                        return 0;
-       }
+       }
        return 1;
 }
 
@@ -431,38 +431,38 @@ static void VertDataZero(float v[], const CCGSubSurf *ss)
 static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++)
+       for (i = 0; i < ss->meshIFC.numLayers; i++)
                dst[i] = src[i];
 }
 
 static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++)
+       for (i = 0; i < ss->meshIFC.numLayers; i++)
                a[i] += b[i];
 }
 
 static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++)
+       for (i = 0; i < ss->meshIFC.numLayers; i++)
                a[i] -= b[i];
 }
 
 static void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++)
+       for (i = 0; i < ss->meshIFC.numLayers; i++)
                v[i] *= f;
 }
 
 static void VertDataAvg4(float v[],
-                                                const float a[], const float b[],
-                                                const float c[], const float d[],
-                                                const CCGSubSurf *ss)
+                         const float a[], const float b[],
+                         const float c[], const float d[],
+                         const CCGSubSurf *ss)
 {
        int i;
-       for(i = 0; i < ss->meshIFC.numLayers; i++)
+       for (i = 0; i < ss->meshIFC.numLayers; i++)
                v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
 }
 
@@ -1133,7 +1133,8 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
                        v->flags = Vert_eEffected | seamflag;
                }
                else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
-                                ((v->flags & Vert_eSeam) != seamflag)) {
+                        ((v->flags & Vert_eSeam) != seamflag))
+               {
                        int i, j;
 
                        VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
@@ -1165,7 +1166,7 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
                        v->flags = Vert_eEffected | seamflag;
                }
                else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
-                                ((v->flags & Vert_eSeam) != seamflag)) {
+                        ((v->flags & Vert_eSeam) != seamflag)) {
                        *prevp = v->next;
                        _ehash_insert(ss->vMap, (EHEntry *) v);
                        VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
@@ -2001,10 +2002,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                        }
                        VertDataMulN(r, 1.0f / f->numVerts, ss);
 
-                       VertDataMulN((float*)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
-                       VertDataAdd((float*)FACE_getCenterData(f), q, ss);
-                       VertDataAdd((float*)FACE_getCenterData(f), r, ss);
-                       VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
+                       VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
+                       VertDataAdd((float *)FACE_getCenterData(f), q, ss);
+                       VertDataAdd((float *)FACE_getCenterData(f), r, ss);
+                       VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
 
                        for (S = 0; S < f->numVerts; S++) {
                                /* interior face shift
@@ -2024,14 +2025,14 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                                                             FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1),
                                                             FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1),
                                                             FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1),
-                                            ss);
+                                                            ss);
 
                                                VertDataAvg4(r,
                                                             FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0),
                                                             FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0),
                                                             FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1),
                                                             FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1),
-                                            ss);
+                                                            ss);
 
                                                VertDataCopy(nCo, co, ss);
                                                VertDataSub(nCo, q, ss);
@@ -2061,7 +2062,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                                                     FACE_getIECo(f, nextLvl, S, fx + 1),
                                                     FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx),
                                                     FACE_getIFCo(f, nextLvl, S, fx, 1),
-                                        ss);
+                                                    ss);
 
                                        VertDataCopy(nCo, co, ss);
                                        VertDataSub(nCo, q, ss);
@@ -2099,8 +2100,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
                        CCGEdge *e = FACE_getEdges(f)[S];
                        CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
 
-                       VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
-                       VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
                        VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
                        VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss);
                        for (x = 1; x < gridSize - 1; x++) {
@@ -2189,7 +2190,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
                        VertDataAdd(q, VERT_getCo(e->v1, curLvl), ss);
                        for (i = 0; i < e->numFaces; i++) {
                                CCGFace *f = e->faces[i];
-                               VertDataAdd(q, (float*)FACE_getCenterData(f), ss);
+                               VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
                                numFaces++;
                        }
                        VertDataMulN(q, 1.0f / (2.0f + numFaces), ss);
@@ -2265,7 +2266,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
                        VertDataZero(q, ss);
                        for (i = 0; i < v->numFaces; i++) {
                                CCGFace *f = v->faces[i];
-                               VertDataAdd(q, (float*)FACE_getCenterData(f), ss);
+                               VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
                                numFaces++;
                        }
                        VertDataMulN(q, 1.0f / numFaces, ss);
@@ -2365,8 +2366,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
                        CCGEdge *e = FACE_getEdges(f)[S];
                        CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
 
-                       VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
-                       VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
                        VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
                        VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1), ss);
 
@@ -2495,7 +2496,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
                        CCGEdge *e = FACE_getEdges(f)[S];
                        CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
 
-                       VertDataCopy((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
+                       VertDataCopy((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
                        VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
 
                        for (x = 0; x < gridSize; x++)
@@ -2546,7 +2547,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
                                VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss);
                        }
 
-                       VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
                        VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
                }
        }
@@ -2595,7 +2596,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
        for (i = 0; i < numEffectedF; i++) {
                CCGFace *f = effectedF[i];
 
-               VertDataZero((float*)FACE_getCenterData(f), ss);
+               VertDataZero((float *)FACE_getCenterData(f), ss);
 
                for (S = 0; S < f->numVerts; S++)
                        for (x = 0; x < gridSize; x++)
@@ -2606,7 +2607,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                        CCGEdge *e = FACE_getEdges(f)[S];
                        CCGEdge *prevE = FACE_getEdges(f)[prevS];
 
-                       VertDataAdd((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
+                       VertDataAdd((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
                        if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
                                VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
 
@@ -2648,7 +2649,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
        for (i = 0; i < numEffectedF; i++) {
                CCGFace *f = effectedF[i];
 
-               VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
+               VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
 
                for (S = 0; S < f->numVerts; S++)
                        for (x = 1; x < gridSize - 1; x++)
@@ -2659,7 +2660,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                        CCGEdge *e = FACE_getEdges(f)[S];
                        CCGEdge *prevE = FACE_getEdges(f)[prevS];
 
-                       VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
                        VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
 
                        for (x = 1; x < gridSize - 1; x++) {
@@ -2674,7 +2675,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                                VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
                        }
 
-                       VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float*)FACE_getCenterData(f), ss);
+                       VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float *)FACE_getCenterData(f), ss);
                        VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0), ss);
                }
        }
index de70ffc..b66a90a 100644 (file)
@@ -80,7 +80,7 @@ short id_type_can_have_animdata(ID *id)
        /* Only some ID-blocks have this info for now */
        // TODO: finish adding this for the other blocktypes
        switch (GS(id->name)) {
-                       /* has AnimData */
+               /* has AnimData */
                case ID_OB:
                case ID_ME: case ID_MB: case ID_CU: case ID_AR: case ID_LT:
                case ID_KE:
@@ -94,7 +94,7 @@ short id_type_can_have_animdata(ID *id)
                        return 1;
                }
                
-                       /* no AnimData */
+               /* no AnimData */
                default:
                        return 0;
        }
@@ -105,14 +105,14 @@ short id_type_can_have_animdata(ID *id)
  * the AnimData pointer is stored immediately after the given ID-block in the struct,
  * as per IdAdtTemplate.
  */
-AnimData *BKE_animdata_from_id (ID *id)
+AnimData *BKE_animdata_from_id(ID *id)
 {
        /* only some ID-blocks have this info for now, so we cast the 
         * types that do to be of type IdAdtTemplate, and extract the
         * AnimData that way
         */
        if (id_type_can_have_animdata(id)) {
-               IdAdtTemplate *iat= (IdAdtTemplate *)id;
+               IdAdtTemplate *iat = (IdAdtTemplate *)id;
                return iat->adt;
        }
        else
@@ -123,24 +123,24 @@ AnimData *BKE_animdata_from_id (ID *id)
  * the AnimData pointer is stored immediately after the given ID-block in the struct,
  * as per IdAdtTemplate. Also note that 
  */
-AnimData *BKE_id_add_animdata (ID *id)
+AnimData *BKE_id_add_animdata(ID *id)
 {
        /* Only some ID-blocks have this info for now, so we cast the 
         * types that do to be of type IdAdtTemplate, and add the AnimData
         * to it using the template
         */
        if (id_type_can_have_animdata(id)) {
-               IdAdtTemplate *iat= (IdAdtTemplate *)id;
+               IdAdtTemplate *iat = (IdAdtTemplate *)id;
                
                /* check if there's already AnimData, in which case, don't add */
                if (iat->adt == NULL) {
                        AnimData *adt;
                        
                        /* add animdata */
-                       adt= iat->adt= MEM_callocN(sizeof(AnimData), "AnimData");
+                       adt = iat->adt = MEM_callocN(sizeof(AnimData), "AnimData");
                        
                        /* set default settings */
-                       adt->act_influence= 1.0f;
+                       adt->act_influence = 1.0f;
                }
                
                return iat->adt;
@@ -174,7 +174,7 @@ short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
        
        /* manage usercount for current action */
        if (adt->action)
-               id_us_min((ID*)adt->action);
+               id_us_min((ID *)adt->action);
        
        /* assume that AnimData's action can in fact be edited... */
        if (act) {
@@ -182,14 +182,14 @@ short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
                if (ELEM(act->idroot, 0, GS(id->name))) {
                        /* can set */
                        adt->action = act;
-                       id_us_plus((ID*)adt->action);
+                       id_us_plus((ID *)adt->action);
                        ok = 1;
                }
                else {
                        /* cannot set */
                        BKE_reportf(reports, RPT_ERROR,
-                                       "Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose", 
-                                       act->id.name+2, id->name);
+                                   "Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose",
+                                   act->id.name + 2, id->name);
                        //ok = 0;
                }
        }
@@ -211,8 +211,8 @@ void BKE_free_animdata(ID *id)
         * types that do to be of type IdAdtTemplate
         */
        if (id_type_can_have_animdata(id)) {
-               IdAdtTemplate *iat= (IdAdtTemplate *)id;
-               AnimData *adt= iat->adt;
+               IdAdtTemplate *iat = (IdAdtTemplate *)id;
+               AnimData *adt = iat->adt;
                
                /* check if there's any AnimData to start with */
                if (adt) {
@@ -234,7 +234,7 @@ void BKE_free_animdata(ID *id)
                        
                        /* free animdata now */
                        MEM_freeN(adt);
-                       iat->adt= NULL;
+                       iat->adt = NULL;
                }
        }
 }
@@ -242,19 +242,19 @@ void BKE_free_animdata(ID *id)
 /* Freeing -------------------------------------------- */
 
 /* Make a copy of the given AnimData - to be used when copying datablocks */
-AnimData *BKE_copy_animdata (AnimData *adt, const short do_action)
+AnimData *BKE_copy_animdata(AnimData *adt, const short do_action)
 {
        AnimData *dadt;
        
        /* sanity check before duplicating struct */
        if (adt == NULL)
                return NULL;
-       dadt= MEM_dupallocN(adt);
+       dadt = MEM_dupallocN(adt);
        
        /* make a copy of action - at worst, user has to delete copies... */
        if (do_action) {
-               dadt->action= BKE_action_copy(adt->action);
-               dadt->tmpact= BKE_action_copy(adt->tmpact);
+               dadt->action = BKE_action_copy(adt->action);
+               dadt->tmpact = BKE_action_copy(adt->tmpact);
        }
        else {
                id_us_plus((ID *)dadt->action);
@@ -268,7 +268,7 @@ AnimData *BKE_copy_animdata (AnimData *adt, const short do_action)
        copy_fcurves(&dadt->drivers, &adt->drivers);
        
        /* don't copy overrides */
-       dadt->overrides.first= dadt->overrides.last= NULL;
+       dadt->overrides.first = dadt->overrides.last = NULL;
        
        /* return */
        return dadt;
@@ -286,7 +286,7 @@ int BKE_copy_animdata_id(ID *id_to, ID *id_from, const short do_action)
        adt = BKE_animdata_from_id(id_from);
        if (adt) {
                IdAdtTemplate *iat = (IdAdtTemplate *)id_to;
-               iat->adt= BKE_copy_animdata(adt, do_action);
+               iat->adt = BKE_copy_animdata(adt, do_action);
        }
 
        return 1;
@@ -294,15 +294,15 @@ int BKE_copy_animdata_id(ID *id_to, ID *id_from, const short do_action)
 
 void BKE_copy_animdata_id_action(ID *id)
 {
-       AnimData *adt= BKE_animdata_from_id(id);
+       AnimData *adt = BKE_animdata_from_id(id);
        if (adt) {
                if (adt->action) {
                        id_us_min((ID *)adt->action);
-                       adt->action= BKE_action_copy(adt->action);
+                       adt->action = BKE_action_copy(adt->action);
                }
                if (adt->tmpact) {
                        id_us_min((ID *)adt->tmpact);
-                       adt->tmpact= BKE_action_copy(adt->tmpact);
+                       adt->tmpact = BKE_action_copy(adt->tmpact);
                }
        }
 }
@@ -313,7 +313,7 @@ static void make_local_strips(ListBase *strips)
 {
        NlaStrip *strip;
 
-       for (strip=strips->first; strip; strip=strip->next) {
+       for (strip = strips->first; strip; strip = strip->next) {
                if (strip->act) BKE_action_make_local(strip->act);
                if (strip->remap && strip->remap->target) BKE_action_make_local(strip->remap->target);
                
@@ -336,7 +336,7 @@ void BKE_animdata_make_local(AnimData *adt)
        // TODO: need to remap the ID-targets too?
        
        /* NLA Data */
-       for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next) 
+       for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
                make_local_strips(&nlt->strips);
 }
 
@@ -355,17 +355,17 @@ void BKE_relink_animdata(AnimData *adt)
                FCurve *fcu;
                
                /* check each driver against all the base paths to see if any should go */
-               for (fcu= adt->drivers.first; fcu; fcu=fcu->next) {
-                       ChannelDriver *driver= fcu->driver;
+               for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
+                       ChannelDriver *driver = fcu->driver;
                        DriverVar *dvar;
                        
                        /* driver variables */
-                       for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
+                       for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
                                /* only change the used targets, since the others will need fixing manually anyway */
                                DRIVER_TARGETS_USED_LOOPER(dvar)
                                {
                                        if (dtar->id && dtar->id->newid) {
-                                               dtar->id= dtar->id->newid;
+                                               dtar->id = dtar->id->newid;
                                        }
                                }
                                DRIVER_TARGETS_LOOPER_END
@@ -381,7 +381,7 @@ void BKE_relink_animdata(AnimData *adt)
  * < basepath: (str) shorter path fragment to look for
  * > returns (bool) whether there is a match
  */
-static short animpath_matches_basepath (const char path[], const char basepath[])
+static short animpath_matches_basepath(const char path[], const char basepath[])
 {
        /* we need start of path to be basepath */
        return (path && basepath) && (strstr(path, basepath) == path);
@@ -395,13 +395,13 @@ static short animpath_matches_basepath (const char path[], const char basepath[]
  */
 void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[])
 {
-       FCurve *fcu, *fcn=NULL;
+       FCurve *fcu, *fcn = NULL;
        
        /* sanity checks */
        if (ELEM3(NULL, srcAct, dstAct, basepath)) {
                if (G.debug & G_DEBUG) {
                        printf("ERROR: action_partition_fcurves_by_basepath(%p, %p, %p) has insufficient info to work with\n",
-                                       (void *)srcAct, (void *)dstAct, (void *)basepath);
+                              (void *)srcAct, (void *)dstAct, (void *)basepath);
                }
                return;
        }
@@ -450,7 +450,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
        
        /* cleanup groups (if present) */
        if (srcAct->groups.first) {
-               bActionGroup *agrp, *grp=NULL;
+               bActionGroup *agrp, *grp = NULL;
                
                for (agrp = srcAct->groups.first; agrp; agrp = grp) {
                        grp = agrp->next;
@@ -475,7 +475,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
  */
 void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths)
 {
-       AnimData *srcAdt=NULL, *dstAdt=NULL;
+       AnimData *srcAdt = NULL, *dstAdt = NULL;
        LinkData *ld;
        
        /* sanity checks */
@@ -499,15 +499,15 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths
        if (srcAdt->action) {
                /* set up an action if necessary, and name it in a similar way so that it can be easily found again */
                if (dstAdt->action == NULL) {
-                       dstAdt->action = add_empty_action(srcAdt->action->id.name+2);
+                       dstAdt->action = add_empty_action(srcAdt->action->id.name + 2);
                }
                else if (dstAdt->action == srcAdt->action) {
                        printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n",
-                               srcID->name, dstID->name, srcAdt->action->id.name);
+                              srcID->name, dstID->name, srcAdt->action->id.name);
                        
                        // TODO: review this...
                        id_us_min(&dstAdt->action->id);
-                       dstAdt->action = add_empty_action(dstAdt->action->id.name+2);
+                       dstAdt->action = add_empty_action(dstAdt->action->id.name + 2);
                }
                        
                /* loop over base paths, trying to fix for each one... */
@@ -519,7 +519,7 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths
        
        /* drivers */
        if (srcAdt->drivers.first) {
-               FCurve *fcu, *fcn=NULL;
+               FCurve *fcu, *fcn = NULL;
                
                /* check each driver against all the base paths to see if any should go */
                for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) {
@@ -547,10 +547,10 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths
 /* Path Validation -------------------------------------------- */
 
 /* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
-static short check_rna_path_is_valid (ID *owner_id, const char *path)
+static short check_rna_path_is_valid(ID *owner_id, const char *path)
 {
        PointerRNA id_ptr, ptr;
-       PropertyRNA *prop=NULL;
+       PropertyRNA *prop = NULL;
        
        /* make initial RNA pointer to start resolving from */
        RNA_id_pointer_create(owner_id, &id_ptr);
@@ -562,30 +562,30 @@ static short check_rna_path_is_valid (ID *owner_id, const char *path)
 /* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate 
  * NOTE: we assume that oldName and newName have [" "] padding around them
  */
-static char *rna_path_rename_fix (ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, int verify_paths)
+static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, int verify_paths)
 {
-       char *prefixPtr= strstr(oldpath, prefix);
-       char *oldNamePtr= strstr(oldpath, oldName);
-       int prefixLen= strlen(prefix);
-       int oldNameLen= strlen(oldName);
+       char *prefixPtr = strstr(oldpath, prefix);
+       char *oldNamePtr = strstr(oldpath, oldName);
+       int prefixLen = strlen(prefix);
+       int oldNameLen = strlen(oldName);
        
        /* only start fixing the path if the prefix and oldName feature in the path,
         * and prefix occurs immediately before oldName
         */
-       if ( (prefixPtr && oldNamePtr) && (prefixPtr+prefixLen == oldNamePtr) ) {
+       if ( (prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr) ) {
                /* if we haven't aren't able to resolve the path now, try again after fixing it */
                if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {         
-                       DynStr *ds= BLI_dynstr_new();
-                       char *postfixPtr= oldNamePtr+oldNameLen;
+                       DynStr *ds = BLI_dynstr_new();
+                       char *postfixPtr = oldNamePtr + oldNameLen;
                        char *newPath = NULL;
                        char oldChar;
                        
                        /* add the part of the string that goes up to the start of the prefix */
                        if (prefixPtr > oldpath) {
-                               oldChar= prefixPtr[0]; 
-                               prefixPtr[0]= 0;
+                               oldChar = prefixPtr[0];
+                               prefixPtr[0] = 0;
                                BLI_dynstr_append(ds, oldpath);
-                               prefixPtr[0]= oldChar;
+                               prefixPtr[0] = oldChar;
                        }
                        
                        /* add the prefix */
@@ -598,7 +598,7 @@ static char *rna_path_rename_fix (ID *owner_id, const char *prefix, const char *
                        BLI_dynstr_append(ds, postfixPtr);
                        
                        /* create new path, and cleanup old data */
-                       newPath= BLI_dynstr_get_cstring(ds);
+                       newPath = BLI_dynstr_get_cstring(ds);
                        BLI_dynstr_free(ds);
                        
                        /* check if the new path will solve our problems */
@@ -620,15 +620,15 @@ static char *rna_path_rename_fix (ID *owner_id, const char *prefix, const char *
 }
 
 /* Check RNA-Paths for a list of F-Curves */
-static void fcurves_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths)
+static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths)
 {
        FCurve *fcu;
        
        /* we need to check every curve... */
-       for (fcu= curves->first; fcu; fcu= fcu->next) {
+       for (fcu = curves->first; fcu; fcu = fcu->next) {
                /* firstly, handle the F-Curve's own path */
                if (fcu->rna_path)
-                       fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths);
+                       fcu->rna_path = rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths);
        }
 }
 
@@ -639,29 +639,29 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix
        FCurve *fcu;
        
        /* we need to check every curve - drivers are F-Curves too! */
-       for (fcu= curves->first; fcu; fcu= fcu->next) {
+       for (fcu = curves->first; fcu; fcu = fcu->next) {
                /* firstly, handle the F-Curve's own path */
                if (fcu->rna_path)
-                       fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
+                       fcu->rna_path = rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
                
                /* driver? */
                if (fcu->driver) {
-                       ChannelDriver *driver= fcu->driver;
+                       ChannelDriver *driver = fcu->driver;
                        DriverVar *dvar;
                        
                        /* driver variables */
-                       for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
+                       for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
                                /* only change the used targets, since the others will need fixing manually anyway */
                                DRIVER_TARGETS_USED_LOOPER(dvar) 
                                {
                                        /* rename RNA path */
                                        if (dtar->rna_path && dtar->id)
-                                               dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
+                                               dtar->rna_path = rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
                                        
                                        /* also fix the bone-name (if applicable) */
                                        if (strstr(prefix, "bones")) {
-                                               if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB) && (!ref_id || ((Object*)(dtar->id))->data == ref_id)) &&
-                                                        (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) )
+                                               if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB) && (!ref_id || ((Object *)(dtar->id))->data == ref_id)) &&
+                                                    (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name) == 0) )
                                                {
                                                        BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
                                                }
@@ -674,12 +674,12 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix
 }
 
 /* Fix all RNA-Paths for Actions linked to NLA Strips */
-static void nlastrips_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths)
+static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths)
 {
        NlaStrip *strip;
        
        /* recursively check strips, fixing only actions... */
-       for (strip= strips->first; strip; strip= strip->next) {
+       for (strip = strips->first; strip; strip = strip->next) {
                /* fix strip's action */
                if (strip->act)
                        fcurves_path_rename_fix(owner_id, prefix, oldName, newName, &strip->act->curves, verify_paths);
@@ -692,7 +692,7 @@ static void nlastrips_path_rename_fix (ID *owner_id, const char *prefix, char *o
 
 /* Fix all RNA-Paths in the AnimData block used by the given ID block
  * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
- *             i.e. pose.bones["Bone"]
+ *       i.e. pose.bones["Bone"]
  */
 void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, const char *prefix, const char *oldName,
                                    const char *newName, int oldSubscript, int newSubscript, int verify_paths)
@@ -706,12 +706,12 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
        
        if ((oldName != NULL) && (newName != NULL)) {
                /* pad the names with [" "] so that only exact matches are made */
-               oldN= BLI_sprintfN("[\"%s\"]", oldName);
-               newN= BLI_sprintfN("[\"%s\"]", newName);
+               oldN = BLI_sprintfN("[\"%s\"]", oldName);
+               newN = BLI_sprintfN("[\"%s\"]", newName);
        } 
        else {
-               oldN= BLI_sprintfN("[%d]", oldSubscript);
-               newN= BLI_sprintfN("[%d]", newSubscript);
+               oldN = BLI_sprintfN("[%d]", oldSubscript);
+               newN = BLI_sprintfN("[%d]", newSubscript);
        }
        
        /* Active action and temp action */
@@ -724,7 +724,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons
        drivers_path_rename_fix(owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths);
        
        /* NLA Data - Animation Data for Strips */
-       for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next)
+       for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
                nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, &nlt->strips, verify_paths);
                
        /* free the temp names */
@@ -741,18 +741,18 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
 
        /* standard data version */
 #define ANIMDATA_IDS_CB(first) \
-       for (id= first; id; id= id->next) { \
-               AnimData *adt= BKE_animdata_from_id(id); \
+       for (id = first; id; id = id->next) { \
+               AnimData *adt = BKE_animdata_from_id(id); \
                if (adt) func(id, adt, user_data); \
        }
        
        /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */
 #define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \
-       for (id= first; id; id= id->next) { \
-               AnimData *adt= BKE_animdata_from_id(id); \
-               NtId_Type *ntp= (NtId_Type *)id; \
+       for (id = first; id; id = id->next) { \
+               AnimData *adt = BKE_animdata_from_id(id); \
+               NtId_Type *ntp = (NtId_Type *)id; \
                if (ntp->nodetree) { \
-                       AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
+                       AnimData *adt2 = BKE_animdata_from_id((ID *)ntp); \
                        if (adt2) func(id, adt2, user_data); \
                } \
                if (adt) func(id, adt, user_data); \
@@ -812,12 +812,12 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
 
 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
  * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
- *             i.e. pose.bones["Bone"]
+ *      i.e. pose.bones["Bone"]
  */
 /* TODO: use BKE_animdata_main_cb for looping over all data  */
 void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const char *oldName, const char *newName)
 {
-       Main *mainptr= G.main;
+       Main *mainptr = G.main;
        ID *id;
        
        /* macro for less typing 
@@ -825,21 +825,21 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha
         *        this outside of the function may make things slightly faster?
         */
 #define RENAMEFIX_ANIM_IDS(first) \
-       for (id= first; id; id= id->next) { \
-               AnimData *adt= BKE_animdata_from_id(id); \
-               BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1);\
+       for (id = first; id; id = id->next) { \
+               AnimData *adt = BKE_animdata_from_id(id); \
+               BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \
        }
        
        /* another version of this macro for nodetrees */
 #define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
-       for (id= first; id; id= id->next) { \
-               AnimData *adt= BKE_animdata_from_id(id); \
-               NtId_Type *ntp= (NtId_Type *)id; \
+       for (id = first; id; id = id->next) { \
+               AnimData *adt = BKE_animdata_from_id(id); \
+               NtId_Type *ntp = (NtId_Type *)id; \
                if (ntp->nodetree) { \
-                       AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
-                       BKE_animdata_fix_paths_rename((ID *)ntp, adt2, ref_id, prefix, oldName, newName, 0, 0, 1);\
+                       AnimData *adt2 = BKE_animdata_from_id((ID *)ntp); \
+                       BKE_animdata_fix_paths_rename((ID *)ntp, adt2, ref_id, prefix, oldName, newName, 0, 0, 1); \
                } \
-               BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1);\
+               BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \
        }
        
        /* nodes */
@@ -901,7 +901,7 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha
 
 /* Find the first path that matches the given criteria */
 // TODO: do we want some method to perform partial matches too?
-KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode))
+KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode))
 {
        KS_Path *ksp;
        
@@ -912,20 +912,20 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[]
        /* loop over paths in the current KeyingSet, finding the first one where all settings match 
         * (i.e. the first one where none of the checks fail and equal 0)
         */
-       for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
-               short eq_id=1, eq_path=1, eq_index=1, eq_group=1;
+       for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+               short eq_id = 1, eq_path = 1, eq_index = 1, eq_group = 1;
                
                /* id */
                if (id != ksp->id)
-                       eq_id= 0;
+                       eq_id = 0;
                
                /* path */
-               if ((ksp->rna_path==NULL) || strcmp(rna_path, ksp->rna_path))
-                       eq_path= 0;
+               if ((ksp->rna_path == NULL) || strcmp(rna_path, ksp->rna_path))
+                       eq_path = 0;
                        
                /* index - need to compare whole-array setting too... */
                if (ksp->array_index != array_index)
-                       eq_index= 0;
+                       eq_index = 0;
                        
                /* group */
                if (group_name) {
@@ -944,19 +944,19 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[]
 /* Defining Tools --------------------------- */
 
 /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
-KeyingSet *BKE_keyingset_add (ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
+KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
 {
        KeyingSet *ks;
        
        /* allocate new KeyingSet */
-       ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
+       ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet");
 
        BLI_strncpy(ks->idname, idname ? idname : name ? name : "KeyingSet", sizeof(ks->idname));
 
        BLI_strncpy(ks->name, name ? name : idname ? idname : "Keying Set", sizeof(ks->name));
 
-       ks->flag= flag;
-       ks->keyingflag= keyingflag;
+       ks->flag = flag;
+       ks->keyingflag = keyingflag;
        
        /* add KeyingSet to list */
        BLI_addtail(list, ks);
@@ -974,7 +974,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char idname[], const char na
 /* Add a path to a KeyingSet. Nothing is returned for now...
  * Checks are performed to ensure that destination is appropriate for the KeyingSet in question
  */
-KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
+KS_Path *BKE_keyingset_add_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
 {
        KS_Path *ksp;
        
@@ -998,27 +998,27 @@ KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[],
        }
        
        /* allocate a new KeyingSet Path */
-       ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
+       ksp = MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
        
        /* just store absolute info */
-       ksp->id= id;
+       ksp->id = id;
        if (group_name)
                BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
        else
-               ksp->group[0]= '\0';
+               ksp->group[0] = '\0';
        
        /* store additional info for relative paths (just in case user makes the set relative) */
        if (id)
-               ksp->idtype= GS(id->name);
+               ksp->idtype = GS(id->name);
        
        /* just copy path info */
        // TODO: should array index be checked too?
-       ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
-       ksp->array_index= array_index;
+       ksp->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
+       ksp->array_index = array_index;
        
        /* store flags */
-       ksp->flag= flag;
-       ksp->groupmode= groupmode;
+       ksp->flag = flag;
+       ksp->groupmode = groupmode;
        
        /* add KeyingSet path to KeyingSet */
        BLI_addtail(&ks->paths, ksp);
@@ -1050,11 +1050,11 @@ void BKE_keyingsets_copy(ListBase *newlist, ListBase *list)
        
        BLI_duplicatelist(newlist, list);
 
-       for (ksn=newlist->first; ksn; ksn=ksn->next) {
+       for (ksn = newlist->first; ksn; ksn = ksn->next) {
                BLI_duplicatelist(&ksn->paths, &ksn->paths);
                
-               for (kspn=ksn->paths.first; kspn; kspn=kspn->next)
-                       kspn->rna_path= MEM_dupallocN(kspn->rna_path);
+               for (kspn = ksn->paths.first; kspn; kspn = kspn->next)
+                       kspn->rna_path = MEM_dupallocN(kspn->rna_path);
        }
 }
 
@@ -1070,8 +1070,8 @@ void BKE_keyingset_free(KeyingSet *ks)
                return;
        
        /* free each path as we go to avoid looping twice */
-       for (ksp= ks->paths.first; ksp; ksp= kspn) {
-               kspn= ksp->next;
+       for (ksp = ks->paths.first; ksp; ksp = kspn) {
+               kspn = ksp->next;
                BKE_keyingset_free_path(ks, ksp);
        }
 }
@@ -1086,10 +1086,10 @@ void BKE_keyingsets_free(ListBase *list)
                return;
        
        /* loop over KeyingSets freeing them 
-        *      - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
+        *  - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
         */
-       for (ks= list->first; ks; ks= ksn) {
-               ksn= ks->next;
+       for (ks = list->first; ks; ks = ksn) {
+               ksn = ks->next;
                BKE_keyingset_free(ks);
                BLI_freelinkN(list, ks);
        }
@@ -1106,25 +1106,25 @@ void BKE_keyingsets_free(ListBase *list)
  *     - path: original path string (as stored in F-Curve data)
  *     - dst: destination string to write data to
  */
-static short animsys_remap_path (AnimMapper *UNUSED(remap), char *path, char **dst)
+static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst)
 {
        /* is there a valid remapping table to use? */
        //if (remap) {
-               /* find a matching entry... to use to remap */
-               // ...TODO...
+       /* find a matching entry... to use to remap */
+       // ...TODO...
        //}
        
        /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */
-       *dst= path;
+       *dst = path;
        return 0;
 }
 
 
 /* less then 1.0 evaluates to false, use epsilon to avoid float error */
-#define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f-FLT_EPSILON)))
+#define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f - FLT_EPSILON)))
 
 /* Write the given value to a setting using RNA, and return success */
-static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
+static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_index, float value)
 {
        PropertyRNA *prop;
        PointerRNA new_ptr;
@@ -1135,13 +1135,13 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
        if (RNA_path_resolve(ptr, path, &new_ptr, &prop)) {
                /* set value - only for animatable numerical values */
                if (RNA_property_animateable(&new_ptr, prop)) {
-                       int array_len= RNA_property_array_length(&new_ptr, prop);
+                       int array_len = RNA_property_array_length(&new_ptr, prop);
                        
                        if (array_len && array_index >= array_len) {
                                if (G.debug & G_DEBUG) {
                                        printf("Animato: Invalid array index. ID = '%s',  '%s[%d]', array length is %d\n",
-                                               (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
-                                               path, array_index, array_len-1);
+                                              (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+                                              path, array_index, array_len - 1);
                                }
                                
                                return 0;
@@ -1198,7 +1198,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
                         * 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) {
-                               ID *id= new_ptr.id.data;
+                               ID *id = new_ptr.id.data;
                                id->flag |= LIB_ID_RECALC;
                                DAG_id_type_tag(G.main, GS(id->name));
                        }
@@ -1213,26 +1213,26 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
                // where some channels will not exist, but shouldn't lock up Action
                if (G.debug & G_DEBUG) {
                        printf("Animato: Invalid path. ID = '%s',  '%s[%d]'\n",
-                               (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>", 
-                               path, array_index);
+                              (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>",
+                              path, array_index);
                }
                return 0;
        }
 }
 
 /* Simple replacement based data-setting of the FCurve using RNA */
-static short animsys_execute_fcurve (PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
+static short animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
 {
        char *path = NULL;
-       short free_path=0;
-       short ok= 0;
+       short free_path = 0;
+       short ok = 0;
        
        /* get path, remapped as appropriate to work in its new environment */
-       free_path= animsys_remap_path(remap, fcu->rna_path, &path);
+       free_path = animsys_remap_path(remap, fcu->rna_path, &path);
        
        /* write value to setting */
        if (path)
-               ok= animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
+               ok = animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
        
        /* free temp path-info */
        if (free_path)
@@ -1245,16 +1245,16 @@ static short animsys_execute_fcurve (PointerRNA *ptr, AnimMapper *remap, FCurve
 /* Evaluate all the F-Curves in the given list 
  * This performs a set of standard checks. If extra checks are required, separate code should be used
  */
-static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
+static void animsys_evaluate_fcurves(PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
 {
        FCurve *fcu;
        
        /* calculate then execute each curve */
-       for (fcu= list->first; fcu; fcu= fcu->next) {
+       for (fcu = list->first; fcu; fcu = fcu->next) {
                /* check if this F-Curve doesn't belong to a muted group */
-               if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) {
+               if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED) == 0) {
                        /* check if this curve should be skipped */
-                       if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
+                       if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
                                calculate_fcurve(fcu, ctime);
                                animsys_execute_fcurve(ptr, remap, fcu); 
                        }
@@ -1266,25 +1266,25 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe
 /* Driver Evaluation */
 
 /* Evaluate Drivers */
-static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctime)
+static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime)
 {
        FCurve *fcu;
        
        /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
         * the depsgraph requested that this driver be evaluated...
         */
-       for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
-               ChannelDriver *driver= fcu->driver;
-               short ok= 0;
+       for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
+               ChannelDriver *driver = fcu->driver;
+               short ok = 0;
                
                /* check if this driver's curve should be skipped */
-               if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
+               if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
                        /* check if driver itself is tagged for recalculation */
-                       if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID)/*&& (driver->flag & DRIVER_FLAG_RECALC)*/) {      // XXX driver recalc flag is not set yet by depsgraph!
+                       if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) {  // XXX driver recalc flag is not set yet by depsgraph!
                                /* evaluate this using values set already in other places */
                                // NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
                                calculate_fcurve(fcu, ctime);
-                               ok= animsys_execute_fcurve(ptr, NULL, fcu);
+                               ok = animsys_execute_fcurve(ptr, NULL, fcu);
                                
                                /* clear recalc flag */
                                driver->flag &= ~DRIVER_FLAG_RECALC;
@@ -1304,7 +1304,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim
  * to reduce the amount of times that users end up having to "revive" wrongly-assigned
  * actions
  */
-static void action_idcode_patch_check (ID *id, bAction *act)
+static void action_idcode_patch_check(ID *id, bAction *act)
 {
        int idcode = 0;
        
@@ -1317,7 +1317,7 @@ static void action_idcode_patch_check (ID *id, bAction *act)
        /* the actual checks... hopefully not too much of a performance hit in the long run... */
        if (act->idroot == 0) {
                /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds)
-                *      - this has problems if there are 2 users, and the first one encountered is the invalid one
+                *  - this has problems if there are 2 users, and the first one encountered is the invalid one
                 *        in which case, the user will need to manually fix this (?)
                 */
                act->idroot = idcode;
@@ -1326,7 +1326,7 @@ static void action_idcode_patch_check (ID *id, bAction *act)
                /* only report this error if debug mode is enabled (to save performance everywhere else) */
                if (G.debug & G_DEBUG) {
                        printf("AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of type %d such as '%s'\n",
-                               act->id.name+2, idcode, id->name);
+                              act->id.name + 2, idcode, id->name);
                }
        }
 }
@@ -1340,7 +1340,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
        
        /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
        if (ELEM(NULL, act, agrp)) return;
-       if ((remap) && (remap->target != act)) remap= NULL;
+       if ((remap) && (remap->target != act)) remap = NULL;
        
        action_idcode_patch_check(ptr->id.data, act);
        
@@ -1349,9 +1349,9 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
                return;
        
        /* calculate then execute each curve */
-       for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) {
+       for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcu->next) {
                /* check if this curve should be skipped */
-               if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) {
+               if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
                        calculate_fcurve(fcu, ctime);
                        animsys_execute_fcurve(ptr, remap, fcu); 
                }
@@ -1363,7 +1363,7 @@ void animsys_evaluate_action(PointerRNA *ptr, bAction *act, AnimMapper *remap, f
 {
        /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
        if (act == NULL) return;
-       if ((remap) && (remap->target != act)) remap= NULL;
+       if ((remap) && (remap->target != act)) remap = NULL;
        
        action_idcode_patch_check(ptr->id.data, act);
        
@@ -1375,18 +1375,18 @@ void animsys_evaluate_action(PointerRNA *ptr, bAction *act, AnimMapper *remap, f
 /* NLA System - Evaluation */
 
 /* calculate influence of strip based for given frame based on blendin/out values */
-static float nlastrip_get_influence (NlaStrip *strip, float cframe)
+static float nlastrip_get_influence(NlaStrip *strip, float cframe)
 {
        /* sanity checks - normalize the blendin/out values? */
-       strip->blendin= fabsf(strip->blendin);
-       strip->blendout= fabsf(strip->blendout);
+       strip->blendin = fabsf(strip->blendin);
+       strip->blendout = fabsf(strip->blendout);
        
        /* result depends on where frame is in respect to blendin/out values */
-       if (IS_EQ(strip->blendin, 0)==0 && (cframe <= (strip->start + strip->blendin))) {
+       if (IS_EQ(strip->blendin, 0) == 0 && (cframe <= (strip->start + strip->blendin))) {
                /* there is some blend-in */
                return fabsf(cframe - strip->start) / (strip->blendin);
        }
-       else if (IS_EQ(strip->blendout, 0)==0 && (cframe >= (strip->end - strip->blendout))) {
+       else if (IS_EQ(strip->blendout, 0) == 0 && (cframe >= (strip->end - strip->blendout))) {
                /* there is some blend-out */
                return fabsf(strip->end - cframe) / (strip->blendout);
        }
@@ -1397,13 +1397,13 @@ static float nlastrip_get_influence (NlaStrip *strip, float cframe)
 }
 
 /* evaluate the evaluation time and influence for the strip, storing the results in the strip */
-static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
+static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime)
 {
        /* firstly, analytically generate values for influence and time (if applicable) */
        if ((strip->flag & NLASTRIP_FLAG_USR_TIME) == 0)
-               strip->strip_time= nlastrip_get_frame(strip, ctime, NLATIME_CONVERT_EVAL);
+               strip->strip_time = nlastrip_get_frame(strip, ctime, NLATIME_CONVERT_EVAL);
        if ((strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) == 0)
-               strip->influence= nlastrip_get_influence(strip, ctime);
+               strip->influence = nlastrip_get_influence(strip, ctime);
        
        /* now strip's evaluate F-Curves for these settings (if applicable) */
        if (strip->fcurves.first) {
@@ -1422,23 +1422,23 @@ static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
         */
        // NOTE: if we add any more of these special cases, we better group them up nicely...
        if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC))
-               strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
+               strip->strip_time = fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
 }
 
 /* gets the strip active at the current time for a list of strips for evaluation purposes */
-NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short index, float ctime)
+NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short index, float ctime)
 {
-       NlaStrip *strip, *estrip=NULL;
+       NlaStrip *strip, *estrip = NULL;
        NlaEvalStrip *nes;
-       short side= 0;
+       short side = 0;
        
        /* loop over strips, checking if they fall within the range */
-       for (strip= strips->first; strip; strip= strip->next) {
+       for (strip = strips->first; strip; strip = strip->next) {
                /* check if current time occurs within this strip  */
                if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
                        /* this strip is active, so try to use it */
-                       estrip= strip;
-                       side= NES_TIME_WITHIN;
+                       estrip = strip;
+                       side = NES_TIME_WITHIN;
                        break;
                }
                
@@ -1447,22 +1447,22 @@ NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short
                        if (strip == strips->first) {
                                /* before first strip - only try to use it if it extends backwards in time too */
                                if (strip->extendmode == NLASTRIP_EXTEND_HOLD)
-                                       estrip= strip;
+                                       estrip = strip;
                                        
                                /* side is 'before' regardless of whether there's a useful strip */
-                               side= NES_TIME_BEFORE;
+                               side = NES_TIME_BEFORE;
                        }
                        else {
                                /* before next strip - previous strip has ended, but next hasn't begun, 
                                 * so blending mode depends on whether strip is being held or not...
-                                *      - only occurs when no transition strip added, otherwise the transition would have
-                                *        been picked up above...
+                                *  - only occurs when no transition strip added, otherwise the transition would have
+                                *    been picked up above...
                                 */
-                               strip= strip->prev;
+                               strip = strip->prev;
                                
                                if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
-                                       estrip= strip;
-                               side= NES_TIME_AFTER;
+                                       estrip = strip;
+                               side = NES_TIME_AFTER;
                        }
                        break;
                }
@@ -1472,9 +1472,9 @@ NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short
                        /* only if this is the last strip should we do anything, and only if that is being held */
                        if (strip == strips->last) {
                                if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
-                                       estrip= strip;
+                                       estrip = strip;
                                        
-                               side= NES_TIME_AFTER;
+                               side = NES_TIME_AFTER;
                                break;
                        }
                        
@@ -1491,15 +1491,15 @@ NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short
        /* if ctime was not within the boundaries of the strip, clamp! */
        switch (side) {
                case NES_TIME_BEFORE: /* extend first frame only */
-                       ctime= estrip->start;
+                       ctime = estrip->start;
                        break;
                case NES_TIME_AFTER: /* extend last frame only */
-                       ctime= estrip->end;
+                       ctime = estrip->end;
                        break;
        }
        
        /* evaluate strip's evaluation controls  
-        *      - skip if no influence (i.e. same effect as muting the strip)
+        *  - skip if no influence (i.e. same effect as muting the strip)
         *      - negative influence is not supported yet... how would that be defined?
         */
        // TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on...
@@ -1528,12 +1528,12 @@ NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short
        }
        
        /* add to list of strips we need to evaluate */
-       nes= MEM_callocN(sizeof(NlaEvalStrip), "NlaEvalStrip");
+       nes = MEM_callocN(sizeof(NlaEvalStrip), "NlaEvalStrip");
        
-       nes->strip= estrip;
-       nes->strip_mode= side;
-       nes->track_index= index;
-       nes->strip_time= estrip->strip_time;
+       nes->strip = estrip;
+       nes->strip_mode = side;
+       nes->track_index = index;
+       nes->strip_time = estrip->strip_time;
        
        if (list)
                BLI_addtail(list, nes);
@@ -1546,7 +1546,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short
 /* find an NlaEvalChannel that matches the given criteria 
  *     - ptr and prop are the RNA data to find a match for
  */
-static NlaEvalChannel *nlaevalchan_find_match (ListBase *channels, PointerRNA *ptr, PropertyRNA *prop, int array_index)
+static NlaEvalChannel *nlaevalchan_find_match(ListBase *channels, PointerRNA *ptr, PropertyRNA *prop, int array_index)
 {
        NlaEvalChannel *nec;
        
@@ -1555,7 +1555,7 @@ static NlaEvalChannel *nlaevalchan_find_match (ListBase *channels, PointerRNA *p
                return NULL;
        
        /* loop through existing channels, checking for a channel which affects the same property */
-       for (nec= channels->first; nec; nec= nec->next) {
+       for (nec = channels->first; nec; nec = nec->next) {
                /* - comparing the PointerRNA's is done by comparing the pointers
                 *   to the actual struct the property resides in, since that all the
                 *   other data stored in PointerRNA cannot allow us to definitively 
@@ -1570,10 +1570,10 @@ static NlaEvalChannel *nlaevalchan_find_match (ListBase *channels, PointerRNA *p
 }
 
 /* verify that an appropriate NlaEvalChannel for this F-Curve exists */
-static NlaEvalChannel *nlaevalchan_verify (PointerRNA *ptr, ListBase *channels, NlaEvalStrip *nes, FCurve *fcu, short *newChan)
+static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, NlaEvalStrip *nes, FCurve *fcu, short *newChan)
 {
        NlaEvalChannel *nec;
-       NlaStrip *strip= nes->strip;
+       NlaStrip *strip = nes->strip;
        PropertyRNA *prop;
        PointerRNA new_ptr;
        char *path = NULL;
@@ -1584,50 +1584,50 @@ static NlaEvalChannel *nlaevalchan_verify (PointerRNA *ptr, ListBase *channels,
                return NULL;
        
        /* get RNA pointer+property info from F-Curve for more convenient handling */
-               /* get path, remapped as appropriate to work in its new environment */
+       /* get path, remapped as appropriate to work in its new environment */
        /* free_path= */ /* UNUSED */ animsys_remap_path(strip->remap, fcu->rna_path, &path);
        
-               /* a valid property must be available, and it must be animatable */
+       /* a valid property must be available, and it must be animatable */
        if (RNA_path_resolve(ptr, path, &new_ptr, &prop) == 0) {
                if (G.debug & G_DEBUG) printf("NLA Strip Eval: Cannot resolve path\n");
                return NULL;
        }
-               /* only ok if animatable */
+       /* only ok if animatable */
        else if (RNA_property_animateable(&new_ptr, prop) == 0) {
                if (G.debug & G_DEBUG) printf("NLA Strip Eval: Property not animatable\n");
                return NULL;
        }
        
        /* try to find a match */
-       nec= nlaevalchan_find_match(channels, &new_ptr, prop, fcu->array_index);
+       nec = nlaevalchan_find_match(channels, &new_ptr, prop, fcu->array_index);
        
        /* allocate a new struct for this if none found */
        if (nec == NULL) {
-               nec= MEM_callocN(sizeof(NlaEvalChannel), "NlaEvalChannel");
-               *newChan= 1;
+               nec = MEM_callocN(sizeof(NlaEvalChannel), "NlaEvalChannel");
+               *newChan = 1;
                BLI_addtail(channels, nec);
                
-               nec->ptr= new_ptr; 
-               nec->prop= prop;
-               nec->index= fcu->array_index;
+               nec->ptr = new_ptr;
+               nec->prop = prop;
+               nec->index = fcu->array_index;
        }
        else
-               *newChan= 0;
+               *newChan = 0;
        
        /* we can now return */
        return nec;
 }
 
 /* accumulate (i.e. blend) the given value on to the channel it affects */
-static void nlaevalchan_accumulate (NlaEvalChannel *nec, NlaEvalStrip *nes, short newChan, float value)
+static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short newChan, float value)
 {
-       NlaStrip *strip= nes->strip;
-       short blendmode= strip->blendmode;
-       float inf= strip->influence;
+       NlaStrip *strip = nes->strip;
+       short blendmode = strip->blendmode;
+       float inf = strip->influence;
        
        /* if channel is new, just store value regardless of blending factors, etc. */
        if (newChan) {
-               nec->value= value;
+               nec->value = value;
                return;
        }
                
@@ -1664,13 +1664,13 @@ static void nlaevalchan_accumulate (NlaEvalChannel *nec, NlaEvalStrip *nes, shor
                         *      - the influence of the accumulated data (elsewhere, that is called dstweight) 
                         *        is 1 - influence, since the strip's influence is srcweight
                         */
-                       nec->value= nec->value * (1.0f - inf)   +   value;
+                       nec->value = nec->value * (1.0f - inf)   +   value;
                        break;
        }
 }
 
 /* accumulate the results of a temporary buffer with the results of the full-buffer */
-static void nlaevalchan_buffers_accumulate (ListBase *channels, ListBase *tmp_buffer, NlaEvalStrip *nes)
+static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buffer, NlaEvalStrip *nes)
 {
        NlaEvalChannel *nec, *necn, *necd;
        
@@ -1679,12 +1679,12 @@ static void nlaevalchan_buffers_accumulate (ListBase *channels, ListBase *tmp_bu
                return;
        
        /* accumulate results in tmp_channels buffer to the accumulation buffer */
-       for (nec= tmp_buffer->first; nec; nec= necn) {
+       for (nec = tmp_buffer->first; nec; nec = necn) {
                /* get pointer to next channel in case we remove the current channel from the temp-buffer */
-               necn= nec->next;
+               necn = nec->next;
                
                /* try to find an existing matching channel for this setting in the accumulation buffer */
-               necd= nlaevalchan_find_match(channels, &nec->ptr, nec->prop, nec->index);
+               necd = nlaevalchan_find_match(channels, &nec->ptr, nec->prop, nec->index);
                
                /* if there was a matching channel already in the buffer, accumulate to it,
                 * otherwise, add the current channel to the buffer for efficiency
@@ -1705,39 +1705,39 @@ static void nlaevalchan_buffers_accumulate (ListBase *channels, ListBase *tmp_bu
 /* F-Modifier stack joining/separation utilities - should we generalise these for BLI_listbase.h interface? */
 
 /* Temporarily join two lists of modifiers together, storing the result in a third list */
-static void nlaeval_fmodifiers_join_stacks (ListBase *result, ListBase *list1, ListBase *list2)
+static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2)
 {
        FModifier *fcm1, *fcm2;
        
        /* if list1 is invalid...  */
        if (ELEM(NULL, list1, list1->first)) {
                if (list2 && list2->first) {
-                       result->first= list2->first;
-                       result->last= list2->last;
+                       result->first = list2->first;
+                       result->last = list2->last;
                }
        }
        /* if list 2 is invalid... */
        else if (ELEM(NULL, list2, list2->first)) {
-               result->first= list1->first;
-               result->last= list1->last;
+               result->first = list1->first;
+               result->last = list1->last;
        }
        else {
                /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result 
-                *      - the original lists must be left unchanged though, as we need that fact for restoring
+                *  - the original lists must be left unchanged though, as we need that fact for restoring
                 */
-               result->first= list1->first;
-               result->last= list2->last;
+               result->first = list1->first;
+               result->last = list2->last;
                
-               fcm1= list1->last;
-               fcm2= list2->first;
+               fcm1 = list1->last;
+               fcm2 = list2->first;
                
-               fcm1->next= fcm2;
-               fcm2->prev= fcm1;
+               fcm1->next = fcm2;
+               fcm2->prev = fcm1;
        }
 }
 
 /* Split two temporary lists of modifiers */
-static void nlaeval_fmodifiers_split_stacks (ListBase *list1, ListBase *list2)
+static void nlaeval_fmodifiers_split_stacks(ListBase *list1, ListBase *list2)
 {
        FModifier *fcm1, *fcm2;
        
@@ -1748,21 +1748,21 @@ static void nlaeval_fmodifiers_split_stacks (ListBase *list1, ListBase *list2)
                return;
                
        /* get endpoints */
-       fcm1= list1->last;
-       fcm2= list2->first;
+       fcm1 = list1->last;
+       fcm2 = list2->first;
        
        /* clear their links */
-       fcm1->next= NULL;
-       fcm2->prev= NULL;
+       fcm1->next = NULL;
+       fcm2->prev = NULL;
 }
 
 /* ---------------------- */
 
 /* evaluate action-clip strip */
-static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+static void nlastrip_evaluate_actionclip(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
 {
        ListBase tmp_modifiers = {NULL, NULL};
-       NlaStrip *strip= nes->strip;
+       NlaStrip *strip = nes->strip;
        FCurve *fcu;
        float evaltime;
        
@@ -1781,16 +1781,16 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L
        nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
        
        /* evaluate strip's modifiers which modify time to evaluate the base curves at */
-       evaltime= evaluate_time_fmodifiers(&tmp_modifiers, NULL, 0.0f, strip->strip_time);
+       evaltime = evaluate_time_fmodifiers(&tmp_modifiers, NULL, 0.0f, strip->strip_time);
        
        /* evaluate all the F-Curves in the action, saving the relevant pointers to data that will need to be used */
-       for (fcu= strip->act->curves.first; fcu; fcu= fcu->next) {
+       for (fcu = strip->act->curves.first; fcu; fcu = fcu->next) {
                NlaEvalChannel *nec;
                float value = 0.0f;
                short newChan = -1;
                
                /* check if this curve should be skipped */
-               if (fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) 
+               if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED))
                        continue;
                if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED))
                        continue;
@@ -1798,7 +1798,7 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L
                /* evaluate the F-Curve's value for the time given in the strip 
                 * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this 
                 */
-               value= evaluate_fcurve(fcu, evaltime);
+               value = evaluate_fcurve(fcu, evaltime);
                
                /* apply strip's F-Curve Modifiers on this value 
                 * NOTE: we apply the strip's original evaluation time not the modified one (as per standard F-Curve eval)
@@ -1809,7 +1809,7 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L
                /* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s)
                 * stored in this channel if it has been used already
                 */
-               nec= nlaevalchan_verify(ptr, channels, nes, fcu, &newChan);
+               nec = nlaevalchan_verify(ptr, channels, nes, fcu, &newChan);
                if (nec)
                        nlaevalchan_accumulate(nec, nes, newChan, value);
        }
@@ -1819,7 +1819,7 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L
 }
 
 /* evaluate transition strip */
-static void nlastrip_evaluate_transition (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
 {
        ListBase tmp_channels = {NULL, NULL};
        ListBase tmp_modifiers = {NULL, NULL};
@@ -1837,12 +1837,12 @@ static void nlastrip_evaluate_transition (PointerRNA *ptr, ListBase *channels, L
         *        otherwise they will be interpolated wrong
         */
        if (nes->strip->flag & NLASTRIP_FLAG_REVERSE) {
-               s1= nes->strip->next;
-               s2= nes->strip->prev;
+               s1 = nes->strip->next;
+               s2 = nes->strip->prev;
        }
        else {
-               s1= nes->strip->prev;
-               s2= nes->strip->next;
+               s1 = nes->strip->prev;
+               s2 = nes->strip->next;
        }
        
        /* prepare template for 'evaluation strip' 
@@ -1852,18 +1852,18 @@ static void nlastrip_evaluate_transition (PointerRNA *ptr, ListBase *channels, L
         *        which doubles up as an additional weighting factor for the strip influences
         *        which allows us to appear to be 'interpolating' between the two extremes
         */
-       tmp_nes= *nes;
+       tmp_nes = *nes;
        
        /* evaluate these strips into a temp-buffer (tmp_channels) */
        // FIXME: modifier evalation here needs some work...
-               /* first strip */
-       tmp_nes.strip_mode= NES_TIME_TRANSITION_START;
-       tmp_nes.strip= s1;
+       /* first strip */
+       tmp_nes.strip_mode = NES_TIME_TRANSITION_START;
+       tmp_nes.strip = s1;
        nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
        
-               /* second strip */
-       tmp_nes.strip_mode= NES_TIME_TRANSITION_END;
-       tmp_nes.strip= s2;
+       /* second strip */
+       tmp_nes.strip_mode = NES_TIME_TRANSITION_END;
+       tmp_nes.strip = s2;
        nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
        
        
@@ -1875,11 +1875,11 @@ static void nlastrip_evaluate_transition (PointerRNA *ptr, ListBase *channels, L
 }
 
 /* evaluate meta-strip */
-static void nlastrip_evaluate_meta (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
+static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
 {
        ListBase tmp_channels = {NULL, NULL};
        ListBase tmp_modifiers = {NULL, NULL};
-       NlaStrip *strip= nes->strip;
+       NlaStrip *strip = nes->strip;
        NlaEvalStrip *tmp_nes;
        float evaltime;
        
@@ -1895,8 +1895,8 @@ static void nlastrip_evaluate_meta (PointerRNA *ptr, ListBase *channels, ListBas
        nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers); 
        
        /* find the child-strip to evaluate */
-       evaltime= (nes->strip_time * (strip->end - strip->start)) + strip->start;
-       tmp_nes= nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime);
+       evaltime = (nes->strip_time * (strip->end - strip->start)) + strip->start;
+       tmp_nes = nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime);
        if (tmp_nes == NULL)
                return;
                
@@ -1918,7 +1918,7 @@ static void nlastrip_evaluate_meta (PointerRNA *ptr, ListBase *channels, ListBas
 /* evaluates the given evaluation strip */
 void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
 {
-       NlaStrip *strip= nes->strip;
+       NlaStrip *strip = nes->strip;
        
        /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition
         * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave
@@ -1958,11 +1958,11 @@ void nladata_flush_channels(ListBase *channels)
                return;
        
        /* for each channel with accumulated values, write its value on the property it affects */
-       for (nec= channels->first; nec; nec= nec->next) {
-               PointerRNA *ptr= &nec->ptr;
-               PropertyRNA *prop= nec->prop;
-               int array_index= nec->index;
-               float value= nec->value;
+       for (nec = channels->first; nec; nec = nec->next) {
+               PointerRNA *ptr = &nec->ptr;
+               PropertyRNA *prop = nec->prop;
+               int array_index = nec->index;
+               float value = nec->value;
                
                /* write values - see animsys_write_rna_setting() to sync the code */
                switch (RNA_property_type(prop)) {
@@ -2000,23 +2000,23 @@ void nladata_flush_channels(ListBase *channels)
  * ! This is exported so that keyframing code can use this for make use of it for anim layers support
  * > echannels: (list<NlaEvalChannels>) evaluation channels with calculated values
  */
-static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime)
+static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime)
 {
        NlaTrack *nlt;
-       short track_index=0;
+       short track_index = 0;
        short has_strips = 0;
        
-       ListBase estrips= {NULL, NULL};
+       ListBase estrips = {NULL, NULL};
        NlaEvalStrip *nes;
        
        /* 1. get the stack of strips to evaluate at current time (influence calculated here) */
-       for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) { 
+       for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next, track_index++) {
                /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */
                if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED))
                        break;
                        
                /* skip if we're only considering a track tagged 'solo' */
-               if ((adt->flag & ADT_NLA_SOLO_TRACK) && (nlt->flag & NLATRACK_SOLO)==0)
+               if ((adt->flag & ADT_NLA_SOLO_TRACK) && (nlt->flag & NLATRACK_SOLO) == 0)
                        continue;
                /* skip if track is muted */
                if (nlt->flag & NLATRACK_MUTED) 
@@ -2026,11 +2026,11 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData
                 *      - used for mainly for still allowing normal action evaluation...
                 */
                if (nlt->strips.first)
-                       has_strips= 1;
+                       has_strips = 1;
                        
                /* otherwise, get strip to evaluate for this channel */
-               nes= nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime);
-               if (nes) nes->track= nlt;
+               nes = nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime);
+               if (nes) nes->track = nlt;
        }
        
        /* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack
@@ -2038,14 +2038,14 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData
         *      - however, if the 'solo' track houses the current 'tweaking' strip, 
         *        then we should allow this to play, otherwise nothing happens
         */
-       if ((adt->action) && ((adt->flag & ADT_NLA_SOLO_TRACK)==0 || (adt->flag & ADT_NLA_EDIT_ON))) {
+       if ((adt->action) && ((adt->flag & ADT_NLA_SOLO_TRACK) == 0 || (adt->flag & ADT_NLA_EDIT_ON))) {
                /* if there are strips, evaluate action as per NLA rules */
                if ((has_strips) || (adt->actstrip)) {
                        /* make dummy NLA strip, and add that to the stack */
-                       NlaStrip dummy_strip= {NULL};
+                       NlaStrip dummy_strip = {NULL};
                        ListBase dummy_trackslist;
                        
-                       dummy_trackslist.first= dummy_trackslist.last= &dummy_strip;
+                       dummy_trackslist.first = dummy_trackslist.last = &dummy_strip;
                        
                        if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) {
                                /* edit active action in-place according to its active strip, so copy the data  */
@@ -2054,17 +2054,17 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData
                        }
                        else {
                                /* set settings of dummy NLA strip from AnimData settings */
-                               dummy_strip.act= adt->action;
-                               dummy_strip.remap= adt->remap;
+                               dummy_strip.act = adt->action;
+                               dummy_strip.remap = adt->remap;
                                
                                /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
                                calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1);
                                dummy_strip.start = dummy_strip.actstart;
-                               dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ?  (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
+                               dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ?  (dummy_strip.actstart + 1.0f) : (dummy_strip.actend);
                                
-                               dummy_strip.blendmode= adt->act_blendmode;
-                               dummy_strip.extendmode= adt->act_extendmode;
-                               dummy_strip.influence= adt->act_influence;
+                               dummy_strip.blendmode = adt->act_blendmode;
+                               dummy_strip.extendmode = adt->act_extendmode;
+                               dummy_strip.influence = adt->act_influence;
                        }
                        
                        /* add this to our list of evaluation strips */
@@ -2084,7 +2084,7 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData
        
        
        /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
-       for (nes= estrips.first; nes; nes= nes->next) 
+       for (nes = estrips.first; nes; nes = nes->next)
                nlastrip_evaluate(ptr, echannels, NULL, nes);
                
        /* 3. free temporary evaluation data that's not used elsewhere */
@@ -2095,9 +2095,9 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData
  *     - All channels that will be affected are not cleared anymore. Instead, we just evaluate into 
  *             some temp channels, where values can be accumulated in one go.
  */
-static void animsys_calculate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
+static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime)
 {
-       ListBase echannels= {NULL, NULL};
+       ListBase echannels = {NULL, NULL};
        
        // TODO: need to zero out all channels used, otherwise we have problems with threadsafety
        // and also when the user jumps between different times instead of moving sequentially...
@@ -2119,7 +2119,7 @@ static void animsys_calculate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
 
 /* Add or get existing Override for given setting */
 #if 0
-AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index))
+AnimOverride *BKE_animsys_validate_override(PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index))
 {
        // FIXME: need to define how to get overrides
        return NULL;
@@ -2129,12 +2129,12 @@ AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUS
 /* -------------------- */
 
 /* Evaluate Overrides */
-static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
+static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
 {
        AnimOverride *aor;
        
        /* for each override, simply execute... */
-       for (aor= adt->overrides.first; aor; aor= aor->next)
+       for (aor = adt->overrides.first; aor; aor = aor->next)
                animsys_write_rna_setting(ptr, aor->rna_path, aor->array_index, aor->value);
 }
 
@@ -2169,7 +2169,7 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
  *
  * Current Status:
  *     - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides. 
- *       However, the code for this is relatively harmless, so is left in the code for now.
+ *    However, the code for this is relatively harmless, so is left in the code for now.
  */
 
 /* Evaluation loop for evaluation animation data 
@@ -2238,7 +2238,7 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct
        }
        
        /* clear recalc flag now */
-       adt->recalc= 0;
+       adt->recalc = 0;
 }
 
 /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only
@@ -2261,25 +2261,25 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
         *        this outside of the function may make things slightly faster?
         */
 #define EVAL_ANIM_IDS(first, aflag) \
-       for (id= first; id; id= id->next) { \
+       for (id = first; id; id = id->next) { \
                if (ID_REAL_USERS(id) > 0) { \
-                       AnimData *adt= BKE_animdata_from_id(id); \
+                       AnimData *adt = BKE_animdata_from_id(id); \
                        BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
                } \
        }
        /* another macro for the "embedded" nodetree cases 
         *      - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees" 
         *        (i.e. scene/material/texture->nodetree) which we need a special exception
-        *        for, otherwise they'd get skipped
+        *    for, otherwise they'd get skipped
         *      - ntp = "node tree parent" = datablock where node tree stuff resides
         */
 #define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \
-       for (id= first; id; id= id->next) { \
+       for (id = first; id; id = id->next) { \
                if (ID_REAL_USERS(id) > 0) { \
-                       AnimData *adt= BKE_animdata_from_id(id); \
-                       NtId_Type *ntp= (NtId_Type *)id; \
+                       AnimData *adt = BKE_animdata_from_id(id); \
+                       NtId_Type *ntp = (NtId_Type *)id; \
                        if (ntp->nodetree) { \
-                               AnimData *adt2= BKE_animdata_from_id((ID *)ntp->nodetree); \
+                               AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \
                                BKE_animsys_evaluate_animdata(scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
                        } \
                        BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
@@ -2344,10 +2344,10 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
        EVAL_ANIM_IDS(main->movieclip.first, ADT_RECALC_ANIM);
 
        /* objects */
-               /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets 
-                * this tagged by Depsgraph on framechange. This optimization means that objects
-                * linked from other (not-visible) scenes will not need their data calculated.
-                */
+       /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
+        * this tagged by Depsgraph on framechange. This optimization means that objects
+        * linked from other (not-visible) scenes will not need their data calculated.
+        */
        EVAL_ANIM_IDS(main->object.first, 0); 
        
        /* worlds */
index 5eab6ae..90a3e61 100644 (file)
@@ -128,7 +128,7 @@ typedef struct LayerTypeInfo {
 } LayerTypeInfo;
 
 static void layerCopy_mdeformvert(const void *source, void *dest,
-                                                                 int count)
+                                  int count)
 {
        int i, size = sizeof(MDeformVert);
 
@@ -139,7 +139,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
 
                if (dvert->totweight) {
                        MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
-                                                                                       "layerCopy_mdeformvert dw");
+                                                       "layerCopy_mdeformvert dw");
 
                        memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
                        dvert->dw = dw;
@@ -204,7 +204,7 @@ static void linklist_free_simple(void *link)
 }
 
 static void layerInterp_mdeformvert(void **sources, float *weights,
-                                                                       float *UNUSED(sub_weights), int count, void *dest)
+                                    float *UNUSED(sub_weights), int count, void *dest)
 {
        MDeformVert *dvert = dest;
        LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */
@@ -234,7 +234,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
                        /* if this def_nr is not in the list, add it */
                        if (!node) {
                                MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
-                                                                                       "layerInterp_mdeformvert tmp_dw");
+                                                                   "layerInterp_mdeformvert tmp_dw");
                                tmp_dw->def_nr = dw->def_nr;
                                tmp_dw->weight = dw->weight * interp_weight;
                                BLI_linklist_prepend(&dest_dw, tmp_dw);
@@ -248,7 +248,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
 
        if (totweight) {
                dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
-                                                               "layerInterp_mdeformvert dvert->dw");
+                                       "layerInterp_mdeformvert dvert->dw");
                dvert->totweight = totweight;
 
                for (i = 0, node = dest_dw; node; node = node->next, ++i)
@@ -262,7 +262,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
 
 
 static void layerInterp_msticky(void **sources, float *weights,
-                                                               float *UNUSED(sub_weights), int count, void *dest)
+                                float *UNUSED(sub_weights), int count, void *dest)
 {
        float co[2], w;
        MSticky *mst;
@@ -271,20 +271,20 @@ static void layerInterp_msticky(void **sources, float *weights,
        co[0] = co[1] = 0.0f;
        for (i = 0; i < count; i++) {
                w = weights ? weights[i] : 1.0f;
-               mst = (MSticky*)sources[i];
+               mst = (MSticky *)sources[i];
 
                madd_v2_v2fl(co, mst->co, w);
        }
 
-       mst = (MSticky*)dest;
+       mst = (MSticky *)dest;
        copy_v2_v2(mst->co, co);
 }
 
 
 static void layerCopy_tface(const void *source, void *dest, int count)
 {
-       const MTFace *source_tf = (const MTFace*)source;
-       MTFace *dest_tf = (MTFace*)dest;
+       const MTFace *source_tf = (const MTFace *)source;
+       MTFace *dest_tf = (MTFace *)dest;
        int i;
 
        for (i = 0; i < count; ++i)
@@ -292,7 +292,7 @@ static void layerCopy_tface(const void *source, void *dest, int count)
 }
 
 static void layerInterp_tface(void **sources, float *weights,
-                                                         float *sub_weights, int count, void *dest)
+                              float *sub_weights, int count, void *dest)
 {
        MTFace *tf = dest;
        int i, j, k;
@@ -326,10 +326,8 @@ static void layerSwap_tface(void *data, const int *corner_indices)
 {
        MTFace *tf = data;
        float uv[4][2];
-       static const short pin_flags[4] =
-               { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 };
-       static const char sel_flags[4] =
-               { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 };
+       static const short pin_flags[4] = { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 };
+       static const char sel_flags[4] = { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 };
        short unwrap = tf->unwrap & ~(TF_PIN1 | TF_PIN2 | TF_PIN3 | TF_PIN4);
        char flag = tf->flag & ~(TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4);
        int j;
@@ -358,8 +356,8 @@ static void layerSwap_tface(void *data, const int *corner_indices)
 static void layerDefault_tface(void *data, int count)
 {
        static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL,
-                                                          0, 0, TF_DYNAMIC|TF_CONVERTED, 0, 0};
-       MTFace *tf = (MTFace*)data;
+                                       0, 0, TF_DYNAMIC | TF_CONVERTED, 0, 0};
+       MTFace *tf = (MTFace *)data;
        int i;
 
        for (i = 0; i < count; i++)
@@ -367,27 +365,27 @@ static void layerDefault_tface(void *data, int count)
 }
 
 static void layerCopy_propFloat(const void *source, void *dest,
-                                                                 int count)
+                                int count)
 {
-       memcpy(dest, source, sizeof(MFloatProperty)*count);
+       memcpy(dest, source, sizeof(MFloatProperty) * count);
 }
 
 static void layerCopy_propInt(const void *source, void *dest,
-                                                                 int count)
+                              int count)
 {
-       memcpy(dest, source, sizeof(MIntProperty)*count);
+       memcpy(dest, source, sizeof(MIntProperty) * count);
 }
 
 static void layerCopy_propString(const void *source, void *dest,
-                                                                 int count)
+                                 int count)
 {
-       memcpy(dest, source, sizeof(MStringProperty)*count);
+       memcpy(dest, source, sizeof(MStringProperty) * count);
 }
 
 static void layerCopy_origspace_face(const void *source, void *dest, int count)
 {
-       const OrigSpaceFace *source_tf = (const OrigSpaceFace*)source;
-       OrigSpaceFace *dest_tf = (OrigSpaceFace*)dest;
+       const OrigSpaceFace *source_tf = (const OrigSpaceFace *)source;
+       OrigSpaceFace *dest_tf = (OrigSpaceFace *)dest;
        int i;
 
        for (i = 0; i < count; ++i)
@@ -395,7 +393,7 @@ static void layerCopy_origspace_face(const void *source, void *dest, int count)
 }
 
 static void layerInterp_origspace_face(void **sources, float *weights,
-                                                         float *sub_weights, int count, void *dest)
+                                       float *sub_weights, int count, void *dest)
 {
        OrigSpaceFace *osf = dest;
        int i, j, k;
@@ -442,7 +440,7 @@ static void layerSwap_origspace_face(void *data, const int *corner_indices)
 static void layerDefault_origspace_face(void *data, int count)
 {
        static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
-       OrigSpaceFace *osf = (OrigSpaceFace*)data;
+       OrigSpaceFace *osf = (OrigSpaceFace *)data;
        int i;
 
        for (i = 0; i < count; i++)
@@ -456,27 +454,27 @@ static void layerSwap_mdisps(void *data, const int *ci)
        int corners, cornersize, S;
 
        if (s->disps) {
-               int nverts= (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
-               corners= multires_mdisp_corners(s);
-               cornersize= s->totdisp/corners;
+               int nverts = (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
+               corners = multires_mdisp_corners(s);
+               cornersize = s->totdisp / corners;
 
-               if (corners!=nverts) {
+               if (corners != nverts) {
                        /* happens when face changed vertex count in edit mode
                         * if it happened, just forgot displacement */
 
                        MEM_freeN(s->disps);
-                       s->totdisp= (s->totdisp/corners)*nverts;
-                       s->disps= MEM_callocN(s->totdisp*sizeof(float)*3, "mdisp swap");
+                       s->totdisp = (s->totdisp / corners) * nverts;
+                       s->disps = MEM_callocN(s->totdisp * sizeof(float) * 3, "mdisp swap");
                        return;
                }
 
-               d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
+               d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
 
                for (S = 0; S < corners; S++)
-                       memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
+                       memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
                
                MEM_freeN(s->disps);
-               s->disps= d;
+               s->disps = d;
        }
 }
 
@@ -527,9 +525,9 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
 
        for (i = 0; i < count; ++i) {
                if (!d[i].disps)
-                       d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read");
+                       d[i].disps = MEM_callocN(sizeof(float) * 3 * d[i].totdisp, "mdisps read");
 
-               if (!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
+               if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
                        printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
                        return 0;
                }
@@ -544,7 +542,7 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count)
        int i;
 
        for (i = 0; i < count; ++i) {
-               if (!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
+               if (!cdf_write_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
                        printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp);
                        return 0;
                }
@@ -560,7 +558,7 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count
        int i;
 
        for (i = 0; i < count; ++i)
-               size += d[i].totdisp*3*sizeof(float);
+               size += d[i].totdisp * 3 * sizeof(float);
 
        return size;
 }
@@ -571,8 +569,8 @@ static void layerCopy_grid_paint_mask(const void *source, void *dest, int count)
        const GridPaintMask *s = source;
        GridPaintMask *d = dest;
 
-       for(i = 0; i < count; ++i) {
-               if(s[i].data) {
+       for (i = 0; i < count; ++i) {
+               if (s[i].data) {
                        d[i].data = MEM_dupallocN(s[i].data);
                        d[i].level = s[i].level;
                }
@@ -589,8 +587,8 @@ static void layerFree_grid_paint_mask(void *data, int count, int UNUSED(size))
        int i;
        GridPaintMask *gpm = data;
 
-       for(i = 0; i < count; ++i) {
-               if(gpm[i].data)
+       for (i = 0; i < count; ++i) {
+               if (gpm[i].data)
                        MEM_freeN(gpm[i].data);
                gpm[i].data = NULL;
                gpm[i].level = 0;
@@ -675,7 +673,7 @@ static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
 static void layerDefault_mloopcol(void *data, int count)
 {
        MLoopCol default_mloopcol = {255, 255, 255, 255};
-       MLoopCol *mlcol = (MLoopCol*)data;
+       MLoopCol *mlcol = (MLoopCol *)data;
        int i;
        for (i = 0; i < count; i++)
                mlcol[i] = default_mloopcol;
@@ -683,7 +681,7 @@ static void layerDefault_mloopcol(void *data, int count)
 }
 
 static void layerInterp_mloopcol(void **sources, float *weights,
-                               float *sub_weights, int count, void *dest)
+                                 float *sub_weights, int count, void *dest)
 {
        MLoopCol *mc = dest;
        int i;
@@ -774,7 +772,7 @@ static void layerInterp_mloopuv(void **sources, float *weights,
                                 float *sub_weights, int count, void *dest)
 {
        MLoopUV *mluv = dest;
-       float *uv= mluv->uv;
+       float *uv = mluv->uv;
        int i;
 
        zero_v2(uv);
@@ -841,10 +839,10 @@ static void layerAdd_mloop_origspace(void *data1, void *data2)
 }
 
 static void layerInterp_mloop_origspace(void **sources, float *weights,
-                                float *sub_weights, int count, void *dest)
+                                        float *sub_weights, int count, void *dest)
 {
        OrigSpaceLoop *mluv = dest;
-       float *uv= mluv->uv;
+       float *uv = mluv->uv;
        int i;
 
        zero_v2(uv);
@@ -869,7 +867,7 @@ static void layerInterp_mloop_origspace(void **sources, float *weights,
 /* --- end copy */
 
 static void layerInterp_mcol(void **sources, float *weights,
-                                                        float *sub_weights, int count, void *dest)
+                             float *sub_weights, int count, void *dest)
 {
        MCol *mc = dest;
        int i, j, k;
@@ -892,7 +890,7 @@ static void layerInterp_mcol(void **sources, float *weights,
                        if (sub_weights) {
                                MCol *src = sources[i];
                                for (k = 0; k < 4; ++k, ++sub_weight, ++src) {
-                                       const float w= (*sub_weight) * weight;
+                                       const float w = (*sub_weight) * weight;
                                        col[j].a += src->a * w;
                                        col[j].r += src->r * w;
                                        col[j].g += src->g * w;
@@ -940,10 +938,10 @@ static void layerSwap_mcol(void *data, const int *corner_indices)
 static void layerDefault_mcol(void *data, int count)
 {
        static MCol default_mcol = {255, 255, 255, 255};
-       MCol *mcol = (MCol*)data;
+       MCol *mcol = (MCol *)data;
        int i;
 
-       for (i = 0; i < 4*count; i++) {
+       for (i = 0; i < 4 * count; i++) {
                mcol[i] = default_mcol;
        }
 }
@@ -1012,13 +1010,13 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
         layerInterp_tface, layerSwap_tface, layerDefault_tface},
        /* 6: CD_MCOL */
        /* 4 MCol structs per face */
-       {sizeof(MCol)*4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
+       {sizeof(MCol) * 4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
        /* 7: CD_ORIGINDEX */
        {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 8: CD_NORMAL */
        /* 3 floats per normal vector */
-       {sizeof(float)*3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 9: CD_POLYINDEX */
        {sizeof(int), "MIntProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 10: CD_PROP_FLT */
@@ -1031,10 +1029,10 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL,
         layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
        /* 14: CD_ORCO */
-       {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 15: CD_MTEXPOLY */
        /* note, when we expose the UV Map / TexFace split to the user, change this back to face Texture */
-       {sizeof(MTexPoly), "MTexPoly", 1, "UVMap"/* "Face Texture" */, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(MTexPoly), "MTexPoly", 1, "UVMap" /* "Face Texture" */, NULL, NULL, NULL, NULL, NULL},
        /* 16: CD_MLOOPUV */
        {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL,
         layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv, 
@@ -1044,23 +1042,23 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
         layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol, 
         layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
        /* 18: CD_TANGENT */
-       {sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(float) * 4 * 4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 19: CD_MDISPS */
        {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
         layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
         NULL, NULL, NULL, NULL, NULL, NULL, 
         layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
        /* 20: CD_PREVIEW_MCOL */
-       {sizeof(MCol)*4, "MCol", 4, "PreviewCol", NULL, NULL, layerInterp_mcol,
+       {sizeof(MCol) * 4, "MCol", 4, "PreviewCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
        /* 21: CD_ID_MCOL */
-       {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
+       {sizeof(MCol) * 4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
        /* 22: CD_TEXTURE_MCOL */
-       {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
+       {sizeof(MCol) * 4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
         layerSwap_mcol, layerDefault_mcol},
        /* 23: CD_CLOTH_ORCO */
-       {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       {sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 24: CD_RECAST */
        {sizeof(MRecast), "MRecast", 1, "Recast", NULL, NULL, NULL, NULL},
 
@@ -1072,7 +1070,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        /* 27: CD_SHAPE_KEYINDEX */
        {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 28: CD_SHAPEKEY */
-       {sizeof(float)*3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey},
+       {sizeof(float) * 3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey},
        /* 29: CD_BWEIGHT */
        {sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight},
        /* 30: CD_CREASE */
@@ -1105,7 +1103,7 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
        /*   5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
        /* 10-14 */ "CDMFloatProperty", "CDMIntProperty", "CDMStringProperty", "CDOrigSpace", "CDOrco",
        /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
-       /* 20-24 */"CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast",
+       /* 20-24 */ "CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast",
 
 /* BMESH ONLY */
        /* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight",
@@ -1118,35 +1116,36 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
 
 
 const CustomDataMask CD_MASK_BAREMESH =
-       CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MLOOP | CD_MASK_MPOLY | CD_MASK_BWEIGHT;
+    CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MLOOP | CD_MASK_MPOLY | CD_MASK_BWEIGHT;
 const CustomDataMask CD_MASK_MESH =
-       CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
-       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL |
-       CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
-       CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP |
-       CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
-       CD_MASK_GRID_PAINT_MASK;
+    CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
+    CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL |
+    CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
+    CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP |
+    CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
+    CD_MASK_GRID_PAINT_MASK;
 const CustomDataMask CD_MASK_EDITMESH =
-       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV |
-       CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX |
-       CD_MASK_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
-       CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
-       CD_MASK_GRID_PAINT_MASK;
+    CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV |
+    CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX |
+    CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
+    CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
+    CD_MASK_GRID_PAINT_MASK;
 const CustomDataMask CD_MASK_DERIVEDMESH =
-       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
-       CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO |
-       CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_PREVIEW_MLOOPCOL |
-       CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
-       CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
-       CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX;
-const CustomDataMask CD_MASK_BMESH = CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
-       CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | 
-       CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
-       CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
-       CD_MASK_GRID_PAINT_MASK;
+    CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
+    CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO |
+    CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_PREVIEW_MLOOPCOL |
+    CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
+    CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
+    CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX;
+const CustomDataMask CD_MASK_BMESH =
+    CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
+    CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
+    CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
+    CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
+    CD_MASK_GRID_PAINT_MASK;
 const CustomDataMask CD_MASK_FACECORNERS =
-       CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
-       CD_MASK_MLOOPCOL;
+    CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
+    CD_MASK_MLOOPCOL;
 
 static const LayerTypeInfo *layerType_getInfo(int type)
 {
@@ -1166,7 +1165,7 @@ static const char *layerType_getName(int type)
 static void customData_update_offsets(CustomData *data);
 
 static CustomDataLayer *customData_add_layer__internal(CustomData *data,
-       int type, int alloctype, void *layerdata, int totelem, const char *name);
+                                                       int type, int alloctype, void *layerdata, int totelem, const char *name);
 
 void CustomData_update_typemap(CustomData *data)
 {
@@ -1175,11 +1174,11 @@ void CustomData_update_typemap(CustomData *data)
        /* since we cant do in a pre-processor do here as an assert */
        BLI_assert(sizeof(data->typemap) / sizeof(int) >= CD_NUMTYPES);
 
-       for (i=0; i<CD_NUMTYPES; i++) {
+       for (i = 0; i < CD_NUMTYPES; i++) {
                data->typemap[i] = -1;
        }
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                if (data->layers[i].type != lasttype) {
                        data->typemap[data->layers[i].type] = i;
                }
@@ -1188,7 +1187,7 @@ void CustomData_update_typemap(CustomData *data)
 }
 
 void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
-                                         CustomDataMask mask, int alloctype, int totelem)
+                      CustomDataMask mask, int alloctype, int totelem)
 {
        /*const LayerTypeInfo *typeInfo;*/
        CustomDataLayer *layer, *newlayer;
@@ -1230,10 +1229,10 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
 
                if ((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE))
                        newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE,
-                               data, totelem, layer->name);
+                                                                 data, totelem, layer->name);
                else
                        newlayer = customData_add_layer__internal(dest, type, alloctype,
-                               data, totelem, layer->name);
+                                                                 data, totelem, layer->name);
                
                if (newlayer) {
                        newlayer->uid = layer->uid;
@@ -1242,7 +1241,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
                        newlayer->active_rnd = lastrender;
                        newlayer->active_clone = lastclone;
                        newlayer->active_mask = lastmask;
-                       newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY);
+                       newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
                }
        }
 
@@ -1250,12 +1249,12 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
 }
 
 void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
-                                        CustomDataMask mask, int alloctype, int totelem)
+                     CustomDataMask mask, int alloctype, int totelem)
 {
        memset(dest, 0, sizeof(*dest));
 
        if (source->external)
-               dest->external= MEM_dupallocN(source->external);
+               dest->external = MEM_dupallocN(source->external);
 
        CustomData_merge(source, dest, mask, alloctype, totelem);
 }
@@ -1279,7 +1278,7 @@ static void CustomData_external_free(CustomData *data)
 {
        if (data->external) {
                MEM_freeN(data->external);
-               data->external= NULL;
+               data->external = NULL;
        }
 }
 
@@ -1318,7 +1317,7 @@ int CustomData_get_layer_index(const CustomData *data, int type)
 {
        int i; 
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return i;
 
@@ -1340,8 +1339,8 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
-               if (data->layers[i].type == type && strcmp(data->layers[i].name, name)==0)
+       for (i = 0; i < data->totlayer; ++i)
+               if (data->layers[i].type == type && strcmp(data->layers[i].name, name) == 0)
                        return i;
 
        return -1;
@@ -1363,7 +1362,7 @@ int CustomData_get_render_layer_index(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return i + data->layers[i].active_rnd;
 
@@ -1374,7 +1373,7 @@ int CustomData_get_clone_layer_index(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return i + data->layers[i].active_clone;
 
@@ -1385,7 +1384,7 @@ int CustomData_get_stencil_layer_index(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return i + data->layers[i].active_mask;
 
@@ -1396,7 +1395,7 @@ int CustomData_get_active_layer(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return data->layers[i].active;
 
@@ -1407,7 +1406,7 @@ int CustomData_get_render_layer(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return data->layers[i].active_rnd;
 
@@ -1418,7 +1417,7 @@ int CustomData_get_clone_layer(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return data->layers[i].active_clone;
 
@@ -1429,7 +1428,7 @@ int CustomData_get_stencil_layer(const CustomData *data, int type)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        return data->layers[i].active_mask;
 
@@ -1440,7 +1439,7 @@ void CustomData_set_layer_active(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        data->layers[i].active = n;
 }
@@ -1449,7 +1448,7 @@ void CustomData_set_layer_render(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        data->layers[i].active_rnd = n;
 }
@@ -1458,7 +1457,7 @@ void CustomData_set_layer_clone(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        data->layers[i].active_clone = n;
 }
@@ -1467,7 +1466,7 @@ void CustomData_set_layer_stencil(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        data->layers[i].active_mask = n;
 }
@@ -1477,51 +1476,51 @@ void CustomData_set_layer_active_index(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
-                       data->layers[i].active = n-i;
+                       data->layers[i].active = n - i;
 }
 
 void CustomData_set_layer_render_index(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
-                       data->layers[i].active_rnd = n-i;
+                       data->layers[i].active_rnd = n - i;
 }
 
 void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
-                       data->layers[i].active_clone = n-i;
+                       data->layers[i].active_clone = n - i;
 }
 
 void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
-                       data->layers[i].active_mask = n-i;
+                       data->layers[i].active_mask = n - i;
 }
 
 void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
 {
        int i;
 
-       for (i=0; i < data->totlayer; ++i)
+       for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
                        data->layers[i].flag |= flag;
 }
 
 static int customData_resize(CustomData *data, int amount)
 {
-       CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp)*(data->maxlayer + amount),
-                                                                          "CustomData->layers");
+       CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp) * (data->maxlayer + amount),
+                                          "CustomData->layers");
        if (!tmp) return 0;
 
        data->maxlayer += amount;
@@ -1535,9 +1534,9 @@ static int customData_resize(CustomData *data, int amount)
 }
 
 static CustomDataLayer *customData_add_layer__internal(CustomData *data,
-       int type, int alloctype, void *layerdata, int totelem, const char *name)
+                                                       int type, int alloctype, void *layerdata, int totelem, const char *name)
 {
-       const LayerTypeInfo *typeInfo= layerType_getInfo(type);
+       const LayerTypeInfo *typeInfo = layerType_getInfo(type);
        int size = typeInfo->size * totelem, flag = 0, index = data->totlayer;
        void *newlayerdata = NULL;
 
@@ -1568,7 +1567,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
        }
        else if (alloctype == CD_DEFAULT) {
                if (typeInfo->set_default)
-                       typeInfo->set_default((char*)newlayerdata, totelem);
+                       typeInfo->set_default((char *)newlayerdata, totelem);
        }
        else if (alloctype == CD_REFERENCE)
                flag |= CD_FLAG_NOFREE;
@@ -1584,25 +1583,25 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
        data->totlayer++;
 
        /* keep layers ordered by type */
-       for ( ; index > 0 && data->layers[index - 1].type > type; --index)
+       for (; index > 0 && data->layers[index - 1].type > type; --index)
                data->layers[index] = data->layers[index - 1];
 
        data->layers[index].type = type;
        data->layers[index].flag = flag;
        data->layers[index].data = newlayerdata;
 
-       if (name || (name=typeInfo->defaultname)) {
+       if (name || (name = typeInfo->defaultname)) {
                BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
                CustomData_set_layer_unique_name(data, index);
        }
        else
                data->layers[index].name[0] = '\0';
 
-       if (index > 0 && data->layers[index-1].type == type) {
-               data->layers[index].active = data->layers[index-1].active;
-               data->layers[index].active_rnd = data->layers[index-1].active_rnd;
-               data->layers[index].active_clone = data->layers[index-1].active_clone;
-               data->layers[index].active_mask = data->layers[index-1].active_mask;
+       if (index > 0 && data->layers[index - 1].type == type) {
+               data->layers[index].active = data->layers[index - 1].active;
+               data->layers[index].active_rnd = data->layers[index - 1].active_rnd;
+               data->layers[index].active_clone = data->layers[index - 1].active_clone;
+               data->layers[index].active_mask = data->layers[index - 1].active_mask;
        }
        else {
                data->layers[index].active = 0;
@@ -1617,13 +1616,13 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
 }
 
 void *CustomData_add_layer(CustomData *data, int type, int alloctype,
-                                                  void *layerdata, int totelem)
+                           void *layerdata, int totelem)
 {
        CustomDataLayer *layer;
-       const LayerTypeInfo *typeInfo= layerType_getInfo(type);
+       const LayerTypeInfo *typeInfo = layerType_getInfo(type);
        
        layer = customData_add_layer__internal(data, type, alloctype, layerdata,
-                                                                                  totelem, typeInfo->defaultname);
+                                              totelem, typeInfo->defaultname);
        CustomData_update_typemap(data);
 
        if (layer)
@@ -1634,12 +1633,12 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype,
 
 /*same as above but accepts a name*/
 void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
-                                                  void *layerdata, int totelem, const char *name)
+                                 void *layerdata, int totelem, const char *name)
 {
        CustomDataLayer *layer;
        
        layer = customData_add_layer__internal(data, type, alloctype, layerdata,
-                                                                                  totelem, name);
+                                              totelem, name);
        CustomData_update_typemap(data);
 
        if (layer)
@@ -1657,8 +1656,8 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
 
        customData_free_layer__internal(&data->layers[index], totelem);
 
-       for (i=index+1; i < data->totlayer; ++i)
-               data->layers[i-1] = data->layers[i];
+       for (i = index + 1; i < data->totlayer; ++i)
+               data->layers[i - 1] = data->layers[i];
 
        data->totlayer--;
 
@@ -1675,7 +1674,7 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
                        }
        }
 
-       if (data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
+       if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
                customData_resize(data, -CUSTOMDATA_GROW);
 
        customData_update_offsets(data);
@@ -1748,7 +1747,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int t
 }
 
 void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
-                                                                                                 const int type, const char *name, const int totelem)
+                                                  const int type, const char *name, const int totelem)
 {
        CustomDataLayer *layer;
        int layer_index;
@@ -1813,7 +1812,7 @@ void CustomData_free_temporary(CustomData *data, int totelem)
 
        data->totlayer = j;
 
-       if (data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
+       if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
                customData_resize(data, -CUSTOMDATA_GROW);
 
        customData_update_offsets(data);
@@ -1836,11 +1835,11 @@ void CustomData_copy_elements(int type, void *source, void *dest, int count)
        if (typeInfo->copy)
                typeInfo->copy(source, dest, count);
        else
-               memcpy(dest, source, typeInfo->size*count);
+               memcpy(dest, source, typeInfo->size * count);
 }
 
 void CustomData_copy_data(const CustomData *source, CustomData *dest,
-                                                 int source_index, int dest_index, int count)
+                          int source_index, int dest_index, int count)
 {
        const LayerTypeInfo *typeInfo;
        int src_i, dest_i;
@@ -1882,12 +1881,12 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
                        
                        if (typeInfo->copy)
                                typeInfo->copy(src_data + src_offset,
-                                                               dest_data + dest_offset,
-                                                               count);
+                                              dest_data + dest_offset,
+                                              count);
                        else
                                memcpy(dest_data + dest_offset,
-                                          src_data + src_offset,
-                                          count * typeInfo->size);
+                                      src_data + src_offset,
+                                      count * typeInfo->size);
 
                        /* if there are multiple source & dest layers of the same type,
                         * we don't want to copy all source layers to the same dest, so
@@ -1911,7 +1910,7 @@ void CustomData_free_elem(CustomData *data, int index, int count)
                                int offset = typeInfo->size * index;
 
                                typeInfo->free((char *)data->layers[i].data + offset,
-                                                          count, typeInfo->size);
+                                              count, typeInfo->size);
                        }
                }
        }
@@ -1920,8 +1919,8 @@ void CustomData_free_elem(CustomData *data, int index, int count)
 #define SOURCE_BUF_SIZE 100
 
 void CustomData_interp(const CustomData *source, CustomData *dest,
-                                          int *src_indices, float *weights, float *sub_weights,
-                                          int count, int dest_index)
+                       int *src_indices, float *weights, float *sub_weights,
+                       int count, int dest_index)
 {
        int src_i, dest_i;
        int dest_offset;
@@ -1934,12 +1933,12 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
         */
        if (count > SOURCE_BUF_SIZE)
                sources = MEM_callocN(sizeof(*sources) * count,
-                                                         "CustomData_interp sources");
+                                     "CustomData_interp sources");
 
        /* interpolates a layer at a time */
        dest_i = 0;
        for (src_i = 0; src_i < source->totlayer; ++src_i) {
-               const LayerTypeInfo *typeInfo= layerType_getInfo(source->layers[src_i].type);
+               const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
                if (!typeInfo->interp) continue;
 
                /* find the first dest layer with type >= the source type
@@ -1962,7 +1961,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
                        dest_offset = dest_index * typeInfo->size;
 
                        typeInfo->interp(sources, weights, sub_weights, count,
-                                                  (char *)dest->layers[dest_i].data + dest_offset);
+                                        (char *)dest->layers[dest_i].data + dest_offset);
 
                        /* if there are multiple source & dest layers of the same type,
                         * we don't want to copy all source layers to the same dest, so
@@ -2016,7 +2015,7 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
        if (layer_index < 0) return NULL;
 
        offset = layerType_getInfo(type)->size * index;
-       return (char *)data->layers[layer_index+n].data + offset;
+       return (char *)data->layers[layer_index + n].data + offset;
 }
 
 void *CustomData_get_layer(const CustomData *data, int type)
@@ -2038,7 +2037,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n)
 }
 
 void *CustomData_get_layer_named(const struct CustomData *data, int type,
-                                                                const char *name)
+                                 const char *name)
 {
        int layer_index = CustomData_get_named_layer_index(data, type, name);
        if (layer_index < 0) return NULL;
@@ -2102,7 +2101,7 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
                              int totloop, int totpoly)
 {
        int i;
-       for (i=0; i < fdata->totlayer; i++) {
+       for (i = 0; i < fdata->totlayer; i++) {
                if (fdata->layers[i].type == CD_MTFACE) {
                        CustomData_add_layer_named(pdata, CD_MTEXPOLY, CD_CALLOC, NULL, totpoly, fdata->layers[i].name);
                        CustomData_add_layer_named(ldata, CD_MLOOPUV, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
@@ -2119,12 +2118,12 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
 void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
 {
        int i;
-       for (i=0; i < pdata->totlayer; i++) {
+       for (i = 0; i < pdata->totlayer; i++) {
                if (pdata->layers[i].type == CD_MTEXPOLY) {
                        CustomData_add_layer_named(fdata, CD_MTFACE, CD_CALLOC, NULL, total, pdata->layers[i].name);
                }
        }
-       for (i=0; i < ldata->totlayer; i++) {
+       for (i = 0; i < ldata->totlayer; i++) {
                if (ldata->layers[i].type == CD_MLOOPCOL) {
                        CustomData_add_layer_named(fdata, CD_MCOL, CD_CALLOC, NULL, total, ldata->layers[i].name);
                }
@@ -2273,7 +2272,7 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
 
                        if (typeInfo->free) {
                                int offset = data->layers[i].offset;
-                               typeInfo->free((char*)*block + offset, 1, typeInfo->size);
+                               typeInfo->free((char *)*block + offset, 1, typeInfo->size);
                        }
                }
        }
@@ -2297,7 +2296,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block)
 }
 
 void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
-                                                       void *src_block, void **dest_block)
+                                void *src_block, void **dest_block)
 {
        const LayerTypeInfo *typeInfo;
        int dest_i, src_i;
@@ -2324,9 +2323,9 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
 
                /* if we found a matching layer, copy the data */
                if (dest->layers[dest_i].type == source->layers[src_i].type &&
-                       strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
-                       char *src_data = (char*)src_block + source->layers[src_i].offset;
-                       char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
+                   strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
+                       char *src_data = (char *)src_block + source->layers[src_i].offset;
+                       char *dest_data = (char *)*dest_block + dest->layers[dest_i].offset;
 
                        typeInfo = layerType_getInfo(source->layers[src_i].type);
 
@@ -2364,7 +2363,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
        layer_index = CustomData_get_layer_index(data, type);
        if (layer_index < 0) return NULL;
 
-       return (char *)block + data->layers[layer_index+n].offset;
+       return (char *)block + data->layers[layer_index + n].offset;
 }
 
 /*gets from the layer at physical index n, note: doesn't check type.*/
@@ -2486,7 +2485,7 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *so
 }
 
 void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights,
-                                                 float *sub_weights, int count, void *dest_block)
+                             float *sub_weights, int count, void *dest_block)
 {
        int i, j;
        void *source_buf[SOURCE_BUF_SIZE];
@@ -2497,7 +2496,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
         */
        if (count > SOURCE_BUF_SIZE)
                sources = MEM_callocN(sizeof(*sources) * count,
-                                                         "CustomData_interp sources");
+                                     "CustomData_interp sources");
 
        /* interpolates a layer at a time */
        for (i = 0; i < data->totlayer; ++i) {
@@ -2508,7 +2507,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
                                sources[j] = (char *)src_blocks[j] + layer->offset;
 
                        typeInfo->interp(sources, weights, sub_weights, count,
-                                                         (char *)dest_block + layer->offset);
+                                        (char *)dest_block + layer->offset);
                }
        }
 
@@ -2529,13 +2528,13 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
                typeInfo = layerType_getInfo(data->layers[i].type);
 
                if (typeInfo->set_default)
-                       typeInfo->set_default((char*)*block + offset, 1);
-               else memset((char*)*block + offset, 0, typeInfo->size);
+                       typeInfo->set_default((char *)*block + offset, 1);
+               else memset((char *)*block + offset, 0, typeInfo->size);
        }
 }
 
 void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
-                                                       int src_index, void **dest_block)
+                               int src_index, void **dest_block)
 {
        const LayerTypeInfo *typeInfo;
        int dest_i, src_i, src_offset;
@@ -2561,7 +2560,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
                if (dest->layers[dest_i].type == source->layers[src_i].type) {
                        int offset = dest->layers[dest_i].offset;
                        char *src_data = source->layers[src_i].data;
-                       char *dest_data = (char*)*dest_block + offset;
+                       char *dest_data = (char *)*dest_block + offset;
 
                        typeInfo = layerType_getInfo(dest->layers[dest_i].type);
                        src_offset = src_index * typeInfo->size;
@@ -2581,7 +2580,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
 }
 
 void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
-                                                         void *src_block, int dest_index)
+                                 void *src_block, int dest_index)
 {
        const LayerTypeInfo *typeInfo;
        int dest_i, src_i, dest_offset;
@@ -2603,7 +2602,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
                /* if we found a matching layer, copy the data */
                if (dest->layers[dest_i].type == source->layers[src_i].type) {
                        int offset = source->layers[src_i].offset;
-                       char *src_data = (char*)src_block + offset;
+                       char *src_data = (char *)src_block + offset;
                        char *dest_data = dest->layers[dest_i].data;
 
                        typeInfo = layerType_getInfo(dest->layers[dest_i].type);
@@ -2665,17 +2664,17 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int
 {
        int i;
        /* see if there is a duplicate */
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                if (i != index) {
-                       CustomDataLayer *layer= &data->layers[i];
+                       CustomDataLayer *layer = &data->layers[i];
                        
                        if (CustomData_is_property_layer(type)) {
-                               if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name)==0) {
+                               if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name) == 0) {
                                        return 1;
                                }
                        }
                        else {
-                               if (i!=index && layer->type==type && strcmp(layer->name, name)==0) {
+                               if (i != index && layer->type == type && strcmp(layer->name, name) == 0) {
                                        return 1;
                                }
                        }
@@ -2687,19 +2686,19 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int
 
 static int customdata_unique_check(void *arg, const char *name)
 {
-       struct {CustomData *data; int type; int index;} *data_arg= arg;
+       struct {CustomData *data; int type; int index; } *data_arg = arg;
        return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index);
 }
 
 void CustomData_set_layer_unique_name(CustomData *data, int index)
 {      
-       CustomDataLayer *nlayer= &data->layers[index];
-       const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type);
+       CustomDataLayer *nlayer = &data->layers[index];
+       const LayerTypeInfo *typeInfo = layerType_getInfo(nlayer->type);
 
-       struct {CustomData *data; int type; int index;} data_arg;
-       data_arg.data= data;
-       data_arg.type= nlayer->type;
-       data_arg.index= index;
+       struct {CustomData *data; int type; int index; } data_arg;
+       data_arg.data = data;
+       data_arg.type = nlayer->type;
+       data_arg.index = index;
 
        if (!typeInfo->defaultname)
                return;
@@ -2739,15 +2738,15 @@ int CustomData_verify_versions(struct CustomData *data, int index)
                typeInfo = layerType_getInfo(layer->type);
 
                if (!typeInfo->defaultname && (index > 0) &&
-                       data->layers[index-1].type == layer->type)
+                   data->layers[index - 1].type == layer->type)
                {
                        keeplayer = 0; /* multiple layers of which we only support one */
                }
        }
 
        if (!keeplayer) {
-               for (i=index+1; i < data->totlayer; ++i)
-                       data->layers[i-1] = data->layers[i];
+               for (i = index + 1; i < data->totlayer; ++i)
+                       data->layers[i - 1] = data->layers[i];
                data->totlayer--;
        }
 
@@ -2768,11 +2767,11 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
        const LayerTypeInfo *typeInfo;
        int i;
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
-               if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+               if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
                else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
                        if (typeInfo->free)
                                typeInfo->free(layer->data, totelem, typeInfo->size);
@@ -2783,7 +2782,7 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
 
 void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem)
 {
-       CustomDataExternal *external= data->external;
+       CustomDataExternal *external = data->external;
        CustomDataLayer *layer;
        CDataFile *cdf;
        CDataFileLayer *blay;
@@ -2794,14 +2793,14 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
        if (!external)
                return;
        
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
-               if (!(mask & CD_TYPE_AS_MASK(layer->type)));
-               else if (layer->flag & CD_FLAG_IN_MEMORY);
+               if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
+               else if (layer->flag & CD_FLAG_IN_MEMORY) ;
                else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read)
-                       update= 1;
+                       update = 1;
        }
 
        if (!update)
@@ -2809,24 +2808,24 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
 
        customdata_external_filename(filename, id, external);
 
-       cdf= cdf_create(CDF_TYPE_MESH);
+       cdf = cdf_create(CDF_TYPE_MESH);
        if (!cdf_read_open(cdf, filename)) {
                fprintf(stderr, "Failed to read %s layer from %s.\n", layerType_getName(layer->type), filename);
                return;
        }
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
-               if (!(mask & CD_TYPE_AS_MASK(layer->type)));
-               else if (layer->flag & CD_FLAG_IN_MEMORY);
+               if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
+               else if (layer->flag & CD_FLAG_IN_MEMORY) ;
                else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
-                       blay= cdf_layer_find(cdf, layer->type, layer->name);
+                       blay = cdf_layer_find(cdf, layer->type, layer->name);
 
                        if (blay) {
                                if (cdf_read_layer(cdf, blay)) {
-                                       if (typeInfo->read(cdf, layer->data, totelem));
+                                       if (typeInfo->read(cdf, layer->data, totelem)) ;
                                        else break;
                                        layer->flag |= CD_FLAG_IN_MEMORY;
                                }
@@ -2842,7 +2841,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
 
 void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, int totelem, int free)
 {
-       CustomDataExternal *external= data->external;
+       CustomDataExternal *external = data->external;
        CustomDataLayer *layer;
        CDataFile *cdf;
        CDataFileLayer *blay;
@@ -2854,13 +2853,13 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
                return;
 
        /* test if there is anything to write */
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
-               if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+               if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
                else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write)
-                       update= 1;
+                       update = 1;
        }
 
        if (!update)
@@ -2870,16 +2869,16 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
        CustomData_external_read(data, id, mask, totelem);
        customdata_external_filename(filename, id, external);
 
-       cdf= cdf_create(CDF_TYPE_MESH);
+       cdf = cdf_create(CDF_TYPE_MESH);
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
                if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) {
                        if (layer->flag & CD_FLAG_IN_MEMORY) {
                                cdf_layer_add(cdf, layer->type, layer->name,
-                                       typeInfo->filesize(cdf, layer->data, totelem));
+                                             typeInfo->filesize(cdf, layer->data, totelem));
                        }
                        else {
                                cdf_free(cdf);
@@ -2893,15 +2892,15 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
                return;
        }
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
                if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
-                       blay= cdf_layer_find(cdf, layer->type, layer->name);
+                       blay = cdf_layer_find(cdf, layer->type, layer->name);
 
                        if (cdf_write_layer(cdf, blay)) {
-                               if (typeInfo->write(cdf, layer->data, totelem));
+                               if (typeInfo->write(cdf, layer->data, totelem)) ;
                                else break;
                        }
                        else
@@ -2915,7 +2914,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
                return;
        }
 
-       for (i=0; i<data->totlayer; i++) {
+       for (i = 0; i < data->totlayer; i++) {
                layer = &data->layers[i];
                typeInfo = layerType_getInfo(layer->type);
 
@@ -2934,7 +2933,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
 
 void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNUSED(totelem), const char *filename)
 {
-       CustomDataExternal *external= data->external;
+       CustomDataExternal *external = data->external;
        CustomDataLayer *layer;
        int layer_index;
 
@@ -2947,17 +2946,17 @@ void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNU
                return;
 
        if (!external) {
-               external= MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
-               data->external= external;
+               external = MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
+               data->external = external;
        }
        BLI_strncpy(external->filename, filename, sizeof(external->filename));
 
-       layer->flag |= CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY;
+       layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
 }
 
 void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
 {
-       CustomDataExternal *external= data->external;
+       CustomDataExternal *external = data->external;
        CustomDataLayer *layer;
        //char filename[FILE_MAX];
        int layer_index; // i, remove_file;
@@ -2977,10 +2976,10 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
                layer->flag &= ~CD_FLAG_EXTERNAL;
 
 #if 0
-               remove_file= 1;
-               for (i=0; i<data->totlayer; i++)
+               remove_file = 1;
+               for (i = 0; i < data->totlayer; i++)
                        if (data->layers[i].flag & CD_FLAG_EXTERNAL)
-                               remove_file= 0;
+                               remove_file = 0;
 
                if (remove_file) {
                        customdata_external_filename(filename, id, external);
@@ -3006,7 +3005,7 @@ int CustomData_external_test(CustomData *data, int type)
 #if 0
 void CustomData_external_remove_object(CustomData *data, ID *id)
 {
-       CustomDataExternal *external= data->external;
+       CustomDataExternal *external = data->external;
        char filename[FILE_MAX];
 
        if (!external)
index 6d0dabe..71801c4 100644 (file)
 
 /************************* File Format Definitions ***************************/
 
-#define CDF_ENDIAN_LITTLE      0
-#define CDF_ENDIAN_BIG         1
+#define CDF_ENDIAN_LITTLE   0
+#define CDF_ENDIAN_BIG      1
 
-#define CDF_DATA_FLOAT 0
+#define CDF_DATA_FLOAT  0
 
 typedef struct CDataFileHeader {
-       char ID[4];                                     /* "BCDF" */
-       char endian;                            /* little, big */
-       char version;                           /* non-compatible versions */
-       char subversion;                        /* compatible sub versions */
-       char pad;                                       /* padding */
-
-       int structbytes;                        /* size of this struct in bytes */
-       int type;                                       /* image, mesh */
-       int totlayer;                           /* number of layers in the file */
+       char ID[4];                 /* "BCDF" */
+       char endian;                /* little, big */
+       char version;               /* non-compatible versions */
+       char subversion;            /* compatible sub versions */
+       char pad;                   /* padding */
+
+       int structbytes;            /* size of this struct in bytes */
+       int type;                   /* image, mesh */
+       int totlayer;               /* number of layers in the file */
 } CDataFileHeader;
 
 typedef struct CDataFileImageHeader {
-       int structbytes;                        /* size of this struct in bytes */
-       int width;                                      /* image width */
-       int height;                                     /* image height */
-       int tile_size;                          /* tile size (required power of 2) */
+       int structbytes;            /* size of this struct in bytes */
+       int width;                  /* image width */
+       int height;                 /* image height */
+       int tile_size;              /* tile size (required power of 2) */
 } CDataFileImageHeader;
 
 typedef struct CDataFileMeshHeader {
-       int structbytes;                        /* size of this struct in bytes */
+       int structbytes;            /* size of this struct in bytes */
 } CDataFileMeshHeader;
 
 struct CDataFileLayer {
-       int structbytes;                                /* size of this struct in bytes */
-       int datatype;                                   /* only float for now */
-       uint64_t datasize;                              /* size of data in layer */
-       int type;                                               /* layer type */
-       char name[CDF_LAYER_NAME_MAX];  /* layer name */
+       int structbytes;                /* size of this struct in bytes */
+       int datatype;                   /* only float for now */
+       uint64_t datasize;              /* size of data in layer */
+       int type;                       /* layer type */
+       char name[CDF_LAYER_NAME_MAX];  /* layer name */
 };
 
 /**************************** Other Definitions ******************************/
 
-#define CDF_VERSION                    0
-#define CDF_SUBVERSION         0
-#define CDF_TILE_SIZE          64
+#define CDF_VERSION         0
+#define CDF_SUBVERSION      0
+#define CDF_TILE_SIZE       64
 
 struct CDataFile {
        int type;
@@ -121,9 +121,9 @@ static int cdf_data_type_size(int datatype)
 
 CDataFile *cdf_create(int type)
 {
-       CDataFile *cdf= MEM_callocN(sizeof(CDataFile), "CDataFile");
+       CDataFile *cdf = MEM_callocN(sizeof(CDataFile), "CDataFile");
 
-       cdf->type= type;
+       cdf->type = type;
 
        return cdf;
 }
@@ -147,11 +147,11 @@ static int cdf_read_header(CDataFile *cdf)
        CDataFileImageHeader *image;
        CDataFileMeshHeader *mesh;
        CDataFileLayer *layer;
-       FILE *f= cdf->readf;
+       FILE *f = cdf->readf;
        size_t offset = 0;
        int a;
 
-       header= &cdf->header;
+       header = &cdf->header;
 
        if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
                return 0;
@@ -161,8 +161,8 @@ static int cdf_read_header(CDataFile *cdf)
        if (header->version > CDF_VERSION)
                return 0;
 
-       cdf->switchendian= header->endian != cdf_endian();
-       header->endian= cdf_endian();
+       cdf->switchendian = header->endian != cdf_endian();
+       header->endian = cdf_endian();
 
        if (cdf->switchendian) {
                SWITCH_INT(header->type);
@@ -174,13 +174,13 @@ static int cdf_read_header(CDataFile *cdf)
                return 0;
 
        offset += header->structbytes;
-       header->structbytes= sizeof(CDataFileHeader);
+       header->structbytes = sizeof(CDataFileHeader);
 
        if (fseek(f, offset, SEEK_SET) != 0)
                return 0;
        
        if (header->type == CDF_TYPE_IMAGE) {
-               image= &cdf->btype.image;
+               image = &cdf->btype.image;
                if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
                        return 0;
 
@@ -192,10 +192,10 @@ static int cdf_read_header(CDataFile *cdf)
                }
 
                offset += image->structbytes;
-               image->structbytes= sizeof(CDataFileImageHeader);
+               image->structbytes = sizeof(CDataFileImageHeader);
        }
        else if (header->type == CDF_TYPE_MESH) {
-               mesh= &cdf->btype.mesh;
+               mesh = &cdf->btype.mesh;
                if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
                        return 0;
 
@@ -203,17 +203,17 @@ static int cdf_read_header(CDataFile *cdf)
                        SWITCH_INT(mesh->structbytes);
 
                offset += mesh->structbytes;
-               mesh->structbytes= sizeof(CDataFileMeshHeader);
+               mesh->structbytes = sizeof(CDataFileMeshHeader);
        }
 
        if (fseek(f, offset, SEEK_SET) != 0)
                return 0;
 
-       cdf->layer= MEM_callocN(sizeof(CDataFileLayer)*header->totlayer, "CDataFileLayer");
-       cdf->totlayer= header->totlayer;
+       cdf->layer = MEM_callocN(sizeof(CDataFileLayer) * header->totlayer, "CDataFileLayer");
+       cdf->totlayer = header->totlayer;
 
-       for (a=0; a<header->totlayer; a++) {
-               layer= &cdf->layer[a];
+       for (a = 0; a < header->totlayer; a++) {
+               layer = &cdf->layer[a];
 
                if (!fread(layer, sizeof(CDataFileLayer), 1, f))
                        return 0;
@@ -229,13 +229,13 @@ static int cdf_read_header(CDataFile *cdf)
                        return 0;
 
                offset += layer->structbytes;
-               layer->structbytes= sizeof(CDataFileLayer);
+               layer->structbytes = sizeof(CDataFileLayer);
 
                if (fseek(f, offset, SEEK_SET) != 0)
                        return 0;
        }
 
-       cdf->dataoffset= offset;
+       cdf->dataoffset = offset;
 
        return 1;
 }
@@ -246,27 +246,27 @@ static int cdf_write_header(CDataFile *cdf)
        CDataFileImageHeader *image;
        CDataFileMeshHeader *mesh;
        CDataFileLayer *layer;
-       FILE *f= cdf->writef;
+       FILE *f = cdf->writef;
        int a;
 
-       header= &cdf->header;
+       header = &cdf->header;
 
        if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
                return 0;
        
        if (header->type == CDF_TYPE_IMAGE) {
-               image= &cdf->btype.image;
+               image = &cdf->btype.image;
                if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
                        return 0;
        }
        else if (header->type == CDF_TYPE_MESH) {
-               mesh= &cdf->btype.mesh;
+               mesh = &cdf->btype.mesh;
                if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
                        return 0;
        }
 
-       for (a=0; a<header->totlayer; a++) {
-               layer= &cdf->layer[a];
+       for (a = 0; a < header->totlayer; a++) {
+               layer = &cdf->layer[a];
 
                if (!fwrite(layer, sizeof(CDataFileLayer), 1, f))
                        return 0;
@@ -279,11 +279,11 @@ int cdf_read_open(CDataFile *cdf, const char *filename)
 {
        FILE *f;
 
-       f= BLI_fopen(filename, "rb");
+       f = BLI_fopen(filename, "rb");
        if (!f)
                return 0;
        
-       cdf->readf= f;
+       cdf->readf = f;
 
        if (!cdf_read_header(cdf)) {
                cdf_read_close(cdf);
@@ -304,8 +304,8 @@ int cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
        int a;
 
        /* seek to right location in file */
-       offset= cdf->dataoffset;
-       for (a=0; a<cdf->totlayer; a++) {
+       offset = cdf->dataoffset;
+       for (a = 0; a < cdf->totlayer; a++) {
                if (&cdf->layer[a] == blay)
                        break;
                else
@@ -326,9 +326,9 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
 
        /* switch endian if necessary */
        if (cdf->switchendian) {
-               fdata= data;
+               fdata = data;
 
-               for (a=0; a<size/sizeof(float); a++) {
+               for (a = 0; a < size / sizeof(float); a++) {
                        SWITCH_INT(fdata[a]);
                }
        }
@@ -340,7 +340,7 @@ void cdf_read_close(CDataFile *cdf)
 {
        if (cdf->readf) {
                fclose(cdf->readf);
-               cdf->readf= NULL;
+               cdf->readf = NULL;
        }
 }
 
@@ -351,34 +351,34 @@ int cdf_write_open(CDataFile *cdf, const char *filename)
        CDataFileMeshHeader *mesh;
        FILE *f;
 
-       f= BLI_fopen(filename, "wb");
+       f = BLI_fopen(filename, "wb");
        if (!f)
                return 0;
        
-       cdf->writef= f;
+       cdf->writef = f;
 
        /* fill header */
-       header= &cdf->header;
+       header = &cdf->header;
        /* strcpy(, "BCDF"); // terminator out of range */
-       header->ID[0]= 'B'; header->ID[1]= 'C'; header->ID[2]= 'D'; header->ID[3]= 'F';
-       header->endian= cdf_endian();
-       header->version= CDF_VERSION;
-       header->subversion= CDF_SUBVERSION;
+       header->ID[0] = 'B'; header->ID[1] = 'C'; header->ID[2] = 'D'; header->ID[3] = 'F';
+       header->endian = cdf_endian();
+       header->version = CDF_VERSION;
+       header->subversion = CDF_SUBVERSION;
 
-       header->structbytes= sizeof(CDataFileHeader);
-       header->type= cdf->type;
-       header->totlayer= cdf->totlayer;
+       header->structbytes = sizeof(CDataFileHeader);
+       header->type = cdf->type;
+       header->totlayer = cdf->totlayer;
 
        if (cdf->type == CDF_TYPE_IMAGE) {
                /* fill image header */
-               image= &cdf->btype.image;
-               image->structbytes= sizeof(CDataFileImageHeader);
-               image->tile_size= CDF_TILE_SIZE;
+               image = &cdf->btype.image;
+               image->structbytes = sizeof(CDataFileImageHeader);
+               image->tile_size = CDF_TILE_SIZE;
        }
        else if (cdf->type == CDF_TYPE_MESH) {
                /* fill mesh header */
-               mesh= &cdf->btype.mesh;
-               mesh->structbytes= sizeof(CDataFileMeshHeader);
+               mesh = &cdf->btype.mesh;
+               mesh->structbytes = sizeof(CDataFileMeshHeader);
        }
 
        cdf_write_header(cdf);
@@ -404,7 +404,7 @@ void cdf_write_close(CDataFile *cdf)
 {
        if (cdf->writef) {
                fclose(cdf->writef);
-               cdf->writef= NULL;
+               cdf->writef = NULL;
        }
 }
 
@@ -420,8 +420,8 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name)
        CDataFileLayer *layer;
        int a;
 
-       for (a=0; a<cdf->totlayer; a++) {
-               layer= &cdf->layer[a];
+       for (a = 0; a < cdf->totlayer; a++) {
+               layer = &cdf->layer[a];
 
                if (layer->type == type && strcmp(layer->name, name) == 0)
                        return layer;
@@ -435,18 +435,18 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
        CDataFileLayer *newlayer, *layer;
 
        /* expand array */
-       newlayer= MEM_callocN(sizeof(CDataFileLayer)*(cdf->totlayer+1), "CDataFileLayer");
-       memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer)*cdf->totlayer);
-       cdf->layer= newlayer;
+       newlayer = MEM_callocN(sizeof(CDataFileLayer) * (cdf->totlayer + 1), "CDataFileLayer");
+       memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer) * cdf->totlayer);
+       cdf->layer = newlayer;
 
        cdf->totlayer++;
 
        /* fill in new layer */
-       layer= &cdf->layer[cdf->totlayer-1];
-       layer->structbytes= sizeof(CDataFileLayer);
-       layer->datatype= CDF_DATA_FLOAT;
-       layer->datasize= datasize;
-       layer->type= type;
+       layer = &cdf->layer[cdf->totlayer - 1];
+       layer->structbytes = sizeof(CDataFileLayer);
+       layer->datatype = CDF_DATA_FLOAT;
+       layer->datasize = datasize;
+       layer->type = type;
        BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
 
        return layer;
index 2bde31c..4d6d6a9 100644 (file)
@@ -46,7 +46,7 @@
 #include "DNA_texture_types.h"
 
 #include "BKE_animsys.h"
-#include "BKE_bvhutils.h"      /* bvh tree     */
+#include "BKE_bvhutils.h"   /* bvh tree        */
 #include "BKE_blender.h"
 #include "BKE_cdderivedmesh.h"
 #include "BKE_constraint.h"
 #endif
 
 /* precalculated gaussian factors for 5x super sampling        */
-static float gaussianFactors[5] = {    0.996849f,
-                                    0.596145f,
-                                    0.596145f,
-                                    0.596145f,
-                                    0.524141f};
+static float gaussianFactors[5] = {0.996849f,
+                                   0.596145f,
+                                   0.596145f,
+                                   0.596145f,
+                                   0.524141f};
 static float gaussianTotal = 3.309425f;
 
 /* UV Image neighboring pixel table x and y list */
@@ -98,11 +98,11 @@ static int neighX[8] = {1, 1, 0, -1, -1, -1, 0, 1};
 static int neighY[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
 /* subframe_updateObject() flags */
-#define UPDATE_PARENTS (1<<0)
-#define UPDATE_MESH (1<<1)
-#define UPDATE_EVERYTHING (UPDATE_PARENTS|UPDATE_MESH)
+#define UPDATE_PARENTS (1 << 0)
+#define UPDATE_MESH (1 << 1)
+#define UPDATE_EVERYTHING (UPDATE_PARENTS | UPDATE_MESH)
 /* surface_getBrushFlags() return vals */
-#define BRUSH_USES_VELOCITY (1<<0)
+#define BRUSH_USES_VELOCITY (1 << 0)
 /* brush mesh raycast status */
 #define HIT_VOLUME 1
 #define HIT_PROXIMITY 2
@@ -113,13 +113,13 @@ static int neighY[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 /* paint effect default movement per frame in global units */
 #define EFF_MOVEMENT_PER_FRAME 0.05f
 /* initial wave time factor */
-#define WAVE_TIME_FAC (1.0f/24.f)
+#define WAVE_TIME_FAC (1.0f / 24.f)
 #define CANVAS_REL_SIZE 5.0f
 /* drying limits */
 #define MIN_WETNESS 0.001f
 #define MAX_WETNESS 5.0f
 /* dissolve macro */
-#define VALUE_DISSOLVE(VALUE, TIME, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) * (pow(MIN_WETNESS, 1.0f/(1.2f*((float)(TIME))/(SCALE)))) : (VALUE) - 1.0f/(TIME)*(SCALE)
+#define VALUE_DISSOLVE(VALUE, TIME, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) *(pow(MIN_WETNESS, 1.0f / (1.2f * ((float)(TIME)) / (SCALE)))) : (VALUE) -1.0f / (TIME)*(SCALE)
 
 /***************************** Internal Structs ***************************/
 
@@ -136,11 +136,11 @@ typedef struct VolumeGrid {
        int dim[3];
        Bounds3D grid_bounds; /* whole grid bounds */
 
-       Bounds3D *bounds;       /* (x*y*z) precalculated grid cell bounds */
+       Bounds3D *bounds;   /* (x*y*z) precalculated grid cell bounds */
        int *s_pos; /* (x*y*z) t_index begin id */
        int *s_num; /* (x*y*z) number of t_index points */
        int *t_index; /* actual surface point index,
-                                                  access: (s_pos+s_num) */
+                              access: (s_pos+s_num) */
 } VolumeGrid;
 
 typedef struct Vec3f {
@@ -148,8 +148,8 @@ typedef struct Vec3f {
 } Vec3f;
 
 typedef struct BakeAdjPoint {
-       float dir[3];   /* vector pointing towards this neighbor */
-       float dist;             /* distance to */
+       float dir[3];   /* vector pointing towards this neighbor */
+       float dist;     /* distance to */
 } BakeAdjPoint;
 
 /* Surface data used while processing a frame  */
@@ -162,8 +162,8 @@ typedef struct PaintBakeNormal {
 typedef struct PaintBakeData {
        /* point space data */
        PaintBakeNormal *bNormal;
-       int *s_pos;     /* index to start reading point sample realCoord */
-       int *s_num;     /* num of realCoord samples */
+       int *s_pos; /* index to start reading point sample realCoord */
+       int *s_num; /* num of realCoord samples */
        Vec3f *realCoord;  /* current pixel center world-space coordinates for each sample
                            *  ordered as (s_pos+s_num)*/
        Bounds3D mesh_bounds;
@@ -172,44 +172,44 @@ typedef struct PaintBakeData {
        BakeAdjPoint *bNeighs; /* current global neighbor distances and directions, if required */
        double average_dist;
        /* space partitioning */
-       VolumeGrid *grid;               /* space partitioning grid to optimize brush checks */
+       VolumeGrid *grid;       /* space partitioning grid to optimize brush checks */
 
        /* velocity and movement */
-       Vec3f *velocity;                /* speed vector in global space movement per frame, if required */
+       Vec3f *velocity;        /* speed vector in global space movement per frame, if required */
        Vec3f *prev_velocity;
-       float *brush_velocity;  /* special temp data for post-p velocity based brushes like smudge
-                                                       *  3 float dir vec + 1 float str */
-       MVert *prev_verts;              /* copy of previous frame vertices. used to observe surface movement */
+       float *brush_velocity;  /* special temp data for post-p velocity based brushes like smudge
+                                *  3 float dir vec + 1 float str */
+       MVert *prev_verts;      /* copy of previous frame vertices. used to observe surface movement */
        float prev_obmat[4][4]; /* previous frame object matrix */
-       int clear;                              /* flag to check if surface was cleared/reset -> have to redo velocity etc. */
+       int clear;              /* flag to check if surface was cleared/reset -> have to redo velocity etc. */
 
 } PaintBakeData;
 
 /* UV Image sequence format point      */
 typedef struct PaintUVPoint {
        /* Pixel / mesh data */
-       unsigned int face_index, pixel_index;   /* face index on domain derived mesh */
-       unsigned int v1, v2, v3;                                /* vertex indexes */
+       unsigned int face_index, pixel_index;   /* face index on domain derived mesh */
+       unsigned int v1, v2, v3;                /* vertex indexes */
 
-       unsigned int neighbour_pixel;   /* If this pixel isn't uv mapped to any face,
-                                                                          but it's neighboring pixel is */
+       unsigned int neighbour_pixel;   /* If this pixel isn't uv mapped to any face,
+                                          but it's neighboring pixel is */
        short quad;
 } PaintUVPoint;
 
 typedef struct ImgSeqFormatData {
        PaintUVPoint *uv_p;
-       Vec3f *barycentricWeights;              /* b-weights for all pixel samples */
+       Vec3f *barycentricWeights;      /* b-weights for all pixel samples */
 } ImgSeqFormatData;
 
 /* adjacency data flags */
-#define ADJ_ON_MESH_EDGE (1<<0)
+#define ADJ_ON_MESH_EDGE (1 << 0)
 
 typedef struct PaintAdjData {
-       int *n_target;          /* array of neighboring point indexes,
-                                                              for single sample use (n_index+neigh_num) */
-       int *n_index;           /* index to start reading n_target for each point */
-       int *n_num;             /* num of neighs for each point */
-       int *flags;             /* vertex adjacency flags */
+       int *n_target;      /* array of neighboring point indexes,
+                                      for single sample use (n_index+neigh_num) */
+       int *n_index;       /* index to start reading n_target for each point */
+       int *n_num;     /* num of neighs for each point */
+       int *flags;     /* vertex adjacency flags */
        int total_targets; /* size of n_target */
 } PaintAdjData;
 
@@ -230,7 +230,7 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
                return 0; /* not supported atm */
        }
        else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
-               if (!surface->canvas->dm) return 0; /* invalid derived mesh */
+               if (!surface->canvas->dm) return 0;  /* invalid derived mesh */
                return surface->canvas->dm->getNumVerts(surface->canvas->dm);
        }
        else
@@ -259,12 +259,11 @@ int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
 }
 
 /* get currently active surface (in user interface) */
-struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
-{
+struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas){
        DynamicPaintSurface *surface = canvas->surfaces.first;
        int i;
 
-       for (i=0; surface; surface=surface->next) {
+       for (i = 0; surface; surface = surface->next) {
                if (i == canvas->active_sur)
                        return surface;
                i++;
@@ -276,12 +275,12 @@ struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas
 void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
 {
        DynamicPaintSurface *surface = canvas->surfaces.first;
-       int done=0;
+       int done = 0;
 
-       for (; surface; surface=surface->next) {
+       for (; surface; surface = surface->next) {
                if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
                        surface->flags |= MOD_DPAINT_PREVIEW;
-                       done=1;
+                       done = 1;
                }
                else
                        surface->flags &= ~MOD_DPAINT_PREVIEW;
@@ -292,7 +291,7 @@ void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
 static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
 {
        DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
-       for (; surface; surface=surface->next) {
+       for (; surface; surface = surface->next) {
                if (surface == t_surface)
                        surface->flags |= MOD_DPAINT_PREVIEW;
                else
@@ -325,14 +324,15 @@ int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *
 
 static int surface_duplicateOutputExists(void *arg, const char *name)
 {
-       DynamicPaintSurface *t_surface = (DynamicPaintSurface*)arg;
+       DynamicPaintSurface *t_surface = (DynamicPaintSurface *)arg;
        DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
 
-       for (; surface; surface=surface->next) {
-               if (surface!=t_surface && surface->type==t_surface->type &&
-                       surface->format==t_surface->format) {
-                       if (surface->output_name[0]!='\0' && !BLI_path_cmp(name, surface->output_name)) return 1;
-                       if (surface->output_name2[0]!='\0' && !BLI_path_cmp(name, surface->output_name2)) return 1;
+       for (; surface; surface = surface->next) {
+               if (surface != t_surface && surface->type == t_surface->type &&
+                   surface->format == t_surface->format)
+               {
+                       if (surface->output_name[0] != '\0' && !BLI_path_cmp(name, surface->output_name)) return 1;
+                       if (surface->output_name2[0] != '\0' && !BLI_path_cmp(name, surface->output_name2)) return 1;
                }
        }
        return 0;
@@ -351,11 +351,11 @@ static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *base
 
 static int surface_duplicateNameExists(void *arg, const char *name)
 {
-       DynamicPaintSurface *t_surface = (DynamicPaintSurface*)arg;
+       DynamicPaintSurface *t_surface = (DynamicPaintSurface *)arg;
        DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
 
-       for (; surface; surface=surface->next) {
-               if (surface!=t_surface && !strcmp(name, surface->name)) return 1;
+       for (; surface; surface = surface->next) {
+               if (surface != t_surface && !strcmp(name, surface->name)) return 1;
        }
        return 0;
 }
@@ -372,8 +372,8 @@ void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char
 void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
 {
        if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
-               surface->output_name[0]='\0';
-               surface->output_name2[0]='\0';
+               surface->output_name[0] = '\0';
+               surface->output_name2[0] = '\0';
                surface->flags |= MOD_DPAINT_ANTIALIAS;
                surface->depth_clamp = 1.0f;
        }
@@ -418,7 +418,7 @@ static int surface_totalSamples(DynamicPaintSurface *surface)
        if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
            surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data)
        {
-               return (surface->data->total_points+surface->data->adj_data->total_targets);
+               return (surface->data->total_points + surface->data->adj_data->total_targets);
        }
 
        return surface->data->total_points;
@@ -428,12 +428,12 @@ static void blendColors(float t_color[3], float t_alpha, float s_color[3], float
 {
        int i;
        float i_alpha = 1.0f - s_alpha;
-       float f_alpha = t_alpha*i_alpha + s_alpha;
+       float f_alpha = t_alpha * i_alpha + s_alpha;
 
        /* blend colors */
        if (f_alpha) {
-               for (i=0; i<3; i++) {
-                       result[i] = (t_color[i]*t_alpha*i_alpha + s_color[i]*s_alpha)/f_alpha;
+               for (i = 0; i < 3; i++) {
+                       result[i] = (t_color[i] * t_alpha * i_alpha + s_color[i] * s_alpha) / f_alpha;
                }
        }
        else {
@@ -451,23 +451,23 @@ static float mixColors(float a_color[3], float a_weight, float b_color[3], float
                /* if first value has no weight just use b_color */
                if (!a_weight) {
                        copy_v3_v3(a_color, b_color);
-                       return b_weight*ratio;
+                       return b_weight * ratio;
                }
-               weight_ratio = b_weight/(a_weight+b_weight);
+               weight_ratio = b_weight / (a_weight + b_weight);
        }
-       else return a_weight*(1.0f-ratio);
+       else return a_weight * (1.0f - ratio);
 
        /* calculate final interpolation factor */
-       if (ratio<=0.5f) {
-               factor = weight_ratio*(ratio*2.0f);
+       if (ratio <= 0.5f) {
+               factor = weight_ratio * (ratio * 2.0f);
        }
        else {
-               ratio = (ratio*2.0f - 1.0f);
-               factor = weight_ratio*(1.0f-ratio) + ratio;
+               ratio = (ratio * 2.0f - 1.0f);
+               factor = weight_ratio * (1.0f - ratio) + ratio;
        }
        /* mix final color */
        interp_v3_v3v3(a_color, a_color, b_color, factor);
-       return (1.0f-factor)*a_weight + factor*b_weight;
+       return (1.0f - factor) * a_weight + factor * b_weight;
 }
 
 /* set "ignore cache" flag for all caches on this object */
@@ -477,7 +477,7 @@ static void object_cacheIgnoreClear(Object *ob, int state)
        PTCacheID *pid;
        BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
 
-       for (pid=pidlist.first; pid; pid=pid->next) {
+       for (pid = pidlist.first; pid; pid = pid->next) {
                if (pid->cache) {
                        if (state)
                                pid->cache->flag |= PTCACHE_IGNORE_CLEAR;
@@ -505,19 +505,19 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram
                if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, frame);
 
                /* skip subframe if object is parented
-               *  to vertex of a dynamic paint canvas */
+                *  to vertex of a dynamic paint canvas */
                if (is_canvas && (ob->partype == PARVERT1 || ob->partype == PARVERT3))
                        return 0;
 
                /* also update constraint targets */
-               for (con = ob->constraints.first; con; con=con->next) {
-                       bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+               for (con = ob->constraints.first; con; con = con->next) {
+                       bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
                        ListBase targets = {NULL, NULL};
 
                        if (cti && cti->get_constraint_targets) {
                                bConstraintTarget *ct;
                                cti->get_constraint_targets(con, &targets);
-                               for (ct= targets.first; ct; ct= ct->next) {
+                               for (ct = targets.first; ct; ct = ct->next) {
                                        if (ct->tar)
                                                subframe_updateObject(scene, ct->tar, 0, frame);
                                }
@@ -528,8 +528,8 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram
                }
        }
        /* for curve following objects, parented curve has to be updated too */
-       if (ob->type==OB_CURVE) {
-               Curve *cu= ob->data;
+       if (ob->type == OB_CURVE) {
+               Curve *cu = ob->data;
                BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
        }
 
@@ -538,7 +538,7 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram
        BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
        if (flags & UPDATE_MESH) {
                /* ignore cache clear during subframe updates
-               *  to not mess up cache validity */
+                *  to not mess up cache validity */
                object_cacheIgnoreClear(ob, 1);
                BKE_object_handle_update(scene, ob);
                object_cacheIgnoreClear(ob, 0);
@@ -575,21 +575,21 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
 
                /* select object */
                if (surface->brush_group) {                                             
-                       if (go->ob)     brushObj = go->ob;                                      
+                       if (go->ob) brushObj = go->ob;
                }                                       
                else                                            
                        brushObj = base->object;
 
                if (!brushObj) {
                        if (surface->brush_group) go = go->next;
-                       else base= base->next;                                  
+                       else base = base->next;
                        continue;                       
                }
 
                if (surface->brush_group)
                        go = go->next;
                else
-                       base= base->next;
+                       base = base->next;
 
                md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
                if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) {
@@ -615,9 +615,9 @@ static int brush_usesMaterial(DynamicPaintBrushSettings *brush, Scene *scene)
 /* check whether two bounds intersect */
 static int boundsIntersect(Bounds3D *b1, Bounds3D *b2)
 {
-       int i=2;
+       int i = 2;
        if (!b1->valid || !b2->valid) return 0;
-       for (; i>=0; i-=1)
+       for (; i >= 0; i -= 1)
                if (!(b1->min[i] <= b2->max[i] && b1->max[i] >= b2->min[i])) return 0;
        return 1;
 }
@@ -625,36 +625,36 @@ static int boundsIntersect(Bounds3D *b1, Bounds3D *b2)
 /* check whether two bounds intersect inside defined proximity */
 static int boundsIntersectDist(Bounds3D *b1, Bounds3D *b2, float dist)
 {
-       int i=2;
+       int i = 2;
        if (!b1->valid || !b2->valid) return 0;
-       for (; i>=0; i-=1)
-               if (!(b1->min[i] <= (b2->max[i]+dist) && b1->max[i] >= (b2->min[i]-dist))) return 0;
+       for (; i >= 0; i -= 1)
+               if (!(b1->min[i] <= (b2->max[i] + dist) && b1->max[i] >= (b2->min[i] - dist))) return 0;
        return 1;
 }
 
 /* check whether bounds intersects a point with given radius */
 static int boundIntersectPoint(Bounds3D *b, float point[3], float radius)
 {
-       int i=2;
+       int i = 2;
        if (!b->valid) return 0;
-       for (; i>=0; i-=1)
-               if (!(b->min[i] <= (point[i]+radius) && b->max[i] >= (point[i]-radius))) return 0;
+       for (; i >= 0; i -= 1)
+               if (!(b->min[i] <= (point[i] + radius) && b->max[i] >= (point[i] - radius))) return 0;
        return 1;
 }
 
 /* expand bounds by a new point */
 static void boundInsert(Bounds3D *b, float point[3])
 {
-       int i=2;
+       int i = 2;
        if (!b->valid) {
                copy_v3_v3(b->min, point);
                copy_v3_v3(b->max, point);
                b->valid = 1;
        }
        else {
-               for (; i>=0; i-=1) {
-                       if (point[i] < b->min[i]) b->min[i]=point[i];
-                       if (point[i] > b->max[i]) b->max[i]=point[i];
+               for (; i >= 0; i -= 1) {
+                       if (point[i] < b->min[i]) b->min[i] = point[i];
+                       if (point[i] > b->max[i]) b->max[i] = point[i];
                }
        }
 }
@@ -662,7 +662,7 @@ static void boundInsert(Bounds3D *b, float point[3])
 float getSurfaceDimension(PaintSurfaceData *sData)
 {
        Bounds3D *mb = &sData->bData->mesh_bounds;
-       return MAX3((mb->max[0]-mb->min[0]), (mb->max[1]-mb->min[1]), (mb->max[2]-mb->min[2]));
+       return MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2]));
 }
 
 static void freeGrid(PaintSurfaceData *data)
@@ -699,7 +699,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                freeGrid(sData);
 
        /* allocate separate bounds for each thread */
-       grid_bounds = MEM_callocN(sizeof(Bounds3D)*num_of_threads, "Grid Bounds");
+       grid_bounds = MEM_callocN(sizeof(Bounds3D) * num_of_threads, "Grid Bounds");
        bData->grid = MEM_callocN(sizeof(VolumeGrid), "Surface Grid");
        grid = bData->grid;
 
@@ -711,7 +711,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
 
                /* calculate canvas dimensions */
                #pragma omp parallel for schedule(static)
-               for (i=0; i<sData->total_points; i++) {
+               for (i = 0; i < sData->total_points; i++) {
                        #ifdef _OPENMP
                        int id = omp_get_thread_num();
                        boundInsert(&grid_bounds[id], (bData->realCoord[bData->s_pos[i]].v));
@@ -721,7 +721,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                }
 
                /* get final dimensions */
-               for (i=0; i<num_of_threads; i++) {
+               for (i = 0; i < num_of_threads; i++) {
                        boundInsert(&grid->grid_bounds, grid_bounds[i].min);
                        boundInsert(&grid->grid_bounds, grid_bounds[i].max);
                }
@@ -732,8 +732,8 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                min_dim = MAX3(td[0], td[1], td[2]) / 1000.f;
 
                /* deactivate zero axises */
-               for (i=0; i<3; i++) {
-                       if (td[i]<min_dim) {td[i]=1.0f; axis-=1;}
+               for (i = 0; i < 3; i++) {
+                       if (td[i] < min_dim) {td[i] = 1.0f; axis -= 1; }
                }
 
                if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) {
@@ -744,22 +744,22 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                }
 
                /* now calculate grid volume/area/width depending on num of active axis */
-               volume = td[0]*td[1]*td[2];
+               volume = td[0] * td[1] * td[2];
 
                /* determine final grid size by trying to fit average 10.000 points per grid cell */
-               dim_factor = (float)pow(volume / ((double)sData->total_points / 10000.0), 1.0/(double)axis);
+               dim_factor = (float)pow(volume / ((double)sData->total_points / 10000.0), 1.0 / (double)axis);
 
                /* define final grid size using dim_factor, use min 3 for active axises */
-               for (i=0; i<3; i++) {
+               for (i = 0; i < 3; i++) {
                        grid->dim[i] = (int)floor(td[i] / dim_factor);
-                       CLAMP(grid->dim[i], (dim[i]>=min_dim) ? 3 : 1, 100);
+                       CLAMP(grid->dim[i], (dim[i] >= min_dim) ? 3 : 1, 100);
                }
-               grid_cells = grid->dim[0]*grid->dim[1]*grid->dim[2];
+               grid_cells = grid->dim[0] * grid->dim[1] * grid->dim[2];
 
                /* allocate memory for grids */
                grid->bounds = MEM_callocN(sizeof(Bounds3D) * grid_cells, "Surface Grid Bounds");
                grid->s_pos = MEM_callocN(sizeof(int) * grid_cells, "Surface Grid Position");
-               grid->s_num = MEM_callocN(sizeof(int) * grid_cells*num_of_threads, "Surface Grid Points");
+               grid->s_num = MEM_callocN(sizeof(int) * grid_cells * num_of_threads, "Surface Grid Points");
                temp_s_num = MEM_callocN(sizeof(int) * grid_cells, "Temp Surface Grid Points");
                grid->t_index = MEM_callocN(sizeof(int) * sData->total_points, "Surface Grid Target Ids");
                temp_t_index = MEM_callocN(sizeof(int) * sData->total_points, "Temp Surface Grid Target Ids");
@@ -771,37 +771,37 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                if (!error) {
                        /* calculate number of points withing each cell */
                        #pragma omp parallel for schedule(static)
-                       for (i=0; i<sData->total_points; i++) {
+                       for (i = 0; i < sData->total_points; i++) {
                                int co[3], j;
-                               for (j=0; j<3; j++) {
-                                       co[j] = (int)floor((bData->realCoord[bData->s_pos[i]].v[j] - grid->grid_bounds.min[j])/dim[j]*grid->dim[j]);
-                                       CLAMP(co[j], 0, grid->dim[j]-1);
+                               for (j = 0; j < 3; j++) {
+                                       co[j] = (int)floor((bData->realCoord[bData->s_pos[i]].v[j] - grid->grid_bounds.min[j]) / dim[j] * grid->dim[j]);
+                                       CLAMP(co[j], 0, grid->dim[j] - 1);
                                }
 
-                               temp_t_index[i] = co[0] + co[1] * grid->dim[0] + co[2] * grid->dim[0]*grid->dim[1];
+                               temp_t_index[i] = co[0] + co[1] * grid->dim[0] + co[2] * grid->dim[0] * grid->dim[1];
                                #ifdef _OPENMP
-                               grid->s_num[temp_t_index[i]+omp_get_thread_num()*grid_cells]++;
+                               grid->s_num[temp_t_index[i] + omp_get_thread_num() * grid_cells]++;
                                #else
                                grid->s_num[temp_t_index[i]]++;
                                #endif
                        }
 
                        /* for first cell only calc s_num */
-                       for (i=1; i<num_of_threads; i++) {
-                               grid->s_num[0] += grid->s_num[i*grid_cells];
+                       for (i = 1; i < num_of_threads; i++) {
+                               grid->s_num[0] += grid->s_num[i * grid_cells];
                        }
 
                        /* calculate grid indexes */
-                       for (i=1; i<grid_cells; i++) {
+                       for (i = 1; i < grid_cells; i++) {
                                int id;
-                               for (id=1; id<num_of_threads; id++) {
-                                       grid->s_num[i] += grid->s_num[i+id*grid_cells];
+                               for (id = 1; id < num_of_threads; id++) {
+                                       grid->s_num[i] += grid->s_num[i + id * grid_cells];
                                }
-                               grid->s_pos[i] = grid->s_pos[i-1] + grid->s_num[i-1];
+                               grid->s_pos[i] = grid->s_pos[i - 1] + grid->s_num[i - 1];
                        }
 
                        /* save point indexes to final array */
-                       for (i=0; i<sData->total_points; i++) {
+                       for (i = 0; i < sData->total_points; i++) {
                                int pos = grid->s_pos[temp_t_index[i]] + temp_s_num[temp_t_index[i]];
                                grid->t_index[pos] = i;
 
@@ -812,17 +812,17 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
                        {
                                int x;
                                #pragma omp parallel for schedule(static)
-                               for (x=0; x<grid->dim[0]; x++) {
+                               for (x = 0; x < grid->dim[0]; x++) {
                                        int y;
-                                       for (y=0; y<grid->dim[1]; y++) {
+                                       for (y = 0; y < grid->dim[1]; y++) {
                                                int z;
-                                               for (z=0; z<grid->dim[2]; z++) {
-                                                       int j, b_index = x + y * grid->dim[0] + z * grid->dim[0]*grid->dim[1];
+                                               for (z = 0; z < grid->dim[2]; z++) {
+                                                       int j, b_index = x + y * grid->dim[0] + z * grid->dim[0] * grid->dim[1];
                                                        /* set bounds */
-                                                       for (j=0; j<3; j++) {
-                                                               int s = (j==0) ? x : ((j==1) ? y : z);
-                                                               grid->bounds[b_index].min[j] = grid->grid_bounds.min[j] + dim[j]/grid->dim[j]*s;
-                                                               grid->bounds[b_index].max[j] = grid->grid_bounds.min[j] + dim[j]/grid->dim[j]*(s+1);
+                                                       for (j = 0; j < 3; j++) {
+                                                               int s = (j == 0) ? x : ((j == 1) ? y : z);
+                                                               grid->bounds[b_index].min[j] = grid->grid_bounds.min[j] + dim[j] / grid->dim[j] * s;
+                                                               grid->bounds[b_index].max[j] = grid->grid_bounds.min[j] + dim[j] / grid->dim[j] * (s + 1);
                                                        }
                                                        grid->bounds[b_index].valid = 1;
                                                }
@@ -857,10 +857,10 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
                pmd->brush->dm = NULL;
 
                if (pmd->brush->paint_ramp)
-                        MEM_freeN(pmd->brush->paint_ramp);
+                       MEM_freeN(pmd->brush->paint_ramp);
                pmd->brush->paint_ramp = NULL;
                if (pmd->brush->vel_ramp)
-                        MEM_freeN(pmd->brush->vel_ramp);
+                       MEM_freeN(pmd->brush->vel_ramp);
                pmd->brush->vel_ramp = NULL;
 
                MEM_freeN(pmd->brush);
@@ -919,7 +919,7 @@ void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
        if (data->format_data) {
                /* format specific free */
                if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
-                       ImgSeqFormatData *format_data = (ImgSeqFormatData*)data->format_data;
+                       ImgSeqFormatData *format_data = (ImgSeqFormatData *)data->format_data;
                        if (format_data->uv_p)
                                MEM_freeN(format_data->uv_p);
                        if (format_data->barycentricWeights)
@@ -989,13 +989,12 @@ void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd)
 /***************************** Initialize and reset ******************************/
 
 /*
-*      Creates a new surface and adds it to the list
-*      If scene is null, frame range of 1-250 is used
-*      A pointer to this surface is returned
-*/
-struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas, Scene *scene)
-{
-       DynamicPaintSurface *surface= MEM_callocN(sizeof(DynamicPaintSurface), "DynamicPaintSurface");
+ * Creates a new surface and adds it to the list
+ * If scene is null, frame range of 1-250 is used
+ * A pointer to this surface is returned
+ */
+struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas, Scene *scene){
+       DynamicPaintSurface *surface = MEM_callocN(sizeof(DynamicPaintSurface), "DynamicPaintSurface");
        if (!surface) return NULL;
 
        surface->canvas = canvas;
@@ -1009,7 +1008,7 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
 
        /* Set initial values */
        surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG | MOD_DPAINT_DISSOLVE_LOG |
-                                        MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW | MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
+                        MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW | MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
        surface->effect = 0;
        surface->effect_ui = 1;
 
@@ -1064,8 +1063,8 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
 }
 
 /*
-*      Initialize modifier data
-*/
+ * Initialize modifier data
+ */
 int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene)
 {
        if (pmd) {
@@ -1212,16 +1211,16 @@ static void dynamicPaint_allocateSurfaceType(DynamicPaintSurface *surface)
 
        switch (surface->type) {
                case MOD_DPAINT_SURFACE_T_PAINT:
-                       sData->type_data = MEM_callocN(sizeof(PaintPoint)*sData->total_points, "DynamicPaintSurface Data");
+                       sData->type_data = MEM_callocN(sizeof(PaintPoint) * sData->total_points, "DynamicPaintSurface Data");
                        break;
                case MOD_DPAINT_SURFACE_T_DISPLACE:
-                       sData->type_data = MEM_callocN(sizeof(float)*sData->total_points, "DynamicPaintSurface DepthData");
+                       sData->type_data = MEM_callocN(sizeof(float) * sData->total_points, "DynamicPaintSurface DepthData");
                        break;
                case MOD_DPAINT_SURFACE_T_WEIGHT:
-                       sData->type_data = MEM_callocN(sizeof(float)*sData->total_points, "DynamicPaintSurface WeightData");
+                       sData->type_data = MEM_callocN(sizeof(float) * sData->total_points, "DynamicPaintSurface WeightData");
                        break;
                case MOD_DPAINT_SURFACE_T_WAVE:
-                       sData->type_data = MEM_callocN(sizeof(PaintWavePoint)*sData->total_points, "DynamicPaintSurface WaveData");
+                       sData->type_data = MEM_callocN(sizeof(PaintWavePoint) * sData->total_points, "DynamicPaintSurface WaveData");
                        break;
        }
 
@@ -1261,21 +1260,21 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
 
        if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
                /* For vertex format, neighbors are connected by edges */
-               neigh_points = 2*dm->getNumEdges(dm);
+               neigh_points = 2 * dm->getNumEdges(dm);
        }
        else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ)
-               neigh_points = sData->total_points*8;
+               neigh_points = sData->total_points * 8;
 
        if (!neigh_points) return;
 
        /* allocate memory */
        ad = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data");
        if (!ad) return;
-       ad->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Index");
-       ad->n_num = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Counts");
-       temp_data = MEM_callocN(sizeof(int)*sData->total_points, "Temp Adj Data");
-       ad->n_target = MEM_callocN(sizeof(int)*neigh_points, "Surface Adj Targets");
-       ad->flags = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Flags");
+       ad->n_index = MEM_callocN(sizeof(int) * sData->total_points, "Surface Adj Index");
+       ad->n_num = MEM_callocN(sizeof(int) * sData->total_points, "Surface Adj Counts");
+       temp_data = MEM_callocN(sizeof(int) * sData->total_points, "Temp Adj Data");
+       ad->n_target = MEM_callocN(sizeof(int) * neigh_points, "Surface Adj Targets");
+       ad->flags = MEM_callocN(sizeof(int) * sData->total_points, "Surface Adj Flags");
        ad->total_targets = neigh_points;
 
        /* in case of allocation error, free memory */
@@ -1298,7 +1297,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
                struct MLoop *mloop = dm->getLoopArray(dm);
 
                /* count number of edges per vertex */
-               for (i=0; i<numOfEdges; i++) {
+               for (i = 0; i < numOfEdges; i++) {
                        ad->n_num[edge[i].v1]++;
                        ad->n_num[edge[i].v2]++;
 
@@ -1307,17 +1306,17 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
                }
 
                /* also add number of vertices to temp_data
-               *  to locate points on "mesh edge" */
-               for (i=0; i<numOfPolys; i++) {
-                       int j=0;
-                       for (; j<mpoly[i].totloop; j++) {
+                *  to locate points on "mesh edge" */
+               for (i = 0; i < numOfPolys; i++) {
+                       int j = 0;
+                       for (; j < mpoly[i].totloop; j++) {
                                temp_data[mloop[mpoly[i].loopstart + j].v]++;
                        }
                }
 
                /* now check if total number of edges+faces for
-               *  each vertex is even, if not -> vertex is on mesh edge */
-               for (i=0; i<sData->total_points; i++) {
+                *  each vertex is even, if not -> vertex is on mesh edge */
+               for (i = 0; i < sData->total_points; i++) {
                        if ((temp_data[i] % 2) ||
                            (temp_data[i] < 4))
                        {
@@ -1330,29 +1329,29 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
 
                /* order n_index array */
                n_pos = 0;
-               for (i=0; i<sData->total_points; i++) {
+               for (i = 0; i < sData->total_points; i++) {
                        ad->n_index[i] = n_pos;
                        n_pos += ad->n_num[i];
                }
 
                /* and now add neighbor data using that info */
-               for (i=0; i<numOfEdges; i++) {
+               for (i = 0; i < numOfEdges; i++) {
                        /* first vertex */
                        int index = edge[i].v1;
-                       n_pos = ad->n_index[index]+temp_data[index];
+                       n_pos = ad->n_index[index] + temp_data[index];
                        ad->n_target[n_pos] = edge[i].v2;
                        temp_data[index]++;
 
                        /* second vertex */
                        index = edge[i].v2;
-                       n_pos = ad->n_index[index]+temp_data[index];
+                       n_pos = ad->n_index[index] + temp_data[index];
                        ad->n_target[n_pos] = edge[i].v1;
                        temp_data[index]++;
                }
        }
        else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
                /* for image sequences, only allocate memory.
-               *  bake initialization takes care of rest */
+                *  bake initialization takes care of rest */
        }
 
        MEM_freeN(temp_data);
@@ -1361,7 +1360,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
 void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
 {
        PaintSurfaceData *sData = surface->data;
-       PaintPoint* pPoint = (PaintPoint*)sData->type_data;
+       PaintPoint *pPoint = (PaintPoint *)sData->type_data;
        DerivedMesh *dm = surface->canvas->dm;
        int i;
 
@@ -1374,7 +1373,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
        else if (surface->init_color_type == MOD_DPAINT_INITIAL_COLOR) {
                /* apply color to every surface point */
                #pragma omp parallel for schedule(static)
-               for (i=0; i<sData->total_points; i++) {
+               for (i = 0; i < sData->total_points; i++) {
                        copy_v3_v3(pPoint[i].color, surface->init_color);
                        pPoint[i].alpha = surface->init_color[3];
                }
@@ -1395,20 +1394,20 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
                if (!tface) return;
 
                /* for vertex surface loop through tfaces and find uv color
-               *  that provides highest alpha */
+                *  that provides highest alpha */
                if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
                        #pragma omp parallel for schedule(static)
-                       for (i=0; i<numOfFaces; i++) {
+                       for (i = 0; i < numOfFaces; i++) {
                                int numOfVert = (mface[i].v4) ? 4 : 3;
                                float uv[3] = {0.0f};
                                int j;
-                               for (j=0; j<numOfVert; j++) {
+                               for (j = 0; j < numOfVert; j++) {
                                        TexResult texres = {0};
-                                       unsigned int *vert = (&mface[i].v1)+j;
+                                       unsigned int *vert = (&mface[i].v1) + j;
 
                                        /* remap to -1.0 to 1.0 */
-                                       uv[0] = tface[i].uv[j][0]*2.0f - 1.0f;
-                                       uv[1] = tface[i].uv[j][1]*2.0f - 1.0f;
+                                       uv[0] = tface[i].uv[j][0] * 2.0f - 1.0f;
+                                       uv[1] = tface[i].uv[j][1] * 2.0f - 1.0f;
 
                                        multitex_ext_safe(tex, uv, &texres);
 
@@ -1420,28 +1419,28 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
                        }
                }
                else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
-                       ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data;
+                       ImgSeqFormatData *f_data = (ImgSeqFormatData *)sData->format_data;
                        int samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
 
                        #pragma omp parallel for schedule(static)
-                       for (i=0; i<sData->total_points; i++) {
+                       for (i = 0; i < sData->total_points; i++) {
                                float uv[9] = {0.0f};
                                float uv_final[3] = {0.0f};
                                int j;
                                TexResult texres = {0};
 
                                /* collect all uvs */
-                               for (j=0; j<3; j++) {
-                                       int v=(f_data->uv_p[i].quad && j>0) ? j+1 : j;
-                                       copy_v2_v2(&uv[j*3], tface[f_data->uv_p[i].face_index].uv[v]);
+                               for (j = 0; j < 3; j++) {
+                                       int v = (f_data->uv_p[i].quad && j > 0) ? j + 1 : j;
+                                       copy_v2_v2(&uv[j * 3], tface[f_data->uv_p[i].face_index].uv[v]);
                                }
 
                                /* interpolate final uv pos */
                                interp_v3_v3v3v3(uv_final, &uv[0], &uv[3], &uv[6],
-                                                f_data->barycentricWeights[i*samples].v);
+                                                f_data->barycentricWeights[i * samples].v);
                                /* remap to -1.0 to 1.0 */
-                               uv_final[0] = uv_final[0]*2.0f - 1.0f;
-                               uv_final[1] = uv_final[1]*2.0f - 1.0f;
+                               uv_final[0] = uv_final[0] * 2.0f - 1.0f;
+                               uv_final[1] = uv_final[1] * 2.0f - 1.0f;
                                        
                                multitex_ext_safe(tex, uv_final, &texres);
 
@@ -1462,37 +1461,37 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
                        if (!col) return;
 
                        #pragma omp parallel for schedule(static)
-                       for (i=0; i<numOfLoops; i++) {
-                               pPoint[mloop[i].v].color[0] = 1.0f/255.f*(float)col[i].b;
-                               pPoint[mloop[i].v].color[1] = 1.0f/255.f*(float)col[i].g;
-                               pPoint[mloop[i].v].color[2] = 1.0f/255.f*(float)col[i].r;
-                               pPoint[mloop[i].v].alpha = 1.0f/255.f*(float)col[i].a;
+                       for (i = 0; i < numOfLoops; i++) {
+                               pPoint[mloop[i].v].color[0] = 1.0f / 255.f * (float)col[i].b;
+                               pPoint[mloop[i].v].color[1] = 1.0f / 255.f * (float)col[i].g;
+                               pPoint[mloop[i].v].color[2] = 1.0f / 255.f * (float)col[i].r;
+                               pPoint[mloop[i].v].alpha = 1.0f / 255.f * (float)col[i].a;
                        }
                }
                else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
-                       ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data;
+                       ImgSeqFormatData *f_data = (ImgSeqFormatData *)sData->format_data;
                        int samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
                        MCol *col = CustomData_get_layer_named(&dm->faceData, CD_MCOL, surface->init_layername);
                        if (!col) return;
 
                        #pragma omp parallel for schedule(static)
-                       for (i=0; i<sData->total_points; i++) {
+                       for (i = 0; i < sData->total_points; i++) {
                                int face_ind = f_data->uv_p[i].face_index;
                                float colors[3][4] = {{0.0f, 0.0f, 0.0f, 0.0f}};
                                float final_color[4];
                                int j;
                                /* collect color values */
-                               for (j=0; j<3; j++) {
-                                       int v=(f_data->uv_p[i].quad && j>0) ? j+1 : j;
-                                       colors[j][0] = 1.0f/255.f*(float)col[face_ind*4+v].b;
-                                       colors[j][1] = 1.0f/255.f*(float)col[face_ind*4+v].g;
-                                       colors[j][2] = 1.0f/255.f*(float)col[face_ind*4+v].r;
-                                       colors[j][3] = 1.0f/255.f*(float)col[face_ind*4+v].a;
+                               for (j = 0; j < 3; j++) {
+                                       int v = (f_data->uv_p[i].quad && j > 0) ? j + 1 : j;
+                                       colors[j][0] = 1.0f / 255.f * (float)col[face_ind * 4 + v].b;
+                                       colors[j][1] = 1.0f / 255.f * (float)col[face_ind * 4 + v].g;
+                                       colors[j][2] = 1.0f / 255.f * (float)col[face_ind * 4 + v].r;
+                                       colors[j][3] = 1.0f / 255.f * (float)col[face_ind * 4 + v].a;
                                }
                                
                                /* interpolate final color */
                                interp_v4_v4v4v4(final_color, colors[0], colors[1], colors[2],
-                                                f_data->barycentricWeights[i*samples].v);
+                                                f_data->barycentricWeights[i * samples].v);
 
                                copy_v3_v3(pPoint[i].color, final_color);
                                pPoint[i].alpha = final_color[3];
@@ -1577,28 +1576,27 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri
        if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
                MVert *mvert = result->getVertArray(result);
                int i;
-               float* value = (float*)sData->type_data;
+               float *value = (float *)sData->type_data;
 
                #pragma omp parallel for schedule(static)
-               for (i=0; i<sData->total_points; i++) {
-                       float normal[3], val=value[i]*surface->disp_factor;
+               for (i = 0; i < sData->total_points; i++) {
+                       float normal[3], val = value[i] * surface->disp_factor;
                        normal_short_to_float_v3(normal, mvert[i].no);
                        normalize_v3(normal);
 
-                       mvert[i].co[0] -= normal[0]*val;
-                       mvert[i].co[1] -= normal[1]*val;
-                       mvert[i].co[2] -= normal[2]*val;
+                       mvert[i].co[0] -= normal[0] * val;
+                       mvert[i].co[1] -= normal[1] * val;
+                       mvert[i].co[2] -= normal[2] * val;
                }
        }
 }
 
 /*
-     Apply canvas data to the object derived mesh
-*/
+ *     Apply canvas data to the object derived mesh
+ */
 static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
                                                        Object *ob,
-                                                       DerivedMesh *dm)
-{      
+                                                       DerivedMesh *dm){
        DerivedMesh *result = CDDM_copy(dm);
 
        if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) {
@@ -1607,7 +1605,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                int update_normals = 0;
 
                /* loop through surfaces */
-               for (surface = pmd->canvas->surfaces.first; surface; surface=surface->next) {
+               for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
                        PaintSurfaceData *sData = surface->data;
 
                        if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) {
@@ -1620,18 +1618,18 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
 
                                                int i;
-                                               PaintPoint* pPoint = (PaintPoint*)sData->type_data;
+                                               PaintPoint *pPoint = (PaintPoint *)sData->type_data;
                                                MLoopCol *col = NULL;
                                                MLoop *mloop = CDDM_get_loops(result);
                                                int totloop = result->numLoopData;
 
                                                /* paint is stored on dry and wet layers, so mix final color first */
-                                               float *fcolor = MEM_callocN(sizeof(float)*sData->total_points*4, "Temp paint color");
+                                               float *fcolor = MEM_callocN(sizeof(float) * sData->total_points * 4, "Temp paint color");
 
                                                #pragma omp parallel for schedule(static)
-                                               for (i=0; i<sData->total_points; i++) {
+                                               for (i = 0; i < sData->total_points; i++) {
                                                        /* blend dry and wet layer */
-                                                       blendColors(pPoint[i].color, pPoint[i].alpha, pPoint[i].e_color, pPoint[i].e_alpha, &fcolor[i*4]);
+                                                       blendColors(pPoint[i].color, pPoint[i].alpha, pPoint[i].e_color, pPoint[i].e_alpha, &fcolor[i * 4]);
                                                }
 
                                                /* viewport preview */
@@ -1649,7 +1647,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
 #endif
 
                                                        /* Save preview results to weight layer to be
-                                                       *   able to share same drawing methods */
+                                                        *   able to share same drawing methods */
                                                        col = CustomData_get_layer(&result->loopData, CD_PREVIEW_MLOOPCOL);
                                                        if (!col)
                                                                col = CustomData_add_layer(&result->loopData, CD_PREVIEW_MLOOPCOL, CD_CALLOC,
@@ -1657,11 +1655,11 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
 
                                                        if (col) {
                                                                #pragma omp parallel for schedule(static)
-                                                               for (i=0; i<totpoly; i++) {
-                                                                       int j=0;
+                                                               for (i = 0; i < totpoly; i++) {
+                                                                       int j = 0;
                                                                        Material *material = give_current_material(ob, mp[i].mat_nr + 1);
 
-                                                                       for (; j<mp[i].totloop; j++) {
+                                                                       for (; j < mp[i].totloop; j++) {
                                                                                int l_index = mp[i].loopstart + j;
                                                                                int v_index = mloop[l_index].v;
 
@@ -1682,14 +1680,14 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                                                                c[2] = 0.65f;
                                                                                        }
                                                                                        /* mix surface color */
-                                                                                       interp_v3_v3v3(c, c, &fcolor[v_index], fcolor[v_index+3]);
+                                                                                       interp_v3_v3v3(c, c, &fcolor[v_index], fcolor[v_index + 3]);
 
                                                                                        rgb_float_to_uchar((unsigned char *)&col[l_index].r, c);
                                                                                }
                                                                                else {
                                                                                        col[l_index].r =
-                                                                                       col[l_index].g =
-                                                                                       col[l_index].b = FTOCHAR(pPoint[v_index].wetness);
+                                                                                           col[l_index].g =
+                                                                                               col[l_index].b = FTOCHAR(pPoint[v_index].wetness);
                                                                                        col[l_index].a = 255;
                                                                                }
                                                                        }
@@ -1708,10 +1706,10 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                /* apply color */
                                                if (col) {
                                                        #pragma omp parallel for schedule(static)
-                                                       for (i=0; i<totloop; i++) {
-                                                               int index = mloop[i].v*4;
+                                                       for (i = 0; i < totloop; i++) {
+                                                               int index = mloop[i].v * 4;
                                                                rgb_float_to_uchar((unsigned char *)&col[i].r, &fcolor[index]);
-                                                               col[i].a = FTOCHAR(fcolor[index+3]); /* IS THIS NEEDED? */
+                                                               col[i].a = FTOCHAR(fcolor[index + 3]); /* IS THIS NEEDED? */
                                                        }
                                                }
                                                
@@ -1725,11 +1723,11 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                /* apply color */
                                                if (col) {
                                                        #pragma omp parallel for schedule(static)
-                                                       for (i=0; i<totloop; i++) {
+                                                       for (i = 0; i < totloop; i++) {
                                                                int index = mloop[i].v;
                                                                col[i].r =
-                                                               col[i].g =
-                                                               col[i].b = FTOCHAR(pPoint[index].wetness);
+                                                                   col[i].g =
+                                                                       col[i].b = FTOCHAR(pPoint[index].wetness);
                                                                col[i].a = 255;
                                                        }
                                                }
@@ -1741,7 +1739,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                        else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
                                                int defgrp_index = defgroup_name_index(ob, surface->output_name);
                                                MDeformVert *dvert = result->getVertDataArray(result, CD_MDEFORMVERT);
-                                               float *weight = (float*)sData->type_data;
+                                               float *weight = (float *)sData->type_data;
 
                                                /* viewport preview */
                                                if (surface->flags & MOD_DPAINT_PREVIEW) {
@@ -1754,11 +1752,11 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                /* apply weights into a vertex group, if doesnt exists add a new layer */
                                                if (defgrp_index >= 0 && !dvert && (surface->output_name[0] != '\0'))
                                                        dvert = CustomData_add_layer_named(&result->vertData, CD_MDEFORMVERT, CD_CALLOC,
-                                                                                                                               NULL, sData->total_points, surface->output_name);
+                                                                                          NULL, sData->total_points, surface->output_name);
                                                if (defgrp_index >= 0 && dvert) {
                                                        int i;
-                                                       for (i=0; i<sData->total_points; i++) {
-                                                               MDeformVert *dv= &dvert[i];
+                                                       for (i = 0; i < sData->total_points; i++) {
+                                                               MDeformVert *dv = &dvert[i];
                                                                MDeformWeight *def_weight = defvert_find_index(dv, defgrp_index);
 
                                                                /* skip if weight value is 0 and no existing weight is found */
@@ -1766,7 +1764,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
 
                                                                        /* if not found, add a weight for it */
                                                                        if (def_weight == NULL) {
-                                                                               def_weight= defvert_verify_index(dv, defgrp_index);
+                                                                               def_weight = defvert_verify_index(dv, defgrp_index);
                                                                        }
 
                                                                        /* set weight value */
@@ -1779,10 +1777,10 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                        else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
                                                MVert *mvert = result->getVertArray(result);
                                                int i;
-                                               PaintWavePoint* wPoint = (PaintWavePoint*)sData->type_data;
+                                               PaintWavePoint *wPoint = (PaintWavePoint *)sData->type_data;
 
                                                #pragma omp parallel for schedule(static)
-                                               for (i=0; i<sData->total_points; i++) {
+                                               for (i = 0; i < sData->total_points; i++) {
                                                        float normal[3];
                                                        normal_short_to_float_v3(normal, mvert[i].no);
                                                        madd_v3_v3fl(mvert[i].co, normal, wPoint[i].height);
@@ -1827,8 +1825,8 @@ void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
 }
 
 /*
-     Updates derived mesh copy and processes dynamic paint step / caches.
-*/
+ *     Updates derived mesh copy and processes dynamic paint step / caches.
+ */
 static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
 {
        if (pmd->canvas) {
@@ -1842,7 +1840,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
                if (canvas->flags & MOD_DPAINT_BAKING) return;
 
                /* loop through surfaces */
-               for (; surface; surface=surface->next) {
+               for (; surface; surface = surface->next) {
                        int current_frame = (int)scene->r.cfra;
 
                        /* free bake data if not required anymore */
@@ -1903,10 +1901,9 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
 }
 
 /* Modifier call. Processes dynamic paint modifier step. */
-struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
-{      
+struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm){
        /* For now generate tessfaces in every case
-       *  XXX - move/remove when most of dpaint functions are converted to use bmesh types */
+        *  XXX - move/remove when most of dpaint functions are converted to use bmesh types */
        DM_ensure_tessface(dm);
 
        /* Update canvas data for a new frame */
@@ -1920,19 +1917,19 @@ struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scen
 /***************************** Image Sequence / UV Image Surface Calls ******************************/
 
 /*
-     Tries to find the neighboring pixel in given (uv space) direction.
-     Result is used by effect system to move paint on the surface.
-*
-*   px, py : origin pixel x and y
-     n_index : lookup direction index (use neighX, neighY to get final index)
-*/
+ *     Tries to find the neighboring pixel in given (uv space) direction.
+ *     Result is used by effect system to move paint on the surface.
+ *
+ *   px, py : origin pixel x and y
+ *     n_index : lookup direction index (use neighX, neighY to get final index)
+ */
 static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh *dm,
                                            const char *uvname, int w, int h, int px, int py, int n_index)
 {
        /* Note: Current method only uses polygon edges to detect neighboring pixels.
-       *  -> It doesn't always lead to the optimum pixel but is accurate enough
-       *  and faster/simplier than including possible face tip point links)
-       */
+        *  -> It doesn't always lead to the optimum pixel but is accurate enough
+        *  and faster/simplier than including possible face tip point links)
+        */
 
        int x, y;
        PaintUVPoint *tPoint = NULL;
@@ -1942,44 +1939,44 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
        x = px + neighX[n_index];
        y = py + neighY[n_index];
 
-       if (x<0 || x>=w) return OUT_OF_TEXTURE;
-       if (y<0 || y>=h) return OUT_OF_TEXTURE;
+       if (x < 0 || x >= w) return OUT_OF_TEXTURE;
+       if (y < 0 || y >= h) return OUT_OF_TEXTURE;
 
-       tPoint = &tempPoints[x+w*y];            /* UV neighbor */
-       cPoint = &tempPoints[px+w*py];          /* Origin point */
+       tPoint = &tempPoints[x + w * y];        /* UV neighbor */
+       cPoint = &tempPoints[px + w * py];      /* Origin point */
 
        /*
-             Check if shifted point is on same face -> it's a correct neighbor
-       *   (and if it isn't marked as an "edge pixel")
-       */
+        *      Check if shifted point is on same face -> it's a correct neighbor
+        *   (and if it isn't marked as an "edge pixel")
+        */
        if ((tPoint->face_index == cPoint->face_index) && (tPoint->neighbour_pixel == -1))
-               return (x+w*y);
+               return (x + w * y);
 
        /*
-             Even if shifted point is on another face
-             -> use this point.
-       *       
-             !! Replace with "is uv faces linked" check !!
-             This should work fine as long as uv island
-             margin is > 1 pixel.
-       */
+        *      Even if shifted point is on another face
+        *      -> use this point.
+        *
+        *      !! Replace with "is uv faces linked" check !!
+        *      This should work fine as long as uv island
+        *      margin is > 1 pixel.
+        */
        if ((tPoint->face_index != -1) && (tPoint->neighbour_pixel == -1)) {
-               return (x+w*y);
+               return (x + w * y);
        }
 
        /*
-             If we get here, the actual neighboring pixel
-             is located on a non-linked uv face, and we have to find
-             it's "real" position.
-       *
-             Simple neighboring face finding algorithm:
-             - find closest uv edge to shifted pixel and get
-               the another face that shares that edge
-             - find corresponding position of that new face edge
-               in uv space
-       *
-             TODO: Implement something more accurate / optimized?
-       */
+        *      If we get here, the actual neighboring pixel
+        *      is located on a non-linked uv face, and we have to find
+        *      it's "real" position.
+        *
+        *      Simple neighboring face finding algorithm:
+        *      - find closest uv edge to shifted pixel and get
+        *        the another face that shares that edge
+        *      - find corresponding position of that new face edge
+        *        in uv space
+        *
+        *      TODO: Implement something more accurate / optimized?
+        */
        {
                int numOfFaces = dm->getNumTessFaces(dm);
                MFace *mface = dm->getTessFaceArray(dm);
@@ -1989,7 +1986,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
                {
                        float pixel[2], dist, t_dist;
                        int i, uindex[3], edge1_index, edge2_index,
-                               e1_index, e2_index, target_face;
+                           e1_index, e2_index, target_face;
                        float closest_point[2], lambda, dir_vec[2];
                        int target_uv1, target_uv2, final_pixel[2], final_index;
 
@@ -2007,41 +2004,41 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
                        }
 
                        /*
-                             Find closest edge to that pixel
-                       */
+                        *      Find closest edge to that pixel
+                        */
                        /* Dist to first edge   */
                        e1_index = cPoint->v1; e2_index = cPoint->v2; edge1_index = uindex[0]; edge2_index = uindex[1];
                        dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[edge1_index], tface[cPoint->face_index].uv[edge2_index]);
 
                        /* Dist to second edge  */
                        t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]);
-                       if (t_dist < dist) {e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist;}
+                       if (t_dist < dist) {e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; }
 
                        /* Dist to third edge   */
                        t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]);
-                       if (t_dist < dist) {e1_index = cPoint->v3; e2_index = cPoint->v1;  edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist;}
+                       if (t_dist < dist) {e1_index = cPoint->v3; e2_index = cPoint->v1;  edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; }
 
 
                        /*
-                             Now find another face that is linked to that edge
-                       */
+                        *      Now find another face that is linked to that edge
+                        */
                        target_face = -1;
 
-                       for (i=0; i<numOfFaces; i++) {
+                       for (i = 0; i < numOfFaces; i++) {
                                /*
-                                     Check if both edge vertices share this face
-                               */
+                                *      Check if both edge vertices share this face
+                                */
                                int v4 = (mface[i].v4) ? mface[i].v4 : -1;
 
                                if ((e1_index == mface[i].v1 || e1_index == mface[i].v2 || e1_index == mface[i].v3 || e1_index == v4) &&
-                                       (e2_index == mface[i].v1 || e2_index == mface[i].v2 || e2_index == mface[i].v3 || e2_index == v4)) {
+                                   (e2_index == mface[i].v1 || e2_index == mface[i].v2 || e2_index == mface[i].v3 || e2_index == v4)) {
                                        if (i == cPoint->face_index) continue;
 
                                        target_face = i;
 
                                        /*
-                                             Get edge UV index
-                                       */
+                                        *      Get edge UV index
+                                        */
                                        if (e1_index == mface[i].v1) target_uv1 = 0;
                                        else if (e1_index == mface[i].v2) target_uv1 = 1;
                                        else if (e1_index == mface[i].v3) target_uv1 = 2;
@@ -2060,8 +2057,8 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
                        if (target_face == -1) return ON_MESH_EDGE;
 
                        /*
-                             If target face is connected in UV space as well, just use original index
-                       */
+                        *      If target face is connected in UV space as well, just use original index
+                        */
                        s_uv1 = (float *)tface[cPoint->face_index].uv[edge1_index];
                        s_uv2 = (float *)tface[cPoint->face_index].uv[edge2_index];
                        t_uv1 = (float *)tface[target_face].uv[target_uv1];
@@ -2074,13 +2071,13 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
                            ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
                             (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) ))
                        {
-                               return ((px+neighX[n_index]) + w*(py+neighY[n_index]));
+                               return ((px + neighX[n_index]) + w * (py + neighY[n_index]));
                        }
 
                        /*
-                             Find a point that is relatively at same edge position
-                             on this other face UV
-                       */
+                        *      Find a point that is relatively at same edge position
+                        *      on this other face UV
+                        */
                        lambda = closest_to_line_v2(closest_point, pixel, tface[cPoint->face_index].uv[edge1_index], tface[cPoint->face_index].uv[edge2_index]);
                        if (lambda < 0.0f) lambda = 0.0f;
                        if (lambda > 1.0f) lambda = 1.0f;
@@ -2104,13 +2101,13 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
                        final_index = final_pixel[0] + w * final_pixel[1];
 
                        /* If we ended up to our origin point ( mesh has smaller than pixel sized faces)        */
-                       if (final_index == (px+w*py)) return NOT_FOUND;
+                       if (final_index == (px + w * py)) return NOT_FOUND;
                        /* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces)   */
                        if (tempPoints[final_index].face_index != target_face) return NOT_FOUND;
 
                        /*
-                             If final point is an "edge pixel", use it's "real" neighbor instead
-                       */
+                        *      If final point is an "edge pixel", use it's "real" neighbor instead
+                        */
                        if (tempPoints[final_index].neighbour_pixel != -1) final_index = cPoint->neighbour_pixel;
 
                        return final_index;
@@ -2119,16 +2116,16 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
 }
 
 /*
-     Create a surface for uv image sequence format
-*/
+ *     Create a surface for uv image sequence format
+ */
 int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
 {
        /* Antialias jitter point relative coords       */
        float jitter5sample[10] =  {0.0f, 0.0f,
-                                                       -0.2f, -0.4f,
-                                                       0.2f, 0.4f,
-                                                       0.4f, -0.2f,
-                                                       -0.4f, 0.3f};
+                                       -0.2f, -0.4f,
+                                       0.2f, 0.4f,
+                                       0.4f, -0.2f,
+                                       -0.4f, 0.3f};
        int ty;
        int w, h;
        int numOfFaces;
@@ -2165,8 +2162,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
        w = h = surface->image_resolution;
 
        /*
-             Start generating the surface
-       */
+        *      Start generating the surface
+        */
        printf("DynamicPaint: Preparing UV surface of %ix%i pixels and %i faces.\n", w, h, numOfFaces);
 
        /* Init data struct */
@@ -2175,55 +2172,55 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
        if (!surface->data) return setError(canvas, "Not enough free memory.");
 
        aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
-       tempPoints = (struct PaintUVPoint *) MEM_callocN(w*h*sizeof(struct PaintUVPoint), "Temp PaintUVPoint");
-       if (!tempPoints) error=1;
+       tempPoints = (struct PaintUVPoint *) MEM_callocN(w * h * sizeof(struct PaintUVPoint), "Temp PaintUVPoint");
+       if (!tempPoints) error = 1;
 
-       final_index = (int *) MEM_callocN(w*h*sizeof(int), "Temp UV Final Indexes");
-       if (!final_index) error=1;
+       final_index = (int *) MEM_callocN(w * h * sizeof(int), "Temp UV Final Indexes");
+       if (!final_index) error = 1;
 
-       tempWeights = (struct Vec3f *) MEM_mallocN(w*h*aa_samples*sizeof(struct Vec3f), "Temp bWeights");
-       if (!tempWeights) error=1;
+       tempWeights = (struct Vec3f *) MEM_mallocN(w * h * aa_samples * sizeof(struct Vec3f), "Temp bWeights");
+       if (!tempWeights) error = 1;
 
        /*
-             Generate a temporary bounding box array for UV faces to optimize
-             the pixel-inside-a-face search.
-       */
+        *      Generate a temporary bounding box array for UV faces to optimize
+        *      the pixel-inside-a-face search.
+        */
        if (!error) {
-               faceBB = (struct Bounds2D *) MEM_mallocN(numOfFaces*sizeof(struct Bounds2D), "MPCanvasFaceBB");
-               if (!faceBB) error=1;
+               faceBB = (struct Bounds2D *) MEM_mallocN(numOfFaces * sizeof(struct Bounds2D), "MPCanvasFaceBB");
+               if (!faceBB) error = 1;
        }
 
        if (!error)
-       for (ty=0; ty<numOfFaces; ty++) {
-               int numOfVert = (mface[ty].v4) ? 4 : 3;
-               int i;
+               for (ty = 0; ty < numOfFaces; ty++) {
+                       int numOfVert = (mface[ty].v4) ? 4 : 3;
+                       int i;
 
-               copy_v2_v2(faceBB[ty].min, tface[ty].uv[0]);
-               copy_v2_v2(faceBB[ty].max, tface[ty].uv[0]);
+                       copy_v2_v2(faceBB[ty].min, tface[ty].uv[0]);
+                       copy_v2_v2(faceBB[ty].max, tface[ty].uv[0]);
 
-               for (i = 1; i<numOfVert; i++) {
-                       if (tface[ty].uv[i][0] < faceBB[ty].min[0]) faceBB[ty].min[0] = tface[ty].uv[i][0];
-                       if (tface[ty].uv[i][1] < faceBB[ty].min[1]) faceBB[ty].min[1] = tface[ty].uv[i][1];
-                       if (tface[ty].uv[i][0] > faceBB[ty].max[0]) faceBB[ty].max[0] = tface[ty].uv[i][0];
-                       if (tface[ty].uv[i][1] > faceBB[ty].max[1]) faceBB[ty].max[1] = tface[ty].uv[i][1];
+                       for (i = 1; i < numOfVert; i++) {
+                               if (tface[ty].uv[i][0] < faceBB[ty].min[0]) faceBB[ty].min[0] = tface[ty].uv[i][0];
+                               if (tface[ty].uv[i][1] < faceBB[ty].min[1]) faceBB[ty].min[1] = tface[ty].uv[i][1];
+                               if (tface[ty].uv[i][0] > faceBB[ty].max[0]) faceBB[ty].max[0] = tface[ty].uv[i][0];
+                               if (tface[ty].uv[i][1] > faceBB[ty].max[1]) faceBB[ty].max[1] = tface[ty].uv[i][1];
 
+                       }
                }
-       }
 
        /*
-             Loop through every pixel and check
-             if pixel is uv-mapped on a canvas face.
-       */
+        *      Loop through every pixel and check
+        *      if pixel is uv-mapped on a canvas face.
+        */
        if (!error) {
                #pragma omp parallel for schedule(static)
                for (ty = 0; ty < h; ty++) {
                        int tx;
                        for (tx = 0; tx < w; tx++) {
                                int i, sample;
-                               int index = tx+w*ty;
+                               int index = tx + w * ty;
                                PaintUVPoint *tPoint = (&tempPoints[index]);
 
-                               short isInside = 0;     /* if point is inside a uv face */
+                               short isInside = 0; /* if point is inside a uv face */
 
                                float d1[2], d2[2], d3[2], point[5][2];
                                float dot00, dot01, dot02, dot11, dot12, invDenom, u, v;
@@ -2238,27 +2235,27 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
                                point[0][1] = ((float)ty + 0.5f) / h;
 
                                /*
-                               * A pixel middle sample isn't enough to find very narrow polygons
-                               * So using 4 samples of each corner too
-                               */
+                                * A pixel middle sample isn't enough to find very narrow polygons
+                                * So using 4 samples of each corner too
+                                */
                                point[1][0] = ((float)tx) / w;
                                point[1][1] = ((float)ty) / h;
 
-                               point[2][0] = ((float)tx+1) / w;
+                               point[2][0] = ((float)tx + 1) / w;
                                point[2][1] = ((float)ty) / h;
 
                                point[3][0] = ((float)tx) / w;
-                               point[3][1] = ((float)ty+1) / h;
+                               point[3][1] = ((float)ty + 1) / h;
 
-                               point[4][0] = ((float)tx+1) / w;
-                               point[4][1] = ((float)ty+1) / h;
+                               point[4][0] = ((float)tx + 1) / w;
+                               point[4][1] = ((float)ty + 1) / h;
 
 
                                /* Loop through samples, starting from middle point     */
-                               for (sample=0; sample<5; sample++) {
+                               for (sample = 0; sample < 5; sample++) {
                                        
                                        /* Loop through every face in the mesh  */
-                                       for (i=0; i<numOfFaces; i++) {
+                                       for (i = 0; i < numOfFaces; i++) {
 
                                                /* Check uv bb  */
                                                if (faceBB[i].min[0] > (point[sample][0])) continue;
@@ -2267,55 +2264,55 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
                                                if (faceBB[i].max[1] < (point[sample][1])) continue;
 
                                                /*  Calculate point inside a triangle check
-                                                     for uv0, 1, 2 */
-                                               sub_v2_v2v2(d1,  tface[i].uv[2], tface[i].uv[0]);       // uv2 - uv0
-                                               sub_v2_v2v2(d2,  tface[i].uv[1], tface[i].uv[0]);       // uv1 - uv0
-                                               sub_v2_v2v2(d3,  point[sample], tface[i].uv[0]);        // point - uv0
+                                                *      for uv0, 1, 2 */
+                                               sub_v2_v2v2(d1,  tface[i].uv[2], tface[i].uv[0]);   // uv2 - uv0
+                                               sub_v2_v2v2(d2,  tface[i].uv[1], tface[i].uv[0]);   // uv1 - uv0
+                                               sub_v2_v2v2(d3,  point[sample], tface[i].uv[0]);    // point - uv0
 
-                                               dot00 = d1[0]*d1[0] + d1[1]*d1[1];
-                                               dot01 = d1[0]*d2[0] + d1[1]*d2[1];
-                                               dot02 = d1[0]*d3[0] + d1[1]*d3[1];
-                                               dot11 = d2[0]*d2[0] + d2[1]*d2[1];
-                                               dot12 = d2[0]*d3[0] + d2[1]*d3[1];
+                                               dot00 = d1[0] * d1[0] + d1[1] * d1[1];
+                                               dot01 = d1[0] * d2[0] + d1[1] * d2[1];
+                                               dot02 = d1[0] * d3[0] + d1[1] * d3[1];
+                                               dot11 = d2[0] * d2[0] + d2[1] * d2[1];
+                                               dot12 = d2[0] * d3[0] + d2[1] * d3[1];
 
                                                invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
                                                u = (dot11 * dot02 - dot01 * dot12) * invDenom;
                                                v = (dot00 * dot12 - dot01 * dot02) * invDenom;
 
-                                               if ((u > 0) && (v > 0) && (u + v < 1)) {isInside=1;} /* is inside a triangle */
+                                               if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 1; } /* is inside a triangle */
 
                                                /*  If collision wasn't found but the face is a quad
-                                                     do another check for the second half */
+                                                *      do another check for the second half */
                                                if ((!isInside) && mface[i].v4) {
 
                                                        /* change d2 to test the other half     */
-                                                       sub_v2_v2v2(d2,  tface[i].uv[3], tface[i].uv[0]);       // uv3 - uv0
+                                                       sub_v2_v2v2(d2,  tface[i].uv[3], tface[i].uv[0]);   // uv3 - uv0
 
                                                        /* test again   */
-                                                       dot00 = d1[0]*d1[0] + d1[1]*d1[1];
-                                                       dot01 = d1[0]*d2[0] + d1[1]*d2[1];
-                                                       dot02 = d1[0]*d3[0] + d1[1]*d3[1];
-                                                       dot11 = d2[0]*d2[0] + d2[1]*d2[1];
-                                                       dot12 = d2[0]*d3[0] + d2[1]*d3[1];
+                                                       dot00 = d1[0]