2.5
authorTon Roosendaal <ton@blender.org>
Wed, 31 Dec 2008 17:11:42 +0000 (17:11 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 31 Dec 2008 17:11:42 +0000 (17:11 +0000)
So, editmode mesh is back! :)
At the moment only TABkey works and mouse select, 1 vertex at a
time. More will follow of course.

Note for the devs:
- G.editMesh has been removed, be careful with old code.
- EditMesh now is property of Mesh itself
  Although it means unlimited editmodes, for migration purposes we
  better stick to 1 "obedit" per scene, which is in Context too
- G.obedit will get removed soon, so use CTX_data_edit_object(C)
  Or if you can't, just scene->obedit for now
- Also removed the CTX_data_edit_mesh(), this has no meaning
  anymore. EditMesh is not context senstitive anymore, only the
  edit-object for time being is.
- Martin: I've already tucked some EditMesh pointer in T and
  removed all G.editMesh there.

51 files changed:
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_bmesh.h
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/multires-firstlevel.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_util.h
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/editmesh.h
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_context.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/ed_util.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c

index 5a1e266..661686c 100644 (file)
@@ -443,14 +443,14 @@ DerivedMesh *mesh_create_derived_no_deform_render(struct Object *ob,
                                                   float (*vertCos)[3],
                                                   CustomDataMask dataMask);
 
-DerivedMesh *editmesh_get_derived_base(void);
-DerivedMesh *editmesh_get_derived_cage(CustomDataMask dataMask);
-DerivedMesh *editmesh_get_derived_cage_and_final(DerivedMesh **final_r,
+DerivedMesh *editmesh_get_derived_base(struct EditMesh *em);
+DerivedMesh *editmesh_get_derived_cage(struct EditMesh *em, CustomDataMask dataMask);
+DerivedMesh *editmesh_get_derived_cage_and_final(struct EditMesh *em, DerivedMesh **final_r,
                                                  CustomDataMask dataMask);
 
 /* returns an array of deform matrices for crazyspace correction, and the
    number of modifiers left */
-int editmesh_get_first_deform_matrices(float (**deformmats)[3][3],
+int editmesh_get_first_deform_matrices(struct EditMesh *em, float (**deformmats)[3][3],
                                        float (**deformcos)[3]);
 
 void weight_to_rgb(float input, float *fr, float *fg, float *fb);
index 71c042e..b3ce544 100644 (file)
@@ -247,7 +247,7 @@ struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int option
 
 /*CONVERSION FUNCTIONS*/
 struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em);
-struct EditMesh *BME_bmesh_to_editmesh(struct BME_Mesh *bm, BME_TransData_Head *td);
+void   BME_bmesh_to_editmesh(struct BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em);
 struct BME_Mesh *BME_derivedmesh_to_bmesh(struct DerivedMesh *dm);
 struct DerivedMesh *BME_bmesh_to_derivedmesh(struct BME_Mesh *bm, struct DerivedMesh *dm);
 #endif
index 791d725..88c71a1 100644 (file)
@@ -142,10 +142,7 @@ int CTX_data_visible_bases(const bContext *C, ListBase *list);
 
 struct Object *CTX_data_active_object(const bContext *C);
 struct Base *CTX_data_active_base(const bContext *C);
-
 struct Object *CTX_data_edit_object(const bContext *C);
-struct EditMesh *CTX_data_edit_mesh(const bContext *C);
-struct ListBase *CTX_data_edit_armature(const bContext *C);
 
 /* Data Evaluation Context */
 
index a534dcc..6c77ac8 100644 (file)
@@ -60,7 +60,7 @@ struct ListBase;
 struct Material;
 struct Bone;
 struct Mesh;
-
+struct EditMesh;
 
 /* used for curves, nurbs, mball, importing */
 typedef struct DispList {
@@ -85,7 +85,7 @@ extern void addnormalsDispList(struct Object *ob, struct ListBase *lb);
 extern void count_displist(struct ListBase *lb, int *totvert, int *totface);
 extern void freedisplist(struct ListBase *lb);
 extern int displist_has_faces(struct ListBase *lb);
-extern void makeDerivedMesh(struct Object *ob, CustomDataMask dataMask);
+extern void makeDerivedMesh(struct Object *ob, struct EditMesh *em, CustomDataMask dataMask);
 extern void makeDispListSurf(struct Object *ob, struct ListBase *dispbase, int forRender);
 extern void makeDispListCurveTypes(struct Object *ob, int forOrco);
 extern void makeDispListMBall(struct Object *ob);
index 2edf10f..4b04a3c 100644 (file)
@@ -60,7 +60,6 @@ struct ARegion;
 struct Object;
 struct bSoundListener;
 struct BMF_Font;
-struct EditMesh;
 struct BME_Glob;
 
 typedef struct Global {
@@ -97,9 +96,6 @@ typedef struct Global {
        short rt;
        int f;
 
-       /* Editmode lists */
-       struct EditMesh *editMesh;
-       
        /* Used for BMesh transformations */
        struct BME_Glob *editBMesh;
     
index 2129042..da6ab7e 100644 (file)
@@ -343,26 +343,22 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) {
        BME_model_end(bm);
        return bm;
 }
-/* adds the geometry in the bmesh to G.editMesh (does not free G.editMesh)
+/* adds the geometry in the bmesh to editMesh (does not free editMesh)
  * if td != NULL, the transdata will be mapped to the EditVert's co */
-EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
+void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) {
        BME_Vert *v1;
        BME_Edge *e;
        BME_Poly *f;
        
        BME_TransData *vtd;
 
-       EditMesh *em;
        EditVert *eve1, *eve2, *eve3, *eve4, **evlist;
        EditEdge *eed;
        EditFace *efa;
 
        int totvert, len, i, numTex, numCol;
 
-       em = G.editMesh;
-
-       if (em == NULL) return NULL;
-
+       if (em == NULL) return;
 
        CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
        CustomData_copy(&bm->edata, &em->edata, CD_MASK_BMESH, CD_CALLOC, 0);
@@ -438,9 +434,6 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
 
        MEM_freeN(evlist);
 
-       //XXX countall();
-
-       return em;
 }
 
 /* Adds the geometry found in dm to bm
index 3b0d90a..1636859 100644 (file)
@@ -629,7 +629,7 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
                        if(draw) {
                                if (draw==2) { /* enabled with stipple */
                                        glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(0); //XXX stipple_quarttone);
+                                       glPolygonStipple(stipple_quarttone);
                                }
                                
                                glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
@@ -666,7 +666,7 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
                        if(draw) {
                                if (draw==2) { /* enabled with stipple */
                                        glEnable(GL_POLYGON_STIPPLE);
-                                       glPolygonStipple(0); //XXX stipple_quarttone);
+                                       glPolygonStipple(stipple_quarttone);
                                }
                                glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
 
@@ -2396,12 +2396,11 @@ static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm)
        return 1;
 }
 
-static void editmesh_calc_modifiers(DerivedMesh **cage_r,
+static void editmesh_calc_modifiers(EditMesh *em, DerivedMesh **cage_r,
                                     DerivedMesh **final_r,
                                     CustomDataMask dataMask)
 {
        Object *ob = G.obedit;
-       EditMesh *em = G.editMesh;
        ModifierData *md;
        float (*deformedVerts)[3] = NULL;
        CustomDataMask mask;
@@ -2742,12 +2741,10 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
        }
 }
 
-static void editmesh_build_data(CustomDataMask dataMask)
+static void editmesh_build_data(EditMesh *em, CustomDataMask dataMask)
 {
        float min[3], max[3];
 
-       EditMesh *em = G.editMesh;
-
        clear_mesh_caches(G.obedit);
 
        if (em->derivedFinal) {
@@ -2763,7 +2760,7 @@ static void editmesh_build_data(CustomDataMask dataMask)
                em->derivedCage = NULL;
        }
 
-       editmesh_calc_modifiers(&em->derivedCage, &em->derivedFinal, dataMask);
+       editmesh_calc_modifiers(em, &em->derivedCage, &em->derivedFinal, dataMask);
        em->lastDataMask = dataMask;
 
        INIT_MINMAX(min, max);
@@ -2778,10 +2775,10 @@ static void editmesh_build_data(CustomDataMask dataMask)
        em->derivedCage->needsFree = 0;
 }
 
-void makeDerivedMesh(Object *ob, CustomDataMask dataMask)
+void makeDerivedMesh(Object *ob, EditMesh *em, CustomDataMask dataMask)
 {
-       if (ob==G.obedit) {
-               editmesh_build_data(dataMask);
+       if (em) {
+               editmesh_build_data(em, dataMask);
        } else {
                mesh_build_data(ob, dataMask);
        }
@@ -2953,35 +2950,35 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
 
 /***/
 
-DerivedMesh *editmesh_get_derived_cage_and_final(DerivedMesh **final_r,
+DerivedMesh *editmesh_get_derived_cage_and_final(EditMesh *em, DerivedMesh **final_r,
                                                  CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!G.editMesh->derivedCage ||
-          (G.editMesh->lastDataMask & dataMask) != dataMask)
-               editmesh_build_data(dataMask);
+       if(!em->derivedCage ||
+          (em->lastDataMask & dataMask) != dataMask)
+               editmesh_build_data(em, dataMask);
 
-       *final_r = G.editMesh->derivedFinal;
-       return G.editMesh->derivedCage;
+       *final_r = em->derivedFinal;
+       return em->derivedCage;
 }
 
-DerivedMesh *editmesh_get_derived_cage(CustomDataMask dataMask)
+DerivedMesh *editmesh_get_derived_cage(EditMesh *em, CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
         * the data we need, rebuild the derived mesh
         */
-       if(!G.editMesh->derivedCage ||
-          (G.editMesh->lastDataMask & dataMask) != dataMask)
-               editmesh_build_data(dataMask);
+       if(!em->derivedCage ||
+          (em->lastDataMask & dataMask) != dataMask)
+               editmesh_build_data(em, dataMask);
 
-       return G.editMesh->derivedCage;
+       return em->derivedCage;
 }
 
-DerivedMesh *editmesh_get_derived_base(void)
+DerivedMesh *editmesh_get_derived_base(EditMesh *em)
 {
-       return getEditMeshDerivedMesh(G.editMesh, G.obedit, NULL);
+       return getEditMeshDerivedMesh(em, G.obedit, NULL);
 }
 
 
@@ -3043,10 +3040,9 @@ float *mesh_get_mapped_verts_nors(Object *ob)
 
 /* ********* crazyspace *************** */
 
-int editmesh_get_first_deform_matrices(float (**deformmats)[3][3], float (**deformcos)[3])
+int editmesh_get_first_deform_matrices(EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3])
 {
        Object *ob = G.obedit;
-       EditMesh *em = G.editMesh;
        ModifierData *md;
        DerivedMesh *dm;
        int i, a, numleft = 0, numVerts = 0;
index 26afa09..9532229 100644 (file)
@@ -434,28 +434,27 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
 static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], int level, int animated)
 {
        Object *ob, *ob_iter;
-       Mesh *me;
+       Mesh *me= par->data;
        Base *base = NULL;
-       float vec[3], no[3], pmat[4][4];
-       int lay, totvert, a, oblay;
        DerivedMesh *dm;
        struct vertexDupliData vdd;
        Scene *sce = NULL;
        Group *group = NULL;
        GroupObject * go = NULL;
+       float vec[3], no[3], pmat[4][4];
+       int lay, totvert, a, oblay;
        
        Mat4CpyMat4(pmat, par->obmat);
        
        /* simple preventing of too deep nested groups */
        if(level>MAX_DUPLI_RECUR) return;
 
-       if(par==G.obedit)
-               dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
+       if(me->edit_mesh)
+               dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
        else
                dm= mesh_get_derived_deform(par, CD_MASK_BAREMESH);
 
        if(G.rendering) {
-               me= par->data;
                vdd.orco= (float(*)[3])get_mesh_orco_verts(par);
                transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0);
        }
@@ -544,7 +543,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
        Base *base = NULL;
        DupliObject *dob;
        DerivedMesh *dm;
-       Mesh *me;
+       Mesh *me= par->data;
        MTFace *mtface;
        MFace *mface;
        MVert *mvert;
@@ -560,9 +559,10 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
        
        Mat4CpyMat4(pmat, par->obmat);
 
-       if(par==G.obedit) {
+       if(me->edit_mesh) {
                int totvert;
-               dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
+               
+               dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
                
                totface= dm->getNumFaces(dm);
                mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
@@ -580,7 +580,6 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
        }
 
        if(G.rendering) {
-               me= (Mesh*)par->data;
 
                orco= (float(*)[3])get_mesh_orco_verts(par);
                transform_mesh_orco_verts(me, orco, me->totvert, 0);
index 0dd9a34..7b14061 100644 (file)
@@ -185,15 +185,10 @@ void free_blender(void)
        free_nodesystem();      
 }
 
-static EditMesh theEditMesh;
-
 void initglobals(void)
 {
        memset(&G, 0, sizeof(Global));
        
-       memset(&theEditMesh, 0, sizeof(theEditMesh));
-       G.editMesh = &theEditMesh;
-
        U.savetime= 1;
 
        G.main= MEM_callocN(sizeof(Main), "initglobals");
@@ -228,10 +223,7 @@ static void clear_global(void)
        free_main(G.main);                      /* free all lib data */
        
        if (G.obedit) {
-//             freeNurblist(&editNurb);
-//             free_editMesh(G.editMesh);
 //             free_editText();
-//             free_editArmature();
        }
 //     free_vertexpaint();
 
index 97a22f9..82b1c71 100644 (file)
@@ -44,6 +44,7 @@
 #include "DNA_object_types.h"
 #include "DNA_action_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_scene_types.h"
@@ -536,6 +537,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
 static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
 {
        DerivedMesh *dm;
+       Mesh *me= ob->data;
        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];
@@ -549,9 +551,9 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
        if (dgroup < 0) return;
        
        /* get DerivedMesh */
-       if ((G.obedit == ob) && (G.editMesh)) {
+       if (me->edit_mesh) {
                /* target is in editmode, so get a special derived mesh */
-               dm = CDDM_from_editmesh(G.editMesh, ob->data);
+               dm = CDDM_from_editmesh(me->edit_mesh, ob->data);
        }
        else {
                /* when not in EditMode, this should exist */
@@ -621,7 +623,7 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4])
        }
        
        /* free temporary DerivedMesh created (in EditMode case) */
-       if (G.editMesh) {
+       if (me->edit_mesh) {
                if (dm) dm->release(dm);
        }
 }
index f4fef11..1e45c68 100644 (file)
@@ -387,15 +387,6 @@ struct Object *CTX_data_edit_object(const bContext *C)
        return ctx_data_pointer_get(C, CTX_data_edit_object);
 }
 
-struct EditMesh *CTX_data_edit_mesh(const bContext *C)
-{
-       return ctx_data_pointer_get(C, CTX_data_edit_mesh);
-}
-
-ListBase *CTX_data_edit_armature(const bContext *C)
-{
-       return ctx_data_pointer_get(C, CTX_data_edit_armature);
-}
 
 /* data evaluation */
 
index c8648e1..4fe862e 100644 (file)
@@ -2577,8 +2577,8 @@ void write_stl(char *str)
 
 static void write_videoscape_mesh(Object *ob, char *str)
 {
-       EditMesh *em = G.editMesh;
        Mesh *me;
+       EditMesh *em = me->edit_mesh;
        Material *ma;
        MFace *mface;
        FILE *fp;
index 07a1a5c..f531c2c 100644 (file)
@@ -142,6 +142,7 @@ void free_mesh(Mesh *me)
        
        if(me->bb) MEM_freeN(me->bb);
        if(me->mselect) MEM_freeN(me->mselect);
+       if(me->edit_mesh) MEM_freeN(me->edit_mesh);
 
        if(me->mr) multires_free(me->mr);
 }
index eebd5e6..38e8b1b 100644 (file)
@@ -7553,20 +7553,21 @@ static void meshdeformModifier_do(
       float (*vertexCos)[3], int numVerts)
 {
        MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
-       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];
-       int a, b, totvert, totcagevert, defgrp_index;
+       Mesh *me= ob->data;
        DerivedMesh *tmpdm, *cagedm;
        MDeformVert *dvert = NULL;
        MDeformWeight *dw;
        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];
+       int a, b, totvert, totcagevert, defgrp_index;
+       
        if(!mmd->object || (!mmd->bindcos && !mmd->needbind))
                return;
        
        /* get cage derivedmesh */
-       if(mmd->object == G.obedit) {
-               tmpdm= editmesh_get_derived_cage_and_final(&cagedm, 0);
+       if(me->edit_mesh) {
+               tmpdm= editmesh_get_derived_cage_and_final(me->edit_mesh, &cagedm, 0);
                if(tmpdm)
                        tmpdm->release(tmpdm);
        }
index 8c667a9..0c21cef 100644 (file)
@@ -83,16 +83,16 @@ void multires_update_customdata(MultiresLevel *lvl1, EditMesh *em, CustomData *s
                
                if(CustomData_has_layer(src, type)) {
                        if(em) {
-                               EditVert *eve= G.editMesh->verts.first;
-                               EditFace *efa= G.editMesh->faces.first;
+                               EditVert *eve= em->verts.first;
+                               EditFace *efa= em->faces.first;
                                CustomData_copy(src, dst, cdmask(type), CD_CALLOC, tot);
                                for(i=0; i<tot; ++i) {
                                        if(type == CD_MDEFORMVERT) {
-                                               CustomData_from_em_block(&G.editMesh->vdata, dst, eve->data, i);
+                                               CustomData_from_em_block(&em->vdata, dst, eve->data, i);
                                                eve= eve->next;
                                        }
                                        else if(type == CD_MTFACE) {
-                                               CustomData_from_em_block(&G.editMesh->fdata, dst, efa->data, i);
+                                               CustomData_from_em_block(&em->fdata, dst, efa->data, i);
                                                efa= efa->next;
                                        }
                                }
index 96e81c6..99e4083 100644 (file)
@@ -274,7 +274,7 @@ static void multires_col_avg2(MultiresCol *avg, MultiresCol *c1, MultiresCol *c2
 void multires_load_cols(Mesh *me)
 {
        MultiresLevel *lvl= BLI_findlink(&me->mr->levels,me->mr->current-1), *cur;
-       EditMesh *em= G.obedit ? G.editMesh : NULL;
+       EditMesh *em= me->edit_mesh;
        CustomData *src= em ? &em->fdata : &me->fdata;
        EditFace *efa= NULL;
        unsigned i,j;
@@ -346,7 +346,7 @@ void multires_load_cols(Mesh *me)
 void multires_create(Object *ob, Mesh *me)
 {
        MultiresLevel *lvl;
-       EditMesh *em= G.obedit ? G.editMesh : NULL;
+       EditMesh *em= me->edit_mesh;
        EditVert *eve= NULL;
        EditFace *efa= NULL;
        EditEdge *eed= NULL;
@@ -954,7 +954,7 @@ static void multires_update_colors(Mesh *me, EditMesh *em)
 
 void multires_update_levels(Mesh *me, const int render)
 {
-       EditMesh *em= (!render && G.obedit) ? G.editMesh : NULL;
+       EditMesh *em= render ? NULL : me->edit_mesh;
 
        multires_update_first_level(me, em);
        multires_update_vertices(me, em);
@@ -964,7 +964,7 @@ void multires_update_levels(Mesh *me, const int render)
 
 static void check_colors(Mesh *me)
 {
-       CustomData *src= G.obedit ? &G.editMesh->fdata : &me->fdata;
+       CustomData *src= me->edit_mesh ? &me->edit_mesh->fdata : &me->fdata;
        const char col= CustomData_has_layer(src, CD_MCOL);
 
        /* Check if vertex colors have been deleted or added */
@@ -1014,8 +1014,8 @@ void multires_to_mcol(MultiresColFace *f, MCol mcol[4])
 void multires_level_to_mesh(Object *ob, Mesh *me, const int render)
 {
        MultiresLevel *lvl= BLI_findlink(&me->mr->levels,me->mr->current-1);
+       EditMesh *em= render ? NULL : me->edit_mesh;
        int i;
-       EditMesh *em= (!render && G.obedit) ? G.editMesh : NULL;
        
        if(em)
                return;
index 51069c7..e52a4a4 100644 (file)
@@ -1665,8 +1665,10 @@ static void give_parvert(Object *par, int nr, float *vec)
        vec[0]=vec[1]=vec[2]= 0.0f;
        
        if(par->type==OB_MESH) {
-               if(G.obedit && (par->data==G.obedit->data)) {
-                       EditMesh *em = G.editMesh;
+               Mesh *me= par->data;
+               
+               if(me->edit_mesh) {
+                       EditMesh *em = me->edit_mesh;
                        EditVert *eve;
                        
                        for(eve= em->verts.first; eve; eve= eve->next) {
@@ -2307,7 +2309,7 @@ void object_handle_update(Object *ob)
                        
                        /* includes all keys and modifiers */
                        if(ob->type==OB_MESH) {
-                               makeDerivedMesh(ob, get_viewedit_datamask());
+                               makeDerivedMesh(ob, NULL, get_viewedit_datamask());
                        }
                        else if(ob->type==OB_MBALL) {
                                makeDispListMBall(ob);
index ab98fb1..81788cd 100644 (file)
@@ -93,10 +93,12 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c
 //TODO is anyfunction that does this? returning the derivedFinal witouth we caring if its in edit mode or not?
 DerivedMesh *object_get_derived_final(Object *ob, CustomDataMask dataMask)
 {
-       if (ob==G.obedit)
+       Mesh *me= ob->data;
+       
+       if (me->edit_mesh)
        {
                DerivedMesh *final = NULL;
-               editmesh_get_derived_cage_and_final(&final, dataMask);
+               editmesh_get_derived_cage_and_final(me->edit_mesh, &final, dataMask);
                return final;
        }
        else
index f1d9223..04903ad 100644 (file)
@@ -2479,9 +2479,10 @@ static void direct_link_curve(FileData *fd, Curve *cu)
                if (cu->wordspace == 0.0) cu->wordspace = 1.0;
        }
 
-       cu->bev.first=cu->bev.last= 0;
-       cu->disp.first=cu->disp.last= 0;
-       cu->path= 0;
+       cu->bev.first=cu->bev.last= NULL;
+       cu->disp.first=cu->disp.last= NULL;
+       cu->editlist.first=cu->editlist.last= NULL;
+       cu->path= NULL;
 
        nu= cu->nurb.first;
        while(nu) {
@@ -2849,7 +2850,8 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
 
        mesh->bb= NULL;
        mesh->mselect = NULL;
-
+       mesh->edit_mesh= NULL;
+       
        /* Multires data */
        mesh->mr= newdataadr(fd, mesh->mr);
        if(mesh->mr) {
index a7fe669..23acfff 100644 (file)
@@ -31,6 +31,7 @@
 struct View3D;
 struct ARegion;
 struct EditMesh;
+struct bContext;
 
 // edge and face flag both
 #define EM_FGON                2
@@ -61,10 +62,19 @@ typedef struct ViewContext {
        struct ARegion *ar;
        struct View3D *v3d;
        struct EditMesh *em;
+       short mval[2];
 } ViewContext;
 
+/* meshtools.c */
+
+intptr_t       mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode);
 
 /* editmesh.c */
+void           make_editMesh(Scene *scene, Object *ob);
+void           load_editMesh(Scene *scene, Object *ob);
+void           remake_editMesh(Scene *scene, Object *ob);
+void           free_editMesh(EditMesh *em);
+
 
 void           EM_init_index_arrays(struct EditMesh *em, int forVert, int forEdge, int forFace);
 void           EM_free_index_arrays(void);
@@ -84,12 +94,17 @@ void                EM_select_edge(EditEdge *eed, int sel);
 void           EM_select_face_fgon(struct EditMesh *em, EditFace *efa, int val);
 void           EM_selectmode_flush(struct EditMesh *em);
 void           EM_deselect_flush(struct EditMesh *em);
-
+                       
+                       /* exported to transform */
+int                    EM_get_actSelection(EditMesh *em, EditSelection *ese);
+void           EM_editselection_normal(float *normal, EditSelection *ese);
+void           EM_editselection_plane(float *plane, EditSelection *ese);
 
 
 /* editmesh_mods.c */
 extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs;
 
+void           mouse_mesh(struct bContext *C, short mval[2]);
 int                    EM_check_backbuf(unsigned int index);
 int                    EM_mask_init_backbuf_border(struct View3D *v3d, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax);
 void           EM_free_backbuf(void);
index 49aee46..a691ab9 100644 (file)
@@ -33,6 +33,10 @@ struct bContext;
 struct uiMenuBlockHandle;
 struct uiBlock;
 
+/* ed_util.c */
+
+void   ED_editors_exit                 (struct bContext *C);
+
 /* ************** Undo ************************ */
 
 /* undo.c */
index 76f7748..af7801b 100644 (file)
@@ -802,13 +802,14 @@ static int editmesh_pointcache_edit(Scene *scene, Object *ob, int totvert, PTCac
 }
 
 /* turns Mesh into editmesh */
-void make_editMesh(Scene *scene, EditMesh *em)
+void make_editMesh(Scene *scene, Object *ob)
 {
-       Mesh *me= G.obedit->data;
+       Mesh *me= ob->data;
        MFace *mface;
        MVert *mvert;
        MSelect *mselect;
        KeyBlock *actkey;
+       EditMesh *em;
        EditVert *eve, **evlist, *eve1, *eve2, *eve3, *eve4;
        EditFace *efa;
        EditEdge *eed;
@@ -819,9 +820,15 @@ void make_editMesh(Scene *scene, EditMesh *em)
        float cacheco[3], cachemat[4][4], *co;
        int tot, a, cacheedit= 0, eekadoodle= 0;
 
-       /* because of reload */
-       free_editMesh(em);
+       if(me->edit_mesh==NULL)
+               me->edit_mesh= MEM_callocN(sizeof(EditMesh), "editmesh");
+       else 
+               /* because of reload */
+               free_editMesh(me->edit_mesh);
+       
+       em= me->edit_mesh;
        
+       em->selectmode= scene->selectmode; // warning needs to be synced
        em->act_face = NULL;
        G.totvert= tot= me->totvert;
        G.totedge= me->totedge;
@@ -834,9 +841,9 @@ void make_editMesh(Scene *scene, EditMesh *em)
        /* initialize fastmalloc for editmesh */
        init_editmesh_fastmalloc(em, me->totvert, me->totedge, me->totface);
 
-       actkey = ob_get_keyblock(G.obedit);
+       actkey = ob_get_keyblock(ob);
        if(actkey) {
-               strcpy(G.editModeTitleExtra, "(Key) ");
+               // XXX strcpy(G.editModeTitleExtra, "(Key) ");
                key_to_mesh(actkey, me);
                tot= actkey->totelem;
                /* undo-ing in past for previous editmode sessions gives corrupt 'keyindex' values */
@@ -848,7 +855,7 @@ void make_editMesh(Scene *scene, EditMesh *em)
        CustomData_copy(&me->vdata, &em->vdata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        mvert= me->mvert;
 
-       cacheedit= editmesh_pointcache_edit(scene, G.obedit, tot, &pid, cachemat, 0);
+       cacheedit= editmesh_pointcache_edit(scene, ob, tot, &pid, cachemat, 0);
 
        evlist= (EditVert **)MEM_mallocN(tot*sizeof(void *),"evlist");
        for(a=0; a<tot; a++, mvert++) {
@@ -1000,13 +1007,14 @@ void make_editMesh(Scene *scene, EditMesh *em)
 }
 
 /* makes Mesh out of editmesh */
-void load_editMesh(Scene *scene, EditMesh *em)
+void load_editMesh(Scene *scene, Object *ob)
 {
-       Mesh *me= G.obedit->data;
+       Mesh *me= ob->data;
        MVert *mvert, *oldverts;
        MEdge *medge;
        MFace *mface;
        MSelect *mselect;
+       EditMesh *em= me->edit_mesh;
        EditVert *eve;
        EditFace *efa, *efa_act;
        EditEdge *eed;
@@ -1075,7 +1083,7 @@ void load_editMesh(Scene *scene, EditMesh *em)
        a= 0;
 
        /* check for point cache editing */
-       cacheedit= editmesh_pointcache_edit(scene, G.obedit, G.totvert, &pid, cachemat, 1);
+       cacheedit= editmesh_pointcache_edit(scene, ob, G.totvert, &pid, cachemat, 1);
 
        while(eve) {
                if(cacheedit) {
@@ -1143,9 +1151,9 @@ void load_editMesh(Scene *scene, EditMesh *em)
        /* write changes to cache */
        if(cacheedit) {
                if(pid.type == PTCACHE_TYPE_CLOTH)
-                       cloth_write_cache(G.obedit, pid.data, pid.cache->editframe);
+                       cloth_write_cache(ob, pid.data, pid.cache->editframe);
                else if(pid.type == PTCACHE_TYPE_SOFTBODY)
-                       sbWriteCache(G.obedit, pid.cache->editframe);
+                       sbWriteCache(ob, pid.cache->editframe);
        }
 
        /* the edges */
@@ -1250,7 +1258,7 @@ void load_editMesh(Scene *scene, EditMesh *em)
                int i,j;
 
                for (ob=G.main->object.first; ob; ob=ob->id.next) {
-                       if (ob->parent==G.obedit && ELEM(ob->partype, PARVERT1,PARVERT3)) {
+                       if (ob->parent==ob && ELEM(ob->partype, PARVERT1,PARVERT3)) {
                                
                                /* duplicate code from below, make it function later...? */
                                if (!vertMap) {
@@ -1311,7 +1319,7 @@ void load_editMesh(Scene *scene, EditMesh *em)
 
        /* are there keys? */
        if(me->key) {
-               KeyBlock *currkey, *actkey = ob_get_keyblock(G.obedit);
+               KeyBlock *currkey, *actkey = ob_get_keyblock(ob);
 
                /* Lets reorder the key data so that things line up roughly
                 * with the way things were before editmode */
@@ -1409,12 +1417,12 @@ void load_editMesh(Scene *scene, EditMesh *em)
        mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
 }
 
-void remake_editMesh(Scene *scene, EditMesh *em)
+void remake_editMesh(Scene *scene, Object *ob)
 {
-       make_editMesh(scene, em);
+       make_editMesh(scene, ob);
 //     allqueue(REDRAWVIEW3D, 0);
 //     allqueue(REDRAWBUTSOBJECT, 0); /* needed to have nice cloth panels */
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
        BIF_undo_push("Undo all changes");
 }
 
@@ -1423,9 +1431,9 @@ void remake_editMesh(Scene *scene, EditMesh *em)
 
 
 
-void separate_mesh(Scene *scene, EditMesh *em)
+void separate_mesh(Scene *scene, Object *ob)
 {
-       EditMesh emcopy;
+       EditMesh *em, emcopy;
        EditVert *eve, *v1;
        EditEdge *eed, *e1;
        EditFace *efa, *vl1;
@@ -1439,7 +1447,8 @@ void separate_mesh(Scene *scene, EditMesh *em)
 
        waitcursor(1);
        
-       me= get_mesh(G.obedit);
+       me= G.obedit->data;
+       em= me->edit_mesh;
        if(me->key) {
                error("Can't separate with vertex keys");
                return;
@@ -1524,7 +1533,7 @@ void separate_mesh(Scene *scene, EditMesh *em)
        /* because new mesh is a copy: reduce user count */
        men->id.us--;
        
-       load_editMesh(scene, em);
+       load_editMesh(scene, G.obedit);
        
        BASACT->flag &= ~SELECT;
        
@@ -1557,14 +1566,16 @@ void separate_mesh(Scene *scene, EditMesh *em)
 
 }
 
-void separate_material(Scene *scene, EditMesh *em)
+void separate_material(Scene *scene, Object *ob)
 {
-       unsigned char curr_mat;
        Mesh *me;
+       EditMesh *em;
+       unsigned char curr_mat;
        
        if(multires_test()) return;
        
-       me= get_mesh(G.obedit);
+       me= G.obedit->data;
+       em= me->edit_mesh;
        if(me->key) {
                error("Can't separate with vertex keys");
                return;
@@ -1578,7 +1589,7 @@ void separate_material(Scene *scene, EditMesh *em)
                                /* select the material */
                                editmesh_select_by_material(em, curr_mat);
                                /* and now separate */
-                               separate_mesh(scene, em);
+                               separate_mesh(scene, ob);
                        }
                }
        }
@@ -1589,9 +1600,9 @@ void separate_material(Scene *scene, EditMesh *em)
 }
 
 
-void separate_mesh_loose(Scene *scene, EditMesh *em)
+void separate_mesh_loose(Scene *scene, Object *ob)
 {
-       EditMesh emcopy;
+       EditMesh *em, emcopy;
        EditVert *eve, *v1;
        EditEdge *eed, *e1;
        EditFace *efa, *vl1;
@@ -1602,7 +1613,8 @@ void separate_mesh_loose(Scene *scene, EditMesh *em)
        int vertsep=0;  
        short done=0, check=1;
                        
-       me= get_mesh(G.obedit);
+       me= G.obedit->data;
+       em= me->edit_mesh;
        if(me->key) {
                error("Can't separate a mesh with vertex keys");
                return;
@@ -1718,7 +1730,7 @@ void separate_mesh_loose(Scene *scene, EditMesh *em)
                        /* because new mesh is a copy: reduce user count */
                        men->id.us--;
                        
-                       load_editMesh(scene, em);
+                       load_editMesh(scene, G.obedit);
                        
                        BASACT->flag &= ~SELECT;
                        
@@ -1754,11 +1766,12 @@ void separate_mesh_loose(Scene *scene, EditMesh *em)
        DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
 }
 
-void separatemenu(Scene *scene, EditMesh *em)
+void separatemenu(Scene *scene, Object *ob)
 {
+       Mesh *me= ob->data;
        short event;
        
-       if(em->verts.first==NULL) return;
+       if(me->edit_mesh->verts.first==NULL) return;
           
        event = pupmenu("Separate %t|Selected%x1|All Loose Parts%x2|By Material%x3");
        
@@ -1767,13 +1780,13 @@ void separatemenu(Scene *scene, EditMesh *em)
        
        switch (event) {
                case 1: 
-                       separate_mesh(scene, em);                   
+                       separate_mesh(scene, ob);
                        break;
                case 2:                     
-                       separate_mesh_loose(scene, em);             
+                       separate_mesh_loose(scene, ob);
                        break;
                case 3:
-                       separate_material(scene, em);
+                       separate_material(scene, ob);
                        break;
        }
        waitcursor(0);
@@ -1875,10 +1888,10 @@ static void *editMesh_to_undoMesh(void)
        EditFaceC *efac=NULL;
        EditSelectionC *esec=NULL;
        int a;
-       
+       return NULL;    // XXX
        um= MEM_callocN(sizeof(UndoMesh), "undomesh");
        
-       um->selectmode = scene->selectmode;
+       um->selectmode = em->selectmode;
        
        for(eve=em->verts.first; eve; eve= eve->next) um->totvert++;
        for(eed=em->edges.first; eed; eed= eed->next) um->totedge++;
@@ -1993,7 +2006,7 @@ static void undoMesh_to_editMesh(void *umv)
        EditFaceC *efac;
        EditSelectionC *esec;
        int a=0;
-
+       return; // XXX
        em->selectmode = um->selectmode;
        
        free_editMesh(em);
@@ -2196,8 +2209,11 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc)
        vc->ar= CTX_wm_region(C);
        vc->scene= CTX_data_scene(C);
        vc->v3d= (View3D *)CTX_wm_space_data(C);
-       vc->obact= vc->scene->basact?vc->scene->basact->object:NULL;
-       vc->obedit= G.obedit; // XXX
-       vc->em= NULL; // XXX
+       vc->obact= CTX_data_active_object(C);
+       vc->obedit= CTX_data_edit_object(C);
+       if(vc->obedit) {
+               Mesh *me= vc->obedit->data;
+               vc->em= me->edit_mesh;
+       }
 }
 
index 4677c03..58c60e4 100644 (file)
@@ -46,7 +46,6 @@ int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge
 
 /* ******************* meshtools.c */
 
-intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode);
 EditVert *editmesh_get_x_mirror_vert(Object *ob, EditMesh *em, float *co);
 int mesh_get_x_mirror_vert(Object *ob, int index);
 
@@ -72,9 +71,6 @@ enum {
 
 
 /* ******************* editmesh.c */
-void make_editMesh(Scene *scene, EditMesh *em);
-void load_editMesh(Scene *scene, EditMesh *em);
-void remake_editMesh(Scene *scene, EditMesh *em);
 
 extern void free_editvert(EditMesh *em, EditVert *eve);
 extern void free_editedge(EditMesh *em, EditEdge *eed);
index 1e72efd..241d992 100644 (file)
@@ -767,14 +767,10 @@ void adduplicate_mesh(EditMesh *em)
 
 /* check whether an object to add mesh to exists, if not, create one
 * returns 1 if new object created, else 0 */
-static int confirm_objectExists(EditMesh *em, Mesh **me, float mat[][3] )
+static int confirm_objectExists(Scene *scene, Mesh **me, float mat[][3] )
 {
-       Scene *scene= NULL; // XXX
        int newob = 0;
        
-       /* deselectall */
-       EM_clear_flag_all(em, SELECT);
-       
        /* if no obedit: new object and enter editmode */
        if(G.obedit==NULL) {
                /* add_object actually returns an object ! :-)
@@ -787,11 +783,14 @@ static int confirm_objectExists(EditMesh *em, Mesh **me, float mat[][3] )
                
                where_is_object(G.obedit);
                
-               make_editMesh(NULL, em); // XXX
+               make_editMesh(scene, G.obedit); 
                newob= 1;
        }
        *me = G.obedit->data;
        
+       /* deselectall */
+       EM_clear_flag_all((*me)->edit_mesh, SELECT);
+       
        /* imat and center and size */
        Mat3CpyMat4(mat, G.obedit->obmat);
        
@@ -1273,7 +1272,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                tot= 4;
                ext= 0;
                fill= 1;
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Plane";
                undostr="Add Plane";
                break;
@@ -1281,7 +1280,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                tot= 4;
                ext= 1;
                fill= 1;
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Cube";
                undostr="Add Cube";
                break;
@@ -1292,7 +1291,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                if (!(do_clever_numbuts("Add Circle", 3, 0))) return;
                ext= 0;
                fill = fill_circle;
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Circle";
                undostr="Add Circle";
                break;
@@ -1306,7 +1305,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                ext= 1;
                fill = fill_cylinder;
                d/=2;
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) {
                        if (fill)       name = "Cylinder";
                        else            name = "Tube";
@@ -1323,7 +1322,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                d/=2;
                ext= 0;
                fill = fill_cone;
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Cone";
                undostr="Add Cone";
                break;
@@ -1331,7 +1330,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                add_numbut(0, NUM|INT, "X res:", 3, 1000, &tot, NULL);
                add_numbut(1, NUM|INT, "Y res:", 3, 1000, &seg, NULL);
                if (!(do_clever_numbuts("Add Grid", 2, 0))) return; 
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Grid";
                undostr="Add Grid";
                break;
@@ -1342,7 +1341,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                
                if (!(do_clever_numbuts("Add UV Sphere", 3, 0))) return;
                
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Sphere";
                undostr="Add UV Sphere";
                break;
@@ -1351,17 +1350,17 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                add_numbut(1, NUM|FLO, "Radius:", 0.001*v3d->grid, 100*v3d->grid, &dia, NULL);
                if (!(do_clever_numbuts("Add Ico Sphere", 2, 0))) return;
                
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Sphere";
                undostr="Add Ico Sphere";
                break;
        case 13:        /* Monkey */
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                if(newob) name = "Suzanne";
                undostr="Add Monkey";
                break;
        default:
-               newob = confirm_objectExists(em, &me, mat );
+               newob = confirm_objectExists(scene, &me, mat );
                break;
        }
 
@@ -1403,7 +1402,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
        
        /* if a new object was created, it stores it in Mesh, for reload original data and undo */
        if ( !(newob) || U.flag & USER_ADD_EDITMODE) {
-               if(newob) load_editMesh(scene, em);
+               if(newob) load_editMesh(scene, G.obedit);
        } else {
                exit_editmode(2);
        }
index 87b34a3..b9b9390 100644 (file)
@@ -73,6 +73,9 @@ editmesh_mods.c, UI level access, no geometry changes
 
 #include "RE_render_ext.h"  /* externtex */
 
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "ED_multires.h"
 #include "ED_mesh.h"
 #include "ED_view3d.h"
@@ -381,16 +384,13 @@ static unsigned int findnearestvert__backbufIndextest(unsigned int index)
  */
 EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict)
 {
-       short mval[2];
-
-// XXX getmouseco_areawin(mval);
        if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)){
                int distance;
                unsigned int index;
                EditVert *eve;
                
-               if(strict) index = sample_backbuf_rect(mval, 50, em_wireoffs, 0xFFFFFF, &distance, strict, findnearestvert__backbufIndextest); 
-               else index = sample_backbuf_rect(mval, 50, em_wireoffs, 0xFFFFFF, &distance, 0, NULL); 
+               if(strict) index = sample_backbuf_rect(vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, strict, findnearestvert__backbufIndextest); 
+               else index = sample_backbuf_rect(vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, 0, NULL); 
                
                eve = BLI_findlink(&vc->em->verts, index-1);
                
@@ -413,8 +413,8 @@ EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict)
                }
 
                data.lastIndex = lastSelectedIndex;
-               data.mval[0] = mval[0];
-               data.mval[1] = mval[1];
+               data.mval[0] = vc->mval[0];
+               data.mval[1] = vc->mval[1];
                data.select = sel;
                data.dist = *dist;
                data.strict = strict;
@@ -489,13 +489,10 @@ static void findnearestedge__doClosest(void *userData, EditEdge *eed, int x0, in
 }
 EditEdge *findnearestedge(ViewContext *vc, int *dist)
 {
-       short mval[2];
-               
-// XXX getmouseco_areawin(mval);
 
        if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) {
                int distance;
-               unsigned int index = sample_backbuf_rect(mval, 50, em_solidoffs, em_wireoffs, &distance,0, NULL);
+               unsigned int index = sample_backbuf_rect(vc->mval, 50, em_solidoffs, em_wireoffs, &distance,0, NULL);
                EditEdge *eed = BLI_findlink(&vc->em->edges, index-1);
 
                if (eed && distance<*dist) {
@@ -509,8 +506,8 @@ EditEdge *findnearestedge(ViewContext *vc, int *dist)
                struct { ViewContext vc; float mval[2]; int dist; EditEdge *closest; } data;
 
                data.vc= *vc;
-               data.mval[0] = mval[0];
-               data.mval[1] = mval[1];
+               data.mval[0] = vc->mval[0];
+               data.mval[1] = vc->mval[1];
                data.dist = *dist;
                data.closest = NULL;
 
@@ -556,19 +553,16 @@ static void findnearestface__doClosest(void *userData, EditFace *efa, int x, int
 }
 static EditFace *findnearestface(ViewContext *vc, int *dist)
 {
-       short mval[2];
-
-// XXX getmouseco_areawin(mval);
 
        if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) {
-               unsigned int index = sample_backbuf(mval[0], mval[1]);
+               unsigned int index = sample_backbuf(vc->mval[0], vc->mval[1]);
                EditFace *efa = BLI_findlink(&vc->em->faces, index-1);
 
                if (efa) {
                        struct { short mval[2]; int dist; EditFace *toFace; } data;
 
-                       data.mval[0] = mval[0];
-                       data.mval[1] = mval[1];
+                       data.mval[0] = vc->mval[0];
+                       data.mval[1] = vc->mval[1];
                        data.dist = 0x7FFF;             /* largest short */
                        data.toFace = efa;
 
@@ -593,8 +587,8 @@ static EditFace *findnearestface(ViewContext *vc, int *dist)
                }
 
                data.lastIndex = lastSelectedIndex;
-               data.mval[0] = mval[0];
-               data.mval[1] = mval[1];
+               data.mval[0] = vc->mval[0];
+               data.mval[1] = vc->mval[1];
                data.dist = *dist;
                data.closest = NULL;
                data.closestIndex = 0;
@@ -2085,7 +2079,7 @@ static void mouse_mesh_loop(ViewContext *vc)
        
        eed= findnearestedge(vc, &dist);
        if(eed) {
-               if (0) { // XXX G.scene->toolsettings->edge_mode == EDGE_MODE_SELECT) {
+               if (vc->scene->toolsettings->edge_mode == EDGE_MODE_SELECT) {
                        if(shift==0) EM_clear_flag_all(em, SELECT);
                
                        if((eed->f & SELECT)==0) select=1;
@@ -2112,7 +2106,9 @@ static void mouse_mesh_loop(ViewContext *vc)
                
                        EM_selectmode_flush(em);
 //                     if (EM_texFaceCheck())
-               } else { /*(G.scene->toolsettings->edge_mode == EDGE_MODE_TAG_*)*/
+                       
+               } 
+               else {
                        int act = (edgetag_context_check(vc->scene, eed)==0);
                        int path = 0;
                        
@@ -2178,10 +2174,9 @@ static void mouse_mesh_loop(ViewContext *vc)
 
 
 /* here actual select happens */
-void mouse_mesh(bContext *C)
+void mouse_mesh(bContext *C, short mval[2])
 {
        ViewContext vc;
-       EditMesh *em= NULL; // XXX
        EditVert *eve;
        EditEdge *eed;
        EditFace *efa;
@@ -2189,50 +2184,52 @@ void mouse_mesh(bContext *C)
        
        /* setup view context for argument to callbacks */
        em_setup_viewcontext(C, &vc);
+       vc.mval[0]= mval[0];
+       vc.mval[1]= mval[1];
        
        if(alt) mouse_mesh_loop(&vc);
        else if(unified_findnearest(&vc, &eve, &eed, &efa)) {
                
-               if((shift)==0) EM_clear_flag_all(em, SELECT);
+               if((shift)==0) EM_clear_flag_all(vc.em, SELECT);
                
                if(efa) {
                        /* set the last selected face */
-                       EM_set_actFace(em, efa);
+                       EM_set_actFace(vc.em, efa);
                        
                        if( (efa->f & SELECT)==0 ) {
-                               EM_store_selection(em, efa, EDITFACE);
-                               EM_select_face_fgon(em, efa, 1);
+                               EM_store_selection(vc.em, efa, EDITFACE);
+                               EM_select_face_fgon(vc.em, efa, 1);
                        }
                        else if(shift) {
-                               EM_remove_selection(em, efa, EDITFACE);
-                               EM_select_face_fgon(em, efa, 0);
+                               EM_remove_selection(vc.em, efa, EDITFACE);
+                               EM_select_face_fgon(vc.em, efa, 0);
                        }
                }
                else if(eed) {
                        if((eed->f & SELECT)==0) {
-                               EM_store_selection(em, eed, EDITEDGE);
+                               EM_store_selection(vc.em, eed, EDITEDGE);
                                EM_select_edge(eed, 1);
                        }
                        else if(shift) {
-                               EM_remove_selection(em, eed, EDITEDGE);
+                               EM_remove_selection(vc.em, eed, EDITEDGE);
                                EM_select_edge(eed, 0);
                        }
                }
                else if(eve) {
                        if((eve->f & SELECT)==0) {
                                eve->f |= SELECT;
-                               EM_store_selection(em, eve, EDITVERT);
+                               EM_store_selection(vc.em, eve, EDITVERT);
                        }
                        else if(shift){ 
-                               EM_remove_selection(em, eve, EDITVERT);
+                               EM_remove_selection(vc.em, eve, EDITVERT);
                                eve->f &= ~SELECT;
                        }
                }
                
                /* frontbuffer draw of last selected only */
-               unified_select_draw(em, eve, eed, efa);
+               unified_select_draw(vc.em, eve, eed, efa);
        
-               EM_selectmode_flush(em);
+               EM_selectmode_flush(vc.em);
                  
 //             if (EM_texFaceCheck()) {
 
@@ -2242,6 +2239,8 @@ void mouse_mesh(bContext *C)
                }
        }
 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+       
 //     rightmouse_transform();
 }
 
index 6cd23eb..2374ef6 100644 (file)
@@ -3757,7 +3757,7 @@ void bevel_menu(EditMesh *em)
                BIF_undo_push("Pre-Bevel");
                free_editMesh(em);
                BME_bevel(bm,0.1f,res,options,0,0,&td);
-               BME_bmesh_to_editmesh(bm, td);
+               BME_bmesh_to_editmesh(bm, td, em);
                EM_selectmode_flush(em);
                G.editBMesh->bm = bm;
                G.editBMesh->td = td;
index 6a57034..4ef8cd4 100644 (file)
 #include "BKE_modifier.h"
 
 #include "ED_anim_api.h"
+#include "ED_mesh.h"
 #include "ED_screen.h"
 #include "ED_types.h"
 #include "ED_util.h"
@@ -194,7 +195,7 @@ void ED_base_object_activate(bContext *C, Base *base)
                                DAG_object_flush_update(scene, tbase->object, OB_RECALC_DATA);
                        }
                }
-               WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, base->object);
+               WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
        }
        else
                WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, NULL);
@@ -366,9 +367,8 @@ void delete_obj(Scene *scene, View3D *v3d, int ok)
        BIF_undo_push("Delete object(s)");
 }
 
-static int return_editmesh_indexar(int *tot, int **indexar, float *cent)
+static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float *cent)
 {
-       EditMesh *em = G.editMesh;
        EditVert *eve;
        int *index, nr, totvert=0;
        
@@ -395,9 +395,8 @@ static int return_editmesh_indexar(int *tot, int **indexar, float *cent)
        return totvert;
 }
 
-static int return_editmesh_vgroup(char *name, float *cent)
+static int return_editmesh_vgroup(EditMesh *em, char *name, float *cent)
 {
-       EditMesh *em = G.editMesh;
        MDeformVert *dvert;
        EditVert *eve;
        int i, totvert=0;
@@ -430,9 +429,10 @@ static int return_editmesh_vgroup(char *name, float *cent)
        return 0;
 }      
 
-static void select_editmesh_hook(HookModifierData *hmd)
+static void select_editmesh_hook(Object *ob, HookModifierData *hmd)
 {
-       EditMesh *em = G.editMesh;
+       Mesh *me= ob->data;
+       EditMesh *em= me->edit_mesh;
        EditVert *eve;
        int index=0, nr=0;
        
@@ -612,9 +612,12 @@ int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r)
        
        switch(G.obedit->type) {
                case OB_MESH:
+               {
+                       Mesh *me= G.obedit->data;
                        /* check selected vertices first */
-                       if( return_editmesh_indexar(tot, indexar, cent_r)) return 1;
-                       else return return_editmesh_vgroup(name, cent_r);
+                       if( return_editmesh_indexar(me->edit_mesh, tot, indexar, cent_r)) return 1;
+                       else return return_editmesh_vgroup(me->edit_mesh, name, cent_r);
+               }
                case OB_CURVE:
                case OB_SURF:
                        return return_editcurve_indexar(tot, indexar, cent_r);
@@ -672,12 +675,13 @@ static void select_editcurve_hook(HookModifierData *hmd)
        }
 }
 
-void hook_select(HookModifierData *hmd) 
+void obedit_hook_select(Object *ob, HookModifierData *hmd) 
 {
-       if(G.obedit->type==OB_MESH) select_editmesh_hook(hmd);
-       else if(G.obedit->type==OB_LATTICE) select_editlattice_hook(hmd);
-       else if(G.obedit->type==OB_CURVE) select_editcurve_hook(hmd);
-       else if(G.obedit->type==OB_SURF) select_editcurve_hook(hmd);
+       
+       if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd);
+       else if(ob->type==OB_LATTICE) select_editlattice_hook(hmd);
+       else if(ob->type==OB_CURVE) select_editcurve_hook(hmd);
+       else if(ob->type==OB_SURF) select_editcurve_hook(hmd);
 }
 
 
@@ -819,7 +823,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                modifier_free(md);
        }
        else if(mode==5) { /* select */
-               hook_select(hmd);
+               obedit_hook_select(G.obedit, hmd);
        }
        else if(mode==6) { /* clear offset */
                where_is_object(ob);    /* ob is hook->parent */
@@ -1435,9 +1439,9 @@ void set_slowparent(Scene *scene, View3D *v3d)
 
 // XXX
 #define BEZSELECTED_HIDDENHANDLES(bezt)   ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
+/* only in edit mode */
 void make_vertex_parent(Scene *scene, View3D *v3d)
 {
-       EditMesh *em = G.editMesh;
        EditVert *eve;
        Base *base;
        Nurb *nu;
@@ -1449,7 +1453,9 @@ void make_vertex_parent(Scene *scene, View3D *v3d)
        /* we need 1 to 3 selected vertices */
        
        if(G.obedit->type==OB_MESH) {
-               eve= em->verts.first;
+               Mesh *me= G.obedit->data;
+               
+               eve= me->edit_mesh->verts.first;
                while(eve) {
                        if(eve->f & 1) {
                                if(v1==0) v1= nr;
@@ -1984,48 +1990,119 @@ void OBJECT_OT_make_track(wmOperatorType *ot)
 }
 
 
-/* *******************  ***************** */
+/* ******************* toggle editmode operator  ***************** */
 
-void enter_editmode(Scene *scene, View3D *v3d, int wc)
+static void exit_editmode(bContext *C, wmOperator *op, int flag)       /* freedata==0 at render, 1= freedata, 2= do undo buffer too */
 {
-       Base *base;
+       Scene *scene= CTX_data_scene(C);
        Object *ob;
-       Mesh *me;
-       bArmature *arm;
+//     Object *obedit= CTX_data_edit_object(C);
+       int freedata = flag; // XXX & EM_FREEDATA;
+       
+       if(G.obedit==NULL) return;
+       
+//     if(flag & EM_WAITCURSOR) waitcursor(1);
+       if(G.obedit->type==OB_MESH) {
+               Mesh *me= G.obedit->data;
+               
+//             if(EM_texFaceCheck())
+//                     allqueue(REDRAWIMAGE, 0);
+               
+//             if(retopo_mesh_paint_check())
+//                     retopo_end_okee();
+               
+               if(G.totvert>MESH_MAX_VERTS) {
+                       error("Too many vertices");
+                       return;
+               }
+               load_editMesh(scene, G.obedit);
+               
+               if(freedata) free_editMesh(me->edit_mesh);
+               
+               if(G.f & G_WEIGHTPAINT)
+                       mesh_octree_table(G.obedit, NULL, NULL, 'e');
+       }
+       else if (G.obedit->type==OB_ARMATURE){  
+//             load_editArmature();
+//             if (freedata) free_editArmature();
+       }
+       else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
+//             extern ListBase editNurb;
+//             load_editNurb();
+//             if(freedata) freeNurblist(&editNurb);
+       }
+       else if(G.obedit->type==OB_FONT && freedata) {
+//             load_editText();
+       }
+       else if(G.obedit->type==OB_LATTICE) {
+//             load_editLatt();
+//             if(freedata) free_editLatt();
+       }
+       else if(G.obedit->type==OB_MBALL) {
+//             extern ListBase editelems;
+//             load_editMball();
+//             if(freedata) BLI_freelistN(&editelems);
+       }
+       
+       ob= G.obedit;
+       
+       /* for example; displist make is different in editmode */
+       if(freedata) G.obedit= NULL;
+       scene->obedit= G.obedit; // XXX
+       
+       if(ob->type==OB_MESH && get_mesh(ob)->mr)
+               multires_edge_level_update(ob, get_mesh(ob));
+       
+       /* also flush ob recalc, doesn't take much overhead, but used for particles */
+       DAG_object_flush_update(scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
+       
+       if(G.obedit==NULL) // XXX && (flag & EM_FREEUNDO)) 
+               ED_undo_push(C, "Editmode");
+       
+       //      if(flag & EM_WAITCURSOR) waitcursor(0);
+       
+       WM_event_add_notifier(C, NC_SCENE|ND_OB_EDIT, scene);
+
+}
+
+
+static void enter_editmode(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Base *base= CTX_data_active_base(C);
+       Object *ob= base->object;
+       View3D *v3d= (View3D *)CTX_wm_space_data(C);
        int ok= 0;
        
        if(scene->id.lib) return;
-       base= BASACT;
-       if(base==0) return;
+       if(base==NULL) return;
        if((v3d==NULL || (base->lay & v3d->lay))==0) return;
        
-       strcpy(G.editModeTitleExtra, "");
-
-       ob= base->object;
-       if(ob->data==0) return;
+       if(ob->data==NULL) return;
        
        if (object_data_is_libdata(ob)) {
                error_libdata();
                return;
        }
        
-       if(wc) waitcursor(1);
+       //if(wc) waitcursor(1);
        
        if(ob->type==OB_MESH) {
-               me= get_mesh(ob);
-               if( me==0 ) return;
+               Mesh *me= ob->data;
+               
                if(me->pv) mesh_pmv_off(ob, me);
                ok= 1;
-               G.obedit= ob;
-// XXX         make_editMesh();
-               allqueue(REDRAWBUTSLOGIC, 0);
-               /*if(G.f & G_FACESELECT) allqueue(REDRAWIMAGE, 0);*/
-// XXX         if (EM_texFaceCheck())
-//                     allqueue(REDRAWIMAGE, 0);
+               G.obedit= ob; // XXX
+               scene->obedit= ob;      // context sees this
+               
+               make_editMesh(scene, ob);
+
+               // XXX          if (EM_texFaceCheck())
+               //                      allqueue(REDRAWIMAGE, 0);
                
        }
        if (ob->type==OB_ARMATURE){
-               arm= base->object->data;
+               bArmature *arm= base->object->data;
                if (!arm) return;
                /*
                 * The function object_data_is_libdata make a problem here, the
@@ -2078,86 +2155,39 @@ void enter_editmode(Scene *scene, View3D *v3d, int wc)
        }
        else G.obedit= NULL;
        
-       if(wc) waitcursor(0);
+//     if(wc) waitcursor(0);
+       WM_event_add_notifier(C, NC_SCENE|ND_OB_EDIT, scene);
        
 }
 
-void exit_editmode(Scene *scene, int flag)     /* freedata==0 at render, 1= freedata, 2= do undo buffer too */
+static int toggle_editmode_exec(bContext *C, wmOperator *op)
 {
-#if 0
-       Object *ob;
-       int freedata = flag; // XXX & EM_FREEDATA;
        
-       if(G.obedit==NULL) return;
-
-       if(flag & EM_WAITCURSOR) waitcursor(1);
-       if(G.obedit->type==OB_MESH) {
-
-               
-               if(EM_texFaceCheck())
-                       allqueue(REDRAWIMAGE, 0);
-               
-               if(retopo_mesh_paint_check())
-                       retopo_end_okee();
-
-               if(G.totvert>MESH_MAX_VERTS) {
-                       error("Too many vertices");
-                       return;
-               }
-               load_editMesh();
-
-               if(freedata) free_editMesh(G.editMesh);
-               
-               if(G.f & G_WEIGHTPAINT)
-                       mesh_octree_table(G.obedit, NULL, 'e');
-       }
-       else if (G.obedit->type==OB_ARMATURE){  
-               load_editArmature();
-               if (freedata) free_editArmature();
-       }
-       else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
-               extern ListBase editNurb;
-               load_editNurb();
-               if(freedata) freeNurblist(&editNurb);
-       }
-       else if(G.obedit->type==OB_FONT && freedata) {
-               load_editText();
-       }
-       else if(G.obedit->type==OB_LATTICE) {
-               load_editLatt();
-               if(freedata) free_editLatt();
-       }
-       else if(G.obedit->type==OB_MBALL) {
-               extern ListBase editelems;
-               load_editMball();
-               if(freedata) BLI_freelistN(&editelems);
-       }
-
-       ob= G.obedit;
+       if(!CTX_data_edit_object(C))
+               enter_editmode(C, op);
+       else
+               exit_editmode(C, op, 1);
        
-       /* for example; displist make is different in editmode */
-       if(freedata) G.obedit= NULL;
+       return OPERATOR_FINISHED;
+}
 
-       if(ob->type==OB_MESH && get_mesh(ob)->mr)
-               multires_edge_level_update(ob, get_mesh(ob));
+void OBJECT_OT_toggle_editmode(wmOperatorType *ot)
+{
        
-       /* also flush ob recalc, doesn't take much overhead, but used for particles */
-       DAG_object_flush_update(scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
-
-       allqueue(REDRAWVIEW3D, 1);
-       allqueue(REDRAWBUTSALL, 0);
-       allqueue(REDRAWACTION, 0);
-       allqueue(REDRAWNLA, 0);
-       allqueue(REDRAWIPO, 0);
-       allqueue(REDRAWOOPS, 0);
-
-       if(G.obedit==NULL && (flag & EM_FREEUNDO)) 
-               BIF_undo_push("Editmode");
+       /* identifiers */
+       ot->name= "Toggle Editmode";
+       ot->idname= "OBJECT_OT_toggle_editmode";
        
-       if(flag & EM_WAITCURSOR) waitcursor(0);
-#endif
+       /* api callbacks */
+       ot->exec= toggle_editmode_exec;
+       
+       ot->poll= ED_operator_areaactive;       // XXX solve
+       ot->flag= OPTYPE_REGISTER;
 }
 
+/* *************************** */
+
+
 void check_editmode(int type)
 {
        
@@ -2170,7 +2200,6 @@ void check_editmode(int type)
 
 void docenter(Scene *scene, View3D *v3d, int centermode)
 {
-       EditMesh *em = G.editMesh;
        Base *base;
        Object *ob;
        Mesh *me, *tme;
@@ -2195,7 +2224,9 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                INIT_MINMAX(min, max);
        
                if(G.obedit->type==OB_MESH) {
-                       for(eve= em->verts.first; eve; eve= eve->next) {
+                       Mesh *me= G.obedit->data;
+                       
+                       for(eve= me->edit_mesh->verts.first; eve; eve= eve->next) {
                                if(v3d->around==V3D_CENTROID) {
                                        total++;
                                        VECADD(cent, cent, eve->co);
@@ -2214,7 +2245,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                cent[2]= (min[2]+max[2])/2.0f;
                        }
                        
-                       for(eve= em->verts.first; eve; eve= eve->next) {
+                       for(eve= me->edit_mesh->verts.first; eve; eve= eve->next) {
                                VecSubf(eve->co, eve->co, cent);                        
                        }
                        
@@ -3313,7 +3344,7 @@ void convertmenu(Scene *scene, View3D *v3d)
        /* texspace and normals */
        if(!basen) BASACT= base;
 
-       enter_editmode(scene, v3d, EM_WAITCURSOR);
+// XXX enter_editmode(scene, v3d, EM_WAITCURSOR);
 // XXX exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
        BASACT= basact;
 
@@ -4311,7 +4342,7 @@ static void apply_objects_internal(Scene *scene, View3D *v3d, int apply_scale, i
                                
                                /* texspace and normals */
                                BASACT= base;
-                               enter_editmode(scene, v3d, EM_WAITCURSOR);
+// XXX                         enter_editmode(scene, v3d, EM_WAITCURSOR);
                                BIF_undo_push("Applied object");        /* editmode undo itself */
 // XXX                         exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
                                BASACT= basact;
@@ -4387,7 +4418,7 @@ static void apply_objects_internal(Scene *scene, View3D *v3d, int apply_scale, i
                                
                                /* texspace and normals */
                                BASACT= base;
-                               enter_editmode(scene, v3d, EM_WAITCURSOR);
+// XXX                         enter_editmode(scene, v3d, EM_WAITCURSOR);
                                BIF_undo_push("Applied object");        /* editmode undo itself */
 // XXX                         exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
                                BASACT= basact;
index 70e12eb..794bba0 100644 (file)
 
 
 /* object_edit.c */
+void OBJECT_OT_toggle_editmode(wmOperatorType *ot);
 void OBJECT_OT_make_parent(wmOperatorType *ot);
 void OBJECT_OT_clear_parent(wmOperatorType *ot);
 void OBJECT_OT_make_track(wmOperatorType *ot);
 void OBJECT_OT_clear_track(wmOperatorType *ot);
-void OBJECT_OT_de_select_all(struct wmOperatorType *ot);
-void OBJECT_OT_select_invert(struct wmOperatorType *ot);
-void OBJECT_OT_select_random(struct wmOperatorType *ot);
-void OBJECT_OT_select_by_type(struct wmOperatorType *ot);
-void OBJECT_OT_select_by_layer(struct wmOperatorType *ot);
+void OBJECT_OT_de_select_all(wmOperatorType *ot);
+void OBJECT_OT_select_invert(wmOperatorType *ot);
+void OBJECT_OT_select_random(wmOperatorType *ot);
+void OBJECT_OT_select_by_type(wmOperatorType *ot);
+void OBJECT_OT_select_by_layer(wmOperatorType *ot);
 
 
 
index 5705622..1084dac 100644 (file)
@@ -62,6 +62,7 @@
 
 void ED_operatortypes_object(void)
 {
+       WM_operatortype_append(OBJECT_OT_toggle_editmode);
        WM_operatortype_append(OBJECT_OT_make_parent);
        WM_operatortype_append(OBJECT_OT_clear_parent);
        WM_operatortype_append(OBJECT_OT_make_track);
@@ -79,11 +80,12 @@ void ED_keymap_object(wmWindowManager *wm)
 {
        ListBase *keymap= WM_keymap_listbase(wm, "View3D Object", SPACE_VIEW3D, 0);
        
-       WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all",AKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "OBJECT_OT_toggle_editmode", TABKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "OBJECT_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "OBJECT_OT_select_random",PADASTERKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "OBJECT_OT_select_by_type",PADASTERKEY, KM_PRESS, KM_CTRL, 0);
-       WM_keymap_add_item(keymap, "OBJECT_OT_select_by_layer",PADASTERKEY, KM_PRESS, KM_ALT, 0);
+       WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "OBJECT_OT_select_by_type", PADASTERKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "OBJECT_OT_select_by_layer", PADASTERKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_make_parent", PKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_clear_parent", PKEY, KM_PRESS, KM_ALT, 0);
        WM_keymap_verify_item(keymap, "OBJECT_OT_make_track", TKEY, KM_PRESS, KM_CTRL, 0);
index 96cc993..573e89b 100644 (file)
 
 /* ******************************************** */
 
+/* defined in BIF_gl.h */
+GLubyte stipple_halftone[128] = {
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55,
+       0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};
+
+
+/*  repeat this pattern
+       X000X000
+       00000000
+       00X000X0
+       00000000 */
+
+
+GLubyte stipple_quarttone[128] = { 
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
+       136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0};
+
+
 void fdrawbezier(float vec[4][3])
 {
        float dist;
index 7e6fc25..e5a1cb9 100644 (file)
@@ -67,7 +67,14 @@ int ed_screen_context(const bContext *C, const bContextDataMember *member, bCont
 
                return 1;
        }
-
+       else if(member == CTX_data_edit_object) {
+               /* convenience for now, 1 object per scene in editmode */
+               if(scene->obedit)
+                       CTX_data_pointer_set(result, scene->obedit);
+               
+               return 1;
+       }
+       
        return 0;
 }
 
index 50a6381..62082fb 100644 (file)
@@ -1069,6 +1069,8 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
        CTX_wm_window_set(C, prevwin);
 }
 
+/* *********************************** */
+
 /* case when on area-edge or in azones, or outside window */
 static void screen_cursor_set(wmWindow *win, wmEvent *event)
 {
index 26d8aec..fa1b53e 100644 (file)
@@ -117,6 +117,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
                case NC_SCENE:
                        switch(wmn->data) {
                                case ND_OB_ACTIVE:
+                               case ND_OB_EDIT:
                                case ND_OB_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
index c0670b3..53487ca 100644 (file)
@@ -550,8 +550,8 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm,
        /* draw the textured mesh */
        draw_textured_begin(scene, v3d, ob);
 
-       if(ob==G.obedit) {
-               dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, G.editMesh);
+       if(me->edit_mesh) {
+               dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
        } else if(faceselect) {
                if(G.f & G_WEIGHTPAINT)
                        dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1);
index 7f8ab31..04fb9a6 100644 (file)
@@ -1207,7 +1207,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co
 void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVert *eve, int x, int y, int index), void *userData, int clipVerts)
 {
        struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
-       DerivedMesh *dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->em, CD_MASK_BAREMESH);
        
        data.vc= *vc;
        data.func = func;
@@ -1251,7 +1251,7 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0
 void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts)
 {
        struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
-       DerivedMesh *dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->em, CD_MASK_BAREMESH);
 
        data.vc= *vc;
        data.func = func;
@@ -1283,7 +1283,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, float *ce
 void mesh_foreachScreenFace(ViewContext *vc, void (*func)(void *userData, EditFace *efa, int x, int y, int index), void *userData)
 {
        struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; float pmat[4][4], vmat[4][4]; } data;
-       DerivedMesh *dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->em, CD_MASK_BAREMESH);
 
        data.vc= *vc;
        data.func = func;
@@ -2353,9 +2353,9 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, Base *base, int dt, int f
 /* returns 1 if nothing was drawn, for detecting to draw an object center */
 static int draw_mesh_object(Scene *scene, View3D *v3d, Base *base, int dt, int flag)
 {
-       EditMesh *em= NULL;             // XXX
        Object *ob= base->object;
        Mesh *me= ob->data;
+       EditMesh *em= me->edit_mesh;
        int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha;
        
        if(G.obedit && ob!=G.obedit && ob->data==G.obedit->data) {
@@ -2367,9 +2367,9 @@ static int draw_mesh_object(Scene *scene, View3D *v3d, Base *base, int dt, int f
                DerivedMesh *finalDM, *cageDM;
                
                if (G.obedit!=ob)
-                       finalDM = cageDM = editmesh_get_derived_base();
+                       finalDM = cageDM = editmesh_get_derived_base(em);
                else
-                       cageDM = editmesh_get_derived_cage_and_final(&finalDM,
+                       cageDM = editmesh_get_derived_cage_and_final(em, &finalDM,
                                                        get_viewedit_datamask());
 
                if(dt>OB_WIRE) {
@@ -5374,7 +5374,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, EditMesh *em, Object *ob)
        switch( ob->type) {
        case OB_MESH:
                if(ob==G.obedit) {
-                       DerivedMesh *dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
+                       DerivedMesh *dm = editmesh_get_derived_cage(em, CD_MASK_BAREMESH);
 
                        EM_init_index_arrays(em, 1, 1, 1);
 
@@ -5414,11 +5414,12 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, EditMesh *em, Object *ob)
 /* helper function for drawing object instances - meshes */
 static void draw_object_mesh_instance(Scene *scene, View3D *v3d, Object *ob, int dt, int outline)
 {
+       Mesh *me= ob->data;
        DerivedMesh *dm=NULL, *edm=NULL;
        int glsl;
        
-       if(G.obedit && ob->data==G.obedit->data)
-               edm= editmesh_get_derived_base();
+       if(me->edit_mesh)
+               edm= editmesh_get_derived_base(me->edit_mesh);
        else 
                dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
 
index 87b6a04..450e790 100644 (file)
@@ -212,6 +212,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                        switch(wmn->data) {
                                case ND_FRAME:
                                case ND_OB_ACTIVE:
+                               case ND_OB_EDIT:
                                case ND_OB_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
@@ -222,6 +223,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
                                case ND_BONE_ACTIVE:
                                case ND_BONE_SELECT:
                                case ND_TRANSFORM:
+                               case ND_GEOM_SELECT:
                                        ED_region_tag_redraw(ar);
                                        break;
                        }
@@ -341,6 +343,7 @@ void ED_spacetype_view3d(void)
        art->regionid = RGN_TYPE_HEADER;
        art->minsizey= HEADERY;
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       art->listener= view3d_main_area_listener;
        
        art->init= view3d_header_area_init;
        art->draw= view3d_header_area_draw;
index f2f1d88..3dcf531 100644 (file)
@@ -1445,6 +1445,7 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot)
 static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        ARegion *ar= CTX_wm_region(C);
+       Object *obedit= CTX_data_edit_object(C);
        short mval[2];  
        
        mval[0]= event->x - ar->winrct.xmin;
@@ -1452,7 +1453,12 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        view3d_operator_needs_opengl(C);
        
-       mouse_select(C, mval, 0);
+       if(obedit) {
+               if(obedit->type==OB_MESH)
+                       mouse_mesh(C, mval);
+       }
+       else 
+               mouse_select(C, mval, 0);
        
        return OPERATOR_FINISHED;
 }
index bb333b2..b621275 100644 (file)
@@ -79,6 +79,7 @@
 #include "BKE_action.h" /* get_action_frame */
 //#include "BKE_bad_level_calls.h"/* popmenu and error */
 #include "BKE_bmesh.h"
+#include "BKE_context.h"
 #include "BKE_constraint.h"
 #include "BKE_global.h"
 #include "BKE_particle.h"
@@ -94,6 +95,7 @@
 
 #include "ED_view3d.h"
 #include "ED_screen.h"
+#include "ED_util.h"
 #include "UI_view2d.h"
 #include "WM_types.h"
 
@@ -1077,7 +1079,7 @@ void transformApply(TransInfo *t)
        }
 }
 
-int transformEnd(TransInfo *t)
+int transformEnd(bContext *C, TransInfo *t)
 {
        if (t->state != TRANS_RUNNING)
        {
@@ -1095,16 +1097,16 @@ int transformEnd(TransInfo *t)
                viewRedrawPost(t);
        
                /*  Undo as last, certainly after special_trans_update! */
-#if 0 // TRANSFORM_FIX_ME              
+
                if(t->state == TRANS_CANCEL) {
-                       if(t->undostr) BIF_undo_push(t->undostr);
+                       if(t->undostr) ED_undo_push(C, t->undostr);
                }
                else {
-                       if(t->undostr) BIF_undo_push(t->undostr);
-                       else BIF_undo_push(transform_to_undostr(t));
+                       if(t->undostr) ED_undo_push(C, t->undostr);
+                       else ED_undo_push(C, transform_to_undostr(t));
                }
                t->undostr= NULL;
-#endif
+
                return 1;
        }
        t->event = NULL;
index dc7949e..6e23fc5 100644 (file)
@@ -238,7 +238,8 @@ typedef struct TransInfo {
        struct ScrArea  *sa;
        struct ARegion  *ar;
        struct Scene    *scene;
-       struct wmEvent  *event; /* last event, reset at the start of each transformApply and nulled at the transformEnd */
+       struct wmEvent  *event;         /* last event, reset at the start of each transformApply and nulled at the transformEnd */
+       struct EditMesh *em;            /* get from context */
     short       mval[2];       /* current mouse position               */
 } TransInfo;
 
@@ -343,7 +344,7 @@ void TFM_OT_transform(struct wmOperatorType *ot);
 void initTransform(struct bContext *C, struct TransInfo *t, int mode, int context, struct wmEvent *event);
 void transformEvent(TransInfo *t, struct wmEvent *event);
 void transformApply(TransInfo *t);
-int  transformEnd(TransInfo *t);
+int  transformEnd(struct bContext *C, TransInfo *t);
 
 void setTransformViewMatrices(TransInfo *t);
 void convertViewVec(TransInfo *t, float *vec, short dx, short dy);
index fc32ac5..5fda8ac 100644 (file)
@@ -345,7 +345,6 @@ static void createTransTexspace(bContext *C, TransInfo *t)
 static void createTransEdge(bContext *C, TransInfo *t) {
 #if 0  // TRANSFORM_FIX_ME
        TransData *td = NULL;
-       EditMesh *em = G.editMesh;
        EditEdge *eed;
        float mtx[3][3], smtx[3][3];
        int count=0, countsel=0;
@@ -1761,9 +1760,8 @@ void flushTransParticles(TransInfo *t)
 #define E_VEC(a)       (vectors + (3 * (a)->tmp.l))
 #define E_NEAR(a)      (nears[((a)->tmp.l)])
 #define THRESHOLD      0.0001f
-static void editmesh_set_connectivity_distance(int total, float *vectors, EditVert **nears)
+static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *vectors, EditVert **nears)
 {
-       EditMesh *em = G.editMesh;
        EditVert *eve;
        EditEdge *eed;
        int i= 0, done= 1;
@@ -1874,9 +1872,8 @@ static void editmesh_set_connectivity_distance(int total, float *vectors, EditVe
 }
 
 /* loop-in-a-loop I know, but we need it! (ton) */
-static void get_face_center(float *cent, EditVert *eve)
+static void get_face_center(float *cent, EditMesh *em, EditVert *eve)
 {
-       EditMesh *em = G.editMesh;
        EditFace *efa;
        
        for(efa= em->faces.first; efa; efa= efa->next)
@@ -1890,7 +1887,7 @@ static void get_face_center(float *cent, EditVert *eve)
 
 //way to overwrite what data is edited with transform
 //static void VertsToTransData(TransData *td, EditVert *eve, BakeKey *key)
-static void VertsToTransData(TransData *td, EditVert *eve)
+static void VertsToTransData(TransData *td, EditMesh *em, EditVert *eve)
 {
        td->flag = 0;
        //if(key)
@@ -1900,8 +1897,8 @@ static void VertsToTransData(TransData *td, EditVert *eve)
        
        VECCOPY(td->center, td->loc);
 // TRANSFORM_FIX_ME    
-//     if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE))
-//             get_face_center(td->center, eve);
+//     if(G.vd->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE))
+               get_face_center(td->center, em, eve);
        VECCOPY(td->iloc, td->loc);
 
        // Setting normals
@@ -1960,17 +1957,18 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
 /* disable subsurf temporal, get mapped cos, and enable it */
 static float *get_crazy_mapped_editverts(void)
 {
+       Mesh *me= G.obedit->data;
        DerivedMesh *dm;
        float *vertexcos;
 
        /* disable subsurf temporal, get mapped cos, and enable it */
        if(modifiers_disable_subsurf_temporary(G.obedit)) {
                /* need to make new derivemesh */
-               makeDerivedMesh(G.obedit, CD_MASK_BAREMESH);
+               makeDerivedMesh(G.obedit, me->edit_mesh, CD_MASK_BAREMESH);
        }
 
        /* now get the cage */
-       dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
+       dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
 
        vertexcos= MEM_mallocN(3*sizeof(float)*G.totvert, "vertexcos map");
        dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos);
@@ -2001,9 +1999,8 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3,
 }
 #undef TAN_MAKE_VEC
 
-static void set_crazyspace_quats(float *origcos, float *mappedcos, float *quats)
+static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos, float *quats)
 {
-       EditMesh *em = G.editMesh;
        EditVert *eve, *prev;
        EditFace *efa;
        float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
@@ -2103,7 +2100,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        // TRANSFORM_FIX_ME
 #if 0
        TransData *tob = NULL;
-       EditMesh *em = G.editMesh;
+       EditMesh *em = t->em;
        EditVert *eve;
        EditVert **nears = NULL;
        EditVert *eve_act = NULL;
@@ -2158,8 +2155,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        if (countsel==0) return;
        
        /* check active */
-       if (G.editMesh->selected.last) {
-               EditSelection *ese = G.editMesh->selected.last;
+       if (em->selected.last) {
+               EditSelection *ese = em->selected.last;
                if ( ese->type == EDITVERT ) {
                        eve_act = (EditVert *)ese->data;
                }
@@ -2179,7 +2176,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        Mat3CpyMat4(mtx, G.obedit->obmat);
        Mat3Inv(smtx, mtx);
 
-       if(propmode) editmesh_set_connectivity_distance(t->total, vectors, nears);
+       if(propmode) editmesh_set_connectivity_distance(t->em, t->total, vectors, nears);
        
        /* detect CrazySpace [tm] */
        if(propmode==0) {
@@ -2195,7 +2192,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
                                if(totleft > 0) {
                                        mappedcos= get_crazy_mapped_editverts();
                                        quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats");
-                                       set_crazyspace_quats((float*)defcos, mappedcos, quats);
+                                       set_crazyspace_quats(t->em, (float*)defcos, mappedcos, quats);
                                        if(mappedcos)
                                                MEM_freeN(mappedcos);
                                }
@@ -2220,7 +2217,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) {
                if(eve->h==0) {
                        if(propmode || eve->f1) {
-                               VertsToTransData(tob, eve);
+                               VertsToTransData(t, tob, t->em, eve);
                                
                                /* selected */
                                if(eve->f1) tob->flag |= TD_SELECTED;
@@ -2338,7 +2335,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
        int propmode = t->flag & T_PROP_EDIT;
        int efa_s1,efa_s2,efa_s3,efa_s4;
 
-       EditMesh *em = G.editMesh;
+       EditMesh *em = t->em;
        EditFace *efa;
        
        if(is_uv_tface_editing_allowed()==0) return;
@@ -2472,7 +2469,7 @@ void flushTransUVs(TransInfo *t)
        TransData2D *td;
        int a, width, height;
        Object *ob= OBACT;
-       EditMesh *em = G.editMesh;
+       EditMesh *em = t->em;
        float aspx, aspy, invx, invy;
 
        transform_aspect_ratio_tface_uv(&aspx, &aspy);
index 25413d2..e9f9d3b 100644 (file)
@@ -667,6 +667,7 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
        Scene *sce = CTX_data_scene(C);
        ARegion *ar = CTX_wm_region(C);
        ScrArea *sa = CTX_wm_area(C);
+       Object *obedit = CTX_data_edit_object(C);
        
        /* moving: is shown in drawobject() (transform color) */
 //  TRANSFORM_FIX_ME   
@@ -677,6 +678,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
        t->scene = sce;
        t->sa = sa;
        t->ar = ar;
+       if (obedit->type==OB_MESH)
+               t->em = ((Mesh *)obedit->data)->edit_mesh;
 
        t->data = NULL;
        t->ext = NULL;
index 31d90fb..692c4a6 100644 (file)
@@ -236,7 +236,7 @@ int calc_manipulator_stats(ScrArea *sa)
                if((ob->lay & G.vd->lay)==0) return 0;
 
                if(G.obedit->type==OB_MESH) {
-                       EditMesh *em = G.editMesh;
+                       EditMesh *em = NULL; // TRANSFORM_FIX_ME
                        EditVert *eve;
                        EditSelection ese;
                        float vec[3]= {0,0,0};
index abd3180..0e2e985 100644 (file)
@@ -67,7 +67,7 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
        
        transformApply(t);
        
-       if (transformEnd(t))
+       if (transformEnd(C, t))
        {
                transformops_exit(C, op);
                return OPERATOR_FINISHED;
@@ -84,7 +84,7 @@ static int transform_exec(bContext *C, wmOperator *op)
        
        transformApply(t);
        
-       transformEnd(t);
+       transformEnd(C, t);
 
        ED_region_tag_redraw(CTX_wm_region(C));
 
index 12a9c0e..7082f1a 100644 (file)
@@ -54,6 +54,8 @@
 //#include "BIF_space.h"
 //#include "BIF_toolbox.h"
 
+#include "ED_mesh.h"
+
 #include "transform.h"
 
 #if 0 // TRANSFORM_FIX_ME
@@ -448,15 +450,16 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
 
                ob= G.obedit;
 
-               if(G.obedit->type==OB_MESH)
+               if(ob->type==OB_MESH)
                {
-                       EditMesh *em = G.editMesh;
+                       Mesh *me= ob->data;
+                       EditMesh *em = me->edit_mesh;
                        EditVert *eve;
                        EditSelection ese;
                        float vec[3]= {0,0,0};
                        
                        /* USE LAST SELECTED WITH ACTIVE */
-                       if (activeOnly && EM_get_actSelection(&ese))
+                       if (activeOnly && EM_get_actSelection(em, &ese))
                        {
                                EM_editselection_normal(normal, &ese);
                                EM_editselection_plane(plane, &ese);
index 5113326..034b8a1 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_curve_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_editVert.h"
 
+#include "BKE_context.h"
 #include "BKE_global.h"
 
+#include "ED_mesh.h"
 #include "ED_util.h"
 
 #include "UI_text.h"
 
 /* ********* general editor util funcs, not BKE stuff please! ********* */
+
+void ED_editors_exit(bContext *C)
+{
+       if(CTX_data_edit_object(C)) {
+               Object *ob= CTX_data_edit_object(C);
+               
+               if(ob->type==OB_MESH) {
+                       Mesh *me= ob->data;
+                       if(me->edit_mesh) {
+                               free_editMesh(me->edit_mesh);
+                               MEM_freeN(me->edit_mesh);
+                               me->edit_mesh= NULL;
+                       }
+               }
+               if(ob->type==OB_FONT) {
+                       //                      free_editText();
+               }
+               //              else if(ob->type==OB_MBALL) 
+               //                      BLI_freelistN(&editelems);
+       }
+       
+       //      free_editLatt();
+       //      free_editArmature();
+       //      free_posebuf();
+       
+}
+
+
 /* ***** XXX: functions are using old blender names, cleanup later ***** */
 
 
index eb88141..ebd0607 100644 (file)
@@ -138,8 +138,10 @@ typedef struct Curve {
        
        struct BoundBox *bb;
        
-       ListBase nurb;
+       ListBase nurb;          /* actual data */
+       ListBase editlist;      /* edited data, not in file */
        ListBase disp;
+       
        struct Object *bevobj, *taperobj, *textoncurve;
        struct Ipo *ipo;
        Path *path;
index 752a236..8e9341c 100644 (file)
@@ -46,6 +46,7 @@ struct Mesh;
 struct OcInfo;
 struct Multires;
 struct PartialVisibility;
+struct EditMesh;
 
 typedef struct Mesh {
        ID id;
@@ -63,11 +64,13 @@ typedef struct Mesh {
        struct TFace *tface;    /* depecrated, use mtface */
        struct MVert *mvert;    /* array of verts */
        struct MEdge *medge;    /* array of edges */
-       struct MDeformVert *dvert;      /* __NLA */
+       struct MDeformVert *dvert;      /* deformgroup vertices */
        struct MCol *mcol;              /* array of colors, this must be the number of faces * 4 */
        struct MSticky *msticky;
        struct Mesh *texcomesh;
        struct MSelect *mselect;
+       
+       struct EditMesh *edit_mesh;     /* not saved in file! */
 
        struct CustomData vdata, edata, fdata;
 
index 325809d..f3ec189 100644 (file)
@@ -517,6 +517,7 @@ typedef struct Scene {
        
        ListBase base;
        struct Base *basact;
+       struct Object *obedit;          /* name replaces old G.obedit */
        
        float cursor[3];
        float twcent[3];                        /* center for transform widget */
index f54fc98..5b49e0d 100644 (file)
@@ -152,6 +152,7 @@ typedef struct wmNotifier {
 #define        ND_SEQUENCER            (6<<16)
 #define ND_OB_ACTIVE           (7<<16)
 #define ND_OB_SELECT           (8<<16)
+#define ND_OB_EDIT                     (9<<16)
 
        /* Object */
 #define        ND_TRANSFORM            (16<<16)
@@ -159,6 +160,7 @@ typedef struct wmNotifier {
 #define ND_POSE                                (18<<16)
 #define ND_BONE_ACTIVE         (19<<16)
 #define ND_BONE_SELECT         (20<<16)
+#define ND_GEOM_SELECT         (21<<16)
 
 /* subtype, 256 entries too */
 #define NOTE_SUBTYPE           0x0000FF00
index 00f1d13..466500a 100644 (file)
@@ -396,6 +396,8 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
                }
        }
        
+       ED_editors_exit(C);
+       
 return;        
        if(wm==NULL) return;
        if(G.fileflags & G_FILE_NO_UI) return;
@@ -517,6 +519,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
                ListBase wmbase;
 
                /* put aside screens to match with persistant windows later */
+               /* also exit screens and editors */
                wm_window_match_init(C, &wmbase); 
                
                retval= BKE_read_file(C, name, NULL, reports);
index ee6c841..15001ea 100644 (file)
@@ -83,6 +83,7 @@
 #include "wm_window.h"
 
 #include "ED_screen.h"
+#include "ED_util.h"
 
 #include "UI_interface.h"
 
@@ -190,6 +191,10 @@ void WM_exit(bContext *C)
        }
        wm_operatortype_free();
        
+       /* all non-screen and non-space stuff editors did, like editmode */
+       if(C)
+               ED_editors_exit(C);
+       
        free_ttfont(); /* bke_font.h */
        
 #ifdef WITH_VERSE
@@ -203,17 +208,6 @@ void WM_exit(bContext *C)
 //     if (G.background == 0)
 //             sound_end_all_sounds();
        
-       if(G.obedit) {
-               if(G.obedit->type==OB_FONT) {
-//                     free_editText();
-               }
-//             else if(G.obedit->type==OB_MBALL) BLI_freelistN(&editelems);
-//             free_editMesh(G.editMesh);
-       }
-       
-//     free_editLatt();
-//     free_editArmature();
-//     free_posebuf();
        
        /* before free_blender so py's gc happens while library still exists */
        /* needed at least for a rare sigsegv that can happen in pydrivers */