editmesh accessor functions. most editmesh access now goes through:
authorJoseph Eagar <joeedh@gmail.com>
Mon, 30 Mar 2009 07:28:37 +0000 (07:28 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Mon, 30 Mar 2009 07:28:37 +0000 (07:28 +0000)
EditMesh *EM_GetEditMesh(Mesh *me);
void EM_EndEditMesh(Mesh *me, EditMesh *em);

as discussed on the mailling list, this is to facilitate migration to bmesh.
next step is to merge this this to the bmesh branch.  this was done in the 2.5
branch to prevent too great a divergance.

also, made makesdna/makesrna work on cygwin/msvc2008/scons.

26 files changed:
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/mesh/editdeform.c
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_loop.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_image/image_panels.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/makesdna/intern/SConscript
source/blender/makesrna/intern/SConscript

index 8c71a1d..fcd179d 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "MEM_guardedalloc.h"
 #include "BLI_blenlib.h"
+#include "BLI_editVert.h"
 #include "BLI_arithb.h"
 #include "BLI_rand.h"
 #include "DNA_listBase.h"
@@ -72,6 +73,8 @@
 #include <config.h>
 #endif
 
+#include "ED_mesh.h"
+
 static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated);
 
 void free_path(Path *path)
@@ -445,6 +448,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
        Scene *sce = NULL;
        Group *group = NULL;
        GroupObject * go = NULL;
+       EditMesh *em;
        float vec[3], no[3], pmat[4][4];
        int lay, totvert, a, oblay;
        
@@ -452,12 +456,15 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
        
        /* simple preventing of too deep nested groups */
        if(level>MAX_DUPLI_RECUR) return;
-
-       if(me->edit_mesh)
-               dm= editmesh_get_derived_cage(scene, par, me->edit_mesh, CD_MASK_BAREMESH);
-       else
+       
+       em = EM_GetEditMesh(me);
+       
+       if(em) {
+               dm= editmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
+               EM_EndEditMesh(me, em);
+       } else
                dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
-
+       
        if(G.rendering) {
                vdd.orco= (float(*)[3])get_mesh_orco_verts(par);
                transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0);
@@ -557,17 +564,19 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        Scene *sce = NULL;
        Group *group = NULL;
        GroupObject *go = NULL;
+       EditMesh *em;
        float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
        
        /* simple preventing of too deep nested groups */
        if(level>MAX_DUPLI_RECUR) return;
        
        Mat4CpyMat4(pmat, par->obmat);
-
-       if(me->edit_mesh) {
+       
+       em = EM_GetEditMesh(me);
+       if(em) {
                int totvert;
                
-               dm= editmesh_get_derived_cage(scene, par, me->edit_mesh, CD_MASK_BAREMESH);
+               dm= editmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
                
                totface= dm->getNumFaces(dm);
                mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
@@ -575,6 +584,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                totvert= dm->getNumVerts(dm);
                mvert= MEM_mallocN(sizeof(MVert)*totvert, "mvert temp");
                dm->copyVertArray(dm, mvert);
+
+               EM_EndEditMesh(me, em);
        }
        else {
                dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
index 22b6d57..b238116 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
+#include "BLI_editVert.h"
 
 #include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
@@ -70,6 +71,7 @@
 #include "BPY_extern.h"
 #endif
 
+#include "ED_mesh.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -390,6 +392,7 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
 {
        DerivedMesh *dm;
        Mesh *me= ob->data;
+       EditMesh *em = EM_GetEditMesh(me);
        float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3];
        float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
        float imat[3][3], tmat[3][3];
@@ -403,9 +406,9 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
        if (dgroup < 0) return;
        
        /* get DerivedMesh */
-       if (me->edit_mesh) {
+       if (em) {
                /* target is in editmode, so get a special derived mesh */
-               dm = CDDM_from_editmesh(me->edit_mesh, ob->data);
+               dm = CDDM_from_editmesh(em, ob->data);
        }
        else {
                /* when not in EditMode, this should exist */
@@ -475,8 +478,9 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
        }
        
        /* free temporary DerivedMesh created (in EditMode case) */
-       if (me->edit_mesh) {
+       if (em) {
                if (dm) dm->release(dm);
+               EM_EndEditMesh(me, em);
        }
 }
 
index 249d3db..ae423cd 100644 (file)
@@ -2388,7 +2388,7 @@ void write_stl(Scene *scene, char *str)
 static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
 {
        Mesh *me= ob->data;
-       EditMesh *em = me->edit_mesh;
+       EditMesh *em = EM_GetEditMesh(me);
        Material *ma;
        MFace *mface;
        FILE *fp;
@@ -2489,6 +2489,8 @@ static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
        }
        
        fclose(fp);
+
+       if (em) EM_EndEditMesh(em);
        
 }
 
index 7ed87e7..1239bc8 100644 (file)
@@ -7541,6 +7541,7 @@ static void meshdeformModifier_do(
        DerivedMesh *tmpdm, *cagedm;
        MDeformVert *dvert = NULL;
        MDeformWeight *dw;
+       EditMesh *em = EM_GetEditMesh(me);
        MVert *cagemvert;
        float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
        float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3];
@@ -7550,10 +7551,11 @@ static void meshdeformModifier_do(
                return;
        
        /* get cage derivedmesh */
-       if(me->edit_mesh) {
-               tmpdm= editmesh_get_derived_cage_and_final(md->scene, ob, me->edit_mesh, &cagedm, 0);
+       if(em) {
+               tmpdm= editmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0);
                if(tmpdm)
                        tmpdm->release(tmpdm);
+               EM_EndEditMesh(em);
        }
        else
                cagedm= mmd->object->derivedFinal;
index 5e0c574..7b59a1e 100644 (file)
@@ -1635,15 +1635,16 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4])
 
 static void give_parvert(Object *par, int nr, float *vec)
 {
+       EditMesh *em;
        int a, count;
        
        vec[0]=vec[1]=vec[2]= 0.0f;
        
        if(par->type==OB_MESH) {
                Mesh *me= par->data;
-               
-               if(me->edit_mesh) {
-                       EditMesh *em = me->edit_mesh;
+               em = EM_GetEditMesh(me);
+
+               if(em) {
                        EditVert *eve;
                        
                        for(eve= em->verts.first; eve; eve= eve->next) {
@@ -1652,6 +1653,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                                        break;
                                }
                        }
+                       EM_EndEditMesh(me, em);
                }
                else {
                        DerivedMesh *dm = par->derivedFinal;
@@ -2294,10 +2296,13 @@ void object_handle_update(Scene *scene, Object *ob)
                        
                        /* includes all keys and modifiers */
                        if(ob->type==OB_MESH) {
+                               EditMesh *em = EM_GetEditMesh(ob->data);
+
                                        // here was vieweditdatamask? XXX
-                               if(ob==scene->obedit)
-                                       makeDerivedMesh(scene, ob, ((Mesh*)ob->data)->edit_mesh, CD_MASK_BAREMESH);
-                               else
+                               if(ob==scene->obedit) {
+                                       makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH);
+                                       EM_EndEditMesh(ob->data, em);
+                               } else
                                        makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH);
                        }
                        else if(ob->type==OB_MBALL) {
index f2197c9..417d931 100644 (file)
 #include "BLI_arithb.h"
 #include "BLI_kdtree.h"
 #include "BLI_kdopbvh.h"
+#include "BLI_editVert.h"
 
 #include "RE_raytrace.h"
 #include "MEM_guardedalloc.h"
 
+#include "ED_mesh.h"
 
 /* Util macros */
 #define TO_STR(a)      #a
@@ -94,11 +96,14 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c
 static DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDataMask dataMask)
 {
        Mesh *me= ob->data;
-       
-       if (me->edit_mesh)
+       EditMesh *em = EM_GetEditMesh(me);
+
+       if (em)
        {
                DerivedMesh *final = NULL;
-               editmesh_get_derived_cage_and_final(scene, ob, me->edit_mesh, &final, dataMask);
+               editmesh_get_derived_cage_and_final(scene, ob, em, &final, dataMask);
+               
+               EM_EndEditMesh(me, em);
                return final;
        }
        else
index 022d8fe..53b5046 100644 (file)
@@ -82,6 +82,12 @@ void         ED_keymap_mesh(struct wmWindowManager *wm);
 
 
 /* editmesh.c */
+
+/*accessor functions for editmesh, all access to editmesh must
+  go through them!*/
+struct EditMesh *EM_GetEditMesh(struct Mesh *me);
+void EM_EndEditMesh(struct Mesh *me, struct EditMesh *em);
+
 void           ED_spacetypes_init(void);
 void           ED_keymap_mesh(struct wmWindowManager *wm);
 
index ca6415d..1bf81f1 100644 (file)
@@ -94,9 +94,10 @@ void sel_verts_defgroup (Object *obedit, int select)
        case OB_MESH:
        {
                Mesh *me= ob->data;
-               
-               for (eve=me->edit_mesh->verts.first; eve; eve=eve->next){
-                       dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
+               EditMesh *em = EM_GetEditMesh(me);
+
+               for (eve=em->verts.first; eve; eve=eve->next){
+                       dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 
                        if (dvert && dvert->totweight){
                                for (i=0; i<dvert->totweight; i++){
@@ -110,8 +111,10 @@ void sel_verts_defgroup (Object *obedit, int select)
                        }
                }
                /* this has to be called, because this function operates on vertices only */
-               if(select) EM_select_flush(me->edit_mesh);      // vertices to edges/faces
-               else EM_deselect_flush(me->edit_mesh);
+               if(select) EM_select_flush(em); // vertices to edges/faces
+               else EM_deselect_flush(em);
+
+               EM_EndEditMesh(em, me);
        }
                break;
        case OB_LATTICE:
@@ -395,18 +398,19 @@ void del_defgroup (Object *ob)
        /* Make sure that any verts with higher indices are adjusted accordingly */
        if(ob->type==OB_MESH) {
                Mesh *me= ob->data;
-               EditMesh *em = me->edit_mesh;
+               EditMesh *em = EM_GetEditMesh(me);
                EditVert *eve;
                MDeformVert *dvert;
                
                for (eve=em->verts.first; eve; eve=eve->next){
-                       dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
+                       dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 
                        if (dvert)
                                for (i=0; i<dvert->totweight; i++)
                                        if (dvert->dw[i].def_nr > (ob->actdef-1))
                                                dvert->dw[i].def_nr--;
                }
+               EM_EndEditMesh(me, em);
        }
        else if(ob->type==OB_LATTICE) {
                Lattice *lt= def_get_lattice(ob);
@@ -720,13 +724,14 @@ void assign_verts_defgroup (Object *obedit, float weight)
        case OB_MESH:
        {
                Mesh *me= ob->data;
-               
-               if (!CustomData_has_layer(&me->edit_mesh->vdata, CD_MDEFORMVERT))
-                       EM_add_data_layer(me->edit_mesh, &me->edit_mesh->vdata, CD_MDEFORMVERT);
+               EditMesh *em = EM_GetEditMesh(me);
+
+               if (!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT))
+                       EM_add_data_layer(em, &em->vdata, CD_MDEFORMVERT);
 
                /* Go through the list of editverts and assign them */
-               for (eve=me->edit_mesh->verts.first; eve; eve=eve->next){
-                       dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
+               for (eve=em->verts.first; eve; eve=eve->next){
+                       dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 
                        if (dvert && (eve->f & 1)){
                                done=0;
@@ -759,6 +764,7 @@ void assign_verts_defgroup (Object *obedit, float weight)
                                }
                        }
                }
+               EM_EndEditMesh(me, em);
        }
                break;
        case OB_LATTICE:
@@ -882,9 +888,10 @@ void remove_verts_defgroup (Object *obedit, int allverts)
        case OB_MESH:
        {
                Mesh *me= ob->data;
-               
-               for (eve=me->edit_mesh->verts.first; eve; eve=eve->next){
-                       dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
+               EditMesh *em = EM_GetEditMesh(me);
+
+               for (eve=em->verts.first; eve; eve=eve->next){
+                       dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
                
                        if (dvert && dvert->dw && ((eve->f & 1) || allverts)){
                                for (i=0; i<dvert->totweight; i++){
@@ -911,6 +918,7 @@ void remove_verts_defgroup (Object *obedit, int allverts)
                                }
                        }
                }
+               EM_EndEditMesh(me, em);
        }
                break;
        case OB_LATTICE:
index 9e24e52..a266bd1 100644 (file)
@@ -1455,9 +1455,10 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
        
        obedit= editbase->object;
        me= obedit->data;
-       em= me->edit_mesh;
+       em= EM_GetEditMesh(me);
        if(me->key) {
                error("Can't separate with vertex keys");
+               EM_EndEditMesh(me, em);
                return 0;
        }
        
@@ -1468,7 +1469,10 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
        
        EM_stats_update(em);
        
-       if(em->totvertsel==0) return 0;
+       if(em->totvertsel==0) {
+               EM_EndEditMesh(me, em);
+               return 0;
+       }
        
        /* we are going to work as follows:
         * 1. add a linked duplicate object: this will be the new one, we remember old pointer
@@ -1536,6 +1540,8 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
        DAG_object_flush_update(scene, basenew->object, OB_RECALC_DATA);        
 
+       EM_EndEditMesh(me, em);
+
        return 1;
 }
 
@@ -1543,7 +1549,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
 static int mesh_separate_material(Scene *scene, Base *editbase)
 {
        Mesh *me= editbase->object->data;
-       EditMesh *em= me->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(me);
        unsigned char curr_mat;
        
        for (curr_mat = 1; curr_mat < editbase->object->totcol; ++curr_mat) {
@@ -1552,9 +1558,13 @@ static int mesh_separate_material(Scene *scene, Base *editbase)
                /* select the material */
                editmesh_select_by_material(em, curr_mat);
                /* and now separate */
-               if(0==mesh_separate_selected(scene, editbase))
+               if(0==mesh_separate_selected(scene, editbase)) {
+                       EM_EndEditMesh(me, em);
                        return 0;
+               }
        }
+
+       EM_EndEditMesh(me, em);
        return 1;
 }
 
@@ -1566,10 +1576,11 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
        int doit= 1;
        
        me= editbase->object->data;
-       em= me->edit_mesh;
+       em= EM_GetEditMesh(me);
        
        if(me->key) {
                error("Can't separate with vertex keys");
+               EM_EndEditMesh(me, em);
                return 0;
        }
        
@@ -1585,6 +1596,8 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
                /* and now separate */
                doit= mesh_separate_selected(scene, editbase);
        }
+
+       EM_EndEditMesh(me, em);
        return 1;
 }
 
@@ -2015,3 +2028,11 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc)
        }
 }
 
+EditMesh *EM_GetEditMesh(Mesh *me)
+{
+       return me->edit_mesh;
+}
+
+void EM_EndEditMesh(Mesh *me, EditMesh *em)
+{
+}
index 04d9045..9307f0c 100644 (file)
 /* XXX */
 
 static float icovert[12][3] = {
-       {0,0,-200}, 
-       {144.72, -105.144,-89.443},
-       {-55.277, -170.128,-89.443}, 
-       {-178.885,0,-89.443},
-       {-55.277,170.128,-89.443}, 
-       {144.72,105.144,-89.443},
-       {55.277,-170.128,89.443},
-       {-144.72,-105.144,89.443},
-       {-144.72,105.144,89.443},
-       {55.277,170.128,89.443},
-       {178.885,0,89.443},
-       {0,0,200}
+       {0.0f,0.0f,-200.0f}, 
+       {144.72f, -105.144f,-89.443f},
+       {-55.277f, -170.128,-89.443f}, 
+       {-178.885f,0.0f,-89.443f},
+       {-55.277f,170.128f,-89.443f}, 
+       {144.72f,105.144f,-89.443f},
+       {55.277f,-170.128f,89.443f},
+       {-144.72f,-105.144f,89.443f},
+       {-144.72f,105.144f,89.443f},
+       {55.277f,170.128f,89.443f},
+       {178.885f,0.0f,89.443f},
+       {0.0f,0.0f,200.0f}
 };
 static short icoface[20][3] = {
        {1,0,2},
@@ -339,15 +339,18 @@ int make_fgon(EditMesh *em, wmOperator *op, int make)
 static int make_fgon_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
 
        if( make_fgon(em, op, 1) ) {
                DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);     
        
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-               
+
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_FINISHED;
        }
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_CANCELLED;
 }
 
@@ -368,15 +371,18 @@ void MESH_OT_fgon_make(struct wmOperatorType *ot)
 static int clear_fgon_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        if( make_fgon(em, op, 0) ) {
                DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);     
                
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+               
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_FINISHED;
        }
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_CANCELLED;
 }
 
@@ -779,7 +785,7 @@ static void addedgeface_mesh(EditMesh *em, wmOperator *op)
 static int addedgeface_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        addedgeface_mesh(em, op);
        
@@ -787,6 +793,7 @@ static int addedgeface_mesh_exec(bContext *C, wmOperator *op)
        
        DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);     
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -976,7 +983,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
         * fill - end capping, and option to fill in circle
         * cent[3] - center of the data. 
         * */
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        EditVert *eve, *v1=NULL, *v2, *v3, *v4=NULL, *vtop, *vdown;
        float phi, phid, vec[3];
        float q[4], cmat[3][3], nor[3]= {0.0, 0.0, 0.0};
@@ -984,8 +991,8 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
        
        EM_clear_flag_all(em, SELECT);
 
-       phid= 2*M_PI/tot;
-       phi= .25*M_PI;
+       phid= 2.0f*(float)M_PI/tot;
+       phi= .25f*(float)M_PI;
 
        switch(type) {
        case PRIM_GRID: /*  grid */
@@ -1257,6 +1264,8 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
        
        if(type!=0 && type!=13)
                righthandfaces(em, 1);  /* otherwise monkey has eyes in wrong direction */
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 
index af85a04..333c3a1 100644 (file)
@@ -625,7 +625,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
 static int knife_cut_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        ARegion *ar= CTX_wm_region(C);
        EditEdge *eed;
        EditVert *eve;
@@ -638,6 +638,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
        
        if (EM_nvertices_selected(em) < 2) {
                error("No edges are selected to operate on");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;;
        }
 
@@ -650,8 +651,11 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
        }
        RNA_END;
        
-       if(len<2) return OPERATOR_CANCELLED;
-       
+       if(len<2) {
+               EM_EndEditMesh(obedit->data, em);
+               return OPERATOR_CANCELLED;
+       }
+
        /*store percentage of edge cut for KNIFE_EXACT here.*/
        for(eed=em->edges.first; eed; eed= eed->next) 
                eed->tmp.fp = 0.0; 
@@ -698,6 +702,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
        
        BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
index 74defee..0f8a15f 100644 (file)
@@ -801,7 +801,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
-       EditMesh *em= me->edit_mesh
+       EditMesh *em= EM_GetEditMesh(me)
 
        int selcount = similar_face_select__internal(scene, em, RNA_int_get(op->ptr, "type"));
        
@@ -809,9 +809,11 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
                /* here was an edge-mode only select flush case, has to be generalized */
                EM_selectmode_flush(em);
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               EM_EndEditMesh(me, em);
                return OPERATOR_FINISHED;
        }
        
+       EM_EndEditMesh(me, em);
        return OPERATOR_CANCELLED;
 }      
 
@@ -1060,7 +1062,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
-       EditMesh *em= me->edit_mesh
+       EditMesh *em= EM_GetEditMesh(me)
 
        int selcount = similar_edge_select__internal(scene, em, RNA_int_get(op->ptr, "type"));
        
@@ -1068,9 +1070,11 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
                /* here was an edge-mode only select flush case, has to be generalized */
                EM_selectmode_flush(em);
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               EM_EndEditMesh(me, em);
                return OPERATOR_FINISHED;
        }
        
+       EM_EndEditMesh(me, em);
        return OPERATOR_CANCELLED;
 }
 
@@ -1113,7 +1117,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
-       EditMesh *em= me->edit_mesh
+       EditMesh *em= EM_GetEditMesh(me)
        EditVert *eve, *base_eve=NULL;
        unsigned int selcount=0; /* count how many new edges we select*/
        
@@ -1139,8 +1143,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                
        }
        
-       if (!ok || !deselcount) /* no data selected OR no more data to select*/
+       if (!ok || !deselcount) { /* no data selected OR no more data to select*/
+               EM_EndEditMesh(me, em);
                return 0;
+       }
        
        if(RNA_enum_is_equal(op->ptr, "type", "FACE")) {
                /* store face users */
@@ -1168,8 +1174,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                                                        eve->f |= SELECT;
                                                        selcount++;
                                                        deselcount--;
-                                                       if (!deselcount) /*have we selected all posible faces?, if so return*/
+                                                       if (!deselcount) {/*have we selected all posible faces?, if so return*/
+                                                               EM_EndEditMesh(me, em);
                                                                return selcount;
+                                                       }
                                                }
                                        }
                                }
@@ -1184,8 +1192,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                                                eve->f |= SELECT;
                                                selcount++;
                                                deselcount--;
-                                               if (!deselcount) /*have we selected all posible faces?, if so return*/
+                                               if (!deselcount) {/*have we selected all posible faces?, if so return*/
+                                                       EM_EndEditMesh(me, em);
                                                        return selcount;
+                                               }
                                        }
                                }
                        } 
@@ -1196,8 +1206,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                                base_dvert= CustomData_em_get(&em->vdata, base_eve->data,
                                        CD_MDEFORMVERT);
 
-                               if (!base_dvert || base_dvert->totweight == 0)
+                               if (!base_dvert || base_dvert->totweight == 0) {
+                                       EM_EndEditMesh(me, em);
                                        return selcount;
+                               }
                                
                                for(eve= em->verts.first; eve; eve= eve->next) {
                                        dvert= CustomData_em_get(&em->vdata, eve->data,
@@ -1212,8 +1224,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
                                                                        eve->f |= SELECT;
                                                                        selcount++;
                                                                        deselcount--;
-                                                                       if (!deselcount) /*have we selected all posible faces?, if so return*/
+                                                                       if (!deselcount) { /*have we selected all posible faces?, if so return*/
+                                                                               EM_EndEditMesh(me, em);
                                                                                return selcount;
+                                                                       }
                                                                        break;
                                                                }
                                                        }
@@ -1226,8 +1240,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
 
        if(selcount) {
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+               EM_EndEditMesh(me, em);
                return OPERATOR_FINISHED;
        }
+
+       EM_EndEditMesh(me, em);
        return OPERATOR_CANCELLED;
 }
 
@@ -1915,7 +1932,7 @@ static void edgering_select(EditMesh *em, EditEdge *startedge, int select)
 static int loop_multiselect(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        EditEdge *eed;
        EditEdge **edarray;
        int edindex, edfirstcount;
@@ -1953,6 +1970,8 @@ static int loop_multiselect(bContext *C, wmOperator *op)
 //     if (EM_texFaceCheck())
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -2490,7 +2509,7 @@ void selectconnected_mesh_all(EditMesh *em)
 static int select_linked_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(obedit->data);
        
        if( RNA_boolean_get(op->ptr, "limit") ) {
                ViewContext vc;
@@ -2501,6 +2520,8 @@ static int select_linked_exec(bContext *C, wmOperator *op)
                selectconnected_mesh_all(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -2629,11 +2650,13 @@ void EM_hide_mesh(EditMesh *em, int swap)
 static int hide_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        EM_hide_mesh(em, RNA_boolean_get(op->ptr, "unselected"));
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -2693,11 +2716,13 @@ void EM_reveal_mesh(EditMesh *em)
 static int reveal_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        EM_reveal_mesh(em);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -2751,7 +2776,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op)
        * small enough, select the edge
        */
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        EditEdge *eed;
        EditFace *efa;
        EditFace **efa1;
@@ -2763,6 +2788,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op)
        
        if(em->selectmode==SCE_SELECT_FACE) {
                BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
 
@@ -2841,6 +2867,8 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op)
 //     if (EM_texFaceCheck())
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -3001,11 +3029,13 @@ static void select_linked_flat_faces(EditMesh *em, wmOperator *op, float sharpne
 static int select_linked_flat_faces_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        select_linked_flat_faces(em, op, RNA_float_get(op->ptr, "sharpness"));
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -3099,11 +3129,13 @@ void select_non_manifold(EditMesh *em, wmOperator *op )
 static int select_non_manifold_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        select_non_manifold(em, op);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -3160,11 +3192,13 @@ void EM_select_swap(EditMesh *em) /* exported for UV */
 static int select_invert_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        EM_select_swap(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -3195,11 +3229,12 @@ void EM_toggle_select_all(EditMesh *em) /* exported for UV */
 static int toggle_select_all_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        EM_toggle_select_all(em);
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);     
+       EM_EndEditMesh(obedit->data, em);
 
        return OPERATOR_FINISHED;
 }
@@ -3262,13 +3297,15 @@ void EM_select_more(EditMesh *em)
 static int select_more(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data)) ;
 
        EM_select_more(em);
 
 //     if (EM_texFaceCheck(em))
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -3350,12 +3387,14 @@ void EM_select_less(EditMesh *em)
 static int select_less(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
 
        EM_select_less(em);
 
 //     if (EM_texFaceCheck(em))
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -3418,12 +3457,13 @@ static void selectrandom_mesh(EditMesh *em, float perc) /* randomly selects a us
 static int mesh_select_random_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        selectrandom_mesh(em, RNA_float_get(op->ptr,"percent"));
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -3507,12 +3547,13 @@ static int mesh_selection_type_exec(bContext *C, wmOperator *op)
 {              
        
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
 
        mesh_selection_type(CTX_data_scene(C), em, RNA_enum_get(op->ptr,"type"));
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+       
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -3540,7 +3581,7 @@ void MESH_OT_selection_type(wmOperatorType *ot)
 static int editmesh_mark_seam(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        Mesh *me= ((Mesh *)obedit->data);
        EditEdge *eed;
        int clear = RNA_boolean_get(op->ptr, "clear");
@@ -3571,6 +3612,7 @@ static int editmesh_mark_seam(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -3593,7 +3635,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot)
 static int editmesh_mark_sharp(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        Mesh *me= ((Mesh *)obedit->data);
        int set = RNA_boolean_get(op->ptr, "set");
        EditEdge *eed;
@@ -3619,6 +3661,7 @@ static int editmesh_mark_sharp(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -4013,7 +4056,7 @@ void righthandfaces(EditMesh *em, int select)     /* makes faces righthand turning *
 static int righthandfaces_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        /* 'standard' behaviour - check if selected, then apply relevant selection */
        
@@ -4021,6 +4064,8 @@ static int righthandfaces_exec(bContext *C, wmOperator *op)
        righthandfaces(em, RNA_boolean_get(op->ptr, "inside"));
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); //TODO is this needed ?
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -4221,7 +4266,7 @@ static int smooth_vertex(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Mesh *me= obedit->data;
-       EditMesh *em= me->edit_mesh
+       EditMesh *em= me; 
 
        EditVert *eve, *eve_mir = NULL;
        EditEdge *eed;
@@ -4230,7 +4275,10 @@ static int smooth_vertex(bContext *C, wmOperator *op)
        int teller=0;
        ModifierData *md= obedit->modifiers.first;
 
-       if(em==NULL) return OPERATOR_CANCELLED;
+       if(em==NULL) {
+               EM_EndEditMesh(obedit->data, em);
+               return OPERATOR_CANCELLED;
+       }
 
        /* count */
        eve= em->verts.first;
@@ -4238,7 +4286,10 @@ static int smooth_vertex(bContext *C, wmOperator *op)
                if(eve->f & SELECT) teller++;
                eve= eve->next;
        }
-       if(teller==0) return OPERATOR_CANCELLED;
+       if(teller==0) {
+               EM_EndEditMesh(obedit->data, em);
+               return OPERATOR_CANCELLED;
+       }
        
        adr=adror= (float *)MEM_callocN(3*sizeof(float *)*teller, "vertsmooth");
        eve= em->verts.first;
@@ -4351,6 +4402,7 @@ static int smooth_vertex(bContext *C, wmOperator *op)
 
 //     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -4475,12 +4527,13 @@ static int vertices_to_sphere_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        View3D *v3d = CTX_wm_view3d(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        
        vertices_to_sphere(scene, v3d, obedit, em, RNA_float_get(op->ptr,"percent"));
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -4524,7 +4577,7 @@ void flipface(EditMesh *em, EditFace *efa)
 static int flip_editnormals(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        EditFace *efa;
        
        efa= em->faces.first;
@@ -4538,6 +4591,7 @@ static int flip_editnormals(bContext *C, wmOperator *op)
        /* update vertex normals too */
        recalc_editnormals(em);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
index abd42f6..89e7fcb 100644 (file)
@@ -487,7 +487,7 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(((Mesh *)obedit->data));
        char msg[100];
 
        int cnt = removedoublesflag(em,1,0,scene->toolsettings->doublimit);
@@ -500,6 +500,7 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op)
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -700,7 +701,7 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
 static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        extrude_mesh(obedit,em, op);
        
@@ -709,6 +710,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -716,12 +718,13 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
 static int mesh_extrude_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(obedit->data);
        
        extrude_mesh(obedit,em, op);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -747,7 +750,7 @@ void MESH_OT_extrude(wmOperatorType *ot)
 static int split_mesh(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        WM_cursor_wait(1);
 
@@ -762,6 +765,7 @@ static int split_mesh(bContext *C, wmOperator *op)
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
 //     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -783,8 +787,8 @@ void MESH_OT_split(wmOperatorType *ot)
 static int extrude_repeat_mesh(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
-       
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
+
        RegionView3D *rv3d = CTX_wm_region_view3d(C);           
                
        int steps = RNA_int_get(op->ptr,"steps");
@@ -820,6 +824,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op)
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
 //     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -848,7 +853,7 @@ static int spin_mesh(bContext *C, float *dvec, int steps, float degr, int dupli
        Object *obedit= CTX_data_edit_object(C);
        View3D *v3d = CTX_wm_view3d(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
        EditVert *eve,*nextve;
        float nor[3]= {0.0f, 0.0f, 0.0f};
@@ -931,6 +936,7 @@ static int spin_mesh(bContext *C, float *dvec, int steps, float degr, int dupli
                DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        }
        
+       EM_EndEditMesh(obedit->data, em);
        return ok;
 }
 
@@ -971,7 +977,7 @@ void MESH_OT_spin(wmOperatorType *ot)
 static int screw_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        EditVert *eve,*v1=0,*v2=0;
        EditEdge *eed;
        float dvec[3], nor[3];
@@ -1007,6 +1013,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op)
        }
        if(v1==NULL || v2==NULL) {
                BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
 
@@ -1025,13 +1032,16 @@ static int screw_mesh_exec(bContext *C, wmOperator *op)
        
        if(spin_mesh(C, dvec, turns*steps, 360.0f*turns, 0)) {
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-               
+               EM_EndEditMesh(obedit->data, em);               
                return OPERATOR_FINISHED;
        }
        else {
                BKE_report(op->reports, RPT_ERROR, "No valid vertices are selected");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 void MESH_OT_screw(wmOperatorType *ot)
@@ -1252,12 +1262,13 @@ static EnumPropertyItem prop_mesh_delete_types[] = {
 static int delete_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        delete_mesh(obedit,em, op,RNA_enum_get(op->ptr, "type"));
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -3626,7 +3637,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed,int dir)
 static int edge_rotate_selected(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
                
        int dir = RNA_int_get(op->ptr,"dir"); // dir == 2 when clockwise and ==1 for counter CW.
        EditEdge *eed;
@@ -3665,6 +3676,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
                else 
                {
                        BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
                }
        }
@@ -3680,6 +3692,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
        else 
        {       
                BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -3691,7 +3704,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
 
        
 //     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-       
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 
 }
@@ -4746,7 +4759,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
        ARegion *ar= CTX_wm_region(C);
        RegionView3D *rv3d= ar->regiondata;
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        EditVert *eve, *nextve;
        EditEdge *eed, *seed= NULL;
        EditFace *efa, *sefa= NULL;
@@ -4790,10 +4803,12 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        if(efa) {
                BKE_report(op->reports, RPT_ERROR, "Can't perform ripping with faces selected this way");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        if(sefa==NULL) {
                BKE_report(op->reports, RPT_ERROR, "No proper selection or faces included");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -4858,6 +4873,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        if(seed==NULL) {        // never happens?
                BKE_report(op->reports, RPT_ERROR, "No proper edge found to start");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -4947,6 +4963,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 //     scene->prop_mode = propmode;
 // XXX scene->proportional = prop;
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -5885,7 +5902,7 @@ void pathselect(EditMesh *em, wmOperator *op)
 static int region_to_loop(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        EditEdge *eed;
        EditFace *efa;
        
@@ -5918,6 +5935,7 @@ static int region_to_loop(bContext *C, wmOperator *op)
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6062,7 +6080,7 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){
 static int loop_to_region(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
 
        EditFace *efa;
@@ -6094,7 +6112,7 @@ static int loop_to_region(bContext *C, wmOperator *op)
 //     if (EM_texFaceCheck())
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-       
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6119,7 +6137,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot)
 static int mesh_rotate_uvs(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        EditFace *efa;
        short change = 0, ccw;
@@ -6129,6 +6147,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
 
        if (!EM_texFaceCheck(em)) {
                BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -6185,13 +6204,14 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        }
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
 static int mesh_mirror_uvs(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        EditFace *efa;
        short change = 0, altaxis;
@@ -6201,6 +6221,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
        
        if (!EM_texFaceCheck(em)) {
                BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -6271,13 +6292,15 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
 //             DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        }
+
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
 static int mesh_rotate_colors(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        EditFace *efa;
        short change = 0, ccw;
@@ -6286,6 +6309,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
        
        if (!EM_vertColorCheck(em)) {
                BKE_report(op->reports, RPT_ERROR, "mesh has no color layers");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -6325,6 +6349,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        }       
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6332,7 +6357,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
 static int mesh_mirror_colors(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        EditFace *efa;
        short change = 0, altaxis;
@@ -6341,6 +6366,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
        
        if (!EM_vertColorCheck(em)) {
                BKE_report(op->reports, RPT_ERROR, "Mesh has no color layers");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -6379,6 +6405,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        }
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6442,12 +6469,13 @@ static int subdivide_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, 1, 0);
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -6469,12 +6497,13 @@ static int subdivide_multi_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, RNA_int_get(op->ptr,"number_cuts"), 0);
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -6499,12 +6528,13 @@ static int subdivide_multi_fractal_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        esubdivideflag(obedit, em, 1, -(RNA_float_get(op->ptr, "random_factor")/100), scene->toolsettings->editbutflag, RNA_int_get(op->ptr, "number_cuts"), 0);
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -6530,12 +6560,13 @@ static int subdivide_smooth_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        esubdivideflag(obedit, em, 1, 0.292f*RNA_float_get(op->ptr, "smoothness"), scene->toolsettings->editbutflag | B_SMOOTH, 1, 0);
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;       
 }
 
@@ -6870,13 +6901,14 @@ static void fill_mesh(EditMesh *em)
 static int fill_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        fill_mesh(em);
        DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
        
 }
@@ -6898,12 +6930,13 @@ void MESH_OT_fill(wmOperatorType *ot)
 static int beauty_fill_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        beauty_fill(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6924,12 +6957,13 @@ void MESH_OT_beauty_fill(wmOperatorType *ot)
 static int convert_quads_to_tris_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        convert_to_triface(em,0);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6950,12 +6984,13 @@ void MESH_OT_convert_quads_to_tris(wmOperatorType *ot)
 static int convert_tris_to_quads_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
        join_triangles(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -6976,12 +7011,13 @@ void MESH_OT_convert_tris_to_quads(wmOperatorType *ot)
 static int edge_flip_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        edge_flip(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -7002,12 +7038,13 @@ void MESH_OT_edge_flip(wmOperatorType *ot)
 static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        mesh_set_smooth_faces(em,1);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -7028,12 +7065,13 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
 static int mesh_faces_shade_solid_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
        
        mesh_set_smooth_faces(em,0);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
index 5c108c5..1c9b173 100644 (file)
 static int mesh_add_duplicate_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh *)ob->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(ob->data);
 
        adduplicateflag(em, SELECT);
        
+       EM_EndEditMesh(ob->data, em);
        return OPERATOR_FINISHED;
 }
 
index 29e3d88..59d7ad7 100644 (file)
@@ -920,7 +920,7 @@ static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, floa
 static void select_editmesh_hook(Object *ob, HookModifierData *hmd)
 {
        Mesh *me= ob->data;
-       EditMesh *em= me->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(me);
        EditVert *eve;
        int index=0, nr=0;
        
@@ -931,6 +931,8 @@ static void select_editmesh_hook(Object *ob, HookModifierData *hmd)
                }
        }
        EM_select_flush(em);
+
+       EM_EndEditMesh(me, em);
 }
 
 static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar, float *cent)
@@ -1103,9 +1105,16 @@ int hook_getIndexArray(Object *obedit, int *tot, int **indexar, char *name, floa
                case OB_MESH:
                {
                        Mesh *me= obedit->data;
+                       EditMesh *em = EM_GetEditMesh(me);
+
                        /* check selected vertices first */
-                       if( return_editmesh_indexar(me->edit_mesh, tot, indexar, cent_r)) return 1;
-                       else return return_editmesh_vgroup(obedit, me->edit_mesh, name, cent_r);
+                       if( return_editmesh_indexar(em, tot, indexar, cent_r)) {
+                               EM_EndEditMesh(me, em);
+                               return 1;
+                       } else {
+                               int ret = return_editmesh_vgroup(obedit, em, name, cent_r);
+                               EM_EndEditMesh(me, em);
+                       }
                }
                case OB_CURVE:
                case OB_SURF:
@@ -2202,8 +2211,9 @@ void make_vertex_parent(Scene *scene, Object *obedit, View3D *v3d)
        
        if(obedit->type==OB_MESH) {
                Mesh *me= obedit->data;
-               
-               eve= me->edit_mesh->verts.first;
+               EditMesh *em = EM_GetEditMesh(me);
+
+               eve= em->verts.first;
                while(eve) {
                        if(eve->f & 1) {
                                if(v1==0) v1= nr;
@@ -2215,6 +2225,8 @@ void make_vertex_parent(Scene *scene, Object *obedit, View3D *v3d)
                        nr++;
                        eve= eve->next;
                }
+
+               EM_EndEditMesh(me, em);
        }
        else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) {
                ListBase *editnurb= curve_get_editcurve(obedit);
@@ -2834,8 +2846,9 @@ static int object_center_set_exec(bContext *C, wmOperator *op)
        
                if(obedit->type==OB_MESH) {
                        Mesh *me= obedit->data;
-                       
-                       for(eve= me->edit_mesh->verts.first; eve; eve= eve->next) {
+                       EditMesh *em = EM_GetEditMesh(me);
+
+                       for(eve= em->verts.first; eve; eve= eve->next) {
                                if(v3d->around==V3D_CENTROID) {
                                        total++;
                                        VECADD(cent, cent, eve->co);
@@ -2854,13 +2867,14 @@ static int object_center_set_exec(bContext *C, wmOperator *op)
                                cent[2]= (min[2]+max[2])/2.0f;
                        }
                        
-                       for(eve= me->edit_mesh->verts.first; eve; eve= eve->next) {
+                       for(eve= em->verts.first; eve; eve= eve->next) {
                                VecSubf(eve->co, eve->co, cent);                        
                        }
                        
-                       recalc_editnormals(me->edit_mesh);
+                       recalc_editnormals(em);
                        tot_change++;
                        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+                       EM_EndEditMesh(me, em);
                }
        }
        
index ff0a89b..d06259d 100644 (file)
@@ -57,6 +57,7 @@
 
 #include "ED_util.h"
 #include "ED_screen.h"
+#include "ED_mesh.h"
 #include "ED_screen_types.h"
 
 #include "RE_pipeline.h"
@@ -216,11 +217,14 @@ int ED_operator_uvedit(bContext *C)
        EditMesh *em= NULL;
 
        if(obedit && obedit->type==OB_MESH)
-               em= ((Mesh *)obedit->data)->edit_mesh;
+               em= EM_GetEditMesh((Mesh *)obedit->data);
 
-    if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE)))
+       if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE))) {
+               EM_EndEditMesh(obedit->data, em);
                return 1;
+       }
 
+       EM_EndEditMesh(obedit->data, em);
        return 0;
 }
 
@@ -230,11 +234,14 @@ int ED_operator_uvmap(bContext *C)
        EditMesh *em= NULL;
 
        if(obedit && obedit->type==OB_MESH)
-               em= ((Mesh *)obedit->data)->edit_mesh;
+               em= EM_GetEditMesh((Mesh *)obedit->data);
 
-    if(em && (em->faces.first))
+       if(em && (em->faces.first)) {
+               EM_EndEditMesh(obedit->data, em);
                return 1;
+       }
 
+       EM_EndEditMesh(obedit->data, em);
        return 0;
 }
 
index ef59252..80ace55 100644 (file)
@@ -381,7 +381,7 @@ static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 static void image_menu_uvlayers(Object *obedit, char *menustr, int *active)
 {
        Mesh *me= (Mesh*)obedit->data;
-       EditMesh *em= me->edit_mesh;
+       EditMesh *em= EM_GetEditMesh(me);
        CustomDataLayer *layer;
        int i, count = 0;
 
@@ -397,6 +397,8 @@ static void image_menu_uvlayers(Object *obedit, char *menustr, int *active)
        }
 
        *active= CustomData_get_active_layer(&em->fdata, CD_MTFACE);
+
+       EM_EndEditMesh(me, em);
 }
 
 static void do_image_buttons(bContext *C, void *arg, int event)
index 9f6a379..b6da741 100644 (file)
@@ -249,7 +249,7 @@ static void image_editvertex_buts(const bContext *C, uiBlock *block)
        
        image_transform_but_attr(sima, &imx, &imy, &step, &digits);
        
-       em= ((Mesh *)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh *)obedit->data);
        for (efa= em->faces.first; efa; efa= efa->next) {
                tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
                if (simaFaceDraw_Check(efa, tf)) {
@@ -338,6 +338,8 @@ static void image_editvertex_buts(const bContext *C, uiBlock *block)
                
                WM_event_add_notifier(C, NC_IMAGE, sima->image);
        }
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 
@@ -441,7 +443,7 @@ static void image_panel_view_properties(const bContext *C, ARegion *ar)
        
        if (obedit && obedit->type==OB_MESH) {
                Mesh *me= obedit->data;
-               EditMesh *em= me->edit_mesh;
+               EditMesh *em= EM_GetEditMesh(me);
                
                if(EM_texFaceCheck(em)) {
                        uiDefBut(block, LABEL, B_NOP, "Draw Type:",             10, 80,120,19, 0, 0, 0, 0, 0, "");
@@ -469,7 +471,8 @@ static void image_panel_view_properties(const bContext *C, ARegion *ar)
                                uiBlockEndAlign(block);
                        }
                }
-               
+
+               EM_EndEditMesh(me, em);
        }
        image_editcursor_buts(C, &ar->v2d, block);
 }
index bfe2f77..db8bdbd 100644 (file)
@@ -255,7 +255,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
        if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin));
        else if(obedit && obedit->type == OB_MESH) {
                Mesh *me= (Mesh*)obedit->data;
-               EditMesh *em= me->edit_mesh;
+               EditMesh *em= EM_GetEditMesh(me);
                MTFace *tf;
                
                if(em && EM_texFaceCheck(em)) {
@@ -278,6 +278,8 @@ static void image_refresh(const bContext *C, ScrArea *sa)
                                }
                        }
                }
+
+               EM_EndEditMesh(obedit->data, em);
        }
 }
 
@@ -755,8 +757,15 @@ int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
        if(ED_space_image_show_paint(sima))
                return 0;
 
-       if(obedit && obedit->type == OB_MESH)
-               return EM_texFaceCheck(((Mesh*)obedit->data)->edit_mesh);
+       if(obedit && obedit->type == OB_MESH) {
+               EditMesh *em = EM_GetEditMesh(obedit->data);
+               int ret;
+       
+               ret = EM_texFaceCheck(em);
+
+               EM_EndEditMesh(obedit->data, em);
+               return ret;
+       }
 
        return 0;
 }
@@ -767,8 +776,15 @@ int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
                return 0;
 
        if(ED_space_image_show_paint(sima))
-               if(obedit && obedit->type == OB_MESH)
-                       return EM_texFaceCheck(((Mesh*)obedit->data)->edit_mesh);
+               if(obedit && obedit->type == OB_MESH) {
+                       EditMesh *em = EM_GetEditMesh(obedit->data);
+                       int ret;
+
+                       ret = EM_texFaceCheck(em);
+
+                       EM_EndEditMesh(obedit->data, em);
+                       return ret;
+               }
 
        return 0;
 }
index e5e5f62..bbcb8b3 100644 (file)
@@ -161,7 +161,7 @@ static void v3d_editvertex_buts(const bContext *C, uiBlock *block, View3D *v3d,
 
        if(ob->type==OB_MESH) {
                Mesh *me= ob->data;
-               EditMesh *em = me->edit_mesh;
+               EditMesh *em = EM_GetEditMesh(me);
                EditVert *eve, *evedef=NULL;
                EditEdge *eed;
                
@@ -209,6 +209,8 @@ static void v3d_editvertex_buts(const bContext *C, uiBlock *block, View3D *v3d,
                                tfp->defweightp= &dvert->dw[0].weight;
                        }
                }
+
+               EM_EndEditMesh(me, em);
        }
        else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
                Curve *cu= ob->data;
@@ -363,7 +365,7 @@ static void v3d_editvertex_buts(const bContext *C, uiBlock *block, View3D *v3d,
                
                if(ob->type==OB_MESH) {
                        Mesh *me= ob->data;
-                       EditMesh *em = me->edit_mesh;
+                       EditMesh *em = EM_GetEditMesh(me);
                        EditVert *eve;
                        EditEdge *eed;
                        
@@ -388,6 +390,8 @@ static void v3d_editvertex_buts(const bContext *C, uiBlock *block, View3D *v3d,
                        }
                        
                        recalc_editnormals(em);
+
+                       EM_EndEditMesh(me, em);
                }
                else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
                        Curve *cu= ob->data;
index 45c2955..28db2f4 100644 (file)
@@ -4886,7 +4886,7 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
        int bit, ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
        
        if(obedit && obedit->type==OB_MESH) {
-               em= ((Mesh *)obedit->data)->edit_mesh;
+               em= EM_GetEditMesh((Mesh *)obedit->data);
        }
        /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
 
@@ -5117,6 +5117,8 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event)
                }
                break;
        }
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *ob, int *xcoord, int yco)
@@ -5481,7 +5483,7 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
 
                /* selection modus */
                if(obedit && (obedit->type == OB_MESH)) {
-                       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+                       EditMesh *em= EM_GetEditMesh((Mesh *)obedit->data);
 
                        uiBlockBeginAlign(block);
                        uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, xco,yco,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)");
@@ -5497,6 +5499,8 @@ void view3d_header_buttons(const bContext *C, ARegion *ar)
                        }
                        uiBlockEndAlign(block);
                        xco+= 20;
+
+                       EM_EndEditMesh(obedit->data, em);
                }
                else if(G.f & G_PARTICLEEDIT) {
                        uiBlockBeginAlign(block);
index 34c9dd2..4b2f23e 100644 (file)
@@ -120,7 +120,7 @@ static void draw_uvs_shadow(SpaceImage *sima, Object *obedit)
        EditFace *efa;
        TFace *tf;
        
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
 
        /* draws the grey mesh when painting */
        glColor3ub(112, 112, 112);
@@ -135,6 +135,8 @@ static void draw_uvs_shadow(SpaceImage *sima, Object *obedit)
                        if(efa->v4) glVertex2fv(tf->uv[3]);
                glEnd();
        }
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 static int draw_uvs_dm_shadow(DerivedMesh *dm)
@@ -426,7 +428,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
        int drawfaces, interpedges, lastsel, sel;
        Image *ima= sima->image;
        
-       em= me->edit_mesh;
+       em= EM_GetEditMesh(me);
        activetf= EM_get_active_mtface(em, &efa_act, NULL, 0); /* will be set to NULL if hidden */
 
        settings= scene->toolsettings;
@@ -824,6 +826,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
        }
 
        glPointSize(1.0);
+       EM_EndEditMesh(obedit->data, em);
 }
 
 void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedit)
index e379820..17b2aff 100644 (file)
 
 int ED_uvedit_test(Object *obedit)
 {
+       EditMesh *em;
+       int ret;
+
        if(obedit->type != OB_MESH)
                return 0;
 
-       return EM_texFaceCheck(((Mesh*)obedit->data)->edit_mesh);
+       em = EM_GetEditMesh(obedit->data);
+       ret = EM_texFaceCheck(em);
+       EM_EndEditMesh(obedit->data, em);
+       
+       return ret;
 }
 
 /************************* assign image ************************/
@@ -98,9 +105,11 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre
        if(!obedit || (obedit->type != OB_MESH))
                return;
 
-       em= ((Mesh*)obedit->data)->edit_mesh;
-       if(!em || !em->faces.first)
+       em= EM_GetEditMesh(((Mesh*)obedit->data));
+       if(!em || !em->faces.first) {
+               EM_EndEditMesh(obedit->data, em);
                return;
+       }
        
        /* ensure we have a uv layer */
        if(!CustomData_has_layer(&em->fdata, CD_MTFACE)) {
@@ -135,6 +144,8 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre
        /* and update depdency graph */
        if(update)
                DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 /* dotile -    1, set the tile flag (from the space image)
@@ -153,7 +164,7 @@ void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, i
        if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
                return;
        
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
 
        for(efa= em->faces.first; efa; efa= efa->next) {
                tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -173,6 +184,7 @@ void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, i
 
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+       EM_EndEditMesh(obedit->data, em);
 }
 
 /*********************** space conversion *********************/
@@ -356,7 +368,7 @@ void uv_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy)
 
 int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float *max)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        int sel;
@@ -373,13 +385,14 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float
                        if(efa->v4 && (uvedit_uv_selected(scene, efa, tf, 3)))  { DO_MINMAX2(tf->uv[3], min, max); sel = 1; }
                }
        }
-
+       
+       EM_EndEditMesh(obedit->data, em);
        return sel;
 }
 
 int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, int mode)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        float min[2], max[2];
@@ -407,10 +420,12 @@ int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, int mod
        if(change) {
                cent[0]= (min[0]+max[0])/2.0;
                cent[1]= (min[1]+max[1])/2.0;
-
+               
+               EM_EndEditMesh(obedit->data, em);
                return 1;
        }
 
+       EM_EndEditMesh(obedit->data, em);
        return 0;
 }
 
@@ -569,7 +584,7 @@ static void find_nearest_uv_vert(Scene *scene, Image *ima, EditMesh *em, float c
 
 int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, float co[2], float uv[2])
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        float mindist, dist;
@@ -599,6 +614,7 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, float co[2],
                }
        }
 
+       EM_EndEditMesh(obedit->data, em);
        return found;
 }
 
@@ -978,7 +994,7 @@ static void weld_align_uv(bContext *C, int tool)
        
        scene= CTX_data_scene(C);
        obedit= CTX_data_edit_object(C);
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
        ima= CTX_data_edit_image(C);
 
        INIT_MINMAX2(min, max);
@@ -1038,6 +1054,8 @@ static void weld_align_uv(bContext *C, int tool)
 
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 static int align_exec(bContext *C, wmOperator *op)
@@ -1111,7 +1129,7 @@ static int stitch_exec(bContext *C, wmOperator *op)
        sima= (SpaceImage*)CTX_wm_space_data(C);
        scene= CTX_data_scene(C);
        obedit= CTX_data_edit_object(C);
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
        ima= CTX_data_edit_image(C);
        
        if(RNA_boolean_get(op->ptr, "use_limit")) {
@@ -1126,8 +1144,10 @@ static int stitch_exec(bContext *C, wmOperator *op)
                EM_init_index_arrays(em, 0, 0, 1);
                vmap= EM_make_uv_vert_map(em, 1, 0, limit);
 
-               if(vmap == NULL)
+               if(vmap == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
 
                for(a=0, eve= em->verts.first; eve; a++, eve= eve->next) {
                        vlist= EM_get_uv_map_vert(vmap, a);
@@ -1256,6 +1276,7 @@ static int stitch_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1288,7 +1309,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
        
        scene= CTX_data_scene(C);
        obedit= CTX_data_edit_object(C);
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
        ima= CTX_data_edit_image(C);
 
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
@@ -1309,6 +1330,7 @@ static int select_inverse_exec(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1338,7 +1360,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
        
        scene= CTX_data_scene(C);
        obedit= CTX_data_edit_object(C);
-       em= ((Mesh*)obedit->data)->edit_mesh;
+       em= EM_GetEditMesh((Mesh*)obedit->data);
        ima= CTX_data_edit_image(C);
        
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
@@ -1376,6 +1398,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1422,7 +1445,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        NearestHit hit;
@@ -1456,14 +1479,18 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        if(loop) {
                /* find edge */
                find_nearest_uv_edge(scene, ima, em, co, &hit);
-               if(hit.efa == NULL)
+               if(hit.efa == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
        }
        else if(selectmode == UV_SELECT_VERTEX) {
                /* find vertex */
                find_nearest_uv_vert(scene, ima, em, co, penalty, &hit);
-               if(hit.efa == NULL)
+               if(hit.efa == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
 
                /* mark 1 vertex as being hit */
                for(i=0; i<4; i++)
@@ -1475,8 +1502,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        else if(selectmode == UV_SELECT_EDGE) {
                /* find edge */
                find_nearest_uv_edge(scene, ima, em, co, &hit);
-               if(hit.efa == NULL)
+               if(hit.efa == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
 
                /* mark 2 edge vertices as being hit */
                for(i=0; i<4; i++)
@@ -1492,8 +1521,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        else if(selectmode == UV_SELECT_FACE) {
                /* find face */
                find_nearest_uv_face(scene, ima, em, co, &hit);
-               if(hit.efa == NULL)
+               if(hit.efa == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
                
                /* make active */
                EM_set_actFace(em, hit.efa);
@@ -1512,11 +1543,15 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        else if(selectmode == UV_SELECT_ISLAND) {
                find_nearest_uv_vert(scene, ima, em, co, NULL, &hit);
 
-               if(hit.efa==NULL)
+               if(hit.efa==NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return OPERATOR_CANCELLED;
+               }
        }
-       else
+       else {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        /* do selection */
        if(loop) {
@@ -1666,7 +1701,8 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
        
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+       
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_PASS_THROUGH|OPERATOR_FINISHED;
 }
 
@@ -1772,12 +1808,13 @@ static int select_linked_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        float limit[2];
        int extend;
 
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
                BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled.");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
 
@@ -1788,6 +1825,7 @@ static int select_linked_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1814,12 +1852,13 @@ static int unlink_selection_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
 
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
                BKE_report(op->reports, RPT_ERROR, "Can't unlink selection when sync selection is enabled.");
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
        }
        
@@ -1841,6 +1880,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1873,7 +1913,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
         * This only needs to be done when the Mesh is not used for
         * selection (so for sticky modes, vertex or location based). */
        
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        int nverts, i;
@@ -1928,8 +1968,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
                /*for(a=0, eve= em->verts.first; eve; a++, eve= eve->next)
                        eve->tmp.l = a; */
                
-               if(vmap == NULL)
+               if(vmap == NULL) {
+                       EM_EndEditMesh(obedit->data, em);
                        return;
+               }
                
                for(efa_index=0, efa= em->faces.first; efa; efa_index++, efa= efa->next) {
                        if(efa->tmp.l) {
@@ -1989,6 +2031,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje
                        }
                }
        }
+       EM_EndEditMesh(obedit->data, em);
 }
 
 static int border_select_exec(bContext *C, wmOperator *op)
@@ -1998,7 +2041,7 @@ static int border_select_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
        ARegion *ar= CTX_wm_region(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tface;
        rcti rect;
@@ -2110,10 +2153,12 @@ static int border_select_exec(bContext *C, wmOperator *op)
                }
 
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+               
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_FINISHED;
        }
-
+       
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_CANCELLED;
 } 
 
@@ -2166,7 +2211,7 @@ int circle_select_exec(bContext *C, wmOperator *op)
        SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        ARegion *ar= CTX_wm_region(C);
        EditFace *efa;
        MTFace *tface;
@@ -2204,6 +2249,7 @@ int circle_select_exec(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -2301,7 +2347,7 @@ void UV_OT_snap_cursor(wmOperatorType *ot)
 
 static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *v2d)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tface;
        short change= 0;
@@ -2319,12 +2365,13 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *
                }
        }
 
+       EM_EndEditMesh(obedit->data, em);
        return change;
 }
 
 static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obedit)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        EditVert *eve;
        MTFace *tface;
@@ -2399,6 +2446,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
        if(!change) {
                MEM_freeN(coords);
                MEM_freeN(usercount);
+               EM_EndEditMesh(obedit->data, em);
                return change;
        }
        
@@ -2445,12 +2493,13 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe
        MEM_freeN(coords);
        MEM_freeN(usercount);
 
+       EM_EndEditMesh(obedit->data, em);
        return change;
 }
 
 static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        Image *ima= sima->image;
        EditFace *efa;
        MTFace *tface;
@@ -2475,6 +2524,7 @@ static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit)
                }
        }
 
+       EM_EndEditMesh(obedit->data, em);
        return change;
 }
 
@@ -2536,7 +2586,7 @@ static int pin_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tface;
        int clear= RNA_boolean_get(op->ptr, "clear");
@@ -2564,6 +2614,7 @@ static int pin_exec(bContext *C, wmOperator *op)
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -2589,7 +2640,7 @@ static int select_pinned_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Image *ima= CTX_data_edit_image(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tface;
        
@@ -2608,6 +2659,7 @@ static int select_pinned_exec(bContext *C, wmOperator *op)
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -2630,7 +2682,7 @@ static int hide_exec(bContext *C, wmOperator *op)
        SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        int swap= RNA_boolean_get(op->ptr, "unselected");
@@ -2638,6 +2690,8 @@ static int hide_exec(bContext *C, wmOperator *op)
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
                EM_hide_mesh(em, swap);
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_FINISHED;
        }
        
@@ -2745,6 +2799,7 @@ static int hide_exec(bContext *C, wmOperator *op)
        EM_validate_selections(em);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -2770,7 +2825,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
        SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        
@@ -2778,6 +2833,8 @@ static int reveal_exec(bContext *C, wmOperator *op)
        if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
                EM_reveal_mesh(em);
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_FINISHED;
        }
        
@@ -2873,6 +2930,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
index d34c0b9..e8a0de2 100644 (file)
 
 static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
 
-       if(ED_uvedit_test(obedit))
+       if(ED_uvedit_test(obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return 1;
+       }
 
        if(em && em->faces.first)
                EM_add_data_layer(em, &em->fdata, CD_MTFACE);
        
-       if(!ED_uvedit_test(obedit))
+       if(!ED_uvedit_test(obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return 0;
+       }
        
        // XXX this image is not in context in 3d view .. only
        // way to get would be to find the first image window?
@@ -95,6 +99,7 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit)
                uvedit_face_select(scene, efa, tf);
        }
 
+       EM_EndEditMesh(obedit->data, em);
        return 1;
 }
 
@@ -218,7 +223,7 @@ static void minimize_stretch_init(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        MinStretch *ms;
        int fill_holes= RNA_boolean_get(op->ptr, "fill_holes");
 
@@ -400,7 +405,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        ParamHandle *handle;
 
        handle = construct_param_handle(scene, em, 1, 0, 1, 1);
@@ -411,6 +416,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -432,7 +438,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        ParamHandle *handle;
 
        handle= construct_param_handle(scene, em, 1, 0, 1, 1);
@@ -443,6 +449,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -464,15 +471,19 @@ static ParamHandle *liveHandle = NULL;
 
 void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
 {
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        short abf = scene->toolsettings->unwrapper == 1;
        short fillholes = scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES;
 
-       if(!ED_uvedit_test(obedit)) return;
+       if(!ED_uvedit_test(obedit)) {
+               EM_EndEditMesh(obedit->data, em);
+               return;
+       }
 
        liveHandle = construct_param_handle(scene, em, 0, fillholes, 1, 1);
 
        param_lscm_begin(liveHandle, PARAM_TRUE, abf);
+       EM_EndEditMesh(obedit->data, em);
 }
 
 void ED_uvedit_live_unwrap_re_solve(void)
@@ -595,7 +606,7 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float
        /* context checks are messy here, making it work in both 3d view and uv editor */
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        View3D *v3d= CTX_wm_view3d(C);
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
        /* common operator properties */
@@ -621,6 +632,8 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float
                Mat4One(rotmat);
        else 
                uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
+
+       EM_EndEditMesh(obedit->data, em);
 }
 
 static void uv_transform_properties(wmOperatorType *ot, int radius)
@@ -773,15 +786,17 @@ static int unwrap_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        ParamHandle *handle;
        int method = RNA_enum_get(op->ptr, "method");
        int fill_holes = RNA_boolean_get(op->ptr, "fill_holes");
        int correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect");
        
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        handle= construct_param_handle(scene, em, 0, fill_holes, 0, correct_aspect);
 
@@ -798,6 +813,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -882,15 +898,17 @@ static int from_view_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        ARegion *ar= CTX_wm_region(C);
        EditFace *efa;
        MTFace *tf;
        float rotmat[4][4];
 
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        if(RNA_boolean_get(op->ptr, "orthographic")) {
                uv_map_rotation_matrix(rotmat, ar->regiondata, obedit, 90.0f, 0.0f, 1.0f);
@@ -928,6 +946,7 @@ static int from_view_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -963,13 +982,15 @@ static int reset_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
 
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        for(efa= em->faces.first; efa; efa= efa->next) {
                if(efa->f & SELECT) {
@@ -992,6 +1013,7 @@ static int reset_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1047,14 +1069,16 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        float center[3], rotmat[4][4];
 
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        uv_map_transform(C, op, center, rotmat);
 
@@ -1077,6 +1101,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1116,14 +1141,16 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        float center[3], rotmat[4][4];
 
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        uv_map_transform(C, op, center, rotmat);
 
@@ -1146,6 +1173,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
@@ -1171,15 +1199,17 @@ static int cube_project_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
-       EditMesh *em= ((Mesh*)obedit->data)->edit_mesh;
+       EditMesh *em= EM_GetEditMesh((Mesh*)obedit->data);
        EditFace *efa;
        MTFace *tf;
        float no[3], cube_size, *loc, dx, dy;
        int cox, coy;
 
        /* add uvs if they don't exist yet */
-       if(!ED_uvedit_ensure_uvs(C, scene, obedit))
+       if(!ED_uvedit_ensure_uvs(C, scene, obedit)) {
+               EM_EndEditMesh(obedit->data, em);
                return OPERATOR_CANCELLED;
+       }
 
        loc= obedit->obmat[3];
        cube_size= RNA_float_get(op->ptr, "cube_size");
@@ -1230,6 +1260,7 @@ static int cube_project_exec(bContext *C, wmOperator *op)
        DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit);
 
+       EM_EndEditMesh(obedit->data, em);
        return OPERATOR_FINISHED;
 }
 
index 4aa8d6a..6a4c7dd 100644 (file)
@@ -2,10 +2,13 @@
 import sys
 import os
 
+def normpath(path):
+       return os.path.abspath(os.path.normpath(path))
+
 Import ('env')
 cflags = ''
 defines = []
-root_build_dir=env['BF_BUILDDIR']
+root_build_dir=normpath(env['BF_BUILDDIR'])
 
 source_files = ['makesdna.c']
 header_files = env.Glob('../*.h')
@@ -31,14 +34,15 @@ if not USE_WINE:
 if sys.platform != 'cygwin':
        makesdna_tool.Append (CCFLAGS = cflags)
 makesdna_tool.Append (CPPDEFINES = defines)
-targetdir = root_build_dir+'/lib'
+targetdir = normpath(root_build_dir+'/lib')
+
 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
        targetdir = '#'+targetdir
 makesdna_tool.Append (LIBPATH = targetdir)
 if env['BF_PROFILE']:
        makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS'])
 
-targetdir = root_build_dir + '/makesdna'
+targetdir = normpath(root_build_dir + '/makesdna')
 
 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
        targetdir = '#' + targetdir
index 489bce1..7bd5211 100644 (file)
@@ -2,10 +2,13 @@
 import sys
 import os
 
+def normpath(path):
+       return os.path.abspath(os.path.normpath(path))
+
 Import ('env')
 cflags = '-Wall'
 defines = []
-root_build_dir=env['BF_BUILDDIR']
+root_build_dir=normpath(env['BF_BUILDDIR'])
 
 source_files = env.Glob('*.c')