style cleanup
authorCampbell Barton <ideasman42@gmail.com>
Fri, 30 Mar 2012 10:00:20 +0000 (10:00 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 30 Mar 2012 10:00:20 +0000 (10:00 +0000)
source/blender/editors/util/crazyspace.c
source/blender/editors/util/ed_util.c
source/blender/editors/util/editmode_undo.c
source/blender/editors/util/numinput.c
source/blender/editors/util/undo.c

index cef440668e637ba223a53cdc33924432175ac6b0..d63ad7f58e6519c3a79c007c33231239f979db67 100644 (file)
@@ -54,7 +54,7 @@ typedef struct {
        short *flags;
 } MappedUserData;
 
-#define TAN_MAKE_VEC(a, b, c)  a[0]= b[0] + 0.2f*(b[0]-c[0]); a[1]= b[1] + 0.2f*(b[1]-c[1]); a[2]= b[2] + 0.2f*(b[2]-c[2])
+#define TAN_MAKE_VEC(a, b, c)   a[0] = b[0] + 0.2f * (b[0] - c[0]); a[1] = b[1] + 0.2f * (b[1] - c[1]); a[2] = b[2] + 0.2f * (b[2] - c[2])
 static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, float *def1, float *def2, float *def3)
 {
        float vecu[3], vecv[3];
@@ -62,11 +62,11 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3,
 
        TAN_MAKE_VEC(vecu, v1, v2);
        TAN_MAKE_VEC(vecv, v1, v3);
-       tri_to_quat( q1,v1, vecu, vecv);
+       tri_to_quat(q1, v1, vecu, vecv);
 
        TAN_MAKE_VEC(vecu, def1, def2);
        TAN_MAKE_VEC(vecv, def1, def3);
-       tri_to_quat( q2,def1, vecu, vecv);
+       tri_to_quat(q2, def1, vecu, vecv);
 
        sub_qt_qtqt(quat, q2, q1);
 }
@@ -74,15 +74,15 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3,
 
 static void make_vertexcos__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 {
-       MappedUserData *mappedData= (MappedUserData*)userData;
+       MappedUserData *mappedData = (MappedUserData *)userData;
        float *vec = mappedData->vertexcos;
 
-       vec+= 3*index;
+       vec += 3 * index;
        if (!mappedData->flags[index]) {
                /* we need coord from prototype vertex, not it clones or images,
                 * suppose they stored in the beginning of vertex array stored in DM */
                copy_v3_v3(vec, co);
-               mappedData->flags[index]= 1;
+               mappedData->flags[index] = 1;
        }
 }
 
@@ -91,11 +91,11 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
        ModifierData *md;
        int disabled = 0;
 
-       for (md=ob->modifiers.first; md; md=md->next)
-               if (md->type==eModifierType_Subsurf)
+       for (md = ob->modifiers.first; md; md = md->next)
+               if (md->type == eModifierType_Subsurf)
                        if (md->mode & eModifierMode_OnCage) {
                                md->mode ^= eModifierMode_DisableTemporary;
-                               disabled= 1;
+                               disabled = 1;
                        }
 
        return disabled;
@@ -104,10 +104,10 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
 /* disable subsurf temporal, get mapped cos, and enable it */
 float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit)
 {
-       Mesh *me= obedit->data;
+       Mesh *me = obedit->data;
        DerivedMesh *dm;
        float *vertexcos;
-       int nverts= me->edit_btmesh->bm->totvert;
+       int nverts = me->edit_btmesh->bm->totvert;
        short *flags;
        MappedUserData userData;
 
@@ -118,13 +118,13 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit)
        }
 
        /* now get the cage */
-       dm= editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
+       dm = editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
 
-       vertexcos= MEM_callocN(3*sizeof(float)*nverts, "vertexcos map");
-       flags= MEM_callocN(sizeof(short)*nverts, "vertexcos flags");
+       vertexcos = MEM_callocN(3 * sizeof(float) * nverts, "vertexcos map");
+       flags = MEM_callocN(sizeof(short) * nverts, "vertexcos flags");
 
-       userData.vertexcos= vertexcos;
-       userData.flags= flags;
+       userData.vertexcos = vertexcos;
+       userData.flags = flags;
        dm->foreachMappedVert(dm, make_vertexcos__mapFunc, &userData);
 
        dm->release(dm);
@@ -143,31 +143,33 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
        BMIter iter, liter;
        BMLoop *l;
        float *v1, *v2, *v3, *co1, *co2, *co3;
-       int *vert_table = MEM_callocN(sizeof(int)*em->bm->totvert, "vert_table");
+       int *vert_table = MEM_callocN(sizeof(int) * em->bm->totvert, "vert_table");
        int index = 0;
 
        BM_mesh_elem_index_ensure(em->bm, BM_VERT);
 
-       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
+       {
                if (!BM_elem_flag_test(v, BM_ELEM_SELECT) || BM_elem_flag_test(v, BM_ELEM_HIDDEN))
                        continue;
                
-               BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_VERT, v) {
+               BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_VERT, v)
+               {
                        BMLoop *l2 = BM_face_other_edge_loop(l->f, l->e, v);
                        
                        /* retrieve mapped coordinates */
-                       v1= mappedcos + 3*BM_elem_index_get(l->v);
-                       v2= mappedcos + 3*BM_elem_index_get(BM_edge_other_vert(l2->e, l->v));
-                       v3= mappedcos + 3*BM_elem_index_get(BM_edge_other_vert(l->e, l->v));
-                       
-                       co1= (origcos)? origcos + 3*BM_elem_index_get(l->v) : l->v->co;
-                       co2= (origcos)? origcos + 3*BM_elem_index_get(BM_edge_other_vert(l2->e, l->v)) : BM_edge_other_vert(l2->e, l->v)->co;
-                       co3= (origcos)? origcos + 3*BM_elem_index_get(BM_edge_other_vert(l->e, l->v)) : BM_edge_other_vert(l->e, l->v)->co;
+                       v1 = mappedcos + 3 * BM_elem_index_get(l->v);
+                       v2 = mappedcos + 3 * BM_elem_index_get(BM_edge_other_vert(l2->e, l->v));
+                       v3 = mappedcos + 3 * BM_elem_index_get(BM_edge_other_vert(l->e, l->v));
+
+                       co1 = (origcos) ? origcos + 3 * BM_elem_index_get(l->v) : l->v->co;
+                       co2 = (origcos) ? origcos + 3 * BM_elem_index_get(BM_edge_other_vert(l2->e, l->v)) : BM_edge_other_vert(l2->e, l->v)->co;
+                       co3 = (origcos) ? origcos + 3 * BM_elem_index_get(BM_edge_other_vert(l->e, l->v)) : BM_edge_other_vert(l->e, l->v)->co;
                        
                        set_crazy_vertex_quat(quats, v1, v2, v3, co1, co2, co3);
-                       quats+= 4;
+                       quats += 4;
                        
-                       vert_table[BM_elem_index_get(l->v)] = index+1;
+                       vert_table[BM_elem_index_get(l->v)] = index + 1;
                        
                        index++;
                        break; /*just do one corner*/
@@ -177,9 +179,9 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
        index = 0;
        BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
                if (vert_table[index] != 0)
-                       BM_elem_index_set(v, vert_table[index]-1); /* set_dirty! */
+                       BM_elem_index_set(v, vert_table[index] - 1);  /* set_dirty! */
                else
-                       BM_elem_index_set(v, -1); /* set_dirty! */
+                       BM_elem_index_set(v, -1);  /* set_dirty! */
                
                index++;
        }
@@ -191,69 +193,69 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
        BMEditFace *efa;
        BMIter iter;
        float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
-       intptr_t index= 0;
+       intptr_t index = 0;
 
        /* two abused locations in vertices */
-       for (eve= em->verts.first; eve; eve= eve->next, index++) {
+       for (eve = em->verts.first; eve; eve = eve->next, index++) {
                eve->tmp.p = NULL;
-               eve->prev= (EditVert *)index;
+               eve->prev = (EditVert *)index;
        }
 
        /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
-       for (efa= em->faces.first; efa; efa= efa->next) {
+       for (efa = em->faces.first; efa; efa = efa->next) {
 
                /* retrieve mapped coordinates */
-               v1= mappedcos + 3*(intptr_t)(efa->v1->prev);
-               v2= mappedcos + 3*(intptr_t)(efa->v2->prev);
-               v3= mappedcos + 3*(intptr_t)(efa->v3->prev);
+               v1 = mappedcos + 3 * (intptr_t)(efa->v1->prev);
+               v2 = mappedcos + 3 * (intptr_t)(efa->v2->prev);
+               v3 = mappedcos + 3 * (intptr_t)(efa->v3->prev);
 
-               co1= (origcos)? origcos + 3*(intptr_t)(efa->v1->prev): efa->v1->co;
-               co2= (origcos)? origcos + 3*(intptr_t)(efa->v2->prev): efa->v2->co;
-               co3= (origcos)? origcos + 3*(intptr_t)(efa->v3->prev): efa->v3->co;
+               co1 = (origcos) ? origcos + 3 * (intptr_t)(efa->v1->prev) : efa->v1->co;
+               co2 = (origcos) ? origcos + 3 * (intptr_t)(efa->v2->prev) : efa->v2->co;
+               co3 = (origcos) ? origcos + 3 * (intptr_t)(efa->v3->prev) : efa->v3->co;
 
-               if (efa->v2->tmp.p==NULL && efa->v2->f1) {
+               if (efa->v2->tmp.p == NULL && efa->v2->f1) {
                        set_crazy_vertex_quat(quats, co2, co3, co1, v2, v3, v1);
-                       efa->v2->tmp.p= (void*)quats;
-                       quats+= 4;
+                       efa->v2->tmp.p = (void *)quats;
+                       quats += 4;
                }
 
                if (efa->v4) {
-                       v4= mappedcos + 3*(intptr_t)(efa->v4->prev);
-                       co4= (origcos)? origcos + 3*(intptr_t)(efa->v4->prev): efa->v4->co;
+                       v4 = mappedcos + 3 * (intptr_t)(efa->v4->prev);
+                       co4 = (origcos) ? origcos + 3 * (intptr_t)(efa->v4->prev) : efa->v4->co;
 
-                       if (efa->v1->tmp.p==NULL && efa->v1->f1) {
+                       if (efa->v1->tmp.p == NULL && efa->v1->f1) {
                                set_crazy_vertex_quat(quats, co1, co2, co4, v1, v2, v4);
-                               efa->v1->tmp.p= (void*)quats;
-                               quats+= 4;
+                               efa->v1->tmp.p = (void *)quats;
+                               quats += 4;
                        }
-                       if (efa->v3->tmp.p==NULL && efa->v3->f1) {
+                       if (efa->v3->tmp.p == NULL && efa->v3->f1) {
                                set_crazy_vertex_quat(quats, co3, co4, co2, v3, v4, v2);
-                               efa->v3->tmp.p= (void*)quats;
-                               quats+= 4;
+                               efa->v3->tmp.p = (void *)quats;
+                               quats += 4;
                        }
-                       if (efa->v4->tmp.p==NULL && efa->v4->f1) {
+                       if (efa->v4->tmp.p == NULL && efa->v4->f1) {
                                set_crazy_vertex_quat(quats, co4, co1, co3, v4, v1, v3);
-                               efa->v4->tmp.p= (void*)quats;
-                               quats+= 4;
+                               efa->v4->tmp.p = (void *)quats;
+                               quats += 4;
                        }
                }
                else {
-                       if (efa->v1->tmp.p==NULL && efa->v1->f1) {
+                       if (efa->v1->tmp.p == NULL && efa->v1->f1) {
                                set_crazy_vertex_quat(quats, co1, co2, co3, v1, v2, v3);
-                               efa->v1->tmp.p= (void*)quats;
-                               quats+= 4;
+                               efa->v1->tmp.p = (void *)quats;
+                               quats += 4;
                        }
-                       if (efa->v3->tmp.p==NULL && efa->v3->f1) {
+                       if (efa->v3->tmp.p == NULL && efa->v3->f1) {
                                set_crazy_vertex_quat(quats, co3, co1, co2, v3, v1, v2);
-                               efa->v3->tmp.p= (void*)quats;
-                               quats+= 4;
+                               efa->v3->tmp.p = (void *)quats;
+                               quats += 4;
                        }
                }
        }
 
        /* restore abused prev pointer */
-       for (prev= NULL, eve= em->verts.first; eve; prev= eve, eve= eve->next)
-               eve->prev= prev;
+       for (prev = NULL, eve = em->verts.first; eve; prev = eve, eve = eve->next)
+               eve->prev = prev;
 #endif
 }
 
@@ -266,61 +268,61 @@ void crazyspace_set_quats_mesh(Mesh *me, float *origcos, float *mappedcos, float
        MFace *mface;
        float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
 
-       mvert= me->mvert;
-       for (i=0; i<me->totvert; i++, mvert++)
-               mvert->flag&= ~ME_VERT_TMP_TAG;
+       mvert = me->mvert;
+       for (i = 0; i < me->totvert; i++, mvert++)
+               mvert->flag &= ~ME_VERT_TMP_TAG;
 
        /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
-       mvert= me->mvert;
-       mface= me->mface;
-       for (i=0; i<me->totface; i++, mface++) {
+       mvert = me->mvert;
+       mface = me->mface;
+       for (i = 0; i < me->totface; i++, mface++) {
 
                /* retrieve mapped coordinates */
-               v1= mappedcos + 3*mface->v1;
-               v2= mappedcos + 3*mface->v2;
-               v3= mappedcos + 3*mface->v3;
+               v1 = mappedcos + 3 * mface->v1;
+               v2 = mappedcos + 3 * mface->v2;
+               v3 = mappedcos + 3 * mface->v3;
 
-               co1= (origcos)? origcos + 3*mface->v1: mvert[mface->v1].co;
-               co2= (origcos)? origcos + 3*mface->v2: mvert[mface->v2].co;
-               co3= (origcos)? origcos + 3*mface->v3: mvert[mface->v3].co;
+               co1 = (origcos) ? origcos + 3 * mface->v1 : mvert[mface->v1].co;
+               co2 = (origcos) ? origcos + 3 * mface->v2 : mvert[mface->v2].co;
+               co3 = (origcos) ? origcos + 3 * mface->v3 : mvert[mface->v3].co;
 
-               if ((mvert[mface->v2].flag&ME_VERT_TMP_TAG)==0) {
-                       set_crazy_vertex_quat(&quats[mface->v2*4], co2, co3, co1, v2, v3, v1);
-                       mvert[mface->v2].flag|= ME_VERT_TMP_TAG;
+               if ((mvert[mface->v2].flag & ME_VERT_TMP_TAG) == 0) {
+                       set_crazy_vertex_quat(&quats[mface->v2 * 4], co2, co3, co1, v2, v3, v1);
+                       mvert[mface->v2].flag |= ME_VERT_TMP_TAG;
                }
 
                if (mface->v4) {
-                       v4= mappedcos + 3*mface->v4;
-                       co4= (origcos)? origcos + 3*mface->v4: mvert[mface->v4].co;
+                       v4 = mappedcos + 3 * mface->v4;
+                       co4 = (origcos) ? origcos + 3 * mface->v4 : mvert[mface->v4].co;
 
-                       if ((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) {
-                               set_crazy_vertex_quat(&quats[mface->v1*4], co1, co2, co4, v1, v2, v4);
-                               mvert[mface->v1].flag|= ME_VERT_TMP_TAG;
+                       if ((mvert[mface->v1].flag & ME_VERT_TMP_TAG) == 0) {
+                               set_crazy_vertex_quat(&quats[mface->v1 * 4], co1, co2, co4, v1, v2, v4);
+                               mvert[mface->v1].flag |= ME_VERT_TMP_TAG;
                        }
-                       if ((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) {
-                               set_crazy_vertex_quat(&quats[mface->v3*4], co3, co4, co2, v3, v4, v2);
-                               mvert[mface->v3].flag|= ME_VERT_TMP_TAG;
+                       if ((mvert[mface->v3].flag & ME_VERT_TMP_TAG) == 0) {
+                               set_crazy_vertex_quat(&quats[mface->v3 * 4], co3, co4, co2, v3, v4, v2);
+                               mvert[mface->v3].flag |= ME_VERT_TMP_TAG;
                        }
-                       if ((mvert[mface->v4].flag&ME_VERT_TMP_TAG)==0) {
-                               set_crazy_vertex_quat(&quats[mface->v4*4], co4, co1, co3, v4, v1, v3);
-                               mvert[mface->v4].flag|= ME_VERT_TMP_TAG;
+                       if ((mvert[mface->v4].flag & ME_VERT_TMP_TAG) == 0) {
+                               set_crazy_vertex_quat(&quats[mface->v4 * 4], co4, co1, co3, v4, v1, v3);
+                               mvert[mface->v4].flag |= ME_VERT_TMP_TAG;
                        }
                }
                else {
-                       if ((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) {
-                               set_crazy_vertex_quat(&quats[mface->v1*4], co1, co2, co3, v1, v2, v3);
-                               mvert[mface->v1].flag|= ME_VERT_TMP_TAG;
+                       if ((mvert[mface->v1].flag & ME_VERT_TMP_TAG) == 0) {
+                               set_crazy_vertex_quat(&quats[mface->v1 * 4], co1, co2, co3, v1, v2, v3);
+                               mvert[mface->v1].flag |= ME_VERT_TMP_TAG;
                        }
-                       if ((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) {
-                               set_crazy_vertex_quat(&quats[mface->v3*4], co3, co1, co2, v3, v1, v2);
-                               mvert[mface->v3].flag|= ME_VERT_TMP_TAG;
+                       if ((mvert[mface->v3].flag & ME_VERT_TMP_TAG) == 0) {
+                               set_crazy_vertex_quat(&quats[mface->v3 * 4], co3, co1, co2, v3, v1, v2);
+                               mvert[mface->v3].flag |= ME_VERT_TMP_TAG;
                        }
                }
        }
 }
 
 int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em, 
-                                                                               float (**deformmats)[3][3], float (**deformcos)[3])
+                                        float (**deformmats)[3][3], float (**deformcos)[3])
 {
        ModifierData *md;
        DerivedMesh *dm;
@@ -342,18 +344,18 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em
                if (!editbmesh_modifier_is_enabled(scene, md, dm))
                        continue;
 
-               if (mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
+               if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
                        if (!defmats) {
-                               dm= getEditDerivedBMesh(em, ob, NULL);
-                               deformedVerts= editbmesh_get_vertex_cos(em, &numVerts);
-                               defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
+                               dm = getEditDerivedBMesh(em, ob, NULL);
+                               deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
+                               defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
 
-                               for (a=0; a<numVerts; a++)
+                               for (a = 0; a < numVerts; a++)
                                        unit_m3(defmats[a]);
                        }
 
                        mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
-                               numVerts);
+                                             numVerts);
                }
                else
                        break;
@@ -366,8 +368,8 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em
        if (dm)
                dm->release(dm);
 
-       *deformmats= defmats;
-       *deformcos= deformedVerts;
+       *deformmats = defmats;
+       *deformcos = deformedVerts;
 
        return numleft;
 }
@@ -376,34 +378,34 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma
 {
        ModifierData *md;
        DerivedMesh *dm;
-       int a, numVerts= 0;
-       float (*defmats)[3][3]= NULL, (*deformedVerts)[3]= NULL;
-       MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
+       int a, numVerts = 0;
+       float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
+       MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
        int has_multires = mmd != NULL && mmd->sculptlvl > 0;
-       int numleft= 0;
+       int numleft = 0;
 
        if (has_multires) {
-               *deformmats= NULL;
-               *deformcos= NULL;
+               *deformmats = NULL;
+               *deformcos = NULL;
                return numleft;
        }
 
-       dm= NULL;
-       md= modifiers_getVirtualModifierList(ob);
+       dm = NULL;
+       md = modifiers_getVirtualModifierList(ob);
 
-       for (; md; md= md->next) {
-               ModifierTypeInfo *mti= modifierType_getInfo(md->type);
+       for (; md; md = md->next) {
+               ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
 
-               if (mti->type==eModifierTypeType_OnlyDeform) {
+               if (mti->type == eModifierTypeType_OnlyDeform) {
                        if (!defmats) {
-                               Mesh *me= (Mesh*)ob->data;
-                               dm= mesh_create_derived(me, ob, NULL);
-                               deformedVerts= mesh_getVertexCos(me, &numVerts);
-                               defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
+                               Mesh *me = (Mesh *)ob->data;
+                               dm = mesh_create_derived(me, ob, NULL);
+                               deformedVerts = mesh_getVertexCos(me, &numVerts);
+                               defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");
 
-                               for (a=0; a<numVerts; a++)
+                               for (a = 0; a < numVerts; a++)
                                        unit_m3(defmats[a]);
                        }
 
@@ -412,63 +414,63 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma
                }
        }
 
-       for (; md; md= md->next) {
-               ModifierTypeInfo *mti= modifierType_getInfo(md->type);
+       for (; md; md = md->next) {
+               ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
 
-               if (mti->type==eModifierTypeType_OnlyDeform)
+               if (mti->type == eModifierTypeType_OnlyDeform)
                        numleft++;
        }
 
        if (dm)
                dm->release(dm);
 
-       *deformmats= defmats;
-       *deformcos= deformedVerts;
+       *deformmats = defmats;
+       *deformcos = deformedVerts;
 
        return numleft;
 }
 
 void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
 {
-       int totleft= sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
+       int totleft = sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
 
        if (totleft) {
                /* there are deformation modifier which doesn't support deformation matrices
                 * calculation. Need additional crazyspace correction */
 
-               float (*deformedVerts)[3]= *deformcos;
-               float (*origVerts)[3]= MEM_dupallocN(deformedVerts);
-               float *quats= NULL;
-               int i, deformed= 0;
-               ModifierData *md= modifiers_getVirtualModifierList(ob);
-               Mesh *me= (Mesh*)ob->data;
+               float (*deformedVerts)[3] = *deformcos;
+               float (*origVerts)[3] = MEM_dupallocN(deformedVerts);
+               float *quats = NULL;
+               int i, deformed = 0;
+               ModifierData *md = modifiers_getVirtualModifierList(ob);
+               Mesh *me = (Mesh *)ob->data;
 
-               for (; md; md= md->next) {
-                       ModifierTypeInfo *mti= modifierType_getInfo(md->type);
+               for (; md; md = md->next) {
+                       ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 
                        if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
 
-                       if (mti->type==eModifierTypeType_OnlyDeform) {
+                       if (mti->type == eModifierTypeType_OnlyDeform) {
                                /* skip leading modifiers which have been already
                                 * handled in sculpt_get_first_deform_matrices */
                                if (mti->deformMatrices && !deformed)
                                        continue;
 
                                mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0, 0);
-                               deformed= 1;
+                               deformed = 1;
                        }
                }
 
-               quats= MEM_mallocN(me->totvert*sizeof(float)*4, "crazy quats");
+               quats = MEM_mallocN(me->totvert * sizeof(float) * 4, "crazy quats");
 
-               crazyspace_set_quats_mesh(me, (float*)origVerts, (float*)deformedVerts, quats);
+               crazyspace_set_quats_mesh(me, (float *)origVerts, (float *)deformedVerts, quats);
 
-               for (i=0; i<me->totvert; i++) {
+               for (i = 0; i < me->totvert; i++) {
                        float qmat[3][3], tmat[3][3];
 
-                       quat_to_mat3(qmat, &quats[i*4]);
+                       quat_to_mat3(qmat, &quats[i * 4]);
                        mul_m3_m3m3(tmat, qmat, (*deformmats)[i]);
                        copy_m3_m3((*deformmats)[i], tmat);
                }
@@ -479,12 +481,12 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3
 
        if (!*deformmats) {
                int a, numVerts;
-               Mesh *me= (Mesh*)ob->data;
+               Mesh *me = (Mesh *)ob->data;
 
-               *deformcos= mesh_getVertexCos(me, &numVerts);
-               *deformmats= MEM_callocN(sizeof(*(*deformmats))*numVerts, "defmats");
+               *deformcos = mesh_getVertexCos(me, &numVerts);
+               *deformmats = MEM_callocN(sizeof(*(*deformmats)) * numVerts, "defmats");
 
-               for (a=0; a<numVerts; a++)
+               for (a = 0; a < numVerts; a++)
                        unit_m3((*deformmats)[a]);
        }
 }
index 78616a2c2280fce920d2eb4244279c34539d6f96..5dce3d0a2fadf931c47e56d35ab45d12dcdf03f3 100644 (file)
 
 void ED_editors_init(bContext *C)
 {
-       Main *bmain= CTX_data_main(C);
-       Scene *sce= CTX_data_scene(C);
-       Object *ob, *obact= (sce && sce->basact)? sce->basact->object: NULL;
+       Main *bmain = CTX_data_main(C);
+       Scene *sce = CTX_data_scene(C);
+       Object *ob, *obact = (sce && sce->basact) ? sce->basact->object : NULL;
        ID *data;
 
        /* toggle on modes for objects that were saved with these enabled. for
         * e.g. linked objects we have to ensure that they are actually the
         * active object in this scene. */
-       for (ob=bmain->object.first; ob; ob=ob->id.next) {
-               int mode= ob->mode;
+       for (ob = bmain->object.first; ob; ob = ob->id.next) {
+               int mode = ob->mode;
 
                if (mode && (mode != OB_MODE_POSE)) {
-                       ob->mode= 0;
-                       data= ob->data;
+                       ob->mode = 0;
+                       data = ob->data;
 
                        if (ob == obact && !ob->id.lib && !(data && data->lib))
                                ED_object_toggle_modes(C, mode);
@@ -91,7 +91,7 @@ void ED_editors_init(bContext *C)
 /* frees all editmode stuff */
 void ED_editors_exit(bContext *C)
 {
-       Main *bmain= CTX_data_main(C);
+       Main *bmain = CTX_data_main(C);
        Scene *sce;
 
        if (!bmain)
@@ -101,20 +101,20 @@ void ED_editors_exit(bContext *C)
        undo_editmode_clear();
        ED_undo_paint_free();
        
-       for (sce=bmain->scene.first; sce; sce= sce->id.next) {
+       for (sce = bmain->scene.first; sce; sce = sce->id.next) {
                if (sce->obedit) {
-                       Object *ob= sce->obedit;
+                       Object *ob = sce->obedit;
                
                        if (ob) {
-                               if (ob->type==OB_MESH) {
-                                       Mesh *me= ob->data;
+                               if (ob->type == OB_MESH) {
+                                       Mesh *me = ob->data;
                                        if (me->edit_btmesh) {
                                                EDBM_mesh_free(me->edit_btmesh);
                                                MEM_freeN(me->edit_btmesh);
-                                               me->edit_btmesh= NULL;
+                                               me->edit_btmesh = NULL;
                                        }
                                }
-                               else if (ob->type==OB_ARMATURE) {
+                               else if (ob->type == OB_ARMATURE) {
                                        ED_armature_edit_free(ob);
                                }
                        }
@@ -136,16 +136,16 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl
 {
        /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
        if (invert)
-               ctrl= !ctrl;
+               ctrl = !ctrl;
        
        if (ctrl && shift) {
-               if (fac3 != 0.0f) *val= fac3*floorf(*val/fac3 +0.5f);
+               if (fac3 != 0.0f) *val = fac3 * floorf(*val / fac3 + 0.5f);
        }
        else if (ctrl) {
-               if (fac2 != 0.0f) *val= fac2*floorf(*val/fac2 +0.5f);
+               if (fac2 != 0.0f) *val = fac2 * floorf(*val / fac2 + 0.5f);
        }
        else {
-               if (fac1 != 0.0f) *val= fac1*floorf(*val/fac1 +0.5f);
+               if (fac1 != 0.0f) *val = fac1 * floorf(*val / fac1 + 0.5f);
        }
 }
 
@@ -154,7 +154,7 @@ int GetButStringLength(const char *str)
 {
        int rt;
        
-       rt= UI_GetStringWidth(str);
+       rt = UI_GetStringWidth(str);
        
        return rt + 15;
 }
@@ -168,11 +168,11 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
        char line[FILE_MAX + 100];
        wmOperatorType *ot = WM_operatortype_find(opname, 1);
 
-       pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE);
-       layout= uiPupMenuLayout(pup);
+       pup = uiPupMenuBegin(C, "Unpack file", ICON_NONE);
+       layout = uiPupMenuLayout(pup);
 
        strcpy(line, "Remove Pack");
-       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
        RNA_enum_set(&props_ptr, "method", PF_REMOVE);
        RNA_string_set(&props_ptr, "id", id_name);
 
@@ -182,11 +182,11 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
                BLI_strncpy(local_name, abs_name, sizeof(local_name));
                BLI_splitdirstring(local_name, fi);
                BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
-               if (strcmp(abs_name, local_name)!=0) {
-                       switch(checkPackedFile(local_name, pf)) {
+               if (strcmp(abs_name, local_name) != 0) {
+                       switch (checkPackedFile(local_name, pf)) {
                                case PF_NOFILE:
                                        BLI_snprintf(line, sizeof(line), "Create %s", local_name);
-                                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
 
@@ -194,7 +194,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
                                case PF_EQUAL:
                                        BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name);
                                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
-                                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
 
@@ -202,13 +202,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
                                case PF_DIFFERS:
                                        BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name);
                                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL);
-                                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
 
                                        BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name);
                                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL);
-                                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
                                        break;
@@ -216,31 +216,31 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
                }
        }
 
-       switch(checkPackedFile(abs_name, pf)) {
+       switch (checkPackedFile(abs_name, pf)) {
                case PF_NOFILE:
                        BLI_snprintf(line, sizeof(line), "Create %s", abs_name);
                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
-                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
                        break;
                case PF_EQUAL:
                        BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name);
                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
-                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
                        break;
                case PF_DIFFERS:
                        BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name);
                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL);
-                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
 
                        BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name);
                        //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL);
-                       props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+                       props_ptr = uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
                        break;
index 4416228e2d3284a83b71438320df5a8cbcb7b7f6..8849a9af9c064efdc1a82acc36ddffcb99d1f2ed 100644 (file)
  * Add this in your local code:
  *
  * void undo_editmode_push(bContext *C, const char *name, 
- *             void * (*getdata)(bContext *C),     // use context to retrieve current editdata
- *             void (*freedata)(void *),                       // pointer to function freeing data
- *             void (*to_editmode)(void *, void *),        // data to editmode conversion
- *             void * (*from_editmode)(void *))      // editmode to data conversion
- *             int  (*validate_undo)(void *, void *))      // check if undo data is still valid
+ *      void * (*getdata)(bContext *C),     // use context to retrieve current editdata
+ *      void (*freedata)(void *),           // pointer to function freeing data
+ *      void (*to_editmode)(void *, void *),        // data to editmode conversion
+ *      void * (*from_editmode)(void *))      // editmode to data conversion
+ *      int  (*validate_undo)(void *, void *))      // check if undo data is still valid
  *
  *
  * Further exported for UI is:
@@ -83,24 +83,24 @@ static void error(const char *UNUSED(arg)) {}
 /* ****** XXX ***** */
 
 
-#define MAXUNDONAME    64
+#define MAXUNDONAME 64
 typedef struct UndoElem {
        struct UndoElem *next, *prev;
-       ID id;                  // copy of editmode object ID
-       Object *ob;             // pointer to edited object
-       int type;               // type of edited object
+       ID id;          // copy of editmode object ID
+       Object *ob;     // pointer to edited object
+       int type;       // type of edited object
        void *undodata;
        uintptr_t undosize;
        char name[MAXUNDONAME];
-       void * (*getdata)(bContext *C);
+       void * (*getdata)(bContext * C);
        void (*freedata)(void *);
        void (*to_editmode)(void *, void *, void *);
        void * (*from_editmode)(void *, void *);
        int (*validate_undo)(void *, void *);
 } UndoElem;
 
-static ListBase undobase={NULL, NULL};
-static UndoElem *curundo= NULL;
+static ListBase undobase = {NULL, NULL};
+static UndoElem *curundo = NULL;
 
 
 /* ********************* xtern api calls ************* */
@@ -114,14 +114,14 @@ static void undo_restore(UndoElem *undo, void *editdata, void *obdata)
 
 /* name can be a dynamic string */
 void undo_editmode_push(bContext *C, const char *name, 
-                                               void * (*getdata)(bContext *C),
-                                               void (*freedata)(void *), 
-                                               void (*to_editmode)(void *, void *, void *),  
-                                               void *(*from_editmode)(void *, void *),
-                                               int (*validate_undo)(void *, void *))
+                        void * (*getdata)(bContext * C),
+                        void (*freedata)(void *),
+                        void (*to_editmode)(void *, void *, void *),
+                        void *(*from_editmode)(void *, void *),
+                        int (*validate_undo)(void *, void *))
 {
        UndoElem *uel;
-       Object *obedit= CTX_data_edit_object(C);
+       Object *obedit = CTX_data_edit_object(C);
        void *editdata;
        int nr;
        uintptr_t memused, totmem, maxmem;
@@ -131,65 +131,65 @@ void undo_editmode_push(bContext *C, const char *name,
        
        /* remove all undos after (also when curundo==NULL) */
        while (undobase.last != curundo) {
-               uel= undobase.last;
+               uel = undobase.last;
                uel->freedata(uel->undodata);
                BLI_freelinkN(&undobase, uel);
        }
        
        /* make new */
-       curundo= uel= MEM_callocN(sizeof(UndoElem), "undo editmode");
+       curundo = uel = MEM_callocN(sizeof(UndoElem), "undo editmode");
        BLI_strncpy(uel->name, name, sizeof(uel->name));
        BLI_addtail(&undobase, uel);
        
-       uel->getdata= getdata;
-       uel->freedata= freedata;
-       uel->to_editmode= to_editmode;
-       uel->from_editmode= from_editmode;
-       uel->validate_undo= validate_undo;
+       uel->getdata = getdata;
+       uel->freedata = freedata;
+       uel->to_editmode = to_editmode;
+       uel->from_editmode = from_editmode;
+       uel->validate_undo = validate_undo;
        
        /* limit amount to the maximum amount*/
-       nr= 0;
-       uel= undobase.last;
+       nr = 0;
+       uel = undobase.last;
        while (uel) {
                nr++;
-               if (nr==U.undosteps) break;
-               uel= uel->prev;
+               if (nr == U.undosteps) break;
+               uel = uel->prev;
        }
        if (uel) {
-               while (undobase.first!=uel) {
-                       UndoElem *first= undobase.first;
+               while (undobase.first != uel) {
+                       UndoElem *first = undobase.first;
                        first->freedata(first->undodata);
                        BLI_freelinkN(&undobase, first);
                }
        }
 
        /* copy  */
-       memused= MEM_get_memory_in_use();
-       editdata= getdata(C);
-       curundo->undodata= curundo->from_editmode(editdata, obedit->data);
-       curundo->undosize= MEM_get_memory_in_use() - memused;
-       curundo->ob= obedit;
-       curundo->id= obedit->id;
-       curundo->type= obedit->type;
+       memused = MEM_get_memory_in_use();
+       editdata = getdata(C);
+       curundo->undodata = curundo->from_editmode(editdata, obedit->data);
+       curundo->undosize = MEM_get_memory_in_use() - memused;
+       curundo->ob = obedit;
+       curundo->id = obedit->id;
+       curundo->type = obedit->type;
 
        if (U.undomemory != 0) {
                /* limit to maximum memory (afterwards, we can't know in advance) */
-               totmem= 0;
-               maxmem= ((uintptr_t)U.undomemory)*1024*1024;
+               totmem = 0;
+               maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024;
 
-               uel= undobase.last;
+               uel = undobase.last;
                while (uel && uel->prev) {
-                       totmem+= uel->undosize;
-                       if (totmem>maxmem) break;
-                       uel= uel->prev;
+                       totmem += uel->undosize;
+                       if (totmem > maxmem) break;
+                       uel = uel->prev;
                }
 
                if (uel) {
                        if (uel->prev && uel->prev->prev)
-                               uel= uel->prev;
+                               uel = uel->prev;
 
-                       while (undobase.first!=uel) {
-                               UndoElem *first= undobase.first;
+                       while (undobase.first != uel) {
+                               UndoElem *first = undobase.first;
                                first->freedata(first->undodata);
                                BLI_freelinkN(&undobase, first);
                        }
@@ -201,69 +201,69 @@ void undo_editmode_push(bContext *C, const char *name,
 static void undo_clean_stack(bContext *C)
 {
        UndoElem *uel, *next;
-       Object *obedit= CTX_data_edit_object(C);
+       Object *obedit = CTX_data_edit_object(C);
        
        /* global undo changes pointers, so we also allow identical names */
        /* side effect: when deleting/renaming object and start editing new one with same name */
        
-       uel= undobase.first; 
+       uel = undobase.first;
        while (uel) {
-               void *editdata= uel->getdata(C);
-               int isvalid= 0;
-               next= uel->next;
+               void *editdata = uel->getdata(C);
+               int isvalid = 0;
+               next = uel->next;
                
                /* for when objects are converted, renamed, or global undo changes pointers... */
-               if (uel->type==obedit->type) {
-                       if (strcmp(uel->id.name, obedit->id.name)==0) {
-                               if (uel->validate_undo==NULL)
-                                       isvalid= 1;
+               if (uel->type == obedit->type) {
+                       if (strcmp(uel->id.name, obedit->id.name) == 0) {
+                               if (uel->validate_undo == NULL)
+                                       isvalid = 1;
                                else if (uel->validate_undo(uel->undodata, editdata))
-                                       isvalid= 1;
+                                       isvalid = 1;
                        }
                }
                if (isvalid) 
-                       uel->ob= obedit;
+                       uel->ob = obedit;
                else {
                        if (uel == curundo)
-                               curundo= NULL;
+                               curundo = NULL;
 
                        uel->freedata(uel->undodata);
                        BLI_freelinkN(&undobase, uel);
                }
                
-               uel= next;
+               uel = next;
        }
        
-       if (curundo == NULL) curundo= undobase.last;
+       if (curundo == NULL) curundo = undobase.last;
 }
 
 /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
 void undo_editmode_step(bContext *C, int step)
 {
-       Object *obedit= CTX_data_edit_object(C);
+       Object *obedit = CTX_data_edit_object(C);
        
        /* prevent undo to happen on wrong object, stack can be a mix */
        undo_clean_stack(C);
        
-       if (step==0) {
+       if (step == 0) {
                undo_restore(curundo, curundo->getdata(C), obedit->data);
        }
-       else if (step==1) {
+       else if (step == 1) {
                
-               if (curundo==NULL || curundo->prev==NULL) error("No more steps to undo");
+               if (curundo == NULL || curundo->prev == NULL) error("No more steps to undo");
                else {
                        if (G.f & G_DEBUG) printf("undo %s\n", curundo->name);
-                       curundo= curundo->prev;
+                       curundo = curundo->prev;
                        undo_restore(curundo, curundo->getdata(C), obedit->data);
                }
        }
        else {
                /* curundo has to remain current situation! */
                
-               if (curundo==NULL || curundo->next==NULL) error("No more steps to redo");
+               if (curundo == NULL || curundo->next == NULL) error("No more steps to redo");
                else {
                        undo_restore(curundo->next, curundo->getdata(C), obedit->data);
-                       curundo= curundo->next;
+                       curundo = curundo->next;
                        if (G.f & G_DEBUG) printf("redo %s\n", curundo->name);
                }
        }
@@ -282,25 +282,25 @@ void undo_editmode_clear(void)
 {
        UndoElem *uel;
        
-       uel= undobase.first;
+       uel = undobase.first;
        while (uel) {
                uel->freedata(uel->undodata);
-               uel= uel->next;
+               uel = uel->next;
        }
        BLI_freelistN(&undobase);
-       curundo= NULL;
+       curundo = NULL;
 }
 
 /* based on index nr it does a restore */
 void undo_editmode_number(bContext *C, int nr)
 {
        UndoElem *uel;
-       int a=1;
+       int a = 1;
        
-       for (uel= undobase.first; uel; uel= uel->next, a++) {
-               if (a==nr) break;
+       for (uel = undobase.first; uel; uel = uel->next, a++) {
+               if (a == nr) break;
        }
-       curundo= uel;
+       curundo = uel;
        undo_editmode_step(C, 0);
 }
 
@@ -308,12 +308,12 @@ void undo_editmode_name(bContext *C, const char *undoname)
 {
        UndoElem *uel;
        
-       for (uel= undobase.last; uel; uel= uel->prev) {
-               if (strcmp(undoname, uel->name)==0)
+       for (uel = undobase.last; uel; uel = uel->prev) {
+               if (strcmp(undoname, uel->name) == 0)
                        break;
        }
        if (uel && uel->prev) {
-               curundo= uel->prev;
+               curundo = uel->prev;
                undo_editmode_step(C, 0);
        }
 }
@@ -324,8 +324,8 @@ int undo_editmode_valid(const char *undoname)
        if (undoname) {
                UndoElem *uel;
                
-               for (uel= undobase.last; uel; uel= uel->prev) {
-                       if (strcmp(undoname, uel->name)==0)
+               for (uel = undobase.last; uel; uel = uel->prev) {
+                       if (strcmp(undoname, uel->name) == 0)
                                break;
                }
                return uel != NULL;
@@ -343,12 +343,12 @@ const char *undo_editmode_get_name(bContext *C, int nr, int *active)
        /* prevent wrong numbers to be returned */
        undo_clean_stack(C);
        
-       if (active) *active= 0;
+       if (active) *active = 0;
        
-       uel= BLI_findlink(&undobase, nr);
+       uel = BLI_findlink(&undobase, nr);
        if (uel) {
-               if (active && uel==curundo)
-                       *active= 1;
+               if (active && uel == curundo)
+                       *active = 1;
                return uel->name;
        }
        return NULL;
@@ -357,7 +357,7 @@ const char *undo_editmode_get_name(bContext *C, int nr, int *active)
 
 void *undo_editmode_get_prev(Object *ob)
 {
-       UndoElem *ue= undobase.last;
-       if (ue && ue->prev && ue->prev->ob==ob) return ue->prev->undodata;
+       UndoElem *ue = undobase.last;
+       if (ue && ue->prev && ue->prev->ob == ob) return ue->prev->undodata;
        return NULL;
 }
index 1d9e053376af89b2ec1b47fce8248fe2d336ad68..c037508687bd5b0c3d078abdee8fda234a51d71c 100644 (file)
@@ -30,8 +30,8 @@
  */
 
 
-#include <math.h>                      /* fabs */
-#include <stdio.h>                     /* for size_t */
+#include <math.h>           /* fabs */
+#include <stdio.h>          /* for size_t */
 
 #include "BLI_utildefines.h"
 #include "BLI_string.h"
 
 void initNumInput(NumInput *n)
 {
-       n->flag         =
-       n->idx          =
-       n->idx_max      =
+       n->flag     =
+       n->idx      =
+       n->idx_max  =
        n->inv[0]   =
        n->inv[1]   =
        n->inv[2]   =
-       n->ctrl[0]      
-       n->ctrl[1]      
-       n->ctrl[2]      = 0;
+       n->ctrl[0]  = 
+       n->ctrl[1]  = 
+       n->ctrl[2]  = 0;
 
-       n->val[0]               
-       n->val[1]       
-       n->val[2]       = 0.0f;
+       n->val[0]   = 
+       n->val[1]   = 
+       n->val[2]   = 0.0f;
 }
 
 void outputNumInput(NumInput *n, char *str)
@@ -67,7 +67,7 @@ void outputNumInput(NumInput *n, char *str)
        char inv[] = "1/";
        short i, j;
 
-       for (j=0; j<=n->idx_max; j++) {
+       for (j = 0; j <= n->idx_max; j++) {
                /* if AFFECTALL and no number typed and cursor not on number, use first number */
                if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
                        i = 0;
@@ -84,35 +84,35 @@ void outputNumInput(NumInput *n, char *str)
                else
                        inv[0] = 0;
 
-               if ( n->val[i] > 1e10f || n->val[i] < -1e10f )
-                       BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
+               if (n->val[i] > 1e10f || n->val[i] < -1e10f)
+                       BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
                else
                        switch (n->ctrl[i]) {
-                       case 0:
-                               BLI_snprintf(&str[j*20], 20, "%sNONE%c", inv, cur);
-                               break;
-                       case 1:
-                       case -1:
-                               BLI_snprintf(&str[j*20], 20, "%s%.0f%c", inv, n->val[i], cur);
-                               break;
-                       case 10:
-                       case -10:
-                               BLI_snprintf(&str[j*20], 20, "%s%.f.%c", inv, n->val[i], cur);
-                               break;
-                       case 100:
-                       case -100:
-                               BLI_snprintf(&str[j*20], 20, "%s%.1f%c", inv, n->val[i], cur);
-                               break;
-                       case 1000:
-                       case -1000:
-                               BLI_snprintf(&str[j*20], 20, "%s%.2f%c", inv, n->val[i], cur);
-                               break;
-                       case 10000:
-                       case -10000:
-                               BLI_snprintf(&str[j*20], 20, "%s%.3f%c", inv, n->val[i], cur);
-                               break;
-                       default:
-                               BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
+                               case 0:
+                                       BLI_snprintf(&str[j * 20], 20, "%sNONE%c", inv, cur);
+                                       break;
+                               case 1:
+                               case -1:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.0f%c", inv, n->val[i], cur);
+                                       break;
+                               case 10:
+                               case -10:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.f.%c", inv, n->val[i], cur);
+                                       break;
+                               case 100:
+                               case -100:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.1f%c", inv, n->val[i], cur);
+                                       break;
+                               case 1000:
+                               case -1000:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.2f%c", inv, n->val[i], cur);
+                                       break;
+                               case 10000:
+                               case -10000:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.3f%c", inv, n->val[i], cur);
+                                       break;
+                               default:
+                                       BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
                        }
        }
 }
@@ -121,7 +121,7 @@ short hasNumInput(NumInput *n)
 {
        short i;
 
-       for (i=0; i<=n->idx_max; i++) {
+       for (i = 0; i <= n->idx_max; i++) {
                if (n->ctrl[i])
                        return 1;
        }
@@ -134,7 +134,7 @@ void applyNumInput(NumInput *n, float *vec)
        short i, j;
 
        if (hasNumInput(n)) {
-               for (j=0; j<=n->idx_max; j++) {
+               for (j = 0; j <= n->idx_max; j++) {
                        /* if AFFECTALL and no number typed and cursor not on number, use first number */
                        if (n->flag & NUM_AFFECT_ALL && n->idx != j && n->ctrl[j] == 0)
                                i = 0;
@@ -166,138 +166,138 @@ char handleNumInput(NumInput *n, wmEvent *event)
 
        if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
-               case NUM_MODAL_INCREMENT_UP:
-                       if (!n->ctrl[idx])
-                               n->ctrl[idx] = 1;
+                       case NUM_MODAL_INCREMENT_UP:
+                               if (!n->ctrl[idx])
+                                       n->ctrl[idx] = 1;
 
-                       n->val[idx] += n->increment;
-                       break;
-               case NUM_MODAL_INCREMENT_DOWN:
-                       if (!n->ctrl[idx])
-                               n->ctrl[idx] = 1;
+                               n->val[idx] += n->increment;
+                               break;
+                       case NUM_MODAL_INCREMENT_DOWN:
+                               if (!n->ctrl[idx])
+                                       n->ctrl[idx] = 1;
 
-                       n->val[idx] -= n->increment;
-                       break;
-               default:
-                       return 0;
+                               n->val[idx] -= n->increment;
+                               break;
+                       default:
+                               return 0;
                }
        }
        else {
                switch (event->type) {
-               case BACKSPACEKEY:
-                       if (n->ctrl[idx] == 0) {
-                               n->val[0]               =
-                                       n->val[1]       =
-                                       n->val[2]       = 0.0f;
-                               n->ctrl[0]              =
-                                       n->ctrl[1]      =
-                                       n->ctrl[2]      = 0;
-                               n->inv[0]               =
-                                       n->inv[1]       =
-                                       n->inv[2]       = 0;
-                       }
-                       else {
-                               n->val[idx] = 0.0f;
-                               n->ctrl[idx] = 0;
-                               n->inv[idx] = 0;
-                       }
-                       break;
-               case PERIODKEY:
-               case PADPERIOD:
-                       if (n->flag & NUM_NO_FRACTION)
-                               return 0;
-
-                       switch (n->ctrl[idx])
-                       {
-                       case 0:
-                       case 1:
-                               n->ctrl[idx] = 10;
-                               break;
-                       case -1:
-                               n->ctrl[idx] = -10;
-                       }
-                       break;
-               case PADMINUS:
-                       if (event->alt)
+                       case BACKSPACEKEY:
+                               if (n->ctrl[idx] == 0) {
+                                       n->val[0]       =
+                                           n->val[1]   =
+                                           n->val[2]   = 0.0f;
+                                       n->ctrl[0]      =
+                                           n->ctrl[1]  =
+                                           n->ctrl[2]  = 0;
+                                       n->inv[0]       =
+                                           n->inv[1]   =
+                                           n->inv[2]   = 0;
+                               }
+                               else {
+                                       n->val[idx] = 0.0f;
+                                       n->ctrl[idx] = 0;
+                                       n->inv[idx] = 0;
+                               }
                                break;
-               case MINUSKEY:
-                       if (n->flag & NUM_NO_NEGATIVE)
+                       case PERIODKEY:
+                       case PADPERIOD:
+                               if (n->flag & NUM_NO_FRACTION)
+                                       return 0;
+
+                               switch (n->ctrl[idx])
+                               {
+                                       case 0:
+                                       case 1:
+                                               n->ctrl[idx] = 10;
+                                               break;
+                                       case -1:
+                                               n->ctrl[idx] = -10;
+                               }
                                break;
+                       case PADMINUS:
+                               if (event->alt)
+                                       break;
+                       case MINUSKEY:
+                               if (n->flag & NUM_NO_NEGATIVE)
+                                       break;
 
-                       if (n->ctrl[idx]) {
-                               n->ctrl[idx] *= -1;
-                               n->val[idx] *= -1;
-                       }
-                       else
-                               n->ctrl[idx] = -1;
-                       break;
-               case PADSLASHKEY:
-               case SLASHKEY:
-                       if (n->flag & NUM_NO_FRACTION)
-                               return 0;
+                               if (n->ctrl[idx]) {
+                                       n->ctrl[idx] *= -1;
+                                       n->val[idx] *= -1;
+                               }
+                               else
+                                       n->ctrl[idx] = -1;
+                               break;
+                       case PADSLASHKEY:
+                       case SLASHKEY:
+                               if (n->flag & NUM_NO_FRACTION)
+                                       return 0;
 
-                       n->inv[idx] = !n->inv[idx];
-                       break;
-               case TABKEY:
-                       if (idx_max == 0)
-                               return 0;
+                               n->inv[idx] = !n->inv[idx];
+                               break;
+                       case TABKEY:
+                               if (idx_max == 0)
+                                       return 0;
 
-                       idx++;
-                       if (idx > idx_max)
-                               idx = 0;
-                       n->idx = idx;
-                       break;
-               case PAD9:
-               case NINEKEY:
-                       Val += 1.0f;
-               case PAD8:
-               case EIGHTKEY:
-                       Val += 1.0f;
-               case PAD7:
-               case SEVENKEY:
-                       Val += 1.0f;
-               case PAD6:
-               case SIXKEY:
-                       Val += 1.0f;
-               case PAD5:
-               case FIVEKEY:
-                       Val += 1.0f;
-               case PAD4:
-               case FOURKEY:
-                       Val += 1.0f;
-               case PAD3:
-               case THREEKEY:
-                       Val += 1.0f;
-               case PAD2:
-               case TWOKEY:
-                       Val += 1.0f;
-               case PAD1:
-               case ONEKEY:
-                       Val += 1.0f;
-               case PAD0:
-               case ZEROKEY:
-                       if (!n->ctrl[idx])
-                               n->ctrl[idx] = 1;
+                               idx++;
+                               if (idx > idx_max)
+                                       idx = 0;
+                               n->idx = idx;
+                               break;
+                       case PAD9:
+                       case NINEKEY:
+                               Val += 1.0f;
+                       case PAD8:
+                       case EIGHTKEY:
+                               Val += 1.0f;
+                       case PAD7:
+                       case SEVENKEY:
+                               Val += 1.0f;
+                       case PAD6:
+                       case SIXKEY:
+                               Val += 1.0f;
+                       case PAD5:
+                       case FIVEKEY:
+                               Val += 1.0f;
+                       case PAD4:
+                       case FOURKEY:
+                               Val += 1.0f;
+                       case PAD3:
+                       case THREEKEY:
+                               Val += 1.0f;
+                       case PAD2:
+                       case TWOKEY:
+                               Val += 1.0f;
+                       case PAD1:
+                       case ONEKEY:
+                               Val += 1.0f;
+                       case PAD0:
+                       case ZEROKEY:
+                               if (!n->ctrl[idx])
+                                       n->ctrl[idx] = 1;
 
-                       if (fabsf(n->val[idx]) > 9999999.0f);
-                       else if (n->ctrl[idx] == 1) {
-                               n->val[idx] *= 10;
-                               n->val[idx] += Val;
-                       }
-                       else if (n->ctrl[idx] == -1) {
-                               n->val[idx] *= 10;
-                               n->val[idx] -= Val;
-                       }
-                       else {
-                               /* float resolution breaks when over six digits after comma */
-                               if ( ABS(n->ctrl[idx]) < 10000000) {
-                                       n->val[idx] += Val / (float)n->ctrl[idx];
-                                       n->ctrl[idx] *= 10;
+                               if (fabsf(n->val[idx]) > 9999999.0f) ;
+                               else if (n->ctrl[idx] == 1) {
+                                       n->val[idx] *= 10;
+                                       n->val[idx] += Val;
                                }
-                       }
-                       break;
-               default:
-                       return 0;
+                               else if (n->ctrl[idx] == -1) {
+                                       n->val[idx] *= 10;
+                                       n->val[idx] -= Val;
+                               }
+                               else {
+                                       /* float resolution breaks when over six digits after comma */
+                                       if (ABS(n->ctrl[idx]) < 10000000) {
+                                               n->val[idx] += Val / (float)n->ctrl[idx];
+                                               n->ctrl[idx] *= 10;
+                                       }
+                               }
+                               break;
+                       default:
+                               return 0;
                }
        }
        
index 69dc1d1f1fbbc4f401a406f73583a7cc36ead8e9..62d761238e4e4773cfc88dfe1369a8ef38abe174 100644 (file)
@@ -78,9 +78,9 @@
 
 void ED_undo_push(bContext *C, const char *str)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       Object *obedit= CTX_data_edit_object(C);
-       Object *obact= CTX_data_active_object(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
+       Object *obedit = CTX_data_edit_object(C);
+       Object *obact = CTX_data_active_object(C);
 
        if (G.f & G_DEBUG)
                printf("undo push %s\n", str);
@@ -88,17 +88,17 @@ void ED_undo_push(bContext *C, const char *str)
        if (obedit) {
                if (U.undosteps == 0) return;
                
-               if (obedit->type==OB_MESH)
+               if (obedit->type == OB_MESH)
                        undo_push_mesh(C, str);
                else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
                        undo_push_curve(C, str);
-               else if (obedit->type==OB_FONT)
+               else if (obedit->type == OB_FONT)
                        undo_push_font(C, str);
-               else if (obedit->type==OB_MBALL)
+               else if (obedit->type == OB_MBALL)
                        undo_push_mball(C, str);
-               else if (obedit->type==OB_LATTICE)
+               else if (obedit->type == OB_LATTICE)
                        undo_push_lattice(C, str);
-               else if (obedit->type==OB_ARMATURE)
+               else if (obedit->type == OB_ARMATURE)
                        undo_push_armature(C, str);
        }
        else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
@@ -112,18 +112,18 @@ void ED_undo_push(bContext *C, const char *str)
        }
        
        if (wm->file_saved) {
-               wm->file_saved= 0;
+               wm->file_saved = 0;
                /* notifier that data changed, for save-over warning or header */
-               WM_event_add_notifier(C, NC_WM|ND_DATACHANGED, NULL);
+               WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
        }
 }
 
 /* note: also check undo_history_exec() in bottom if you change notifiers */
 static int ed_undo_step(bContext *C, int step, const char *undoname)
 {      
-       Object *obedit= CTX_data_edit_object(C);
-       Object *obact= CTX_data_active_object(C);
-       ScrArea *sa= CTX_wm_area(C);
+       Object *obedit = CTX_data_edit_object(C);
+       Object *obact = CTX_data_active_object(C);
+       ScrArea *sa = CTX_wm_area(C);
 
        /* undo during jobs are running can easily lead to freeing data using by jobs,
         * or they can just lead to freezing job in some other cases */
@@ -136,8 +136,8 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                return ED_undo_gpencil_step(C, step, undoname);
        }
 
-       if (sa && sa->spacetype==SPACE_IMAGE) {
-               SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
+       if (sa && sa->spacetype == SPACE_IMAGE) {
+               SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
                
                if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
                        if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
@@ -149,7 +149,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                }
        }
 
-       if (sa && sa->spacetype==SPACE_TEXT) {
+       if (sa && sa->spacetype == SPACE_TEXT) {
                ED_text_undo_step(C, step);
        }
        else if (obedit) {
@@ -159,28 +159,28 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                        else
                                undo_editmode_step(C, step);
 
-                       WM_event_add_notifier(C, NC_GEOM|ND_DATA, NULL);
+                       WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
                }
        }
        else {
-               int do_glob_undo= 0;
+               int do_glob_undo = 0;
                
                if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
                        if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname))
-                               do_glob_undo= 1;
+                               do_glob_undo = 1;
                }
                else if (obact && obact->mode & OB_MODE_SCULPT) {
                        if (!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname))
-                               do_glob_undo= 1;
+                               do_glob_undo = 1;
                }
                else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
-                       if (step==1)
+                       if (step == 1)
                                PE_undo(CTX_data_scene(C));
                        else
                                PE_redo(CTX_data_scene(C));
                }
                else {
-                       do_glob_undo= 1;
+                       do_glob_undo = 1;
                }
                
                if (do_glob_undo) {
@@ -194,7 +194,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
                                else
                                        BKE_undo_step(C, step);
 
-                               WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, CTX_data_scene(C));
+                               WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
                        }
                        
                }
@@ -229,19 +229,19 @@ void ED_undo_pop_op(bContext *C, wmOperator *op)
 /* name optionally, function used to check for operator redo panel */
 int ED_undo_valid(const bContext *C, const char *undoname)
 {
-       Object *obedit= CTX_data_edit_object(C);
-       Object *obact= CTX_data_active_object(C);
-       ScrArea *sa= CTX_wm_area(C);
+       Object *obedit = CTX_data_edit_object(C);
+       Object *obact = CTX_data_active_object(C);
+       ScrArea *sa = CTX_wm_area(C);
        
-       if (sa && sa->spacetype==SPACE_IMAGE) {
-               SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
+       if (sa && sa->spacetype == SPACE_IMAGE) {
+               SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
                
                if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) {
                        return 1;
                }
        }
        
-       if (sa && sa->spacetype==SPACE_TEXT) {
+       if (sa && sa->spacetype == SPACE_TEXT) {
                return 1;
        }
        else if (obedit) {
@@ -254,11 +254,11 @@ int ED_undo_valid(const bContext *C, const char *undoname)
                /* if below tests fail, global undo gets executed */
                
                if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
-                       if ( ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) )
+                       if (ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) )
                                return 1;
                }
                else if (obact && obact->mode & OB_MODE_SCULPT) {
-                       if ( ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) )
+                       if (ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) )
                                return 1;
                }
                else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
@@ -338,14 +338,14 @@ void ED_OT_redo(wmOperatorType *ot)
 /* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
 int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
 {
-       int ret= 0;
+       int ret = 0;
 
        if (op) {
-               wmWindowManager *wm= CTX_wm_manager(C);
-               struct Scene *scene= CTX_data_scene(C);
+               wmWindowManager *wm = CTX_wm_manager(C);
+               struct Scene *scene = CTX_data_scene(C);
 
-               ARegion *ar= CTX_wm_region(C);
-               ARegion *ar1= BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW);
+               ARegion *ar = CTX_wm_region(C);
+               ARegion *ar1 = BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW);
 
                if (ar1)
                        CTX_wm_region_set(C, ar1);
@@ -369,14 +369,14 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
                                op->type->check(C, op); /* ignore return value since its running again anyway */
                        }
 
-                       retval= WM_operator_repeat(C, op);
-                       if ((retval & OPERATOR_FINISHED)==0) {
+                       retval = WM_operator_repeat(C, op);
+                       if ((retval & OPERATOR_FINISHED) == 0) {
                                if (G.f & G_DEBUG)
                                        printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
                                ED_undo_redo(C);
                        }
                        else {
-                               ret= 1;
+                               ret = 1;
                        }
                }
                else {
@@ -411,13 +411,13 @@ void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_ev
 
 /* ************************** */
 
-#define UNDOSYSTEM_GLOBAL      1
-#define UNDOSYSTEM_EDITMODE    2
-#define UNDOSYSTEM_PARTICLE    3
+#define UNDOSYSTEM_GLOBAL   1
+#define UNDOSYSTEM_EDITMODE 2
+#define UNDOSYSTEM_PARTICLE 3
 
 static int get_undo_system(bContext *C)
 {
-       Object *obedit= CTX_data_edit_object(C);
+       Object *obedit = CTX_data_edit_object(C);
        
        /* find out which undo system */
        if (obedit) {
@@ -425,7 +425,7 @@ static int get_undo_system(bContext *C)
                        return UNDOSYSTEM_EDITMODE;
        }
        else {
-               Object *obact= CTX_data_active_object(C);
+               Object *obact = CTX_data_active_object(C);
                
                if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
                        return UNDOSYSTEM_PARTICLE;
@@ -439,29 +439,29 @@ static int get_undo_system(bContext *C)
 /* create enum based on undo items */
 static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem)
 {
-       EnumPropertyItem item_tmp= {0}, *item= NULL;
-       int active, i= 0;
+       EnumPropertyItem item_tmp = {0}, *item = NULL;
+       int active, i = 0;
        
        while (TRUE) {
-               const char *name= NULL;
+               const char *name = NULL;
                
-               if (undosys==UNDOSYSTEM_PARTICLE) {
-                       name= PE_undo_get_name(CTX_data_scene(C), i, &active);
+               if (undosys == UNDOSYSTEM_PARTICLE) {
+                       name = PE_undo_get_name(CTX_data_scene(C), i, &active);
                }
-               else if (undosys==UNDOSYSTEM_EDITMODE) {
-                       name= undo_editmode_get_name(C, i, &active);
+               else if (undosys == UNDOSYSTEM_EDITMODE) {
+                       name = undo_editmode_get_name(C, i, &active);
                }
                else {
-                       name= BKE_undo_get_name(i, &active);
+                       name = BKE_undo_get_name(i, &active);
                }
                
                if (name) {
-                       item_tmp.identifier= item_tmp.name= name;
+                       item_tmp.identifier = item_tmp.name = name;
                        if (active)
-                               item_tmp.icon= ICON_RESTRICT_VIEW_OFF;
+                               item_tmp.icon = ICON_RESTRICT_VIEW_OFF;
                        else 
-                               item_tmp.icon= ICON_NONE;
-                       item_tmp.value= i++;
+                               item_tmp.icon = ICON_NONE;
+                       item_tmp.value = i++;
                        RNA_enum_item_add(&item, totitem, &item_tmp);
                }
                else
@@ -476,22 +476,22 @@ static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem)
 
 static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
-       int undosys, totitem= 0;
+       int undosys, totitem = 0;
        
-       undosys= get_undo_system(C);
+       undosys = get_undo_system(C);
        
        if (undosys) {
-               EnumPropertyItem *item= rna_undo_itemf(C, undosys, &totitem);
+               EnumPropertyItem *item = rna_undo_itemf(C, undosys, &totitem);
                
                if (totitem > 0) {
-                       uiPopupMenu *pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
-                       uiLayout *layout= uiPupMenuLayout(pup);
-                       uiLayout *split= uiLayoutSplit(layout, 0, 0), *column = NULL;
+                       uiPopupMenu *pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
+                       uiLayout *layout = uiPupMenuLayout(pup);
+                       uiLayout *split = uiLayoutSplit(layout, 0, 0), *column = NULL;
                        int i, c;
                        
-                       for (c=0, i=totitem-1; i >= 0; i--, c++) {
-                               if ( (c % 20)==0 )
-                                       column= uiLayoutColumn(split, 0);
+                       for (c = 0, i = totitem - 1; i >= 0; i--, c++) {
+                               if ( (c % 20) == 0)
+                                       column = uiLayoutColumn(split, 0);
                                if (item[i].identifier)
                                        uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value);
                                
@@ -510,19 +510,19 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
 static int undo_history_exec(bContext *C, wmOperator *op)
 {
        if (RNA_struct_property_is_set(op->ptr, "item")) {
-               int undosys= get_undo_system(C);
-               int item= RNA_int_get(op->ptr, "item");
+               int undosys = get_undo_system(C);
+               int item = RNA_int_get(op->ptr, "item");
                
-               if (undosys==UNDOSYSTEM_PARTICLE) {
+               if (undosys == UNDOSYSTEM_PARTICLE) {
                        PE_undo_number(CTX_data_scene(C), item);
                }
-               else if (undosys==UNDOSYSTEM_EDITMODE) {
-                       undo_editmode_number(C, item+1);
-                       WM_event_add_notifier(C, NC_GEOM|ND_DATA, NULL);
+               else if (undosys == UNDOSYSTEM_EDITMODE) {
+                       undo_editmode_number(C, item + 1);
+                       WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
                }
                else {
                        BKE_undo_number(C, item);
-                       WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, CTX_data_scene(C));
+                       WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
                }
                WM_event_add_notifier(C, NC_WINDOW, NULL);