2.5
authorTon Roosendaal <ton@blender.org>
Fri, 2 Jan 2009 19:10:35 +0000 (19:10 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 2 Jan 2009 19:10:35 +0000 (19:10 +0000)
From the anti-globalization department:
G.obedit terminated!

Wherever possible, use CTX_data_edit_object(C) to get this
now. It's stored in scene now, and the screen context has
it defined.

60 files changed:
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_displist.h
source/blender/blenkernel/BKE_font.h
source/blender/blenkernel/BKE_global.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenlib/BLI_editVert.h
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/readfile.h
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_loop.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_edit.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_view3d/drawarmature.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_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
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_orientations.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/util/editmode_undo.c
source/blender/editors/util/undo.c
source/blender/makesdna/DNA_armature_types.h
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_customdata_types.h
source/blender/makesdna/DNA_lattice_types.h
source/blender/makesdna/DNA_meta_types.h
source/blender/radiosity/intern/source/radpreprocess.c
source/blender/render/intern/source/convertblender.c
source/blender/windowmanager/intern/wm_files.c

index 661686cf2a0f3a43a384e11a250fc1a4562937f2..dc932af65180356909b84cbbe83c2ad8328ebb20 100644 (file)
@@ -443,14 +443,15 @@ DerivedMesh *mesh_create_derived_no_deform_render(struct Object *ob,
                                                   float (*vertCos)[3],
                                                   CustomDataMask dataMask);
 
-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,
+DerivedMesh *editmesh_get_derived_base(struct Object *, struct EditMesh *em);
+DerivedMesh *editmesh_get_derived_cage(struct Object *, struct EditMesh *em, CustomDataMask dataMask);
+DerivedMesh *editmesh_get_derived_cage_and_final(struct Object *, struct EditMesh *em, DerivedMesh **final_r,
                                                  CustomDataMask dataMask);
+void makeDerivedMesh(struct Object *ob, struct EditMesh *em, CustomDataMask dataMask);
 
 /* returns an array of deform matrices for crazyspace correction, and the
    number of modifiers left */
-int editmesh_get_first_deform_matrices(struct EditMesh *em, float (**deformmats)[3][3],
+int editmesh_get_first_deform_matrices(struct Object *, struct EditMesh *em, float (**deformmats)[3][3],
                                        float (**deformcos)[3]);
 
 void weight_to_rgb(float input, float *fr, float *fg, float *fb);
index 6c77ac83e6b85f7bab5ac70fb6b6342870ad5fbe..64a451f3b19afc693b77c3b906b28d31e523a72b 100644 (file)
@@ -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, 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 3f6b295b9bada45bd7e52dddd207d489b9dad626..caeddf606387a81155ecd60c056d4b76b63fab8b 100644 (file)
@@ -67,7 +67,7 @@ struct chartrans *text_to_curve(struct Object *ob, int mode);
 int style_to_sel(int style, int toggle);
 int mat_to_sel(void);
 
-int getselection(int *start, int *end);
+int getselection(struct Object *ob, int *start, int *end);
 
 void chtoutf8(unsigned long c, char *o);
 void wcs2utf8s(char *dst, wchar_t *src);
index 4b04a3c45d57fda89497b0cd0ce264db2c266fac..ea0c021652adda0d08fcedda530415960236312e 100644 (file)
@@ -68,7 +68,6 @@ typedef struct Global {
        struct Main *main;
        struct Scene *scene;                    /* denk aan file.c */
        struct bScreen *curscreen;
-       struct Object *obedit;
        char editModeTitleExtra[64];
        
        /* fonts, allocated global data */
index 1636859d29b601aed40c783b44aa3e715e6df15e..9c8e88aceb5c3698b676a24ea4f52d6986bcab24 100644 (file)
@@ -2396,11 +2396,10 @@ static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm)
        return 1;
 }
 
-static void editmesh_calc_modifiers(EditMesh *em, DerivedMesh **cage_r,
+static void editmesh_calc_modifiers(Object *ob, EditMesh *em, DerivedMesh **cage_r,
                                     DerivedMesh **final_r,
                                     CustomDataMask dataMask)
 {
-       Object *ob = G.obedit;
        ModifierData *md;
        float (*deformedVerts)[3] = NULL;
        CustomDataMask mask;
@@ -2694,58 +2693,59 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
 {
        Mesh *me = ob->data;
        float min[3], max[3];
-
+       int needMapping= 0; //
+       
        clear_mesh_caches(ob);
 
-       if(ob!=G.obedit) {
-               Object *obact = G.scene->basact?G.scene->basact->object:NULL;
-               int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT);
-               int needMapping = editing && (ob==obact);
-
-               if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
-                       MCol *wpcol = (MCol*)calc_weightpaint_colors(ob);
-                       int layernum = CustomData_number_of_layers(&me->fdata, CD_MCOL);
-                       int prevactive = CustomData_get_active_layer(&me->fdata, CD_MCOL);
-                       int prevrender = CustomData_get_render_layer(&me->fdata, CD_MCOL);
-
-                       /* ugly hack here, we temporarily add a new active mcol layer with
-                          weightpaint colors in it, that is then duplicated in CDDM_from_mesh */
-                       CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, wpcol, me->totface);
-                       CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
-                       CustomData_set_layer_render(&me->fdata, CD_MCOL, layernum);
-
-                       mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
-                                           &ob->derivedFinal, 0, 1,
-                                           needMapping, dataMask, -1);
-
-                       CustomData_free_layer_active(&me->fdata, CD_MCOL, me->totface);
-                       CustomData_set_layer_active(&me->fdata, CD_MCOL, prevactive);
-                       CustomData_set_layer_render(&me->fdata, CD_MCOL, prevrender);
-               } else {
-                       mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
-                                           &ob->derivedFinal, G.rendering, 1,
-                                           needMapping, dataMask, -1);
-               }
+// XXX         Object *obact = scene->basact?scene->basact->object:NULL;
+//             int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT);
+//             int needMapping = editing && (ob==obact);
+//             if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
+       if(dataMask & CD_MASK_WEIGHTPAINT) {
+               MCol *wpcol = (MCol*)calc_weightpaint_colors(ob);
+               int layernum = CustomData_number_of_layers(&me->fdata, CD_MCOL);
+               int prevactive = CustomData_get_active_layer(&me->fdata, CD_MCOL);
+               int prevrender = CustomData_get_render_layer(&me->fdata, CD_MCOL);
+
+               /* ugly hack here, we temporarily add a new active mcol layer with
+                  weightpaint colors in it, that is then duplicated in CDDM_from_mesh */
+               CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, wpcol, me->totface);
+               CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
+               CustomData_set_layer_render(&me->fdata, CD_MCOL, layernum);
+
+               mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
+                                                       &ob->derivedFinal, 0, 1,
+                                                       needMapping, dataMask, -1);
+
+               CustomData_free_layer_active(&me->fdata, CD_MCOL, me->totface);
+               CustomData_set_layer_active(&me->fdata, CD_MCOL, prevactive);
+               CustomData_set_layer_render(&me->fdata, CD_MCOL, prevrender);
+       } 
+       else {
+               mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
+                                                       &ob->derivedFinal, G.rendering, 1,
+                                                       needMapping, dataMask, -1);
+       }
+
+       INIT_MINMAX(min, max);
 
-               INIT_MINMAX(min, max);
+       ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
 
-               ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
+       if(!ob->bb)
+               ob->bb= MEM_callocN(sizeof(BoundBox), "bb");
+       boundbox_set_from_min_max(ob->bb, min, max);
 
-               if(!ob->bb)
-                       ob->bb= MEM_callocN(sizeof(BoundBox), "bb");
-               boundbox_set_from_min_max(ob->bb, min, max);
+       ob->derivedFinal->needsFree = 0;
+       ob->derivedDeform->needsFree = 0;
+       ob->lastDataMask = dataMask;
 
-               ob->derivedFinal->needsFree = 0;
-               ob->derivedDeform->needsFree = 0;
-               ob->lastDataMask = dataMask;
-       }
 }
 
-static void editmesh_build_data(EditMesh *em, CustomDataMask dataMask)
+static void editmesh_build_data(Object *obedit, EditMesh *em, CustomDataMask dataMask)
 {
        float min[3], max[3];
 
-       clear_mesh_caches(G.obedit);
+       clear_mesh_caches(obedit);
 
        if (em->derivedFinal) {
                if (em->derivedFinal!=em->derivedCage) {
@@ -2760,16 +2760,16 @@ static void editmesh_build_data(EditMesh *em, CustomDataMask dataMask)
                em->derivedCage = NULL;
        }
 
-       editmesh_calc_modifiers(em, &em->derivedCage, &em->derivedFinal, dataMask);
+       editmesh_calc_modifiers(obedit, em, &em->derivedCage, &em->derivedFinal, dataMask);
        em->lastDataMask = dataMask;
 
        INIT_MINMAX(min, max);
 
        em->derivedFinal->getMinMax(em->derivedFinal, min, max);
 
-       if(!G.obedit->bb)
-               G.obedit->bb= MEM_callocN(sizeof(BoundBox), "bb");
-       boundbox_set_from_min_max(G.obedit->bb, min, max);
+       if(!obedit->bb)
+               obedit->bb= MEM_callocN(sizeof(BoundBox), "bb");
+       boundbox_set_from_min_max(obedit->bb, min, max);
 
        em->derivedFinal->needsFree = 0;
        em->derivedCage->needsFree = 0;
@@ -2778,7 +2778,7 @@ static void editmesh_build_data(EditMesh *em, CustomDataMask dataMask)
 void makeDerivedMesh(Object *ob, EditMesh *em, CustomDataMask dataMask)
 {
        if (em) {
-               editmesh_build_data(em, dataMask);
+               editmesh_build_data(ob, em, dataMask);
        } else {
                mesh_build_data(ob, dataMask);
        }
@@ -2950,7 +2950,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
 
 /***/
 
-DerivedMesh *editmesh_get_derived_cage_and_final(EditMesh *em, DerivedMesh **final_r,
+DerivedMesh *editmesh_get_derived_cage_and_final(Object *obedit, EditMesh *em, DerivedMesh **final_r,
                                                  CustomDataMask dataMask)
 {
        /* if there's no derived mesh or the last data mask used doesn't include
@@ -2958,27 +2958,27 @@ DerivedMesh *editmesh_get_derived_cage_and_final(EditMesh *em, DerivedMesh **fin
         */
        if(!em->derivedCage ||
           (em->lastDataMask & dataMask) != dataMask)
-               editmesh_build_data(em, dataMask);
+               editmesh_build_data(obedit, em, dataMask);
 
        *final_r = em->derivedFinal;
        return em->derivedCage;
 }
 
-DerivedMesh *editmesh_get_derived_cage(EditMesh *em, CustomDataMask dataMask)
+DerivedMesh *editmesh_get_derived_cage(Object *obedit, 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(!em->derivedCage ||
           (em->lastDataMask & dataMask) != dataMask)
-               editmesh_build_data(em, dataMask);
+               editmesh_build_data(obedit, em, dataMask);
 
        return em->derivedCage;
 }
 
-DerivedMesh *editmesh_get_derived_base(EditMesh *em)
+DerivedMesh *editmesh_get_derived_base(Object *obedit, EditMesh *em)
 {
-       return getEditMeshDerivedMesh(em, G.obedit, NULL);
+       return getEditMeshDerivedMesh(em, obedit, NULL);
 }
 
 
@@ -3040,9 +3040,8 @@ float *mesh_get_mapped_verts_nors(Object *ob)
 
 /* ********* crazyspace *************** */
 
-int editmesh_get_first_deform_matrices(EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3])
+int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3])
 {
-       Object *ob = G.obedit;
        ModifierData *md;
        DerivedMesh *dm;
        int i, a, numleft = 0, numVerts = 0;
index 953222960f20d13b687e89a1cfc1fdcaef89bc6a..bf88ad16bdf2784e00e26ba8c49080a0dc269c46 100644 (file)
@@ -72,7 +72,7 @@
 #include <config.h>
 #endif
 
-static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated);
+static void object_duplilist_recursive(ID *id, Object *ob, Object *obedit, ListBase *duplilist, float par_space_mat[][4], int level, int animated);
 
 void free_path(Path *path)
 {
@@ -98,9 +98,10 @@ void calc_curvepath(Object *ob)
        
        if(ob==NULL || ob->type != OB_CURVE) return;
        cu= ob->data;
-       //XXX if(ob==G.obedit) nu= editNurb.first;
-       //XXX else 
-       nu= cu->nurb.first;
+       if(cu->editnurb) 
+               nu= cu->editnurb->first;
+       else 
+               nu= cu->nurb.first;
        
        if(cu->path) free_path(cu->path);
        cu->path= NULL;
@@ -298,7 +299,7 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
        return dob;
 }
 
-static void group_duplilist(ListBase *lb, Object *ob, int level, int animated)
+static void group_duplilist(ListBase *lb, Object *ob, Object *obedit, int level, int animated)
 {
        DupliObject *dob;
        Group *group;
@@ -334,7 +335,7 @@ static void group_duplilist(ListBase *lb, Object *ob, int level, int animated)
                        
                        if(go->ob->transflag & OB_DUPLI) {
                                Mat4CpyMat4(dob->ob->obmat, dob->mat);
-                               object_duplilist_recursive((ID *)group, go->ob, lb, ob->obmat, level+1, animated);
+                               object_duplilist_recursive((ID *)group, go->ob, obedit, lb, ob->obmat, level+1, animated);
                                Mat4CpyMat4(dob->ob->obmat, dob->omat);
                        }
                }
@@ -386,7 +387,7 @@ struct vertexDupliData {
        ListBase *lb;
        float pmat[4][4];
        float obmat[4][4]; /* Only used for dupliverts inside dupligroups, where the ob->obmat is modified */
-       Object *ob, *par;
+       Object *ob, *par, *obedit;
        float (*orco)[3];
 };
 
@@ -426,12 +427,12 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
                float tmpmat[4][4];
                Mat4CpyMat4(tmpmat, vdd->ob->obmat);
                Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
-               object_duplilist_recursive((ID *)vdd->id, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated);
+               object_duplilist_recursive((ID *)vdd->id, vdd->ob, vdd->obedit, vdd->lb, obmat, vdd->level+1, vdd->animated);
                Mat4CpyMat4(vdd->ob->obmat, tmpmat);
        }
 }
 
-static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], int level, int animated)
+static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, float par_space_mat[][4], int level, int animated)
 {
        Object *ob, *ob_iter;
        Mesh *me= par->data;
@@ -450,7 +451,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_
        if(level>MAX_DUPLI_RECUR) return;
 
        if(me->edit_mesh)
-               dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
+               dm= editmesh_get_derived_cage(par, me->edit_mesh, CD_MASK_BAREMESH);
        else
                dm= mesh_get_derived_deform(par, CD_MASK_BAREMESH);
 
@@ -484,7 +485,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_
                        oblay = ob_iter->lay;
                }
                
-               if (lay & oblay && G.obedit!=ob_iter) {
+               if (lay & oblay && obedit!=ob_iter) {
                        ob=ob_iter->parent;
                        while(ob) {
                                if(ob==par) {
@@ -505,13 +506,14 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_
                                        vdd.animated= animated;
                                        vdd.lb= lb;
                                        vdd.ob= ob;
+                                       vdd.obedit= obedit;
                                        vdd.par= par;
                                        Mat4CpyMat4(vdd.pmat, pmat);
                                        
                                        /* mballs have a different dupli handling */
                                        if(ob->type!=OB_MBALL) ob->flag |= OB_DONE;     /* doesnt render */
 
-                                       if(par==G.obedit) {
+                                       if(par==obedit) {
                                                dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
                                        }
                                        else {
@@ -537,7 +539,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_
        dm->release(dm);
 }
 
-static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], int level, int animated)
+static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, float par_space_mat[][4], int level, int animated)
 {
        Object *ob, *ob_iter;
        Base *base = NULL;
@@ -562,7 +564,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
        if(me->edit_mesh) {
                int totvert;
                
-               dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
+               dm= editmesh_get_derived_cage(par, me->edit_mesh, CD_MASK_BAREMESH);
                
                totface= dm->getNumFaces(dm);
                mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
@@ -611,7 +613,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
                        oblay = ob_iter->lay;
                }
                
-               if (lay & oblay && G.obedit!=ob_iter) {
+               if (lay & oblay && obedit!=ob_iter) {
                        ob=ob_iter->parent;
                        while(ob) {
                                if(ob==par) {
@@ -704,7 +706,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
                                                        float tmpmat[4][4];
                                                        Mat4CpyMat4(tmpmat, ob->obmat);
                                                        Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */
-                                                       object_duplilist_recursive((ID *)id, ob, lb, ob->obmat, level+1, animated);
+                                                       object_duplilist_recursive((ID *)id, ob, obedit, lb, ob->obmat, level+1, animated);
                                                        Mat4CpyMat4(ob->obmat, tmpmat);
                                                }
                                        }
@@ -718,7 +720,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma
                else            go= go->next;           /* group loop */
        }
        
-       if(par==G.obedit) {
+       if(par==obedit) {
                MEM_freeN(mface);
                MEM_freeN(mvert);
        }
@@ -1020,7 +1022,7 @@ static void font_duplilist(ListBase *lb, Object *par, int level, int animated)
 }
 
 /* ***************************** */
-static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
+static void object_duplilist_recursive(ID *id, Object *ob, Object *obedit, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
 {      
        if((ob->transflag & OB_DUPLI)==0)
                return;
@@ -1043,7 +1045,7 @@ static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist,
        }
        else if(ob->transflag & OB_DUPLIVERTS) {
                if(ob->type==OB_MESH) {
-                       vertex_duplilist(duplilist, id, ob, par_space_mat, level+1, animated);
+                       vertex_duplilist(duplilist, id, obedit, ob, par_space_mat, level+1, animated);
                }
                else if(ob->type==OB_FONT) {
                        if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
@@ -1053,7 +1055,7 @@ static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist,
        }
        else if(ob->transflag & OB_DUPLIFACES) {
                if(ob->type==OB_MESH)
-                       face_duplilist(duplilist, id, ob, par_space_mat, level+1, animated);
+                       face_duplilist(duplilist, id, obedit, ob, par_space_mat, level+1, animated);
        }
        else if(ob->transflag & OB_DUPLIFRAMES) {
                if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
@@ -1062,7 +1064,7 @@ static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist,
        } else if(ob->transflag & OB_DUPLIGROUP) {
                DupliObject *dob;
                
-               group_duplilist(duplilist, ob, level+1, animated); /* now recursive */
+               group_duplilist(duplilist, ob, obedit, level+1, animated); /* now recursive */
 
                if (level==0) {
                        for(dob= duplilist->first; dob; dob= dob->next)
@@ -1078,7 +1080,7 @@ ListBase *object_duplilist(Scene *sce, Object *ob)
 {
        ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist");
        duplilist->first= duplilist->last= NULL;
-       object_duplilist_recursive((ID *)sce, ob, duplilist, NULL, 0, 0);
+       object_duplilist_recursive((ID *)sce, ob, sce->obedit, duplilist, NULL, 0, 0);
        return duplilist;
 }
 
index 0b5925a0b385b91bb6ea6df3c84c15bb5678fa16..e7ae7997e9fb549a407343681f45cd0035249837 100644 (file)
@@ -906,6 +906,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
                                                   int numVerts, int deformflag, 
                                                   float (*prevCos)[3], const char *defgrp_name)
 {
+       bArmature *arm= armOb->data;
        bPoseChannel *pchan, **defnrToPC = NULL;
        MDeformVert *dverts = NULL;
        bDeformGroup *dg;
@@ -921,7 +922,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
        int armature_def_nr = -1;
        int totchan;
 
-       if(armOb == G.obedit) return;
+       if(arm->edbo) return;
        
        Mat4Invert(obinv, target->obmat);
        Mat4CpyMat4(premat, target->obmat);
@@ -2280,8 +2281,8 @@ void where_is_pose (Object *ob)
        if(ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) 
           armature_rebuild_pose(ob, arm);
        
-       /* In restposition we read the data from the bones */
-       if(ob==G.obedit || (arm->flag & ARM_RESTPOS)) {
+       /* In editmode or restposition we read the data from the bones */
+       if(arm->edbo || (arm->flag & ARM_RESTPOS)) {
                
                for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
                        bone= pchan->bone;
index 8adfe33dfe3daa43a6f6524b6d21be4d2b32ec7c..ef740038e572da7af9f8482fef2924bd5530b332 100644 (file)
@@ -222,17 +222,12 @@ static void clear_global(void)
        fastshade_free_render();        /* lamps hang otherwise */
        free_main(G.main);                      /* free all lib data */
        
-       if (G.obedit) {
-//             free_editText();
-       }
 //     free_vertexpaint();
 
        G.curscreen= NULL;
        G.scene= NULL;
        G.main= NULL;
        
-       G.obedit= NULL;
-       
        G.f &= ~(G_WEIGHTPAINT + G_VERTEXPAINT + G_FACESELECT + G_PARTICLEEDIT);
 }
 
index 7fa4f406c7b2bc2390c37f037306fe3c951f844e..0a58ae59386993be30665e32a7c99c8ac8ee1aaf 100644 (file)
@@ -1136,7 +1136,7 @@ void makebevelcurve(Object *ob, ListBase *disp)
        disp->first = disp->last = NULL;
 
        /* if a font object is being edited, then do nothing */
-       if( ob == G.obedit && ob->type == OB_FONT ) return;
+// XXX if( ob == obedit && ob->type == OB_FONT ) return;
 
        if(cu->bevobj && cu->bevobj!=ob) {
                if(cu->bevobj->type==OB_CURVE) {
@@ -1529,7 +1529,7 @@ void makeBevelList(Object *ob)
        /* STEP 1: MAKE POLYS  */
 
        BLI_freelistN(&(cu->bev));
-       if(ob==G.obedit && ob->type!=OB_FONT) nu= editNurb.first;
+       if(cu->editnurb && ob->type!=OB_FONT) nu= cu->editnurb->first;
        else nu= cu->nurb.first;
        
        while(nu) {
index f5deda9c3c915bfcbbd4bf1f02ec290218934456..e090a2e4cae96a475390ce1a5690170080515a9d 100644 (file)
@@ -1764,7 +1764,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
                for(itA = node->child; itA; itA= itA->next) {
                        all_layer |= itA->lay;
                        /* the relationship is visible */
-                       if((itA->lay & layer) || (itA->node->ob == G.obedit)) {
+                       if((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
                                if(itA->node->type==ID_OB) {
                                        obc= itA->node->ob;
                                        oldflag= obc->recalc;
@@ -1795,7 +1795,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
                        }
                }
                /* even nicer, we can clear recalc flags...  */
-               if((all_layer & layer)==0 && (ob != G.obedit)) {
+               if((all_layer & layer)==0) { // XXX && (ob != obedit)) {
                        /* but existing displaylists or derivedmesh should be freed */
                        if(ob->recalc & OB_RECALC_DATA)
                                object_free_display(ob);
@@ -1809,7 +1809,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
        /* could merge this in with loop above...? (ton) */
        for(itA = node->child; itA; itA= itA->next) {
                /* the relationship is visible */
-               if((itA->lay & layer) || (itA->node->ob == G.obedit)) {
+               if((itA->lay & layer)) {                // XXX  || (itA->node->ob == obedit)
                        if(itA->node->type==ID_OB) {
                                obc= itA->node->ob;
                                /* child moves */
index 3a9e0eb8febf22181989e89f7d337d3fb6cea1f5..52ec529b82a60ea16229de5dd26dae5b78d3570a 100644 (file)
@@ -662,7 +662,7 @@ void shadeDispList(Base *base)
 
                init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
                
-               if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
+               if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
                
                        /* now we need the normals */
                        cu= ob->data;
@@ -985,7 +985,7 @@ void filldisplist(ListBase *dispbase, ListBase *to)
                        dl= dl->next;
                }
                
-               if(totvert && BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) {
+               if(totvert && BLI_edgefill(0, 0)) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
 
                        /* count faces  */
                        tot= 0;
@@ -1217,12 +1217,14 @@ static ModifierData *curve_get_tesselate_point(Object *ob, int forRender, int ed
        return preTesselatePoint;
 }
 
-void curve_calc_modifiers_pre(Object *ob, ListBase *nurb, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r)
+static void curve_calc_modifiers_pre(Object *ob, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r)
 {
-       int editmode = (!forRender && ob==G.obedit);
        ModifierData *md = modifiers_getVirtualModifierList(ob);
-       ModifierData *preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
+       ModifierData *preTesselatePoint;
+       Curve *cu= ob->data;
+       ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb;
        int numVerts = 0;
+       int editmode = (!forRender && cu->editnurb);
        float (*originalVerts)[3] = NULL;
        float (*deformedVerts)[3] = NULL;
        int required_mode;
@@ -1230,9 +1232,11 @@ void curve_calc_modifiers_pre(Object *ob, ListBase *nurb, int forRender, float (
        if(forRender) required_mode = eModifierMode_Render;
        else required_mode = eModifierMode_Realtime;
 
+       preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
+       
        if(editmode) required_mode |= eModifierMode_Editmode;
 
-       if(ob!=G.obedit && do_ob_key(ob)) {
+       if(cu->editnurb==NULL && do_ob_key(ob)) {
                deformedVerts = curve_getVertexCos(ob->data, nurb, &numVerts);
                originalVerts = MEM_dupallocN(deformedVerts);
        }
@@ -1266,17 +1270,21 @@ void curve_calc_modifiers_pre(Object *ob, ListBase *nurb, int forRender, float (
        *numVerts_r = numVerts;
 }
 
-static void curve_calc_modifiers_post(Object *ob, ListBase *nurb, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
+static void curve_calc_modifiers_post(Object *ob, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
 {
-       int editmode = (!forRender && ob==G.obedit);
        ModifierData *md = modifiers_getVirtualModifierList(ob);
-       ModifierData *preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
+       ModifierData *preTesselatePoint;
+       Curve *cu= ob->data;
+       ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb;
        DispList *dl;
        int required_mode;
+       int editmode = (!forRender && cu->editnurb);
 
        if(forRender) required_mode = eModifierMode_Render;
        else required_mode = eModifierMode_Realtime;
 
+       preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
+       
        if(editmode) required_mode |= eModifierMode_Editmode;
 
        if (preTesselatePoint) {
@@ -1371,14 +1379,12 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
        float (*originalVerts)[3];
        float (*deformedVerts)[3];
                
-       if(!forRender && ob==G.obedit) {
-               //XXX nubase= &editNurb;
-       }
-       else {
+       if(!forRender && cu->editnurb)
+               nubase= cu->editnurb;
+       else
                nubase= &cu->nurb;
-       }
 
-       curve_calc_modifiers_pre(ob, nubase, forRender, &originalVerts, &deformedVerts, &numVerts);
+       curve_calc_modifiers_pre(ob, forRender, &originalVerts, &deformedVerts, &numVerts);
 
        for (nu=nubase->first; nu; nu=nu->next) {
                if(forRender || nu->hide==0) {
@@ -1432,7 +1438,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
                tex_space_curve(cu);
        }
 
-       curve_calc_modifiers_post(ob, nubase, dispbase, forRender, originalVerts, deformedVerts);
+       curve_calc_modifiers_post(ob, dispbase, forRender, originalVerts, deformedVerts);
 }
 
 void makeDispListCurveTypes(Object *ob, int forOrco)
@@ -1450,14 +1456,18 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
        if(ob->type==OB_SURF) {
                makeDispListSurf(ob, dispbase, 0);
        }
-       else if ELEM(ob->type, OB_CURVE, OB_FONT) {
+       else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
                ListBase dlbev;
+               ListBase *nubase;
                float (*originalVerts)[3];
                float (*deformedVerts)[3];
-               //XXX int obedit= (G.obedit && G.obedit->data==ob->data && G.obedit->type==OB_CURVE);
-               ListBase *nubase= &cu->nurb; //XXX ListBase *nubase = obedit?&editNurb:&cu->nurb;
                int numVerts;
 
+               if(cu->editnurb)
+                       nubase= cu->editnurb;
+               else
+                       nubase= &cu->nurb;
+               
                BLI_freelistN(&(cu->bev));
                
                if(cu->path) free_path(cu->path);
@@ -1465,7 +1475,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
                
                if(ob->type==OB_FONT) text_to_curve(ob, 0);
                
-               if(!forOrco) curve_calc_modifiers_pre(ob, nubase, 0, &originalVerts, &deformedVerts, &numVerts);
+               if(!forOrco) curve_calc_modifiers_pre(ob, 0, &originalVerts, &deformedVerts, &numVerts);
 
                makeBevelList(ob);
 
@@ -1593,7 +1603,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
 
                if(cu->flag & CU_PATH) calc_curvepath(ob);
 
-               if(!forOrco) curve_calc_modifiers_post(ob, nubase, &cu->disp, 0, originalVerts, deformedVerts);
+               if(!forOrco) curve_calc_modifiers_post(ob, &cu->disp, 0, originalVerts, deformedVerts);
                tex_space_curve(cu);
        }
        
index 4fe862e5f52ec643d0bd35afd5061c3fe02f847b..911efda21bd28b672de9a555926546ffd864d6b6 100644 (file)
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
  *
- * The Original Code is: all of this file.
  *
  * Contributor(s): 
  * - Martin DeMello
  *   Added dxf_read_arc, dxf_read_ellipse and dxf_read_lwpolyline
  *   Copyright (C) 2004 by Etheract Software Labs
  *
+ * - Blender Foundation
+ *
  * ***** END GPL LICENSE BLOCK *****
  *  
  *  eigen videoscape formaat:
@@ -687,190 +688,6 @@ static void read_videoscape_mesh(char *str)
        //XXX waitcursor(1);
 }
 
-static void read_radiogour(char *str)
-{
-       Object *ob;
-       Mesh *me;
-       MVert *mvert;
-       MFace *mface;
-       FILE *fp;
-       float *vertdata, *vd, min[3], max[3], cent[3], ftemp;
-       unsigned int *colv, *colf, *colvertdata;
-       int  itemp, a, b, verts, tottria=0, totquad=0, totedge=0, poly, nr0, nr, first;
-       int end;
-       char s[50];
-       
-       fp= fopen(str, "rb");
-       if(fp==NULL) {
-               //XXX error("Can't read file");
-               return;
-       }
-       
-       fscanf(fp, "%40s", s);
-       
-       fscanf(fp, "%d\n", &verts);
-       if(verts<=0) {
-               fclose(fp);
-               //XXX error("Read error");
-               return;
-       }
-       
-       if(verts>MESH_MAX_VERTS) {
-               //XXX error("too many vertices");
-               fclose(fp);
-               return;
-       }
-       
-       INIT_MINMAX(min, max);
-       vd= vertdata= MEM_mallocN(sizeof(float)*3*verts, "videoscapelezer");
-       colv= colvertdata= MEM_mallocN(verts*sizeof(float), "coldata");
-       
-       for(a=0; a<verts; a++) {
-               fscanf(fp, "%f %f %f %i", vd, vd+1, vd+2, colv);
-               DO_MINMAX(vd, min, max);
-               vd+=3;
-               colv++;
-       }
-       
-       /* count faces */
-       end= 1;
-       while(end>0) {
-               end= fscanf(fp,"%d", &poly);
-               if(end<=0) break;
-       
-               if(poly==3) tottria++;
-               else if(poly==4) totquad++;
-               else totedge+= poly;
-       
-               for(a=0;a<poly;a++) {
-                       end= fscanf(fp,"%d", &nr);
-                       if(end<=0) break;
-               }
-               if(end<=0) break;
-               
-       }
-       
-       if(totedge+tottria+totquad>MESH_MAX_VERTS) {
-               printf(" var1: %d, var2: %d, var3: %d \n", totedge, tottria, totquad);
-               //XXX error("too many faces");
-               MEM_freeN(vertdata);
-               MEM_freeN(colvertdata);
-               fclose(fp);
-               return;
-       }
-       
-       /* new object */
-       ob= add_object(OB_MESH);
-       me= ob->data;
-       me->totvert= verts;
-       me->totface= totedge+tottria+totquad;
-       me->flag= 0;
-
-       me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC,
-                                       NULL, me->totvert);
-       me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC,
-                                       NULL, me->totface);
-       
-       /* verts */
-       
-       cent[0]= (min[0]+max[0])/2.0f;
-       cent[1]= (min[1]+max[1])/2.0f;
-       cent[2]= (min[2]+max[2])/2.0f;
-       VECCOPY(ob->loc, cent);
-       
-       a= me->totvert;
-       vd= vertdata;
-       mvert= me->mvert;
-       while(a--) {
-               VecSubf(mvert->co, vd, cent);
-               mvert++;
-               vd+= 3;
-       }
-       
-       /* faces */
-       if(me->totface) {
-               rewind(fp);
-       
-               fscanf(fp, "%40s", s);
-               fscanf(fp, "%d\n", &verts);
-               for(a=0;a<verts;a++) {
-                       fscanf(fp, "%f %f %f %i", &ftemp, &ftemp, &ftemp, &itemp);
-               }
-               
-               a= me->totface;
-               mface= me->mface;
-               while(a--) {
-                       end= fscanf(fp,"%d", &poly);
-                       if(end<=0) break;
-       
-                       if(poly==3 || poly==4) {
-                               fscanf(fp,"%d", &nr);
-                               mface->v1= MIN2(nr, me->totvert-1);
-                               fscanf(fp,"%d", &nr);
-                               mface->v2= MIN2(nr, me->totvert-1);
-                               fscanf(fp,"%d", &nr);
-                               mface->v3= MIN2(nr, me->totvert-1);
-                               if(poly==4) {
-                                       if( fscanf(fp,"%d", &nr) <=0 ) break;
-                                       mface->v4= MIN2(nr, me->totvert-1);
-                               }
-                               
-                               test_index_face(mface, NULL, 0, poly);
-                               
-                               mface++;
-                       }
-                       else {
-                               if( fscanf(fp,"%d", &nr0) <=0) break;
-                               first= nr0;
-                               for(b=1; b<poly; b++) {
-                                       end= fscanf(fp,"%d", &nr);
-                                       if(end<=0) break;
-                                       nr= MIN2(nr, me->totvert-1);
-                                       mface->v1= nr;
-                                       mface->v2= nr0;
-                                       nr0= nr;
-                                       mface++;
-                                       a--;
-                               }
-                               mface->v1= first;
-                               mface->v2= nr;
-                               mface->flag= ME_SMOOTH;
-                               
-                               mface++;
-                               if(end<=0) break;
-                       }
-               }
-               
-               /* mcol is 4 colors per face */
-               me->mcol= MEM_mallocN(4*sizeof(int)*me->totface, "mcol");
-               colf= (unsigned int *)me->mcol;
-
-               a= me->totface;
-               mface= me->mface;
-               while(a--) {
-                       
-                       colf[0]= colvertdata[mface->v1];
-                       colf[1]= colvertdata[mface->v2];
-                       colf[2]= colvertdata[mface->v3];
-                       colf[3]= colvertdata[mface->v4];
-                       
-                       colf+= 4;
-                       mface++;
-               }
-               
-               MEM_freeN(colvertdata);
-       }
-       
-       fclose(fp);
-       MEM_freeN(vertdata);
-       
-       mesh_add_normals_flags(me);
-       make_edges(me, 0);
-
-       //XXX waitcursor(1);
-}
-
-
 static void read_videoscape_lamp(char *str)
 {
        Object *ob;
@@ -2387,16 +2204,8 @@ int BKE_read_exotic(char *name)
 
                                //XXX waitcursor(1);
                                
-                               if(*s0==GOUR) {
-                                       if(G.obedit) {
-                                               //XXX error("Unable to perform function in EditMode");
-                                       } else {
-                                               read_radiogour(name);
-                                               retval = 1;
-                                       }
-                               }
-                               else if ELEM4(*s0, DDG1, DDG2, DDG3, DDG4) {
-                                       if(G.obedit) {
+                               if(ELEM4(*s0, DDG1, DDG2, DDG3, DDG4)) {
+                                       if(0) { // XXX obedit) {
                                                //XXX error("Unable to perform function in EditMode");
                                        } else {
                                                read_videoscape(name);
@@ -2618,7 +2427,7 @@ static void write_videoscape_mesh(Object *ob, char *str)
 
        fprintf(fp,"3DG1\n");
 
-       if(G.obedit) {
+       if(em) {
 
                fprintf(fp, "%d\n", G.totvert);
        
index a8a97742c2471c4abfa57efe8d12c842971bc581..529d4cc5268874f3b64c08490b0a67559a6e7e45 100644 (file)
@@ -622,13 +622,11 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
        }
 }
 
-int getselection(int *start, int *end)
+int getselection(Object *ob, int *start, int *end)
 {
-       Curve *cu;
+       Curve *cu= ob->data;
        
-       if (G.obedit==NULL || G.obedit->type != OB_FONT) return 0;
-       
-       cu= G.obedit->data;
+       if (cu->editstr==NULL || ob->type != OB_FONT) return 0;
 
        if (cu->selstart == 0) return 0;
        if (cu->selstart <= cu->selend) {
@@ -677,8 +675,8 @@ struct chartrans *text_to_curve(Object *ob, int mode)
        cu= (Curve *) ob->data;
        vfont= cu->vfont;
 
-       if(cu->str == 0) return 0;
-       if(vfont == 0) return 0;
+       if(cu->str == NULL) return 0;
+       if(vfont == NULL) return 0;
 
        // Create unicode string
        utf8len = utf8slen(cu->str);
@@ -731,7 +729,7 @@ struct chartrans *text_to_curve(Object *ob, int mode)
 
        if (selboxes) MEM_freeN(selboxes);
        selboxes = NULL;
-       if (getselection(&selstart, &selend))
+       if (getselection(ob, &selstart, &selend))
                selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
 
        tb = &(cu->tb[0]);
@@ -1113,7 +1111,7 @@ struct chartrans *text_to_curve(Object *ob, int mode)
        }
        
        /* cursor first */
-       if(ob==G.obedit) {
+       if(cu->editstr) {
                ct= chartransdata+cu->pos;
                si= (float)sin(ct->rot);
                co= (float)cos(ct->rot);
index 3f9143bb405f4390b50cef3f2b756b907773f41d..d397279e63eee67fbca295b911bc80689afc43c4 100644 (file)
@@ -297,14 +297,17 @@ void make_local_lattice(Lattice *lt)
 void init_latt_deform(Object *oblatt, Object *ob)
 {
                /* we make an array with all differences */
-       Lattice *lt = deformLatt = (oblatt==G.obedit)?editLatt:oblatt->data;
-       BPoint *bp = lt->def;
+       Lattice *ltoblatt->data;
+       BPoint *bp;
        DispList *dl = find_displist(&oblatt->disp, DL_VERTS);
        float *co = dl?dl->verts:NULL;
        float *fp, imat[4][4];
        float fu, fv, fw;
        int u, v, w;
 
+       if(lt->editlatt) lt= lt->editlatt;
+       bp = lt->def;
+       
        fp= latticedata= MEM_mallocN(sizeof(float)*3*deformLatt->pntsu*deformLatt->pntsv*deformLatt->pntsw, "latticedata");
        
                /* for example with a particle system: ob==0 */
@@ -868,10 +871,13 @@ void outside_lattice(Lattice *lt)
 
 float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
 {
-       Lattice *lt = (G.obedit==ob)?editLatt:ob->data;
-       int i, numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
+       Lattice *lt = ob->data;
+       int i, numVerts;
        float (*vertexCos)[3] = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos");
 
+       if(lt->editlatt) lt= lt->editlatt;
+       numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
+       
        for (i=0; i<numVerts; i++) {
                VECCOPY(vertexCos[i], lt->def[i].vec);
        }
@@ -891,9 +897,10 @@ void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3])
 
 void lattice_calc_modifiers(Object *ob)
 {
-       float (*vertexCos)[3] = NULL;
+       Lattice *lt= ob->data;
        ModifierData *md = modifiers_getVirtualModifierList(ob);
-       int numVerts, editmode = G.obedit==ob;
+       float (*vertexCos)[3] = NULL;
+       int numVerts, editmode = (lt->editlatt!=NULL);
 
        freedisplist(&ob->disp);
 
@@ -931,7 +938,8 @@ struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
 {
        if(oblatt->type == OB_LATTICE)
        {
-               Lattice *lt = (oblatt==G.obedit)?editLatt:(Lattice*)oblatt->data;
+               Lattice *lt = (Lattice*)oblatt->data;
+               if(lt->editlatt) lt= lt->editlatt;
                return lt->dvert;
        }
 
index d697ef2de4e563b434784ffef87ae0c2370b2c8b..ccbc1cc17a14b4009e54b94cb81c9846c500b05c 100644 (file)
@@ -858,12 +858,13 @@ void delete_material_index()
        short *totcolp;
        int a, actcol;
        
-       if(G.obedit) {
+       //      if(obedit) {
                //XXX error("Unable to perform function in EditMode");
-               return;
-       }
+               //              return;
+       //      }
+       
        ob= ((G.scene->basact)? (G.scene->basact->object) : 0) ;
-       if(ob==0 || ob->totcol==0) return;
+       if(ob==NULL || ob->totcol==0) return;
        
        /* take a mesh/curve/mball as starting point, remove 1 index,
         * AND with all objects that share the ob->data
index d84ad0a5215678f0ad120f69996a1b4b300b9b6a..8914ebac4e05b0a876fba1f3f22d9242ebbcb9c4 100644 (file)
@@ -287,7 +287,6 @@ int is_basis_mball(Object *ob)
  */
 Object *find_basis_mball(Object *basis)
 {
-       extern ListBase editelems; /* editmball.c */
        Base *base;
        Object *ob,*bob= basis;
        MetaElem *ml=NULL;
@@ -302,13 +301,13 @@ Object *find_basis_mball(Object *basis)
                
                if (ob->type==OB_MBALL) {
                        if(ob==bob){
+                               MetaBall *mb= ob->data;
+                               
                                /* if bob object is in edit mode, then dynamic list of all MetaElems
                                 * is stored in editelems */
-                               if(ob==G.obedit) ml= editelems.first;
-                               /* keep track of linked data too! */
-                               else if(G.obedit && G.obedit->data==ob->data) ml= editelems.first;
+                               if(mb->editelems) ml= mb->editelems->first;
                                /* if bob object is in object mode */
-                               else ml= ((MetaBall*)ob->data)->elems.first;
+                               else ml= mb->elems.first;
                        }
                        else{
                                splitIDname(ob->id.name+2, obname, &obnr);
@@ -316,13 +315,13 @@ Object *find_basis_mball(Object *basis)
                                /* object ob has to be in same "group" ... it means, that it has to have
                                 * same base of its name */
                                if(strcmp(obname, basisname)==0){
+                                       MetaBall *mb= ob->data;
+                                       
                                        /* if object is in edit mode, then dynamic list of all MetaElems
                                         * is stored in editelems */
-                                       if(ob==G.obedit) ml= editelems.first;
-                                       /* keep track of linked data too! */
-                                       else if(bob==G.obedit && bob->data==ob->data) ml= editelems.first;
-                                       /* object is in object mode */
-                                       else ml= ((MetaBall*)ob->data)->elems.first;
+                                       if(mb->editelems) ml= mb->editelems->first;
+                                       /* if bob object is in object mode */
+                                       else ml= mb->elems.first;
                                        
                                        if(obnr<basisnr){
                                                if(!(ob->flag & OB_FROMDUPLI)){
@@ -1454,7 +1453,6 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
 
 float init_meta(Object *ob)    /* return totsize */
 {
-       extern ListBase editelems; /* editmball.c */
        Base *base;
        Object *bob;
        MetaBall *mb;
@@ -1483,8 +1481,7 @@ float init_meta(Object *ob)       /* return totsize */
                                mat= imat= 0;
                                mb= ob->data;
        
-                               if(ob==G.obedit) ml= editelems.first;
-                               else if(G.obedit && G.obedit->type==OB_MBALL && G.obedit->data==mb) ml= editelems.first;
+                               if(mb->editelems) ml= mb->editelems->first;
                                else ml= mb->elems.first;
                        }
                        else {
@@ -1494,8 +1491,8 @@ float init_meta(Object *ob)       /* return totsize */
                                splitIDname(bob->id.name+2, name, &nr);
                                if( strcmp(obname, name)==0 ) {
                                        mb= bob->data;
-                                       if(G.obedit && G.obedit->type==OB_MBALL && G.obedit->data==mb) 
-                                               ml= editelems.first;
+                                       
+                                       if(mb->editelems) ml= mb->editelems->first;
                                        else ml= mb->elems.first;
                                }
                        }
index 38e8b1b1abe0a12779724b5b5a4435bd50630aaf..30f065a40a099657e7ccd2b1433784b49942e306 100644 (file)
@@ -7567,7 +7567,7 @@ static void meshdeformModifier_do(
        
        /* get cage derivedmesh */
        if(me->edit_mesh) {
-               tmpdm= editmesh_get_derived_cage_and_final(me->edit_mesh, &cagedm, 0);
+               tmpdm= editmesh_get_derived_cage_and_final(ob, me->edit_mesh, &cagedm, 0);
                if(tmpdm)
                        tmpdm->release(tmpdm);
        }
@@ -8718,8 +8718,9 @@ int modifiers_isDeformed(Object *ob)
        ModifierData *md = modifiers_getVirtualModifierList(ob);
        
        for (; md; md=md->next) {
-               if(ob==G.obedit && (md->mode & eModifierMode_Editmode)==0);
-               else if(modifier_isDeformer(md))
+                       // XXX if(ob==obedit && (md->mode & eModifierMode_Editmode)==0);
+                       // else 
+                       if(modifier_isDeformer(md))
                        return 1;
        }
        return 0;
index 99e4083f68d15f0cbedb6a532ded6a4a4da0aba0..a1566b1a0ed00cafe8ee0ae21377ad8133680279 100644 (file)
@@ -1285,7 +1285,7 @@ void multires_set_level(Object *ob, Mesh *me, const int render)
 /* Update the edge visibility flags to only show edges on or below the edgelvl */
 void multires_edge_level_update(Object *ob, Mesh *me)
 {
-       if(!G.obedit) {
+       if(!me->edit_mesh) {
                MultiresLevel *cr_lvl= BLI_findlink(&me->mr->levels,me->mr->current-1);
                MultiresLevel *edge_lvl= BLI_findlink(&me->mr->levels,me->mr->edgelvl-1);
                const int threshold= edge_lvl->totedge * pow(2, me->mr->current - me->mr->edgelvl);
index e52a4a4f8e0476034826dcef771e4f5cd1245b73..d9101feb204561747b87207b91335eda60d296e3 100644 (file)
@@ -1706,7 +1706,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                        }
                }
        }
-       else if ELEM(par->type, OB_CURVE, OB_SURF) {
+       else if (ELEM(par->type, OB_CURVE, OB_SURF)) {
                Nurb *nu;
                Curve *cu;
                BPoint *bp;
@@ -1714,8 +1714,10 @@ static void give_parvert(Object *par, int nr, float *vec)
                int found= 0;
                
                cu= par->data;
-               nu= cu->nurb.first;
-               //XXX if(par==G.obedit) nu= editNurb.first;
+               if(cu->editnurb)
+                       nu= cu->editnurb->first;
+               else
+                       nu= cu->nurb.first;
                
                count= 0;
                while(nu && !found) {
@@ -1755,7 +1757,7 @@ static void give_parvert(Object *par, int nr, float *vec)
                DispList *dl = find_displist(&par->disp, DL_VERTS);
                float *co = dl?dl->verts:NULL;
                
-               if(par==G.obedit) latt= editLatt;
+               if(latt->editlatt) latt= latt->editlatt;
                
                a= latt->pntsu*latt->pntsv*latt->pntsw;
                count= 0;
@@ -1782,7 +1784,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
        /* in local ob space */
        Mat4One(mat);
        
-       if ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE) {
+       if (ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) {
                
                give_parvert(par, ob->par1, v1);
                give_parvert(par, ob->par2, v2);
@@ -2163,7 +2165,7 @@ BoundBox *object_get_boundbox(Object *ob)
        if(ob->type==OB_MESH) {
                bb = mesh_get_bb(ob);
        }
-       else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
+       else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
                bb= ( (Curve *)ob->data )->bb;
        }
        else if(ob->type==OB_MBALL) {
index 4f7f5402d0d5b0ce98d2360b5c3169b2088e8bb0..3ad17790f45f94d8b4f473c8043cabaeaa40efb2 100644 (file)
@@ -4334,8 +4334,8 @@ static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
                        int readMask, activeParts = 0, fileParts = 0;
                        gzFile gzf;
        
-                       if(ob==G.obedit) // off...
-                               return;
+// XXX                 if(ob==G.obedit) // off...
+//                             return;
        
                        // ok, start loading
                        strcpy(filename, fss->surfdataPath);
index 81788cd24a8380fec4f953b80b54a585ca160914..3b29409d75c27744e7c179708d0bbe060a4f23d9 100644 (file)
@@ -98,7 +98,7 @@ DerivedMesh *object_get_derived_final(Object *ob, CustomDataMask dataMask)
        if (me->edit_mesh)
        {
                DerivedMesh *final = NULL;
-               editmesh_get_derived_cage_and_final(me->edit_mesh, &final, dataMask);
+               editmesh_get_derived_cage_and_final(ob, me->edit_mesh, &final, dataMask);
                return final;
        }
        else
@@ -237,8 +237,9 @@ void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
        //Setup nearest
        nearest.index = -1;
        nearest.dist = FLT_MAX;
-
+#ifndef __APPLE__
 #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
+#endif
        for(i = 0; i<calc->numVerts; ++i)
        {
                float *co = calc->vertexCos[i];
@@ -443,7 +444,9 @@ do
 
 
        //Now, everything is ready to project the vertexs!
+#ifndef __APPLE__
 #pragma omp parallel for private(i,hit) schedule(static)
+#endif
        for(i = 0; i<calc->numVerts; ++i)
        {
                float *co = calc->vertexCos[i];
@@ -547,7 +550,9 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
 
 
        //Find the nearest vertex
+#ifndef __APPLE__
 #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
+#endif
        for(i = 0; i<calc->numVerts; ++i)
        {
                float *co = calc->vertexCos[i];
index a4a4d5ffd846a544153d13cb30bb4fa440d70251..fec89690090ecda022458f16ad8790325051e9e8 100644 (file)
@@ -174,6 +174,8 @@ typedef struct EditMesh
        
        /* copy from scene */
        short selectmode;
+       /* copy from object actcol */
+       short mat_nr;
        
        struct DerivedMesh *derivedCage, *derivedFinal;
        /* the custom data layer mask that was last used to calculate
index 41267738cf5b2dcd0ccb08695818b928a25bc556..82923be09cf9d1528cd21b9ebddde3340cf1c16e 100644 (file)
@@ -809,7 +809,7 @@ static int read_file_dna(FileData *fd)
        return 0;
 }
 
-static int fd_read_from_file(FileData *filedata, void *buffer, int size)
+static int fd_read_from_file(FileData *filedata, void *buffer, unsigned int size)
 {
        int readsize = read(filedata->filedes, buffer, size);
 
@@ -822,7 +822,7 @@ static int fd_read_from_file(FileData *filedata, void *buffer, int size)
        return (readsize);
 }
 
-static int fd_read_gzip_from_file(FileData *filedata, void *buffer, int size)
+static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size)
 {
        int readsize = gzread(filedata->gzfiledes, buffer, size);
 
@@ -835,7 +835,7 @@ static int fd_read_gzip_from_file(FileData *filedata, void *buffer, int size)
        return (readsize);
 }
 
-static int fd_read_from_memory(FileData *filedata, void *buffer, int size)
+static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int size)
 {
                // don't read more bytes then there are available in the buffer
        int readsize = MIN2(size, filedata->buffersize - filedata->seek);
@@ -1998,7 +1998,8 @@ static void direct_link_armature(FileData *fd, bArmature *arm)
        Bone    *bone;
 
        link_list(fd, &arm->bonebase);
-
+       arm->edbo= NULL;
+       
        bone=arm->bonebase.first;
        while (bone) {
                direct_link_bones(fd, bone);
@@ -2182,9 +2183,9 @@ static void direct_link_mball(FileData *fd, MetaBall *mb)
 
        link_list(fd, &(mb->elems));
 
-       mb->disp.first= mb->disp.last= 0;
-
-       mb->bb= 0;
+       mb->disp.first= mb->disp.last= NULL;
+       mb->editelems= NULL;
+       mb->bb= NULL;
 }
 
 /* ************ READ WORLD ***************** */
@@ -2481,9 +2482,10 @@ static void direct_link_curve(FileData *fd, Curve *cu)
 
        cu->bev.first=cu->bev.last= NULL;
        cu->disp.first=cu->disp.last= NULL;
-       cu->editlist.first=cu->editlist.last= NULL;
+       cu->editnurb= NULL;
        cu->path= NULL;
-
+       cu->editstr= NULL;
+       
        nu= cu->nurb.first;
        while(nu) {
                nu->bezt= newdataadr(fd, nu->bezt);
@@ -2925,6 +2927,8 @@ static void direct_link_latt(FileData *fd, Lattice *lt)
        
        lt->dvert= newdataadr(fd, lt->dvert);
        direct_link_dverts(fd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert);
+       
+       lt->editlatt= NULL;
 }
 
 
index b084e377d19b1feba309ee02e8c6b06c48038f01..f0e00b75b67c4b0578d45436c932024b567e4e09 100644 (file)
@@ -44,7 +44,7 @@ typedef struct FileData {
        int eof;
        int buffersize;
        int seek;
-       int (*read)(struct FileData *filedata, void *buffer, int size);
+       int (*read)(struct FileData *filedata, void *buffer, unsigned int size);
 
        // variables needed for reading from memory / stream
        char *buffer;
index 80e5d0f910a2304cb2dcd6a06ef8b6ebaca12d72..ab9627df28d51694b1124d61c4d62c109f4f23a0 100644 (file)
@@ -389,8 +389,7 @@ EditFace *addfacelist(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, Ed
                CustomData_em_copy_data(&em->fdata, &em->fdata, example->data, &efa->data);
        }
        else {
-               if (G.obedit && G.obedit->actcol)
-                       efa->mat_nr= G.obedit->actcol-1;
+               efa->mat_nr= em->mat_nr;
 
                CustomData_em_set_default(&em->fdata, &efa->data);
        }
@@ -1431,7 +1430,7 @@ void remake_editMesh(Scene *scene, Object *ob)
 
 
 
-void separate_mesh(Scene *scene, Object *ob)
+void separate_mesh(Scene *scene, Object *obedit)
 {
        EditMesh *em, emcopy;
        EditVert *eve, *v1;
@@ -1442,12 +1441,12 @@ void separate_mesh(Scene *scene, Object *ob)
        Base *base, *oldbase;
        ListBase edve, eded, edvl;
        
-       TEST_EDITMESH
+       if(obedit==NULL) return;
        if(multires_test()) return;
 
        waitcursor(1);
        
-       me= G.obedit->data;
+       me= obedit->data;
        em= me->edit_mesh;
        if(me->key) {
                error("Can't separate with vertex keys");
@@ -1470,7 +1469,7 @@ void separate_mesh(Scene *scene, Object *ob)
        base= FIRSTBASE;
        while(base) {
 //     XXX     if(base->lay & G.vd->lay) {
-                       if(base->object==G.obedit) base->flag |= SELECT;
+                       if(base->object==obedit) base->flag |= SELECT;
                        else base->flag &= ~SELECT;
 //             }
                base= base->next;
@@ -1521,19 +1520,19 @@ void separate_mesh(Scene *scene, Object *ob)
                efa= vl1;
        }
        
-       oldob= G.obedit;
+       oldob= obedit;
        oldbase= BASACT;
        
        adduplicate(1, 0); /* notrans and a linked duplicate */
        
-       G.obedit= BASACT->object;       /* basact was set in adduplicate()  */
+       obedit= BASACT->object; /* basact was set in adduplicate()  */
        
        men= copy_mesh(me);
-       set_mesh(G.obedit, men);
+       set_mesh(obedit, men);
        /* because new mesh is a copy: reduce user count */
        men->id.us--;
        
-       load_editMesh(scene, G.obedit);
+       load_editMesh(scene, obedit);
        
        BASACT->flag &= ~SELECT;
        
@@ -1554,19 +1553,19 @@ void separate_mesh(Scene *scene, Object *ob)
        /* hashedges are freed now, make new! */
        editMesh_set_hash(em);
 
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
-       G.obedit= oldob;
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
+       obedit= oldob;
        BASACT= oldbase;
        BASACT->flag |= SELECT;
        
        waitcursor(0);
 
 //     allqueue(REDRAWVIEW3D, 0);
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
 
 }
 
-void separate_material(Scene *scene, Object *ob)
+void separate_material(Scene *scene, Object *obedit)
 {
        Mesh *me;
        EditMesh *em;
@@ -1574,33 +1573,33 @@ void separate_material(Scene *scene, Object *ob)
        
        if(multires_test()) return;
        
-       me= G.obedit->data;
+       me= obedit->data;
        em= me->edit_mesh;
        if(me->key) {
                error("Can't separate with vertex keys");
                return;
        }
        
-       if(G.obedit && em) {
-               if(G.obedit->type == OB_MESH) {
-                       for (curr_mat = 1; curr_mat < G.obedit->totcol; ++curr_mat) {
+       if(obedit && em) {
+               if(obedit->type == OB_MESH) {
+                       for (curr_mat = 1; curr_mat < obedit->totcol; ++curr_mat) {
                                /* clear selection, we're going to use that to select material group */
                                EM_clear_flag_all(em, SELECT);
                                /* select the material */
                                editmesh_select_by_material(em, curr_mat);
                                /* and now separate */
-                               separate_mesh(scene, ob);
+                               separate_mesh(scene, obedit);
                        }
                }
        }
        
        //      allqueue(REDRAWVIEW3D, 0);
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        
 }
 
 
-void separate_mesh_loose(Scene *scene, Object *ob)
+void separate_mesh_loose(Scene *scene, Object *obedit)
 {
        EditMesh *em, emcopy;
        EditVert *eve, *v1;
@@ -1613,14 +1612,13 @@ void separate_mesh_loose(Scene *scene, Object *ob)
        int vertsep=0;  
        short done=0, check=1;
                        
-       me= G.obedit->data;
+       me= obedit->data;
        em= me->edit_mesh;
        if(me->key) {
                error("Can't separate a mesh with vertex keys");
                return;
        }
 
-       TEST_EDITMESH
        if(multires_test()) return;
        waitcursor(1);  
        
@@ -1639,7 +1637,7 @@ void separate_mesh_loose(Scene *scene, Object *ob)
                base= FIRSTBASE;
                while(base) {
 // XXX                 if(base->lay & G.vd->lay) {
-                               if(base->object==G.obedit) base->flag |= SELECT;
+                               if(base->object==obedit) base->flag |= SELECT;
                                else base->flag &= ~SELECT;
 //                     }
                        base= base->next;
@@ -1718,19 +1716,19 @@ void separate_mesh_loose(Scene *scene, Object *ob)
                                efa= vl1;
                        }
                        
-                       oldob= G.obedit;
+                       oldob= obedit;
                        oldbase= BASACT;
                        
                        adduplicate(1, 0); /* notrans and a linked duplicate*/
                        
-                       G.obedit= BASACT->object;       /* basact was set in adduplicate()  */
+                       obedit= BASACT->object; /* basact was set in adduplicate()  */
 
                        men= copy_mesh(me);
-                       set_mesh(G.obedit, men);
+                       set_mesh(obedit, men);
                        /* because new mesh is a copy: reduce user count */
                        men->id.us--;
                        
-                       load_editMesh(scene, G.obedit);
+                       load_editMesh(scene, obedit);
                        
                        BASACT->flag &= ~SELECT;
                        
@@ -1751,7 +1749,7 @@ void separate_mesh_loose(Scene *scene, Object *ob)
                        /* hashedges are freed now, make new! */
                        editMesh_set_hash(em);
                        
-                       G.obedit= oldob;
+                       obedit= oldob;
                        BASACT= oldbase;
                        BASACT->flag |= SELECT; 
                                        
@@ -1763,12 +1761,12 @@ void separate_mesh_loose(Scene *scene, Object *ob)
                
        waitcursor(0);
 //     allqueue(REDRAWVIEW3D, 0);
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
 }
 
-void separatemenu(Scene *scene, Object *ob)
+void separatemenu(Scene *scene, Object *obedit)
 {
-       Mesh *me= ob->data;
+       Mesh *me= obedit->data;
        short event;
        
        if(me->edit_mesh->verts.first==NULL) return;
@@ -1780,13 +1778,13 @@ void separatemenu(Scene *scene, Object *ob)
        
        switch (event) {
                case 1: 
-                       separate_mesh(scene, ob);
+                       separate_mesh(scene, obedit);
                        break;
                case 2:                     
-                       separate_mesh_loose(scene, ob);
+                       separate_mesh_loose(scene, obedit);
                        break;
                case 3:
-                       separate_material(scene, ob);
+                       separate_material(scene, obedit);
                        break;
        }
        waitcursor(0);
@@ -1975,8 +1973,9 @@ static void *editMesh_to_undoMesh(void *emv)
 //     um->retopo_mode= scene->toolsettings->retopo_mode;
        
        {
-               Multires *mr= get_mesh(G.obedit)->mr;
-               UndoMesh *prev= undo_editmode_get_prev(G.obedit);
+               Mesh *me= NULL; // XXX
+               Multires *mr= me->mr;
+               UndoMesh *prev= NULL; // XXX undo_editmode_get_prev(obedit);
                
                um->mru= NULL;
                
@@ -2103,7 +2102,7 @@ static void undoMesh_to_editMesh(void *umv, void *emv)
 //     }
        
        {
-               Mesh *me= get_mesh(G.obedit);
+               Mesh *me= NULL; // XXX;
                multires_free(me->mr);
                me->mr= NULL;
                if(um->mru && um->mru->mr) me->mr= multires_copy(um->mru->mr);
@@ -2192,9 +2191,7 @@ EditFace *EM_get_face_for_index(int index)
 int EM_texFaceCheck(EditMesh *em)
 {
        /* some of these checks could be a touch overkill */
-       if (    (G.obedit) &&
-                       (G.obedit->type == OB_MESH) &&
-                       (em) &&
+       if (    (em) &&
                        (em->faces.first) &&
                        (CustomData_has_layer(&em->fdata, CD_MTFACE)))
                return 1;
@@ -2205,9 +2202,7 @@ int EM_texFaceCheck(EditMesh *em)
 int EM_vertColorCheck(EditMesh *em)
 {
        /* some of these checks could be a touch overkill */
-       if (    (G.obedit) &&
-                       (G.obedit->type == OB_MESH) &&
-                       (em) &&
+       if (    (em) &&
                        (em->faces.first) &&
                        (CustomData_has_layer(&em->fdata, CD_MCOL)))
                return 1;
index 60d821b98018e97610292aeea3aa99c093e2d158..1833682b19e022af3d02326a1371e700ee77438d 100644 (file)
@@ -131,14 +131,13 @@ static void get_view_aligned_coordinate(float *fp, short mval[2])
 //     }
 }
 
-void add_click_mesh(Scene *scene, EditMesh *em)
+void add_click_mesh(Scene *scene, Object *obedit, EditMesh *em)
 {
        View3D *v3d= NULL; // XXX
        EditVert *eve, *v1;
        float min[3], max[3];
        int done= 0;
        
-       TEST_EDITMESH
        if(multires_test()) return;
        
        INIT_MINMAX(min, max);
@@ -174,10 +173,10 @@ void add_click_mesh(Scene *scene, EditMesh *em)
                VecMulf(cent, 0.5f);
                VECCOPY(min, cent);
                
-               Mat4MulVecfl(G.obedit->obmat, min);     // view space
+               Mat4MulVecfl(obedit->obmat, min);       // view space
                get_view_aligned_coordinate(min, mval);
-               Mat4Invert(G.obedit->imat, G.obedit->obmat); 
-               Mat4MulVecfl(G.obedit->imat, min); // back in object space
+               Mat4Invert(obedit->imat, obedit->obmat); 
+               Mat4MulVecfl(obedit->imat, min); // back in object space
                
                VecSubf(min, min, cent);
                
@@ -206,7 +205,7 @@ void add_click_mesh(Scene *scene, EditMesh *em)
                        }
                }
                
-               extrudeflag(em, SELECT, nor);
+               extrudeflag(obedit, em, SELECT, nor);
                rotateflag(em, SELECT, cent, mat);
                translateflag(em, SELECT, min);
                
@@ -218,11 +217,11 @@ void add_click_mesh(Scene *scene, EditMesh *em)
                
                eve= addvertlist(em, 0, NULL);
 
-               Mat3CpyMat4(mat, G.obedit->obmat);
+               Mat3CpyMat4(mat, obedit->obmat);
                Mat3Inv(imat, mat);
                
                VECCOPY(eve->co, curs);
-               VecSubf(eve->co, eve->co, G.obedit->obmat[3]);
+               VecSubf(eve->co, eve->co, obedit->obmat[3]);
 
                Mat3MulVecfl(imat, eve->co);
                
@@ -232,7 +231,7 @@ void add_click_mesh(Scene *scene, EditMesh *em)
        retopo_do_all();
        
        BIF_undo_push("Add vertex/edge/face");
-// XXX DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
+// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
        
        while(0); // XXX get_mbut()&R_MOUSE);
 
@@ -258,7 +257,7 @@ static void make_fgon(EditMesh *em, int make)
                        }
                }
                EM_fgon_flags(em);      // redo flags and indices for fgons
-// XXX         DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);       
+// XXX         DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); 
                BIF_undo_push("Clear FGon");
                return;
        }
@@ -335,7 +334,7 @@ static void make_fgon(EditMesh *em, int make)
        else {
                EM_fgon_flags(em);      // redo flags and indices for fgons
 
-// XXX         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
+// XXX         DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
                BIF_undo_push("Make FGon");
        }
 }
@@ -601,7 +600,7 @@ void addfaces_from_edgenet(EditMesh *em)
        EM_select_flush(em);
        
        BIF_undo_push("Add faces");
-// XXX DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+// XXX DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 }
 
 void addedgeface_mesh(EditMesh *em)
@@ -633,7 +632,7 @@ void addedgeface_mesh(EditMesh *em)
                EM_select_edge(eed, 1);
                BIF_undo_push("Add edge");
 
-               // XXX          DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
+               // XXX          DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
                return;
        }
        else if(amount > 4) {
@@ -735,14 +734,13 @@ void addedgeface_mesh(EditMesh *em)
                BIF_undo_push("Add face");
        }
        
-// XXX DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
+// XXX DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
 }
 
 
-void adduplicate_mesh(EditMesh *em)
+void adduplicate_mesh(Object *obedit, EditMesh *em)
 {
 
-       TEST_EDITMESH
        if(multires_test()) return;
 
        waitcursor(1);
@@ -757,8 +755,8 @@ void adduplicate_mesh(EditMesh *em)
                * This shouldn't be necessary, derived queries should be
                * automatically building this data if invalid. Or something.
                */
-// XXX DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
-       object_handle_update(G.obedit);
+// XXX DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
+       object_handle_update(obedit);
 
 // XXX BIF_TransformSetUndo("Add Duplicate");
 //     initTransform(TFM_TRANSLATION, CTX_NO_PET);
@@ -767,32 +765,32 @@ 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(Scene *scene, Mesh **me, float mat[][3] )
+static int confirm_objectExists(Scene *scene, Object *obedit, Mesh **me, float mat[][3] )
 {
        int newob = 0;
        
        /* if no obedit: new object and enter editmode */
-       if(G.obedit==NULL) {
+       if(obedit==NULL) {
                /* add_object actually returns an object ! :-)
                But it also stores the added object struct in
                G.scene->basact->object (BASACT->object) */
 
 // XXX         add_object_draw(OB_MESH);
 
-               G.obedit= BASACT->object;
+               obedit= BASACT->object;
                
-               where_is_object(G.obedit);
+               where_is_object(obedit);
                
-               make_editMesh(scene, G.obedit); 
+               make_editMesh(scene, obedit); 
                newob= 1;
        }
-       *me = G.obedit->data;
+       *me = obedit->data;
        
        /* deselectall */
        EM_clear_flag_all((*me)->edit_mesh, SELECT);
        
        /* imat and center and size */
-       Mat3CpyMat4(mat, G.obedit->obmat);
+       Mat3CpyMat4(mat, obedit->obmat);
        
        return newob;
 }
@@ -943,7 +941,7 @@ signed char monkeyf[250][4]= {
        // ------------------------------- end copied code
 
 
-void make_prim(EditMesh *em, int type, float imat[3][3], int tot, int seg,
+void make_prim(Object *obedit, EditMesh *em, int type, float imat[3][3], int tot, int seg,
                int subdiv, float dia, float d, int ext, int fill,
         float cent[3])
 {
@@ -992,7 +990,7 @@ void make_prim(EditMesh *em, int type, float imat[3][3], int tot, int seg,
                vec[1]= dia*phid;
                Mat3MulVecfl(imat, vec);
                for(a=0;a<seg-1;a++) {
-                       extrudeflag_vert(em, 2, nor);   // nor unused
+                       extrudeflag_vert(obedit, em, 2, nor);   // nor unused
                        translateflag(em, 2, vec);
                }
                break;
@@ -1027,7 +1025,7 @@ void make_prim(EditMesh *em, int type, float imat[3][3], int tot, int seg,
                QuatToMat3(q, cmat);
                
                for(a=0; a<seg; a++) {
-                       extrudeflag_vert(em, 2, nor); // nor unused
+                       extrudeflag_vert(obedit, em, 2, nor); // nor unused
                        rotateflag(em, 2, v1->co, cmat);
                }
 
@@ -1074,7 +1072,7 @@ void make_prim(EditMesh *em, int type, float imat[3][3], int tot, int seg,
                        }
 
                        dia*=200;
-                       for(a=1; a<subdiv; a++) esubdivideflag(em, 2, dia, 0,1,0);
+                       for(a=1; a<subdiv; a++) esubdivideflag(obedit, em, 2, dia, 0,1,0);
                        /* and now do imat */
                        eve= em->verts.first;
                        while(eve) {
@@ -1234,7 +1232,7 @@ void make_prim(EditMesh *em, int type, float imat[3][3], int tot, int seg,
                righthandfaces(em, 1);  /* otherwise monkey has eyes in wrong direction */
 }
 
-void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
+void add_primitiveMesh(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em, int type)
 {
        Mesh *me;
        float *curs, d, dia, phi, phid, cent[3], imat[3][3], mat[3][3];
@@ -1252,7 +1250,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
        /* this function also comes from an info window */
 // XXX if ELEM(curarea->spacetype, SPACE_VIEW3D, SPACE_INFO); else return;
 
-       if (G.obedit && G.obedit->type==OB_MESH && multires_test()) return;
+       if (obedit && obedit->type==OB_MESH && multires_test()) return;
        
        /* if editmode exists for other type, it exits */
        check_editmode(OB_MESH);
@@ -1272,7 +1270,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                tot= 4;
                ext= 0;
                fill= 1;
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Plane";
                undostr="Add Plane";
                break;
@@ -1280,7 +1278,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                tot= 4;
                ext= 1;
                fill= 1;
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Cube";
                undostr="Add Cube";
                break;
@@ -1291,7 +1289,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(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Circle";
                undostr="Add Circle";
                break;
@@ -1305,7 +1303,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                ext= 1;
                fill = fill_cylinder;
                d/=2;
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) {
                        if (fill)       name = "Cylinder";
                        else            name = "Tube";
@@ -1322,7 +1320,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
                d/=2;
                ext= 0;
                fill = fill_cone;
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Cone";
                undostr="Add Cone";
                break;
@@ -1330,7 +1328,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(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Grid";
                undostr="Add Grid";
                break;
@@ -1341,7 +1339,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(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Sphere";
                undostr="Add UV Sphere";
                break;
@@ -1350,31 +1348,31 @@ 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(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Sphere";
                undostr="Add Ico Sphere";
                break;
        case 13:        /* Monkey */
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                if(newob) name = "Suzanne";
                undostr="Add Monkey";
                break;
        default:
-               newob = confirm_objectExists(scene, &me, mat );
+               newob = confirm_objectExists(scene, obedit, &me, mat );
                break;
        }
 
        if( name!=NULL ) {
-               rename_id((ID *)G.obedit, name );
+               rename_id((ID *)obedit, name );
                rename_id((ID *)me, name );
        }
        
        d = -d;
        curs= give_cursor(scene, v3d);
        VECCOPY(cent, curs);
-       cent[0]-= G.obedit->obmat[3][0];
-       cent[1]-= G.obedit->obmat[3][1];
-       cent[2]-= G.obedit->obmat[3][2];
+       cent[0]-= obedit->obmat[3][0];
+       cent[1]-= obedit->obmat[3][1];
+       cent[2]-= obedit->obmat[3][2];
 
        if ( !(newob) || U.flag & USER_ADD_VIEWALIGNED) Mat3CpyMat4(imat, v3d->viewmat);
        else Mat3One(imat);
@@ -1389,7 +1387,7 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
        phid= 2*M_PI/tot;
        phi= .25*M_PI;
 
-       make_prim(em, type, imat, tot, seg, subdiv, dia, d, ext, fill, cent);
+       make_prim(obedit, em, type, imat, tot, seg, subdiv, dia, d, ext, fill, cent);
 
        if(type<2) tot = totoud;
 
@@ -1398,11 +1396,11 @@ void add_primitiveMesh(Scene *scene, View3D *v3d, EditMesh *em, int type)
        
        if(type!=0 && type!=13) righthandfaces(em, 1);  /* otherwise monkey has eyes in wrong direction... */
 
-// XXX DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+// XXX DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        
        /* 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, G.obedit);
+               if(newob) load_editMesh(scene, obedit);
        } else {
                exit_editmode(2);
        }
index 115207736c942e5fce9ecd28d02f796c75627461..974528626d064fbb0367b13f7f2b5d2eeb578d5b 100644 (file)
@@ -917,7 +917,7 @@ short extrudeflag_face_indiv(EditMesh *em, short flag, float *nor)
        EditEdge *eed;
        EditFace *efa, *nextfa;
        
-       if(G.obedit==0 || get_mesh(G.obedit)==0) return 0;
+       if(em==NULL) return 0;
        
        /* selected edges with 1 or more selected face become faces */
        /* selected faces each makes new faces */
@@ -1091,7 +1091,7 @@ short extrudeflag_verts_indiv(EditMesh *em, short flag, float *nor)
 
 /* this is actually a recode of extrudeflag(), using proper edge/face select */
 /* hurms, doesnt use 'flag' yet, but its not called by primitive making stuff anyway */
-static short extrudeflag_edge(EditMesh *em, short flag, float *nor)
+static short extrudeflag_edge(Object *obedit, EditMesh *em, short flag, float *nor)
 {
        /* all select edges/faces: extrude */
        /* old select is cleared, in new ones it is set */
@@ -1101,9 +1101,9 @@ static short extrudeflag_edge(EditMesh *em, short flag, float *nor)
        short del_old= 0;
        ModifierData *md;
        
-       if(G.obedit==0 || get_mesh(G.obedit)==0) return 0;
+       if(em==NULL) return 0;
 
-       md = G.obedit->modifiers.first;
+       md = obedit->modifiers.first;
        
        /* selected edges with 0 or 1 selected face become faces */
        /* selected faces generate new faces */
@@ -1166,7 +1166,7 @@ static short extrudeflag_edge(EditMesh *em, short flag, float *nor)
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        Mat4Invert(imtx, mmd->mirror_ob->obmat);
-                                       Mat4MulMat4(mtx, G.obedit->obmat, imtx);
+                                       Mat4MulMat4(mtx, obedit->obmat, imtx);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
@@ -1346,7 +1346,7 @@ static short extrudeflag_edge(EditMesh *em, short flag, float *nor)
        return 'n'; // normal constraint 
 }
 
-short extrudeflag_vert(EditMesh *em, short flag, float *nor)
+short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor)
 {
        /* all verts/edges/faces with (f & 'flag'): extrude */
        /* from old verts, 'flag' is cleared, in new ones it is set */
@@ -1356,9 +1356,9 @@ short extrudeflag_vert(EditMesh *em, short flag, float *nor)
        short sel=0, del_old= 0, is_face_sel=0;
        ModifierData *md;
 
-       if(G.obedit==0 || get_mesh(G.obedit)==0) return 0;
+       if(em) return 0;
 
-       md = G.obedit->modifiers.first;
+       md = obedit->modifiers.first;
 
        /* clear vert flag f1, we use this to detect a loose selected vertice */
        eve= em->verts.first;
@@ -1453,7 +1453,7 @@ short extrudeflag_vert(EditMesh *em, short flag, float *nor)
                                if (mmd->mirror_ob) {
                                        float imtx[4][4];
                                        Mat4Invert(imtx, mmd->mirror_ob->obmat);
-                                       Mat4MulMat4(mtx, G.obedit->obmat, imtx);
+                                       Mat4MulMat4(mtx, obedit->obmat, imtx);
                                }
 
                                for (eed= em->edges.first; eed; eed= eed->next) {
@@ -1633,12 +1633,12 @@ short extrudeflag_vert(EditMesh *em, short flag, float *nor)
 }
 
 /* generic extrude */
-short extrudeflag(EditMesh *em, short flag, float *nor)
+short extrudeflag(Object *obedit, EditMesh *em, short flag, float *nor)
 {
        if(em->selectmode & SCE_SELECT_VERTEX)
-               return extrudeflag_vert(em, flag, nor);
+               return extrudeflag_vert(obedit, em, flag, nor);
        else 
-               return extrudeflag_edge(em, flag, nor);
+               return extrudeflag_edge(obedit, em, flag, nor);
                
 }
 
index d12c2845718a821061766838ac32907c097fe905..13cc90f3e2d45e807f9f8baf5a3acfbb8b2df930 100644 (file)
@@ -146,7 +146,7 @@ static void edgering_sel(EditMesh *em, EditEdge *startedge, int select, int prev
        if(previewlines > 0 && select == 0){
 // XXX                 persp(PERSP_VIEW);
 // XXX                 glPushMatrix();
-// XXX                 mymultmatrix(G.obedit->obmat);
+// XXX                 mymultmatrix(obedit->obmat);
 
                        for(efa= em->faces.first; efa; efa= efa->next) {
                                if(efa->v4 == NULL) {  continue; }
@@ -193,7 +193,7 @@ static void edgering_sel(EditMesh *em, EditEdge *startedge, int select, int prev
                }
        }
 }
-void CutEdgeloop(EditMesh *em, int numcuts)
+void CutEdgeloop(Object *obedit, EditMesh *em, int numcuts)
 {
        ViewContext vc; // XXX
        EditEdge *nearest=NULL, *eed;
@@ -363,9 +363,9 @@ void CutEdgeloop(EditMesh *em, int numcuts)
                fac= 1.0f;
 // XXX         if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return;
                fac= 0.292f*fac;                        
-               esubdivideflag(em, SELECT,fac,B_SMOOTH,numcuts,SUBDIV_SELECT_LOOPCUT);
+               esubdivideflag(obedit, em, SELECT,fac,B_SMOOTH,numcuts,SUBDIV_SELECT_LOOPCUT);
        } else {
-               esubdivideflag(em, SELECT,0,0,numcuts,SUBDIV_SELECT_LOOPCUT);
+               esubdivideflag(obedit, em, SELECT,0,0,numcuts,SUBDIV_SELECT_LOOPCUT);
        }
        /* if this was a single cut, enter edgeslide mode */
        if(numcuts == 1 && hasHidden == 0){
@@ -383,7 +383,7 @@ void CutEdgeloop(EditMesh *em, int numcuts)
                EM_selectmode_set(em);
        }       
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        return;
 }
 
@@ -449,7 +449,7 @@ static CutCurve *get_mouse_trail(int *len, char mode, char cutmode, struct GHash
 /* prototype */
 static float seg_intersect(struct EditEdge * e, CutCurve *c, int len, char mode, struct GHash *gh);
 
-void KnifeSubdivide(EditMesh *em, char mode)
+void KnifeSubdivide(Object *obedit, EditMesh *em, char mode)
 {
        EditEdge *eed;
        EditVert *eve;
@@ -461,7 +461,7 @@ void KnifeSubdivide(EditMesh *em, char mode)
        short numcuts=1;
        float  *scr, co[4];
        
-       if (G.obedit==0) return;
+       if (em==NULL) return;
 
        if (EM_nvertices_selected(em) < 2) {
                error("No edges are selected to operate on");
@@ -488,7 +488,7 @@ void KnifeSubdivide(EditMesh *em, char mode)
                scr = MEM_mallocN(sizeof(float)*2, "Vertex Screen Coordinates");
                VECCOPY(co, eve->co);
                co[3]= 1.0;
-               Mat4MulVec4fl(G.obedit->obmat, co);
+//             Mat4MulVec4fl(obedit->obmat, co);
 // XXX         project_float(co,scr);
                BLI_ghash_insert(gh, eve, scr);
                eve->f1 = 0; /*store vertex intersection flag here*/
@@ -514,9 +514,9 @@ void KnifeSubdivide(EditMesh *em, char mode)
                        eed= eed->next;
                }
                
-               if(mode==KNIFE_EXACT) esubdivideflag(em, SELECT, 0, B_KNIFE|B_PERCENTSUBD,1,SUBDIV_SELECT_ORIG);
-               else if (mode==KNIFE_MIDPOINT) esubdivideflag(em, SELECT, 0, B_KNIFE,1,SUBDIV_SELECT_ORIG);
-               else if (mode==KNIFE_MULTICUT) esubdivideflag(em, SELECT, 0, B_KNIFE,numcuts,SUBDIV_SELECT_ORIG);
+               if(mode==KNIFE_EXACT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE|B_PERCENTSUBD,1,SUBDIV_SELECT_ORIG);
+               else if (mode==KNIFE_MIDPOINT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE,1,SUBDIV_SELECT_ORIG);
+               else if (mode==KNIFE_MULTICUT) esubdivideflag(obedit, em, SELECT, 0, B_KNIFE,numcuts,SUBDIV_SELECT_ORIG);
 
                eed=em->edges.first;
                while(eed){
@@ -687,7 +687,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
        return(perc);
 } 
 
-void LoopMenu(EditMesh *em) /* Called by KKey */
+void LoopMenu(Object *obedit, EditMesh *em) /* Called by KKey */
 {
        short ret;
        
@@ -696,16 +696,16 @@ void LoopMenu(EditMesh *em) /* Called by KKey */
                                
        switch (ret){
                case 2:
-                       CutEdgeloop(em, 1);
+                       CutEdgeloop(obedit, em, 1);
                        break;
                case 3: 
-                       KnifeSubdivide(em, KNIFE_EXACT);
+                       KnifeSubdivide(obedit, em, KNIFE_EXACT);
                        break;
                case 4:
-                       KnifeSubdivide(em, KNIFE_MIDPOINT);
+                       KnifeSubdivide(obedit, em, KNIFE_MIDPOINT);
                        break;
                case 5:
-                       KnifeSubdivide(em, KNIFE_MULTICUT);
+                       KnifeSubdivide(obedit, em, KNIFE_MULTICUT);
                        break;
        }
 
index fb7bb46982a8a39f73ae9cdbc8c62d1a17c134e8..018df499dcccc79927869a932277ffc4caebe8c8 100644 (file)
@@ -98,14 +98,14 @@ static int pupmenu() {return 0;}
 
 /* ****************************** MIRROR **************** */
 
-void EM_select_mirrored(EditMesh *em)
+void EM_select_mirrored(Object *obedit, EditMesh *em)
 {
        if(em->selectmode & SCE_SELECT_VERTEX) {
                EditVert *eve, *v1;
                
                for(eve= em->verts.first; eve; eve= eve->next) {
                        if(eve->f & SELECT) {
-                               v1= editmesh_get_x_mirror_vert(G.obedit, em, eve->co);
+                               v1= editmesh_get_x_mirror_vert(obedit, em, eve->co);
                                if(v1) {
                                        eve->f &= ~SELECT;
                                        v1->f |= SELECT;
@@ -120,14 +120,14 @@ void EM_automerge(int update)
 // XXX int len;
        
 //     if ((G.scene->automerge) &&
-//             (G.obedit && G.obedit->type==OB_MESH) &&
-//             (((Mesh*)G.obedit->data)->mr==NULL)
+//             (obedit && obedit->type==OB_MESH) &&
+//             (((Mesh*)obedit->data)->mr==NULL)
 //       ) {
 //             len = removedoublesflag(1, 1, G.scene->toolsettings->doublimit);
 //             if (len) {
 //                     G.totvert -= len; /* saves doing a countall */
 //                     if (update) {
-//                             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//                             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 //                     }
 //             }
 //     }
@@ -194,7 +194,7 @@ int EM_init_backbuf_border(ViewContext *vc, short xmin, short ymin, short xmax,
        unsigned int *dr;
        int a;
        
-       if(G.obedit==NULL || vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0;
+       if(vc->obedit==NULL || vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0;
        
        buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
        if(buf==NULL) return 0;
@@ -242,7 +242,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s
        int a;
        
        /* method in use for face selecting too */
-       if(G.obedit==NULL) {
+       if(vc->obedit==NULL) {
                if(FACESEL_PAINT_TEST);
                else return 0;
        }
@@ -304,7 +304,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads)
        int radsq;
        
        /* method in use for face selecting too */
-       if(G.obedit==NULL) {
+       if(vc->obedit==NULL) {
                if(FACESEL_PAINT_TEST);
                else return 0;
        }
@@ -475,7 +475,7 @@ static void findnearestedge__doClosest(void *userData, EditEdge *eed, int x0, in
                        vec[0]= eed->v1->co[0] + labda*(eed->v2->co[0] - eed->v1->co[0]);
                        vec[1]= eed->v1->co[1] + labda*(eed->v2->co[1] - eed->v1->co[1]);
                        vec[2]= eed->v1->co[2] + labda*(eed->v2->co[2] - eed->v1->co[2]);
-                       Mat4MulVecfl(G.obedit->obmat, vec);
+                       Mat4MulVecfl(data->vc.obedit->obmat, vec);
 
                        if(view3d_test_clipping(data->vc.v3d, vec)==0) {
                                data->dist = distance;
@@ -610,147 +610,6 @@ static EditFace *findnearestface(ViewContext *vc, int *dist)
        }
 }
 
-#if 0
-/* for interactivity, frontbuffer draw in current window */
-static void draw_dm_mapped_vert__mapFunc(void *theVert, int index, float *co, float *no_f, short *no_s)
-{
-       if (EM_get_vert_for_index(index)==theVert) {
-               bglVertex3fv(co);
-       }
-}
-static void draw_dm_mapped_vert(EditMesh *em, DerivedMesh *dm, EditVert *eve)
-{
-       EM_init_index_arrays(em, 1, 0, 0);
-       bglBegin(GL_POINTS);
-       dm->foreachMappedVert(dm, draw_dm_mapped_vert__mapFunc, eve);
-       bglEnd();
-       EM_free_index_arrays();
-}
-
-static int draw_dm_mapped_edge__setDrawOptions(void *theEdge, int index)
-{
-       return EM_get_edge_for_index(index)==theEdge;
-}
-static void draw_dm_mapped_edge(EditMesh *em, DerivedMesh *dm, EditEdge *eed)
-{
-       EM_init_index_arrays(em, 0, 1, 0);
-       dm->drawMappedEdges(dm, draw_dm_mapped_edge__setDrawOptions, eed);
-       EM_free_index_arrays();
-}
-
-static void draw_dm_mapped_face_center__mapFunc(void *theFace, int index, float *cent, float *no)
-{
-       if (EM_get_face_for_index(index)==theFace) {
-               bglVertex3fv(cent);
-       }
-}
-static void draw_dm_mapped_face_center(EditMesh *em, DerivedMesh *dm, EditFace *efa)
-{
-       EM_init_index_arrays(em, 0, 0, 1);
-       bglBegin(GL_POINTS);
-       dm->foreachMappedFaceCenter(dm, draw_dm_mapped_face_center__mapFunc, efa);
-       bglEnd();
-       EM_free_index_arrays();
-}
-
-#endif
-
-static void unified_select_draw(EditMesh *em, EditVert *eve, EditEdge *eed, EditFace *efa)
-{
-#if 0
-       /* XXX depricated, no frontbuffer, later we can partial copy? */
-       
-       DerivedMesh *dm = editmesh_get_derived_cage(CD_MASK_BAREMESH);
-
-       glDrawBuffer(GL_FRONT);
-
-// XXX persp(PERSP_VIEW);
-       
-       if(v3d->flag & V3D_CLIPPING)
-               view3d_set_clipping(v3d);
-       
-       glPushMatrix();
-       mymultmatrix(G.obedit->obmat);
-       
-       /* face selected */
-       if(efa) {
-               if(em->selectmode & SCE_SELECT_VERTEX) {
-                       glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-                       
-                       if(efa->f & SELECT) BIF_ThemeColor(TH_VERTEX_SELECT);
-                       else BIF_ThemeColor(TH_VERTEX);
-                       
-                       bglBegin(GL_POINTS);
-                       bglVertex3fv(efa->v1->co);
-                       bglVertex3fv(efa->v2->co);
-                       bglVertex3fv(efa->v3->co);
-                       if(efa->v4) bglVertex3fv(efa->v4->co);
-                       bglEnd();
-               }
-
-               if(em->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE)) {
-                       if(efa->fgonf==0) {
-                               BIF_ThemeColor((efa->f & SELECT)?TH_EDGE_SELECT:TH_WIRE);
-       
-                               draw_dm_mapped_edge(em, dm, efa->e1);
-                               draw_dm_mapped_edge(em, dm, efa->e2);
-                               draw_dm_mapped_edge(em, dm, efa->e3);
-                               if (efa->e4) {
-                                       draw_dm_mapped_edge(em, dm, efa->e4);
-                               }
-                       }
-               }
-               
-               if( CHECK_OB_DRAWFACEDOT(G.scene, v3d, G.obedit->dt) ) {
-                       if(efa->fgonf==0) {
-                               glPointSize(BIF_GetThemeValuef(TH_FACEDOT_SIZE));
-                               BIF_ThemeColor((efa->f & SELECT)?TH_FACE_DOT:TH_WIRE);
-
-                               draw_dm_mapped_face_center(em, dm, efa);
-                       }
-               }
-       }
-       /* edge selected */
-       if(eed) {
-               if(em->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE)) {
-                       BIF_ThemeColor((eed->f & SELECT)?TH_EDGE_SELECT:TH_WIRE);
-
-                       draw_dm_mapped_edge(em, dm, eed);
-               }
-               if(em->selectmode & SCE_SELECT_VERTEX) {
-                       glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-                       
-                       BIF_ThemeColor((eed->f & SELECT)?TH_VERTEX_SELECT:TH_VERTEX);
-                       
-                       draw_dm_mapped_vert(em, dm, eed->v1);
-                       draw_dm_mapped_vert(em, dm, eed->v2);
-               }
-       }
-       if(eve) {
-               if(em->selectmode & SCE_SELECT_VERTEX) {
-                       glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-                       
-                       BIF_ThemeColor((eve->f & SELECT)?TH_VERTEX_SELECT:TH_VERTEX);
-                       
-                       draw_dm_mapped_vert(em, dm, eve);
-               }
-       }
-
-       glPointSize(1.0);
-       glPopMatrix();
-
-       bglFlush();
-       glDrawBuffer(GL_BACK);
-
-       if(v3d->flag & V3D_CLIPPING)
-               view3d_clr_clipping();
-       
-
-       dm->release(dm);
-#endif
-}
-
-
 /* best distance based on screen coords. 
    use em->selectmode to define how to use 
    selected vertices and edges get disadvantage
@@ -1484,7 +1343,7 @@ void EM_mesh_copy_edge(EditMesh *em, short type)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                
                BIF_undo_push("Copy Edge Attribute");
        }
@@ -1613,7 +1472,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                if (type==3) {
 // XXX                 allqueue(REDRAWIMAGE, 0);                       
                }
@@ -1747,7 +1606,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, short type)
        }
 
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                
                BIF_undo_push("Copy Face Layer");
        }
@@ -2102,9 +1961,6 @@ static void mouse_mesh_loop(ViewContext *vc)
                                        edgeloop_select(em, eed, select);
                        }
 
-                       /* frontbuffer draw of last selected only */
-                       unified_select_draw(em, NULL, eed, NULL);
-               
                        EM_selectmode_flush(em);
 //                     if (EM_texFaceCheck())
                        
@@ -2165,9 +2021,7 @@ static void mouse_mesh_loop(ViewContext *vc)
                                break;
                        }
                        
-                       unified_select_draw(em, NULL, eed, NULL);
-                       
-//                     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//                     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                }
                                
        }
@@ -2228,20 +2082,18 @@ void mouse_mesh(bContext *C, short mval[2], short extend)
                        }
                }
                
-               /* frontbuffer draw of last selected only */
-               unified_select_draw(vc.em, eve, eed, efa);
-       
                EM_selectmode_flush(vc.em);
                  
 //             if (EM_texFaceCheck()) {
 
-               if (efa && efa->mat_nr != G.obedit->actcol-1) {
-                       G.obedit->actcol= efa->mat_nr+1;
+               if (efa && efa->mat_nr != vc.obedit->actcol-1) {
+                       vc.obedit->actcol= efa->mat_nr+1;
+                       vc.em->mat_nr= efa->mat_nr;
 //                     BIF_preview_changed(ID_MA);
                }
        }
 
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
        
 //     rightmouse_transform();
 }
@@ -2481,7 +2333,7 @@ void hide_mesh(EditMesh *em, int swap)
        EditFace *efa;
        int a;
        
-       if(G.obedit==0) return;
+       if(em==NULL) return;
 
        /* hide happens on least dominant select mode, and flushes up, not down! (helps preventing errors in subsurf) */
        /*  - vertex hidden, always means edge is hidden too
@@ -2573,7 +2425,7 @@ void hide_mesh(EditMesh *em, int swap)
        G.totedgesel= G.totfacesel= G.totvertsel= 0;
 //     if(EM_texFaceCheck())
 
-       //      DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
+       //      DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
        BIF_undo_push("Hide");
 }
 
@@ -2584,7 +2436,7 @@ void reveal_mesh(EditMesh *em)
        EditEdge *eed;
        EditFace *efa;
        
-       if(G.obedit==0) return;
+       if(em==NULL) return;
 
        for(eve= em->verts.first; eve; eve= eve->next) {
                if(eve->h) {
@@ -2611,7 +2463,7 @@ void reveal_mesh(EditMesh *em)
        EM_selectmode_flush(em);
 
 //     if (EM_texFaceCheck())
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
        BIF_undo_push("Reveal");
 }
 
@@ -3245,7 +3097,7 @@ static int toggle_select_all_exec(bContext *C, wmOperator *op)
                
 //             if (EM_texFaceCheck())
        
-       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        return OPERATOR_FINISHED;
 }
 
@@ -3600,7 +3452,7 @@ void Vertex_Menu(EditMesh *em)
                        break;
        }
        /* some items crashed because this is in the original W menu but not here. should really manage this better */
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 }
 
 
@@ -3647,16 +3499,16 @@ void Edge_Menu(EditMesh *em)
        case 11:
 //             editmesh_mark_sharp(em, 1);
                BIF_undo_push("Mark Sharp");
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                break;
        case 12: 
 //             editmesh_mark_sharp(em, 0);
                BIF_undo_push("Clear Sharp");
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                break;
        }
        /* some items crashed because this is in the original W menu but not here. should really manage this better */
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 }
 
 void Face_Menu(EditMesh *em) 
@@ -3673,7 +3525,7 @@ void Face_Menu(EditMesh *em)
        {
                case 1:
 //                     flip_editnormals(em);
-//                     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//                     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                        BIF_undo_push("Flip Normals");
                        break;
                case 2:
@@ -3688,7 +3540,7 @@ void Face_Menu(EditMesh *em)
                        
                case 5: /* Quads to Tris */
 //                     convert_to_triface(em, 0);
-//                     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//                     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                        break;
                case 6: /* Tris to Quads */
 //                     join_triangles(em);
@@ -3718,7 +3570,7 @@ void Face_Menu(EditMesh *em)
                        break;
        }
        /* some items crashed because this is in the original W menu but not here. should really manage this better */
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 }
 
 
@@ -3929,7 +3781,7 @@ void righthandfaces(EditMesh *em, int select)     /* makes faces righthand turning *
 
        recalc_editnormals(em);
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        waitcursor(0);
 }
@@ -4008,19 +3860,19 @@ void faceselect_align_view_to_selected(View3D *v3d, Mesh *me, int axis)
 }
 
 /* helper for below, to survive non-uniform scaled objects */
-static void face_getnormal_obspace(EditFace *efa, float *fno)
+static void face_getnormal_obspace(Object *obedit, EditFace *efa, float *fno)
 {
        float vec[4][3];
        
        VECCOPY(vec[0], efa->v1->co);
-       Mat4Mul3Vecfl(G.obedit->obmat, vec[0]);
+       Mat4Mul3Vecfl(obedit->obmat, vec[0]);
        VECCOPY(vec[1], efa->v2->co);
-       Mat4Mul3Vecfl(G.obedit->obmat, vec[1]);
+       Mat4Mul3Vecfl(obedit->obmat, vec[1]);
        VECCOPY(vec[2], efa->v3->co);
-       Mat4Mul3Vecfl(G.obedit->obmat, vec[2]);
+       Mat4Mul3Vecfl(obedit->obmat, vec[2]);
        if(efa->v4) {
                VECCOPY(vec[3], efa->v4->co);
-               Mat4Mul3Vecfl(G.obedit->obmat, vec[3]);
+               Mat4Mul3Vecfl(obedit->obmat, vec[3]);
                
                CalcNormFloat4(vec[0], vec[1], vec[2], vec[3], fno);
        }
@@ -4028,7 +3880,7 @@ static void face_getnormal_obspace(EditFace *efa, float *fno)
 }
 
 
-void editmesh_align_view_to_selected(EditMesh *em, View3D *v3d, int axis)
+void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d, int axis)
 {
        int nselverts= EM_nvertices_selected(em);
        float norm[3]={0.0, 0.0, 0.0}; /* used for storing the mesh normal */
@@ -4042,7 +3894,7 @@ void editmesh_align_view_to_selected(EditMesh *em, View3D *v3d, int axis)
                        if (faceselectedAND(efa, SELECT)) {
                                float fno[3];
                                
-                               face_getnormal_obspace(efa, fno);
+                               face_getnormal_obspace(obedit, efa, fno);
                                norm[0]+= fno[0];
                                norm[1]+= fno[1];
                                norm[2]+= fno[2];
@@ -4073,7 +3925,7 @@ void editmesh_align_view_to_selected(EditMesh *em, View3D *v3d, int axis)
                        }
                }
 
-               Mat4Mul3Vecfl(G.obedit->obmat, norm);
+               Mat4Mul3Vecfl(obedit->obmat, norm);
                view3d_align_axis_to_vector(v3d, axis, norm);
        } 
        else if (nselverts==2) { /* Align view to edge (or 2 verts) */ 
@@ -4090,7 +3942,7 @@ void editmesh_align_view_to_selected(EditMesh *em, View3D *v3d, int axis)
                                leve= eve;
                        }
                }
-               Mat4Mul3Vecfl(G.obedit->obmat, norm);
+               Mat4Mul3Vecfl(obedit->obmat, norm);
                view3d_align_axis_to_vector(v3d, axis, norm);
        } 
        else if (nselverts==1) { /* Align view to vert normal */ 
@@ -4104,23 +3956,23 @@ void editmesh_align_view_to_selected(EditMesh *em, View3D *v3d, int axis)
                                break; /* we know this is the only selected vert, so no need to keep looking */
                        }
                }
-               Mat4Mul3Vecfl(G.obedit->obmat, norm);
+               Mat4Mul3Vecfl(obedit->obmat, norm);
                view3d_align_axis_to_vector(v3d, axis, norm);
        }
 } 
 
 /* **************** VERTEX DEFORMS *************** */
 
-void vertexsmooth(EditMesh *em)
+void vertexsmooth(Object *obedit, EditMesh *em)
 {
        EditVert *eve, *eve_mir = NULL;
        EditEdge *eed;
        float *adror, *adr, fac;
        float fvec[3];
        int teller=0;
-       ModifierData *md= G.obedit->modifiers.first;
+       ModifierData *md= obedit->modifiers.first;
 
-       if(G.obedit==0) return;
+       if(em==NULL) return;
 
        /* count */
        eve= em->verts.first;
@@ -4198,7 +4050,7 @@ void vertexsmooth(EditMesh *em)
                        if(eve->f1) {
                                
 // XXX                         if (G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR) {
-//                                     eve_mir= editmesh_get_x_mirror_vert(G.obedit, em, eve->co);
+//                                     eve_mir= editmesh_get_x_mirror_vert(obedit, em, eve->co);
 //                             }
                                
                                adr = eve->tmp.p;
@@ -4237,21 +4089,21 @@ void vertexsmooth(EditMesh *em)
 
        recalc_editnormals(em);
 
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Vertex Smooth");
 }
 
-void vertexnoise(EditMesh *em)
+void vertexnoise(Object *obedit, EditMesh *em)
 {
        Material *ma;
        Tex *tex;
        EditVert *eve;
        float b2, ofs, vec[3];
 
-       if(G.obedit==0) return;
+       if(em==NULL) return;
        
-       ma= give_current_material(G.obedit, G.obedit->actcol);
+       ma= give_current_material(obedit, obedit->actcol);
        if(ma==0 || ma->mtex[0]==0 || ma->mtex[0]->tex==0) {
                return;
        }
@@ -4283,33 +4135,31 @@ void vertexnoise(EditMesh *em)
        }
 
        recalc_editnormals(em);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Vertex Noise");
 }
 
-void vertices_to_sphere(Scene *scene, View3D *v3d, EditMesh *em)
+void vertices_to_sphere(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em)
 {
        EditVert *eve;
        float *curs, len, vec[3], cent[3], fac, facm, imat[3][3], bmat[3][3];
        int tot;
        short perc=100;
        
-       TEST_EDITMESH
-       
 // XXX if(button(&perc, 1, 100, "Percentage:")==0) return;
        
        fac= perc/100.0;
        facm= 1.0-fac;
        
-       Mat3CpyMat4(bmat, G.obedit->obmat);
+       Mat3CpyMat4(bmat, obedit->obmat);
        Mat3Inv(imat, bmat);
 
        /* center */
        curs= give_cursor(scene, v3d);
-       cent[0]= curs[0]-G.obedit->obmat[3][0];
-       cent[1]= curs[1]-G.obedit->obmat[3][1];
-       cent[2]= curs[2]-G.obedit->obmat[3][2];
+       cent[0]= curs[0]-obedit->obmat[3][0];
+       cent[1]= curs[1]-obedit->obmat[3][1];
+       cent[2]= curs[2]-obedit->obmat[3][2];
        Mat3MulVecfl(imat, cent);
 
        len= 0.0;
@@ -4344,7 +4194,7 @@ void vertices_to_sphere(Scene *scene, View3D *v3d, EditMesh *em)
        }
        
        recalc_editnormals(em);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("To Sphere");
 }
index 663ed2ef2c14c8a2f2df44c2fa5ccaf66942d35d..1d5e2b24d17c16d444eba469b4c2a3471227521d 100644 (file)
@@ -594,12 +594,11 @@ void hashvert_flag(EditMesh *em, int flag)
 }
 
 /* generic extern called extruder */
-void extrude_mesh(EditMesh *em)
+void extrude_mesh(Object *obedit, EditMesh *em)
 {
        float nor[3]= {0.0, 0.0, 0.0};
        short nr, transmode= 0;
 
-       TEST_EDITMESH
        if(multires_test()) return;
        
        if(em->selectmode & SCE_SELECT_VERTEX) {
@@ -631,7 +630,7 @@ void extrude_mesh(EditMesh *em)
                
        if(nr<1) return;
 
-       if(nr==1)  transmode= extrudeflag(em, SELECT, nor);
+       if(nr==1)  transmode= extrudeflag(obedit, em, SELECT, nor);
        else if(nr==4) transmode= extrudeflag_verts_indiv(em, SELECT, nor);
        else if(nr==3) transmode= extrudeflag_edges_indiv(em, SELECT, nor);
        else transmode= extrudeflag_face_indiv(em, SELECT, nor);
@@ -648,8 +647,8 @@ void extrude_mesh(EditMesh *em)
                        * This shouldn't be necessary, derived queries should be
                        * automatically building this data if invalid. Or something.
                        */
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);     
-               object_handle_update(G.obedit);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);       
+               object_handle_update(obedit);
 
                /* individual faces? */
 //             BIF_TransformSetUndo("Extrude");
@@ -660,8 +659,8 @@ void extrude_mesh(EditMesh *em)
                else {
 //                     initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR);
                        if(transmode=='n') {
-                               Mat4MulVecfl(G.obedit->obmat, nor);
-                               VecSubf(nor, nor, G.obedit->obmat[3]);
+                               Mat4MulVecfl(obedit->obmat, nor);
+                               VecSubf(nor, nor, obedit->obmat[3]);
 //                             BIF_setSingleAxisConstraint(nor, "along normal");
                        }
 //                     Transform();
@@ -673,7 +672,6 @@ void extrude_mesh(EditMesh *em)
 void split_mesh(EditMesh *em)
 {
 
-       TEST_EDITMESH
        if(multires_test()) return;
 
        if(okee(" Split ")==0) return;
@@ -688,18 +686,17 @@ void split_mesh(EditMesh *em)
 
        waitcursor(0);
 
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Split");
 
 }
 
-void extrude_repeat_mesh(View3D *v3d, EditMesh *em, int steps, float offs)
+void extrude_repeat_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float offs)
 {
        float dvec[3], tmat[3][3], bmat[3][3], nor[3]= {0.0, 0.0, 0.0};
        short a;
 
-       TEST_EDITMESH
        if(multires_test()) return;
        
        /* dvec */
@@ -712,12 +709,12 @@ void extrude_repeat_mesh(View3D *v3d, EditMesh *em, int steps, float offs)
        dvec[2]*= offs;
 
        /* base correction */
-       Mat3CpyMat4(bmat, G.obedit->obmat);
+       Mat3CpyMat4(bmat, obedit->obmat);
        Mat3Inv(tmat, bmat);
        Mat3MulVecfl(tmat, dvec);
 
        for(a=0; a<steps; a++) {
-               extrudeflag(em, SELECT, nor);
+               extrudeflag(obedit, em, SELECT, nor);
                translateflag(em, SELECT, dvec);
        }
        
@@ -725,12 +722,12 @@ void extrude_repeat_mesh(View3D *v3d, EditMesh *em, int steps, float offs)
        
        EM_fgon_flags(em);
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Extrude Repeat");
 }
 
-void spin_mesh(View3D *v3d, EditMesh *em, int steps, float degr, float *dvec, int mode)
+void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, float *dvec, int mode)
 {
        EditVert *eve,*nextve;
        float nor[3]= {0.0, 0.0, 0.0};
@@ -739,18 +736,17 @@ void spin_mesh(View3D *v3d, EditMesh *em, int steps, float degr, float *dvec, in
        float phi;
        short a,ok;
 
-       TEST_EDITMESH
        if(multires_test()) return;
        
        /* imat and center and size */
-       Mat3CpyMat4(bmat, G.obedit->obmat);
+       Mat3CpyMat4(bmat, obedit->obmat);
        Mat3Inv(imat,bmat);
 
        curs= give_cursor(NULL, v3d);
        VECCOPY(cent, curs);
-       cent[0]-= G.obedit->obmat[3][0];
-       cent[1]-= G.obedit->obmat[3][1];
-       cent[2]-= G.obedit->obmat[3][2];
+       cent[0]-= obedit->obmat[3][0];
+       cent[1]-= obedit->obmat[3][1];
+       cent[2]-= obedit->obmat[3][2];
        Mat3MulVecfl(imat, cent);
 
        phi= degr*M_PI/360.0;
@@ -782,7 +778,7 @@ void spin_mesh(View3D *v3d, EditMesh *em, int steps, float degr, float *dvec, in
        ok= 1;
 
        for(a=0;a<steps;a++) {
-               if(mode==0) ok= extrudeflag(em, SELECT, nor);
+               if(mode==0) ok= extrudeflag(obedit, em, SELECT, nor);
                else adduplicateflag(em, SELECT);
                if(ok==0) {
                        error("No valid vertices are selected");
@@ -811,20 +807,19 @@ void spin_mesh(View3D *v3d, EditMesh *em, int steps, float degr, float *dvec, in
 
        EM_fgon_flags(em);
 
-       //      DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+       //      DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        
        if(dvec==NULL) BIF_undo_push("Spin");
 }
 
-void screw_mesh(EditMesh *em, int steps, int turns)
+void screw_mesh(Object *obedit, EditMesh *em, int steps, int turns)
 {
        View3D *v3d= NULL; // XXX
        EditVert *eve,*v1=0,*v2=0;
        EditEdge *eed;
        float dvec[3], nor[3];
 
-       TEST_EDITMESH
        if(multires_test()) return;
        
        /* clear flags */
@@ -868,7 +863,7 @@ void screw_mesh(EditMesh *em, int steps, int turns)
        dvec[1]= ( (v1->co[1]- v2->co[1]) )/(steps);
        dvec[2]= ( (v1->co[2]- v2->co[2]) )/(steps);
 
-       VECCOPY(nor, G.obedit->obmat[2]);
+       VECCOPY(nor, obedit->obmat[2]);
 
        if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.000) {
                dvec[0]= -dvec[0];
@@ -876,7 +871,7 @@ void screw_mesh(EditMesh *em, int steps, int turns)
                dvec[2]= -dvec[2];
        }
 
-       spin_mesh(v3d, em, turns*steps, turns*360, dvec, 0);
+       spin_mesh(v3d, obedit, em, turns*steps, turns*360, dvec, 0);
 
        BIF_undo_push("Spin");
 }
@@ -928,7 +923,7 @@ static void erase_vertices(EditMesh *em, ListBase *l)
        }
 }
 
-void delete_mesh(EditMesh *em)
+void delete_mesh(Object *obedit, EditMesh *em)
 {
        EditFace *efa, *nextvl;
        EditVert *eve,*nextve;
@@ -937,7 +932,6 @@ void delete_mesh(EditMesh *em)
        int count;
        char *str="Erase";
 
-       TEST_EDITMESH
        if(multires_test()) return;
        
        event= pupmenu("Erase %t|Vertices%x10|Edges%x1|Faces%x2|All%x3|Edges & Faces%x4|Only Faces%x5|Edge Loop%x6");
@@ -1068,7 +1062,7 @@ void delete_mesh(EditMesh *em)
 
        EM_fgon_flags(em);      // redo flags and indices for fgons
 
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        BIF_undo_push(str);
 }
 
@@ -1082,7 +1076,7 @@ void fill_mesh(EditMesh *em)
        EditFace *efa,*nextvl, *efan;
        short ok;
 
-       if(G.obedit==0 || (G.obedit->type!=OB_MESH)) return;
+       if(em==NULL) return;
        if(multires_test()) return;
 
        waitcursor(1);
@@ -1136,7 +1130,7 @@ void fill_mesh(EditMesh *em)
                }
        }
 
-       if(BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) {
+       if(BLI_edgefill(0, em->mat_nr)) {
                efa= fillfacebase.first;
                while(efa) {
                        /* normals default pointing up */
@@ -1151,7 +1145,7 @@ void fill_mesh(EditMesh *em)
 
        waitcursor(0);
        EM_select_flush(em);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Fill");
 }
@@ -2366,7 +2360,7 @@ static EditVert *subdivideedgenum(EditMesh *em, EditEdge *edge, int curpoint, in
        return ev;
 }
 
-void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype)
+void esubdivideflag(Object *obedit, EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype)
 {
        EditFace *ef;
        EditEdge *eed, *cedge, *sort[4];
@@ -2374,7 +2368,7 @@ void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts,
        struct GHash *gh;
        float length[4], v1mat[3], v2mat[3], v3mat[3], v4mat[3];
        int i, j, edgecount, touchcount, facetype,hold;
-       ModifierData *md= G.obedit->modifiers.first;
+       ModifierData *md= obedit->modifiers.first;
        int ctrl= 0; // XXX
        
        if(multires_test()) return;
@@ -2438,10 +2432,10 @@ void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts,
                                VECCOPY(v2mat, ef->v2->co);
                                VECCOPY(v3mat, ef->v3->co);
                                VECCOPY(v4mat, ef->v4->co);                                             
-                               Mat4Mul3Vecfl(G.obedit->obmat, v1mat);
-                               Mat4Mul3Vecfl(G.obedit->obmat, v2mat);                                                                                  
-                               Mat4Mul3Vecfl(G.obedit->obmat, v3mat);
-                               Mat4Mul3Vecfl(G.obedit->obmat, v4mat);
+                               Mat4Mul3Vecfl(obedit->obmat, v1mat);
+                               Mat4Mul3Vecfl(obedit->obmat, v2mat);                                                                                    
+                               Mat4Mul3Vecfl(obedit->obmat, v3mat);
+                               Mat4Mul3Vecfl(obedit->obmat, v4mat);
                                
                                length[0] = VecLenf(v1mat, v2mat);
                                length[1] = VecLenf(v2mat, v3mat);
@@ -2532,7 +2526,7 @@ void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts,
                }                                                                 
        }
 
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        // Now for each face in the mesh we need to figure out How many edges were cut
        // and which filling method to use for that face
        for(ef = em->faces.first;ef;ef = ef->next) {
@@ -2735,7 +2729,7 @@ void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts,
        }
        
        recalc_editnormals(em);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 }
 
 static int count_selected_edges(EditEdge *ed)
@@ -3085,7 +3079,7 @@ void beauty_fill(EditMesh *em)
 
        EM_select_flush(em);
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Beauty Fill");
 }
@@ -3390,7 +3384,7 @@ void join_triangles(EditMesh *em)
        if(edsortblock) MEM_freeN(edsortblock);
                
        EM_selectmode_flush(em);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Convert Triangles to Quads");
 }
@@ -3488,7 +3482,7 @@ void edge_flip(EditMesh *em)
        
        MEM_freeN(efaar);
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Flip Triangle Edges");
        
@@ -3725,7 +3719,7 @@ void edge_rotate_selected(EditMesh *em, int dir)
        /* flush selected vertices (again) to edges/faces */
        EM_select_flush(em);
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        BIF_undo_push("Rotate Edge");   
 }
@@ -3849,7 +3843,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
        
 //     initNumInput(&num);
                
-//     view3d_get_object_project_mat(curarea, G.obedit, projectMat, viewMat);
+//     view3d_get_object_project_mat(curarea, obedit, projectMat, viewMat);
        
        mvalo[0] = -1; mvalo[1] = -1; 
        numsel =0;  
@@ -4417,7 +4411,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
 //                     scrarea_do_windraw(curarea);   
 //                     persp(PERSP_VIEW);   
 //                     glPushMatrix();   
-//                     mymultmatrix(G.obedit->obmat);
+//                     mymultmatrix(obedit->obmat);
 
                        glColor3ub(0, 255, 0);   
                        glBegin(GL_LINES);
@@ -4549,7 +4543,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                } else {
                        draw = 0;
                }
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);      
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);        
        }
        
        
@@ -4569,7 +4563,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
        
        if(!immediate)
                EM_automerge(0);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 //     scrarea_queue_winredraw(curarea);                
        
        //BLI_ghash_free(edgesgh, freeGHash, NULL); 
@@ -4618,7 +4612,7 @@ int EdgeLoopDelete(EditMesh *em)
        EM_select_more(em);
        removedoublesflag(em, 1,0, 0.001);
        EM_select_flush(em);
-       //      DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+       //      DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        return 1;
 }
 
@@ -4700,9 +4694,7 @@ void mesh_set_smooth_faces(EditMesh *em, short event)
 {
        EditFace *efa;
 
-       if(G.obedit==0) return;
-       
-       if(G.obedit->type != OB_MESH) return;
+       if(em==NULL) return;
        
        efa= em->faces.first;
        while(efa) {
@@ -4713,7 +4705,7 @@ void mesh_set_smooth_faces(EditMesh *em, short event)
                efa= efa->next;
        }
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
        
        if(event==1) BIF_undo_push("Set Smooth");
        else if(event==0) BIF_undo_push("Set Solid");
@@ -4771,7 +4763,7 @@ void mesh_rip(EditMesh *em)
        EM_selectmode_set(em);
        
 // XXX getmouseco_areawin(mval);
-//     view3d_get_object_project_mat(curarea, G.obedit, projectMat, viewMat);
+//     view3d_get_object_project_mat(curarea, obedit, projectMat, viewMat);
 
        /* find best face, exclude triangles and break on face select or faces with 2 edges select */
        mindist= 1000000.0f;
@@ -4957,10 +4949,10 @@ void mesh_rip(EditMesh *em)
 // XXX G.scene->proportional = prop;
 }
 
-void shape_propagate(Scene *scene, EditMesh *em)
+void shape_propagate(Scene *scene, Object *obedit, EditMesh *em)
 {
        EditVert *ev = NULL;
-       Mesh* me = (Mesh*)G.obedit->data;
+       Mesh* me = (Mesh*)obedit->data;
        Key*  ky = NULL;
        KeyBlock* kb = NULL;
        Base* base=NULL;
@@ -4996,7 +4988,7 @@ void shape_propagate(Scene *scene, EditMesh *em)
        }               
 
        BIF_undo_push("Propagate Blendshape Verts");
-       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        return; 
 }
 
@@ -5041,7 +5033,7 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
                                }               
                        }       
                        sprintf(str,"Blending at %d%c  MMB to Copy at 100%c",(int)(perc*100),'%','%');
-//                     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//                     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 //                     headerprint(str);
 //                     force_draw(0);                  
 
@@ -5083,11 +5075,11 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
 
 
 
-void shape_copy_select_from(EditMesh *em)
+void shape_copy_select_from(Object *obedit, EditMesh *em)
 {
-       Mesh* me = (Mesh*)G.obedit->data;
+       Mesh* me = (Mesh*)obedit->data;
        EditVert *ev = NULL;
-       int totverts = 0,curshape = G.obedit->shapenr;
+       int totverts = 0,curshape = obedit->shapenr;
        
        Key*  ky = NULL;
        KeyBlock *kb = NULL,*thisBlock = NULL;
@@ -5641,7 +5633,7 @@ int collapseEdges(EditMesh *em)
        freecollections(&allcollections);
        removedoublesflag(em, 1, 0, MERGELIMIT);
        /*get rid of this!*/
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
 //     if (EM_texFaceCheck())
 
@@ -5701,7 +5693,7 @@ int merge_target(EditMesh *em, int target, int uvmerge)
                collapseuvs(em, NULL);
        }
        
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
        return removedoublesflag(em, 1, 0, MERGELIMIT);
        
@@ -5866,7 +5858,7 @@ void pathselect(EditMesh *em)
                        MEM_freeN(previous);
                        BLI_heap_free(heap, NULL);
                        EM_select_flush(em);
-               //                      DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+               //                      DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
 //                     if (EM_texFaceCheck())
                }
@@ -5903,7 +5895,7 @@ void region_to_loop(EditMesh *em)
                
                em->selectmode = SCE_SELECT_EDGE;
                EM_selectmode_set(em);
-       //              DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+       //              DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
 //             if (EM_texFaceCheck())
 
@@ -6062,7 +6054,7 @@ void loop_to_region(EditMesh *em)
        }
        
        freecollections(&allcollections);
-//     DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//     DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
 //     if (EM_texFaceCheck())
 
@@ -6134,7 +6126,7 @@ void mesh_rotate_uvs(EditMesh *em)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
                BIF_undo_push("Rotate UV face");
        }
@@ -6217,7 +6209,7 @@ void mesh_mirror_uvs(EditMesh *em)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
                BIF_undo_push("Mirror UV face");
        }
@@ -6267,7 +6259,7 @@ void mesh_rotate_colors(EditMesh *em)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
 
                BIF_undo_push("Rotate Color face");
        }       
@@ -6316,7 +6308,7 @@ void mesh_mirror_colors(EditMesh *em)
        }
        
        if (change) {
-//             DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+//             DAG_object_flush_update(G.scene, obedit, OB_RECALC_DATA);
                BIF_undo_push("Mirror Color face");
        }
 }
index a23e3e4201285a55323b29f62a5a498879e063be..8000d2278857a9b90a10dc92a1a02487c7f5c617 100644 (file)
@@ -35,8 +35,6 @@
 struct bContext;
 struct wmOperatorType;
 
-#define TEST_EDITMESH  if(G.obedit==0) return; /* layer test XXX */
-
 #define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float));
 
 /* ******************** editface.c */
@@ -136,8 +134,8 @@ void recalc_editnormals(EditMesh *em);
 extern short extrudeflag_face_indiv(EditMesh *em, short flag, float *nor);
 extern short extrudeflag_verts_indiv(EditMesh *em, short flag, float *nor);
 extern short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor);
-extern short extrudeflag_vert(EditMesh *em, short flag, float *nor);
-extern short extrudeflag(EditMesh *em, short flag, float *nor);
+extern short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor);
+extern short extrudeflag(Object *obedit, EditMesh *em, short flag, float *nor);
 
 extern void adduplicateflag(EditMesh *em, int flag);
 extern void delfaceflag(EditMesh *em, int flag);
@@ -193,7 +191,7 @@ extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short st
 
 void join_triangles(EditMesh *em);
 int removedoublesflag(EditMesh *em, short flag, short automerge, float limit);         /* return amount */
-void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype);
+void esubdivideflag(Object *obedit, EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype);
 int EdgeSlide(EditMesh *em, short immediate, float imperc);
 
 
index 97ce1ec617a2fd5b46fb17e14b3ae90d489554c3..94730be507c7b56e5ea7bf393fc2bef6f56f8a38 100644 (file)
@@ -118,7 +118,7 @@ int join_mesh(Scene *scene, View3D *v3d)
        MDeformVert *dvert;
        CustomData vdata, edata, fdata;
 
-       if(G.obedit) return 0;
+       if(scene->obedit) return 0;
        
        ob= OBACT;
        if(!ob || ob->type!=OB_MESH) return 0;
@@ -445,7 +445,7 @@ void sort_faces(Scene *scene, View3D *v3d)
        int ctrl= 0;    // XXX
        
        if(!ob) return;
-       if(G.obedit) return;
+       if(scene->obedit) return;
        if(ob->type!=OB_MESH) return;
        if (!v3d) return;
        
@@ -709,7 +709,7 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
                if(MeshOctree.table) {
                        Mesh *me= ob->data;
                        bt= MeshOctree.table + mesh_octree_get_base_offs(co, MeshOctree.offs, MeshOctree.div);
-                       if(ob==G.obedit)
+                       if(me->edit_mesh)
                                return mesh_octree_find_index(bt, NULL, NULL, co);
                        else
                                return mesh_octree_find_index(bt, MeshOctree.orco, me->mvert, co);
@@ -724,7 +724,7 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
                 * we are using the undeformed coordinates*/
                INIT_MINMAX(min, max);
 
-               if(ob==G.obedit) {
+               if(me->edit_mesh==em) {
                        EditVert *eve;
                        
                        for(eve= em->verts.first; eve; eve= eve->next)
@@ -765,7 +765,7 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
                
                MeshOctree.table= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table");
                
-               if(ob==G.obedit) {
+               if(me->edit_mesh==em) {
                        EditVert *eve;
 
                        for(eve= em->verts.first; eve; eve= eve->next) {
@@ -1106,7 +1106,7 @@ void objects_bake_render(Scene *scene, short event, char **error_msg)
 static void objects_bake_render_ui(Scene *scene, short event)
 {
        char *error_msg = NULL;
-//     int is_editmode = (G.obedit!=NULL);
+//     int is_editmode = (obedit!=NULL);
        
        /* Deal with editmode, this is a bit clunky but since UV's are in editmode, users are likely to bake from their */
 // XXX if (is_editmode) exit_editmode(0);
index 9d18d300e998e830cb8772e2fa2c2c4cfb9392e0..87f0d5ee80e8e5870ee461bfbf87c7cb8db89a6e 100644 (file)
@@ -254,7 +254,7 @@ void add_object_draw(Scene *scene, View3D *v3d, int type)   /* for toolbox or menu
        
        exit_paint_modes();
 
-// XXX if (G.obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
+// XXX if (obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
        ob= add_object(type);
 //     ED_base_object_activate(C, BASACT);
        base_init_from_view3d(BASACT, v3d);
@@ -285,7 +285,7 @@ void add_objectLamp(Scene *scene, View3D *v3d, short type)
 {
        Lamp *la;
 
-       if(G.obedit==0) {
+       if(scene->obedit==NULL) { // XXX get from context
                add_object_draw(scene, v3d, OB_LAMP);
                base_init_from_view3d(BASACT, v3d);
        }
@@ -311,7 +311,7 @@ void delete_obj(Scene *scene, View3D *v3d, int ok)
        Base *base, *nbase;
        int islamp= 0;
        
-       if(G.obedit) return;
+       if(scene->obedit) return; // XXX get from context
        if(scene->id.lib) return;
 
        for(base= FIRSTBASE; base; base= nbase) {
@@ -399,7 +399,7 @@ static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float
        return totvert;
 }
 
-static int return_editmesh_vgroup(EditMesh *em, char *name, float *cent)
+static int return_editmesh_vgroup(Object *obedit, EditMesh *em, char *name, float *cent)
 {
        MDeformVert *dvert;
        EditVert *eve;
@@ -407,7 +407,7 @@ static int return_editmesh_vgroup(EditMesh *em, char *name, float *cent)
        
        cent[0]= cent[1]= cent[2]= 0.0;
        
-       if(G.obedit->actdef) {
+       if(obedit->actdef) {
                
                /* find the vertices */
                for(eve= em->verts.first; eve; eve= eve->next) {
@@ -415,7 +415,7 @@ static int return_editmesh_vgroup(EditMesh *em, char *name, float *cent)
 
                        if(dvert) {
                                for(i=0; i<dvert->totweight; i++){
-                                       if(dvert->dw[i].def_nr == (G.obedit->actdef-1)) {
+                                       if(dvert->dw[i].def_nr == (obedit->actdef-1)) {
                                                totvert++;
                                                VecAddf(cent, cent, eve->co);
                                        }
@@ -423,7 +423,7 @@ static int return_editmesh_vgroup(EditMesh *em, char *name, float *cent)
                        }
                }
                if(totvert) {
-                       bDeformGroup *defGroup = BLI_findlink(&G.obedit->defbase, G.obedit->actdef-1);
+                       bDeformGroup *defGroup = BLI_findlink(&obedit->defbase, obedit->actdef-1);
                        strcpy(name, defGroup->name);
                        VecMulf(cent, 1.0f/(float)totvert);
                        return 1;
@@ -608,19 +608,19 @@ static void apply_obmat(Object *ob)
        
 }
 
-int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r)
+int hook_getIndexArray(Object *obedit, int *tot, int **indexar, char *name, float *cent_r)
 {
        *indexar= NULL;
        *tot= 0;
        name[0]= 0;
        
-       switch(G.obedit->type) {
+       switch(obedit->type) {
                case OB_MESH:
                {
-                       Mesh *me= G.obedit->data;
+                       Mesh *me= obedit->data;
                        /* check selected vertices first */
                        if( return_editmesh_indexar(me->edit_mesh, tot, indexar, cent_r)) return 1;
-                       else return return_editmesh_vgroup(me->edit_mesh, name, cent_r);
+                       else return return_editmesh_vgroup(obedit, me->edit_mesh, name, cent_r);
                }
                case OB_CURVE:
                case OB_SURF:
@@ -694,8 +694,9 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
        ModifierData *md = NULL;
        HookModifierData *hmd = NULL;
        Object *ob=NULL;
+       Object *obedit= scene->obedit;  // XXX get from context
        
-       if(G.obedit==NULL) return;
+       if(obedit==NULL) return;
        
        /* preconditions */
        if(mode==2) { /* selected object */
@@ -718,7 +719,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                char *cp;
                
                /* make pupmenu with hooks */
-               for(md=G.obedit->modifiers.first; md; md= md->next) {
+               for(md=obedit->modifiers.first; md; md= md->next) {
                        if (md->type==eModifierType_Hook) 
                                maxlen+=32;
                }
@@ -734,7 +735,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                else if(mode==5) strcpy(cp, "Select %t|");
                else if(mode==6) strcpy(cp, "Clear Offset %t|");
                
-               for(md=G.obedit->modifiers.first; md; md= md->next) {
+               for(md=obedit->modifiers.first; md; md= md->next) {
                        if (md->type==eModifierType_Hook) {
                                strcat(cp, md->name);
                                strcat(cp, " |");
@@ -747,7 +748,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                if(nr<1) return;
                
                a= 1;
-               for(md=G.obedit->modifiers.first; md; md=md->next) {
+               for(md=obedit->modifiers.first; md; md=md->next) {
                        if (md->type==eModifierType_Hook) {
                                if(a==nr) break;
                                a++;
@@ -764,7 +765,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                int tot, ok, *indexar;
                char name[32];
                
-               ok = hook_getIndexArray(&tot, &indexar, name, cent);
+               ok = hook_getIndexArray(obedit, &tot, &indexar, name, cent);
                
                if(ok==0) {
                        error("Requires selected vertices or active Vertex Group");
@@ -781,7 +782,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                                ob->lay= newbase->lay;
                                
                                /* transform cent to global coords for loc */
-                               VecMat4MulVecfl(ob->loc, G.obedit->obmat, cent);
+                               VecMat4MulVecfl(ob->loc, obedit->obmat, cent);
                                
                                /* restore, add_object sets active */
                                BASACT= base;
@@ -790,14 +791,14 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                        
                        /* new hook */
                        if(mode==1 || mode==2) {
-                               ModifierData *md = G.obedit->modifiers.first;
+                               ModifierData *md = obedit->modifiers.first;
                                
                                while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
                                        md = md->next;
                                }
                                
                                hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
-                               BLI_insertlinkbefore(&G.obedit->modifiers, md, hmd);
+                               BLI_insertlinkbefore(&obedit->modifiers, md, hmd);
                                sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
                        }
                        else if (hmd->indexar) MEM_freeN(hmd->indexar); /* reassign, hook was set */
@@ -817,24 +818,24 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
                                
                                Mat4Invert(ob->imat, ob->obmat);
                                /* apparently this call goes from right to left... */
-                               Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL, 
+                               Mat4MulSerie(hmd->parentinv, ob->imat, obedit->obmat, NULL, 
                                                         NULL, NULL, NULL, NULL, NULL);
                        }
                }
        }
        else if(mode==3) { /* remove */
-               BLI_remlink(&G.obedit->modifiers, md);
+               BLI_remlink(&obedit->modifiers, md);
                modifier_free(md);
        }
        else if(mode==5) { /* select */
-               obedit_hook_select(G.obedit, hmd);
+               obedit_hook_select(obedit, hmd);
        }
        else if(mode==6) { /* clear offset */
                where_is_object(ob);    /* ob is hook->parent */
 
                Mat4Invert(ob->imat, ob->obmat);
                /* this call goes from right to left... */
-               Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL, 
+               Mat4MulSerie(hmd->parentinv, ob->imat, obedit->obmat, NULL, 
                                         NULL, NULL, NULL, NULL, NULL);
        }
 
@@ -862,11 +863,12 @@ static void ignore_parent_tx( Object *ob )
 
 void add_hook_menu(Scene *scene, View3D *v3d)
 {
+       Object *obedit= scene->obedit;  // XXX get from context
        int mode;
        
-       if(G.obedit==NULL) return;
+       if(obedit==NULL) return;
        
-       if(modifiers_findByType(G.obedit, eModifierType_Hook))
+       if(modifiers_findByType(obedit, eModifierType_Hook))
                mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6");
        else
                mode= pupmenu("Hooks %t|Add, New Empty %x1|Add, To Selected Object %x2");
@@ -888,9 +890,9 @@ void make_track(Scene *scene, View3D *v3d, short mode)
        /*short mode=0;*/
        
        if(scene->id.lib) return;
-       if(G.obedit) {
-               return;
-       }
+// XXX if(obedit) {
+//             return; 
+//     }
        if(BASACT==0) return;
 
        mode= pupmenu("Make Track %t|TrackTo Constraint %x1|LockTrack Constraint %x2|Old Track %x3");
@@ -1037,7 +1039,7 @@ static EnumPropertyItem prop_clear_track_types[] = {
 /* note, poll should check for editable scene */
 static int object_clear_track_exec(bContext *C, wmOperator *op)
 {
-       if(G.obedit) return OPERATOR_CANCELLED;
+       if(CTX_data_edit_object(C)) return OPERATOR_CANCELLED;
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
                /*if(TESTBASELIB(v3d, base)) {*/
@@ -1324,7 +1326,6 @@ static int object_clear_location_exec(bContext *C, wmOperator *op)
 
 void OBJECT_OT_clear_location(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
        
        /* identifiers */
        ot->name= "Clear Object Location";
@@ -1377,7 +1378,6 @@ static int object_clear_rotation_exec(bContext *C, wmOperator *op)
 
 void OBJECT_OT_clear_rotation(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
        
        /* identifiers */
        ot->name= "Clear Object Rotation";
@@ -1434,7 +1434,6 @@ static int object_clear_scale_exec(bContext *C, wmOperator *op)
 
 void OBJECT_OT_clear_scale(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
        
        /* identifiers */
        ot->name= "Clear Object Scale";
@@ -1535,7 +1534,7 @@ 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)
+void make_vertex_parent(Scene *scene, Object *obedit, View3D *v3d)
 {
        EditVert *eve;
        Base *base;
@@ -1547,8 +1546,8 @@ void make_vertex_parent(Scene *scene, View3D *v3d)
        
        /* we need 1 to 3 selected vertices */
        
-       if(G.obedit->type==OB_MESH) {
-               Mesh *me= G.obedit->data;
+       if(obedit->type==OB_MESH) {
+               Mesh *me= obedit->data;
                
                eve= me->edit_mesh->verts.first;
                while(eve) {
@@ -1563,7 +1562,7 @@ void make_vertex_parent(Scene *scene, View3D *v3d)
                        eve= eve->next;
                }
        }
-       else if(ELEM(G.obedit->type, OB_SURF, OB_CURVE)) {
+       else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) {
                extern ListBase editNurb;
                nu= editNurb.first;
                while(nu) {
@@ -1600,7 +1599,7 @@ void make_vertex_parent(Scene *scene, View3D *v3d)
                        nu= nu->next;
                }
        }
-       else if(G.obedit->type==OB_LATTICE) {
+       else if(obedit->type==OB_LATTICE) {
                
                a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
                bp= editLatt->def;
@@ -2091,14 +2090,14 @@ void ED_object_exit_editmode(bContext *C, int flag)
 {
        Scene *scene= CTX_data_scene(C);
        Object *ob;
-//     Object *obedit= CTX_data_edit_object(C);
+       Object *obedit= CTX_data_edit_object(C);
        int freedata = flag & EM_FREEDATA;
        
-       if(G.obedit==NULL) return;
+       if(obedit==NULL) return;
        
        if(flag & EM_WAITCURSOR) waitcursor(1);
-       if(G.obedit->type==OB_MESH) {
-               Mesh *me= G.obedit->data;
+       if(obedit->type==OB_MESH) {
+               Mesh *me= obedit->data;
                
 //             if(EM_texFaceCheck())
                
@@ -2109,40 +2108,40 @@ void ED_object_exit_editmode(bContext *C, int flag)
                        error("Too many vertices");
                        return;
                }
-               load_editMesh(scene, G.obedit);
+               load_editMesh(scene, obedit);
                
                if(freedata) free_editMesh(me->edit_mesh);
                
                if(G.f & G_WEIGHTPAINT)
-                       mesh_octree_table(G.obedit, NULL, NULL, 'e');
+                       mesh_octree_table(obedit, NULL, NULL, 'e');
        }
-       else if (G.obedit->type==OB_ARMATURE){  
+       else if (obedit->type==OB_ARMATURE){    
 //             load_editArmature();
 //             if (freedata) free_editArmature();
        }
-       else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
+       else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) {
 //             extern ListBase editNurb;
 //             load_editNurb();
 //             if(freedata) freeNurblist(&editNurb);
        }
-       else if(G.obedit->type==OB_FONT && freedata) {
+       else if(obedit->type==OB_FONT && freedata) {
 //             load_editText();
        }
-       else if(G.obedit->type==OB_LATTICE) {
+       else if(obedit->type==OB_LATTICE) {
 //             load_editLatt();
 //             if(freedata) free_editLatt();
        }
-       else if(G.obedit->type==OB_MBALL) {
+       else if(obedit->type==OB_MBALL) {
 //             extern ListBase editelems;
 //             load_editMball();
 //             if(freedata) BLI_freelistN(&editelems);
        }
        
-       ob= G.obedit;
+       ob= obedit;
        
        /* for example; displist make is different in editmode */
-       if(freedata) G.obedit= NULL;
-       scene->obedit= G.obedit; // XXX
+       if(freedata) obedit= NULL;
+       scene->obedit= obedit; // XXX for context
        
        if(ob->type==OB_MESH && get_mesh(ob)->mr)
                multires_edge_level_update(ob, get_mesh(ob));
@@ -2150,7 +2149,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
        /* 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)) 
+       if(obedit==NULL) // XXX && (flag & EM_FREEUNDO)) 
                ED_undo_push(C, "Editmode");
        
        if(flag & EM_WAITCURSOR) waitcursor(0);
@@ -2186,7 +2185,6 @@ void ED_object_enter_editmode(bContext *C, int flag)
                
                if(me->pv) mesh_pmv_off(ob, me);
                ok= 1;
-               G.obedit= ob; // XXX
                scene->obedit= ob;      // context sees this
                
                make_editMesh(scene, ob);
@@ -2208,40 +2206,40 @@ void ED_object_enter_editmode(bContext *C, int flag)
                        error_libdata();
                        return;
                }
-               ok=1;
-               G.obedit=ob;
+//             ok=1;
+               scene->obedit= ob;
 // XXX         make_editArmature();
                /* to ensure all goes in restposition and without striding */
-               DAG_object_flush_update(scene, G.obedit, OB_RECALC);
+               DAG_object_flush_update(scene, ob, OB_RECALC);
 
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, ob);
        }
        else if(ob->type==OB_FONT) {
-               G.obedit= ob;
-               ok= 1;
+               scene->obedit= ob; // XXX for context
+//             ok= 1;
 // XXX         make_editText();
        }
        else if(ob->type==OB_MBALL) {
-               G.obedit= ob;
-               ok= 1;
+               scene->obedit= ob; // XXX for context
+//             ok= 1;
 // XXX         make_editMball();
        }
        else if(ob->type==OB_LATTICE) {
-               G.obedit= ob;
-               ok= 1;
+               scene->obedit= ob; // XXX for context
+//             ok= 1;
 // XXX         make_editLatt();
        }
        else if(ob->type==OB_SURF || ob->type==OB_CURVE) {
-               ok= 1;
-               G.obedit= ob;
+//             ok= 1;
+               scene->obedit= ob; // XXX for context
 // XXX         make_editNurb();
        }
        
        if(ok) {
-               DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
        }
        else {
-               G.obedit= NULL;
+               scene->obedit= NULL; // XXX for context
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob);
        }
        
@@ -2278,8 +2276,9 @@ void OBJECT_OT_toggle_editmode(wmOperatorType *ot)
 
 void check_editmode(int type)
 {
+       Object *obedit= NULL; // XXX
        
-       if (G.obedit==0 || G.obedit->type==type) return;
+       if (obedit==NULL || obedit->type==type) return;
 
 // XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
 }
@@ -2294,6 +2293,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
        Curve *cu;
 /*     BezTriple *bezt;
        BPoint *bp; */
+       Object *obedit= NULL; // XXX
        Nurb *nu, *nu1;
        EditVert *eve;
        float cent[3], centn[3], min[3], max[3], omat[3][3];
@@ -2307,12 +2307,12 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
        
        cent[0]= cent[1]= cent[2]= 0.0;
        
-       if(G.obedit) {
+       if(obedit) {
 
                INIT_MINMAX(min, max);
        
-               if(G.obedit->type==OB_MESH) {
-                       Mesh *me= G.obedit->data;
+               if(obedit->type==OB_MESH) {
+                       Mesh *me= obedit->data;
                        
                        for(eve= me->edit_mesh->verts.first; eve; eve= eve->next) {
                                if(v3d->around==V3D_CENTROID) {
@@ -2339,7 +2339,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                        
 // XXX                 recalc_editnormals();
                        tot_change++;
-                       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+                       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
                }
        }
        
@@ -2361,7 +2361,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                if(base->object->id.lib) {
                                        tot_lib_error++;
                                }
-                               else if(G.obedit==0 && (me=get_mesh(base->object)) ) {
+                               else if(obedit==0 && (me=get_mesh(base->object)) ) {
                                        if (me->id.lib) {
                                                tot_lib_error++;
                                        } else {
@@ -2463,10 +2463,10 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                else if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
                                        
                                        /* totally weak code here... (ton) */
-                                       if(G.obedit==base->object) {
+                                       if(obedit==base->object) {
                                                extern ListBase editNurb;
                                                nu1= editNurb.first;
-                                               cu= G.obedit->data;
+                                               cu= obedit->data;
                                        }
                                        else {
                                                cu= base->object->data;
@@ -2517,7 +2517,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                                        nu= nu->next;
                                                }
                                
-                                               if(centermode && G.obedit==0) {
+                                               if(centermode && obedit==0) {
                                                        Mat3CpyMat4(omat, base->object->obmat);
                                                        
                                                        Mat3MulVecfl(omat, cent);
@@ -2530,9 +2530,9 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                                }
                                                
                                                tot_change++;
-                                               if(G.obedit) {
+                                               if(obedit) {
                                                        if (centermode==0) {
-                                                               DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+                                                               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
                                                        }
                                                        break;
                                                }
@@ -2578,7 +2578,7 @@ void docenter(Scene *scene, View3D *v3d, int centermode)
                                                where_is_object(base->object);
                                                ignore_parent_tx(base->object);
                                                
-                                               if(G.obedit) 
+                                               if(obedit) 
                                                        break;
                                        }
                                }
@@ -2610,7 +2610,7 @@ void docenter_new(Scene *scene, View3D *v3d)
 {
        if(scene->id.lib) return;
 
-       if(G.obedit) {
+       if(scene->obedit) { // XXX get from context
                error("Unable to center new in Edit Mode");
        }
        else {
@@ -2622,7 +2622,7 @@ void docenter_cursor(Scene *scene, View3D *v3d)
 {
        if(scene->id.lib) return;
 
-       if(G.obedit) {
+       if(scene->obedit) { // XXX get from context
                error("Unable to center cursor in Edit Mode");
        }
        else {
@@ -2819,13 +2819,14 @@ void special_editmenu(Scene *scene, View3D *v3d)
 {
 // XXX static short numcuts= 2;
        Object *ob= OBACT;
+       Object *obedit= NULL; // XXX
        float fac;
        int nr,ret;
        short randfac;
        
        if(ob==NULL) return;
        
-       if(G.obedit==NULL) {
+       if(obedit==NULL) {
                
                if(ob->flag & OB_POSEMODE) {
 // XXX                 pose_special_editmenu();
@@ -2938,7 +2939,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
                                break;
                        }
                        
-                       DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+                       DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
                        
                        if(nr>0) waitcursor(0);
 #endif
@@ -3017,7 +3018,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
                        }                       
                }
        }
-       else if(G.obedit->type==OB_MESH) {
+       else if(obedit->type==OB_MESH) {
                /* This is all that is needed, since all other functionality is in Ctrl+ V/E/F but some users didnt like, so for now have the old/big menu */
                /*
                nr= pupmenu("Subdivide Mesh%t|Subdivide%x1|Subdivide Multi%x2|Subdivide Multi Fractal%x3|Subdivide Smooth%x4");
@@ -3137,12 +3138,12 @@ void special_editmenu(Scene *scene, View3D *v3d)
                }
                
                
-               DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
                
                if(nr>0) waitcursor(0);
                
        }
-       else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
+       else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) {
 
                nr= pupmenu("Specials%t|Subdivide%x1|Switch Direction%x2|Set Goal Weight%x3|Set Radius%x4|Smooth%x5|Smooth Radius%x6");
                
@@ -3166,9 +3167,9 @@ void special_editmenu(Scene *scene, View3D *v3d)
 // XXX                 smoothradiusNurb();
                        break;
                }
-               DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
+               DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
        }
-       else if(G.obedit->type==OB_ARMATURE) {
+       else if(obedit->type==OB_ARMATURE) {
                nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Switch Direction%x7|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6");
 //             if(nr==1)
 // XXX                 subdivide_armature(1);
@@ -3185,7 +3186,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
 //             else if(nr == 7)
 // XXX                 switch_direction_armature();
        }
-       else if(G.obedit->type==OB_LATTICE) {
+       else if(obedit->type==OB_LATTICE) {
                static float weight= 1.0f;
                { // XXX
 // XXX         if(fbutton(&weight, 0.0f, 1.0f, 10, 10, "Set Weight")) {
@@ -3227,6 +3228,7 @@ void convertmenu(Scene *scene, View3D *v3d)
 {
        Base *base, *basen=NULL, *basact, *basedel=NULL;
        Object *obact, *ob, *ob1;
+       Object *obedit= NULL; // XXX
        Curve *cu;
        Nurb *nu;
        MetaBall *mb;
@@ -3238,7 +3240,7 @@ void convertmenu(Scene *scene, View3D *v3d)
        obact= OBACT;
        if (obact == NULL) return;
        if(!obact->flag & SELECT) return;
-       if(G.obedit) return;
+       if(obedit) return;
        
        basact= BASACT; /* will be restored */
                
@@ -3546,8 +3548,8 @@ void flip_subdivison(Scene *scene, View3D *v3d, int level)
                mode= eModifierMode_Render|eModifierMode_Realtime;
        
        if(level == -1) {
-               if (G.obedit) {
-                       object_has_subdivision_particles(G.obedit, &havesubdiv, &havepart, 0);                  
+               if (scene->obedit) { // XXX get from context
+                       object_has_subdivision_particles(scene->obedit, &havesubdiv, &havepart, 0);                     
                } else {
                        for(base= scene->base.first; base; base= base->next) {
                                if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) {
@@ -3569,8 +3571,8 @@ void flip_subdivison(Scene *scene, View3D *v3d, int level)
        else if(havepart)
                particles= 1;
 
-       if (G.obedit) { 
-               object_flip_subdivison_particles(scene, G.obedit, &set, level, mode, particles, 0);
+       if (scene->obedit) {     // XXX get from context
+               object_flip_subdivison_particles(scene, scene->obedit, &set, level, mode, particles, 0);
        } else {
                for(base= scene->base.first; base; base= base->next) {
                        if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) {
@@ -3847,7 +3849,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
 
        if(!(ob=OBACT)) return;
        
-       if(G.obedit) {
+       if(scene->obedit) { // XXX get from context
                /* obedit_copymenu(); */
                return;
        }
@@ -4099,7 +4101,7 @@ void copy_attr_menu(Scene *scene, View3D *v3d)
        
        if(!(ob=OBACT)) return;
        
-       if (G.obedit) {
+       if (scene->obedit) { // XXX get from context
 //             if (ob->type == OB_MESH)
 // XXX                 mesh_copy_menu();
                return;
@@ -4761,7 +4763,7 @@ void apply_object(Scene *scene, View3D *v3d)
        int shift= 0;
        
        if(scene->id.lib) return;
-       if(G.obedit) return;
+       if(scene->obedit) return; // XXX get from context
        
        if(shift) {
                ob= OBACT;
@@ -5791,7 +5793,7 @@ void image_aspect(Scene *scene, View3D *v3d)
        float x, y, space;
        int a, b, done;
        
-       if(G.obedit) return;
+       if(scene->obedit) return; // XXX get from context
        if(scene->id.lib) return;
        
        for(base= FIRSTBASE; base; base= base->next) {
@@ -6044,7 +6046,7 @@ void texspace_edit(Scene *scene, View3D *v3d)
         * texspacedraw is set:
         */
        
-       if(G.obedit) return;
+       if(scene->obedit) return; // XXX get from context
        
        for(base= FIRSTBASE; base; base= base->next) {
                if(TESTBASELIB(v3d, base)) {
index 397f64dd000510091a6f1576a232d2c9992b887d..c3c45466ac1f4944e831d415cf547e2d8dbc45de 100644 (file)
@@ -613,13 +613,14 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0);
                                
                                if(ob->pose) {
+                                       bArmature *arm= ob->data;
                                        bPoseChannel *pchan;
                                        TreeElement *ten;
                                        TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0);
                                        
                                        tenla->name= "Pose";
                                        
-                                       if(ob!=G.obedit && (ob->flag & OB_POSEMODE)) {  // channels undefined in editmode, but we want the 'tenla' pose icon itself
+                                       if(arm->edbo==NULL && (ob->flag & OB_POSEMODE)) {       // channels undefined in editmode, but we want the 'tenla' pose icon itself
                                                int a= 0, const_index= 1000;    /* ensure unique id for bone constraints */
                                                
                                                for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) {
@@ -895,7 +896,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                bArmature *arm= (bArmature *)id;
                                int a= 0;
                                
-                               if(G.obedit && G.obedit->data==arm) {
+                               if(arm->edbo) {
                                        EditBone *ebone;
                                        TreeElement *ten;
                                        
@@ -1631,7 +1632,7 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
        
        sce= (Scene *)outliner_search_back(soops, te, ID_SCE);
        if(sce && scene != sce) {
-// XXX         if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX         if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                set_scene(sce);
        }
        
@@ -1659,7 +1660,7 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
                        ED_base_object_activate(C, base); /* adds notifier */
        }
        
-// XXX if(ob!=G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX if(ob!=obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
 //     else countall(); /* exit_editmode calls f() */
 }
 
@@ -1811,7 +1812,7 @@ static int tree_element_active_world(Scene *scene, SpaceOops *soops, TreeElement
        
        if(set) {       // make new scene active
                if(sce && scene != sce) {
-// XXX                 if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX                 if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                        set_scene(sce);
                }
        }
@@ -2094,7 +2095,7 @@ static int tree_element_active_pose(TreeElement *te, TreeStoreElem *tselem, int
        Object *ob= (Object *)tselem->id;
        
        if(set) {
-// XXX         if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX         if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
 //             if(ob->flag & OB_POSEMODE) exit_posemode();
 //             else enter_posemode();
        }
@@ -2248,12 +2249,12 @@ static int do_outliner_mouse_event(bContext *C, Scene *scene, ARegion *ar, Space
                                                /* editmode? */
                                                if(te->idcode==ID_SCE) {
                                                        if(scene!=(Scene *)tselem->id) {
-// XXX                                                         if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX                                                         if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                                                                set_scene((Scene *)tselem->id);
                                                        }
                                                }
                                                else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) {
-// XXX                                                 if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX                                                 if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
 //                                                     else {
 //                                                             enter_editmode(EM_WAITCURSOR);
 //                                                             extern_set_butspace(F9KEY, 0);
@@ -2857,7 +2858,7 @@ static void object_delete_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem
        if(base==NULL) base= object_in_scene((Object *)tselem->id, scene);
        if(base) {
                // check also library later
-// XXX         if(G.obedit==base->object) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
+// XXX         if(obedit==base->object) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                
                if(base==BASACT) {
                        G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE);
@@ -3448,7 +3449,7 @@ static void outliner_draw_iconrow(Scene *scene, SpaceOops *soops, ListBase *lb,
                        active= 0;
                        if(tselem->type==0) {
                                if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id);
-                               else if(G.obedit && G.obedit->data==tselem->id) active= 1;
+                               else if(scene->obedit && scene->obedit->data==tselem->id) active= 1;    // XXX use context?
                                else active= tree_element_active(scene, soops, te, 0);
                        }
                        else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0);
@@ -3514,10 +3515,10 @@ static void outliner_draw_tree_element(Scene *scene, ARegion *ar, SpaceOops *soo
                                }
 
                        }
-                       else if(G.obedit && G.obedit->data==tselem->id) {
-                               glColor4ub(255, 255, 255, 100);
-                               active= 2;
-                       }
+// XXX context?                        else if(obedit && obedit->data==tselem->id) {
+//                             glColor4ub(255, 255, 255, 100);
+//                             active= 2;
+//                     }
                        else {
                                if(tree_element_active(scene, soops, te, 0)) {
                                        glColor4ub(220, 220, 255, 100);
@@ -3902,18 +3903,21 @@ static void namebutton_cb(bContext *C, void *tep, void *oldnamep)
                                test_idbutton(tselem->id->name+2);
                                break;
                        case TSE_EBONE:
-                               if(G.obedit && G.obedit->data==(ID *)tselem->id) {
+                       {
+                               bArmature *arm= (bArmature *)tselem->id;
+                               if(arm->edbo) {
                                        EditBone *ebone= te->directdata;
                                        char newname[32];
                                        
                                        /* restore bone name */
                                        BLI_strncpy(newname, ebone->name, 32);
                                        BLI_strncpy(ebone->name, oldnamep, 32);
-// XXX                                 armature_bone_rename(G.obedit->data, oldnamep, newname);
+// XXX                                 armature_bone_rename(obedit->data, oldnamep, newname);
                                }
                                allqueue(REDRAWOOPS, 0);
                                allqueue(REDRAWVIEW3D, 1);
                                allqueue(REDRAWBUTSEDIT, 0);
+                       }
                                break;
 
                        case TSE_BONE:
index c9307f8e1fb3f9593ecfe07a6f5f36a81a4f114f..b1b1f50492063d1c583cd16003acd21eaf85117e 100644 (file)
@@ -2516,8 +2516,8 @@ int draw_armature(Scene *scene, View3D *v3d, Base *base, int dt, int flag)
        
        /* arm->flag is being used to detect mode... */
        /* editmode? */
-       if(ob==G.obedit || (G.obedit && ob->data==G.obedit->data)) {
-               if(ob==G.obedit) arm->flag |= ARM_EDITMODE;
+       if(arm->edbo) {
+               arm->flag |= ARM_EDITMODE;
                draw_ebones(v3d, ob, dt);
                arm->flag &= ~ARM_EDITMODE;
        }
index 53487ca79ff4ec1d6d5dad3c71d9a118454fe8db..ad62329f8fce418dc6eb552d685c8ef3bd822b96 100644 (file)
@@ -340,7 +340,8 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, Object *ob)
        unsigned char obcol[4];
        int istex, solidtex= 0;
 
-       if(v3d->drawtype==OB_SOLID || (ob==G.obedit && v3d->drawtype!=OB_TEXTURE)) {
+       // XXX scene->obedit warning
+       if(v3d->drawtype==OB_SOLID || (ob==scene->obedit && v3d->drawtype!=OB_TEXTURE)) {
                /* draw with default lights in solid draw mode and edit mode */
                solidtex= 1;
                Gtexdraw.islit= -1;
@@ -470,7 +471,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                return;
 
        /* don't draw when editing */
-       if(ob==G.obedit)
+       if(me->edit_mesh)
                return;
        else if(ob==OBACT)
                if(FACESEL_PAINT_TEST)
@@ -568,7 +569,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm,
        draw_textured_end();
        
        /* draw edges and selected faces over textured mesh */
-       if(!G.obedit && faceselect)
+       if(!me->edit_mesh && faceselect)
                draw_tfaces3D(v3d, ob, me, dm);
 
        /* reset from negative scale correction */
index 70435e54e9da3aeb0a904e1f7038595be639c050..963eaf15c488ed34b49ba528921643c2cb7b41e8 100644 (file)
@@ -144,7 +144,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
           (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED));
 }
 
-static int check_material_alpha(Base *base, Object *ob, int glsl)
+static int check_material_alpha(Base *base, Mesh *me, int glsl)
 {
        if(base->flag & OB_FROMDUPLI)
                return 0;
@@ -152,10 +152,10 @@ static int check_material_alpha(Base *base, Object *ob, int glsl)
        if(G.f & G_PICKSEL)
                return 0;
                        
-       if(G.obedit && G.obedit->data==ob->data)
+       if(me->edit_mesh)
                return 0;
        
-       return (glsl || (ob->dtx & OB_DRAWTRANSP));
+       return (glsl || (base->object->dtx & OB_DRAWTRANSP));
 }
 
        /***/
@@ -1084,7 +1084,7 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
 void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPoint *bp, int x, int y), void *userData)
 {
        BPoint *bp = editLatt->def;
-       DispList *dl = find_displist(&G.obedit->disp, DL_VERTS);
+       DispList *dl = find_displist(&vc->obedit->disp, DL_VERTS);
        float *co = dl?dl->verts:NULL;
        float pmat[4][4], vmat[4][4];
        int i, N = editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
@@ -1125,19 +1125,17 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
 /* lattice color is hardcoded, now also shows weightgroup values in edit mode */
 static void drawlattice(View3D *v3d, Object *ob)
 {
-       Lattice *lt;
+       Lattice *lt= ob->data;
        DispList *dl;
        int u, v, w;
        int use_wcol= 0;
 
-       lt= (ob==G.obedit)?editLatt:ob->data;
-       
        /* now we default make displist, this will modifiers work for non animated case */
        if(ob->disp.first==NULL)
                lattice_calc_modifiers(ob);
        dl= find_displist(&ob->disp, DL_VERTS);
        
-       if(ob==G.obedit) {
+       if(lt->editlatt) {
                cpack(0x004000);
                
                if(ob->defbase.first && lt->dvert) {
@@ -1146,6 +1144,8 @@ static void drawlattice(View3D *v3d, Object *ob)
                }
        }
        
+       if(lt->editlatt) lt= lt->editlatt;
+       
        glBegin(GL_LINES);
        for(w=0; w<lt->pntsw; w++) {
                int wxt = (w==0 || w==lt->pntsw-1);
@@ -1175,7 +1175,7 @@ static void drawlattice(View3D *v3d, Object *ob)
        if(use_wcol)
                glShadeModel(GL_FLAT);
 
-       if(ob==G.obedit) {
+       if( ((Lattice *)ob->data)->editlatt ) {
                if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
                
                lattice_draw_verts(lt, dl, 0);
@@ -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(vc->em, CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->obedit, 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(vc->em, CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->obedit, 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(vc->em, CD_MASK_BAREMESH);
+       DerivedMesh *dm = editmesh_get_derived_cage(vc->obedit, vc->em, CD_MASK_BAREMESH);
 
        data.vc= *vc;
        data.func = func;
@@ -1648,7 +1648,7 @@ static void draw_dm_bweights(Scene *scene, DerivedMesh *dm)
 
 /* EditMesh drawing routines*/
 
-static void draw_em_fancy_verts(Scene *scene, View3D *v3d, EditMesh *em, DerivedMesh *cageDM, EditVert *eve_act)
+static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, EditMesh *em, DerivedMesh *cageDM, EditVert *eve_act)
 {
        int sel;
 
@@ -1687,7 +1687,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, EditMesh *em, Derived
                                draw_dm_verts(cageDM, sel, eve_act);
                        }
                        
-                       if( CHECK_OB_DRAWFACEDOT(scene, v3d, G.obedit->dt) ) {
+                       if( CHECK_OB_DRAWFACEDOT(scene, v3d, obedit->dt) ) {
                                glPointSize(fsize);
                                glColor4ubv((GLubyte *)fcol);
                                draw_dm_face_centers(cageDM, sel);
@@ -2083,10 +2083,10 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, Object *ob, EditMesh *em, D
        
                draw_em_fancy_edges(scene, v3d, cageDM, 0, eed_act);
        }
-       if(ob==G.obedit) {
+       if(em) {
 // XXX         retopo_matrix_update(v3d);
 
-               draw_em_fancy_verts(scene, v3d, em, cageDM, eve_act);
+               draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act);
 
                if(G.f & G_DRAWNORMALS) {
                        UI_ThemeColor(TH_NORMAL);
@@ -2354,22 +2354,23 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, Base *base, int dt, int f
 static int draw_mesh_object(Scene *scene, View3D *v3d, Base *base, int dt, int flag)
 {
        Object *ob= base->object;
+       Object *obedit= scene->obedit; // XXX hrumf, see below
        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) {
+       if(obedit && ob!=obedit && ob->data==obedit->data) {
                if(ob_get_key(ob));
                else drawlinked= 1;
        }
        
-       if(ob==G.obedit || drawlinked) {
+       if(ob==obedit || drawlinked) {
                DerivedMesh *finalDM, *cageDM;
                
-               if (G.obedit!=ob)
-                       finalDM = cageDM = editmesh_get_derived_base(em);
+               if (obedit!=ob)
+                       finalDM = cageDM = editmesh_get_derived_base(ob, em);
                else
-                       cageDM = editmesh_get_derived_cage_and_final(em, &finalDM,
+                       cageDM = editmesh_get_derived_cage_and_final(ob, em, &finalDM,
                                                        get_viewedit_datamask());
 
                if(dt>OB_WIRE) {
@@ -2380,10 +2381,10 @@ static int draw_mesh_object(Scene *scene, View3D *v3d, Base *base, int dt, int f
 
                draw_em_fancy(scene, v3d, ob, em, cageDM, finalDM, dt);
 
-               if (G.obedit!=ob && finalDM)
+               if (obedit!=ob && finalDM)
                        finalDM->release(finalDM);
        }
-//     else if(!G.obedit && (G.f & G_SCULPTMODE) &&(scene->sculptdata.flags & SCULPT_DRAW_FAST) &&
+//     else if(!em && (G.f & G_SCULPTMODE) &&(scene->sculptdata.flags & SCULPT_DRAW_FAST) &&
 //             OBACT==ob && !sculpt_modifiers_active(ob)) {
 // XXX         sculptmode_draw_mesh(0);
 //     }
@@ -2391,7 +2392,7 @@ static int draw_mesh_object(Scene *scene, View3D *v3d, Base *base, int dt, int f
                /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */
                if(me->totface<=4 || boundbox_clip(v3d, ob->obmat, (ob->bb)? ob->bb: me->bb)) {
                        glsl = draw_glsl_material(scene, ob, v3d, dt);
-                       check_alpha = check_material_alpha(base, ob, glsl);
+                       check_alpha = check_material_alpha(base, me, glsl);
 
                        if(dt==OB_SOLID || glsl) {
                                GPU_set_object_materials(v3d, scene, ob, glsl,
@@ -2721,7 +2722,7 @@ static int drawDispList(Scene *scene, View3D *v3d, Base *base, int dt)
                                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
                                        drawDispListsolid(lb, ob, 0);
                                }
-                               if(ob==G.obedit && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0 && cu->ext2 == 0.0) {
+                               if(cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0 && cu->ext2 == 0.0) {
                                        cpack(0);
                                        draw_index_wire= 0;
                                        drawDispListwire(lb);
@@ -2844,7 +2845,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, Base *base, Part
 
        if(pars==0) return;
 
-       if(!G.obedit && psys_in_edit_mode(psys)
+       // XXX what logic is this?
+       if(!scene->obedit && psys_in_edit_mode(psys)
                && psys->flag & PSYS_HAIR_DONE && part->draw_as==PART_DRAW_PATH)
                return;
                
@@ -4175,10 +4177,10 @@ static int drawmball(Scene *scene, View3D *v3d, Base *base, int dt)
        
        mb= ob->data;
 
-       if(ob==G.obedit) {
+       if(mb->editelems) {
                UI_ThemeColor(TH_WIRE);
                if((G.f & G_PICKSEL)==0 ) drawDispList(scene, v3d, base, dt);
-               ml= editelems.first;
+               ml= mb->editelems->first;
        }
        else {
                if((base->flag & OB_FROMDUPLI)==0) 
@@ -4189,7 +4191,7 @@ static int drawmball(Scene *scene, View3D *v3d, Base *base, int dt)
        if(ml==NULL) return 1;
        
        /* in case solid draw, reset wire colors */
-       if(ob!=G.obedit && (ob->flag & SELECT)) {
+       if(mb->editelems && (ob->flag & SELECT)) {
                if(ob==OBACT) UI_ThemeColor(TH_ACTIVE);
                else UI_ThemeColor(TH_SELECT);
        }
@@ -4203,7 +4205,7 @@ static int drawmball(Scene *scene, View3D *v3d, Base *base, int dt)
        while(ml) {
        
                /* draw radius */
-               if(ob==G.obedit) {
+               if(mb->editelems) {
                        if((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0);
                        else cpack(0x3030A0);
                        
@@ -4215,7 +4217,7 @@ static int drawmball(Scene *scene, View3D *v3d, Base *base, int dt)
                drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad, imat);
 
                /* draw stiffness */
-               if(ob==G.obedit) {
+               if(mb->editelems) {
                        if((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0);
                        else cpack(0x30A030);
                        
@@ -4242,7 +4244,8 @@ static void draw_forcefield(Scene *scene, Object *ob)
        if(G.f & G_RENDER_SHADOW)
                return;
        
-       if(ob!=G.obedit && (ob->flag & SELECT)) {
+       /* XXX why? */
+       if(ob!=scene->obedit && (ob->flag & SELECT)) {
                if(ob==OBACT) curcol= TH_ACTIVE;
                else curcol= TH_SELECT;
        }
@@ -4575,7 +4578,8 @@ static void drawSolidSelect(Scene *scene, View3D *v3d, Base *base)
 
 static void drawWireExtra(Scene *scene, View3D *v3d, Object *ob) 
 {
-       if(ob!=G.obedit && (ob->flag & SELECT)) {
+       // XXX scene->obedit warning
+       if(ob!=scene->obedit && (ob->flag & SELECT)) {
                if(ob==OBACT) {
                        if(ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP_ACTIVE);
                        else UI_ThemeColor(TH_ACTIVE);
@@ -4705,7 +4709,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
        ob= base->object;
 
-       if (ob!=G.obedit) {
+       /* XXX ermfh... */
+       if (ob!=scene->obedit) {
                if (ob->restrictflag & OB_RESTRICT_VIEW) 
                        return;
        }
@@ -4724,7 +4729,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
        /* draw keys? */
        if(base==(scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) {
-               if(flag==0 && warning_recursive==0 && ob!=G.obedit) {
+               if(flag==0 && warning_recursive==0 && ob!=scene->obedit) {
                        if(ob->ipo && ob->ipo->showkey && (ob->ipoflag & OB_DRAWKEY)) {
                                ListBase elems;
                                CfraElem *ce;
@@ -4856,7 +4861,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        if(ob==OBACT && (G.f & (G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT))) {
                if(ob->type==OB_MESH) {
 
-                       if(ob==G.obedit);
+                       if(ob==scene->obedit);
                        else {
                                if(dt<OB_SOLID)
                                        zbufoff= 1;
@@ -4878,7 +4883,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        if(dt>=OB_BOUNDBOX ) {
 
                dtx= ob->dtx;
-               if(G.obedit==ob) {
+               if(scene->obedit==ob) {
                        // the only 2 extra drawtypes alowed in editmode
                        dtx= dtx & (OB_DRAWWIRE|OB_TEXSPACE);
                }
@@ -4890,7 +4895,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
        /* draw outline for selected solid objects, mesh does itself */
        if((v3d->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
-               if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit && (flag && DRAW_SCENESET)==0) {
+               if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=scene->obedit && (flag && DRAW_SCENESET)==0) {
                        if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(flag&DRAW_PICKING)) {
                                drawSolidSelect(scene, v3d, base);
                        }
@@ -4908,7 +4913,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                case OB_FONT:
                        cu= ob->data;
                        if (cu->disp.first==NULL) makeDispListCurveTypes(ob, 0);
-                       if(ob==G.obedit) {
+                       if(cu->editstr) {
                                tekentextcurs();
 
                                if (cu->flag & CU_FAST) {
@@ -4963,7 +4968,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                                setlinestyle(0);
 
 
-                               if (getselection(&selstart, &selend) && selboxes) {
+                               if (getselection(ob, &selstart, &selend) && selboxes) {
                                        float selboxw;
 
                                        cpack(0xffffff);
@@ -5002,8 +5007,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
                        if (cu->disp.first==NULL) makeDispListCurveTypes(ob, 0);
 
-                       if(ob==G.obedit) {
-                               drawnurb(scene, v3d, base, editNurb.first, dt);
+                       if(cu->editnurb) {
+                               drawnurb(scene, v3d, base, cu->editnurb->first, dt);
                        }
                        else if(dt==OB_BOUNDBOX) 
                                draw_bounding_volume(ob);
@@ -5015,13 +5020,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        }                       
                        break;
                case OB_MBALL:
-                       if(ob==G.obedit) 
+               {
+                       MetaBall *mb= ob->data;
+                       
+                       if(mb->editelems) 
                                drawmball(scene, v3d, base, dt);
                        else if(dt==OB_BOUNDBOX) 
                                draw_bounding_volume(ob);
                        else 
                                empty_object= drawmball(scene, v3d, base, dt);
                        break;
+               }
                case OB_EMPTY:
                        drawaxes(ob->empty_drawsize, flag, ob->empty_drawtype);
                        break;
@@ -5049,7 +5058,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
        if(             (warning_recursive==0) &&
                        (ob->particlesystem.first) &&
                        (flag & DRAW_PICKING)==0 &&
-                       (ob!=G.obedit)  
+                       (ob!=scene->obedit)     
          ) {
                ParticleSystem *psys;
                if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
@@ -5060,7 +5069,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                
                if(G.f & G_PARTICLEEDIT && ob==OBACT) {
                        psys= NULL; // XXX PE_get_current(ob);
-                       if(psys && !G.obedit && psys_in_edit_mode(psys))
+                       if(psys && !scene->obedit && psys_in_edit_mode(psys))
                                draw_particle_edit(scene, v3d, ob, psys, dt);
                }
                glDepthMask(GL_TRUE); 
@@ -5156,10 +5165,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                ListBase *list;
                
                /* draw hook center and offset line */
-               if(ob!=G.obedit) draw_hooks(ob);
+               if(ob!=scene->obedit) draw_hooks(ob);
                
                /* help lines and so */
-               if(ob!=G.obedit && ob->parent && (ob->parent->lay & v3d->lay)) {
+               if(ob!=scene->obedit && ob->parent && (ob->parent->lay & v3d->lay)) {
                        setlinestyle(3);
                        glBegin(GL_LINES);
                        glVertex3fv(ob->obmat[3]);
@@ -5317,14 +5326,14 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, float *cent, f
 }
 
 /* two options, facecolors or black */
-static int bbs_mesh_solid_EM(Scene *scene, View3D *v3d, DerivedMesh *dm, int facecol)
+static int bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol)
 {
        cpack(0);
 
        if (facecol) {
                dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0);
 
-               if( CHECK_OB_DRAWFACEDOT(scene, v3d, G.obedit->dt) ) {
+               if( CHECK_OB_DRAWFACEDOT(scene, v3d, ob->dt) ) {
                        glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
                
                        bglBegin(GL_POINTS);
@@ -5373,14 +5382,15 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, Object *ob)
 
        switch( ob->type) {
        case OB_MESH:
-               if(ob==G.obedit) {
-                       Mesh *me= ob->data;
-                       EditMesh *em= me->edit_mesh;
-                       DerivedMesh *dm = editmesh_get_derived_cage(em, CD_MASK_BAREMESH);
+       {
+               Mesh *me= ob->data;
+               EditMesh *em= me->edit_mesh;
+               if(em) {
+                       DerivedMesh *dm = editmesh_get_derived_cage(ob, em, CD_MASK_BAREMESH);
 
                        EM_init_index_arrays(em, 1, 1, 1);
 
-                       em_solidoffs= bbs_mesh_solid_EM(scene, v3d, dm, scene->selectmode & SCE_SELECT_FACE);
+                       em_solidoffs= bbs_mesh_solid_EM(scene, v3d, ob, dm, scene->selectmode & SCE_SELECT_FACE);
                        
                        bglPolygonOffset(v3d->dist, 1.0);
                        
@@ -5399,7 +5409,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, Object *ob)
                        EM_free_index_arrays();
                }
                else bbs_mesh_solid(ob);
-
+       }
                break;
        case OB_CURVE:
        case OB_SURF:
@@ -5421,7 +5431,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, Object *ob, int
        int glsl;
        
        if(me->edit_mesh)
-               edm= editmesh_get_derived_base(me->edit_mesh);
+               edm= editmesh_get_derived_base(ob, me->edit_mesh);
        else 
                dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
 
index 232b9d9d97475b76b06649e0668e17a237b80085..a70a6ab8fd8b45c0694ef79c7150b7444c02173f 100644 (file)
@@ -351,10 +351,6 @@ static int view3d_context(const bContext *C, const bContextDataMember *member, b
 
                return 1;
        }
-       else if(member == CTX_data_edit_object) {
-               CTX_data_pointer_set(result, G.obedit);
-               return 1;
-       }
 
        return 0;
 }
index ad18f6675a38b75999a6c28f2bb6d8c467367159..90840533d5571e0193b3b3a306bed6ee6e67a9c9 100644 (file)
@@ -370,7 +370,7 @@ static void drawgrid(ARegion *ar, View3D *v3d)
 }
 
 
-static void drawfloor(View3D *v3d)
+static void drawfloor(Scene *scene, View3D *v3d)
 {
        float vert[3], grid;
        int a, gridlines, emphasise;
@@ -381,7 +381,7 @@ static void drawfloor(View3D *v3d)
        
        if(v3d->gridlines<3) return;
        
-       if(v3d->zbuf && G.obedit) glDepthMask(0);       // for zbuffer-select
+       if(v3d->zbuf && scene->obedit) glDepthMask(0);  // for zbuffer-select
        
        gridlines= v3d->gridlines/2;
        grid= gridlines*v3d->grid;
@@ -489,7 +489,7 @@ static void drawfloor(View3D *v3d)
                glEnd();
        }
        
-       if(v3d->zbuf && G.obedit) glDepthMask(1);       
+       if(v3d->zbuf && scene->obedit) glDepthMask(1);  
        
 }
 
@@ -740,7 +740,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d)
                        char *name= NULL;
                        
                        /* show name of active bone too (if possible) */
-                       if(ob==G.obedit) {
+                       if(arm->edbo) {
 //     XXX                     EditBone *ebo;
 //                             for (ebo=G.edbo.first; ebo; ebo=ebo->next){
 //                                     if ((ebo->flag & BONE_ACTIVE) && (ebo->layer & arm->layer)) {
@@ -1055,7 +1055,7 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
 #endif
 
        if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || G.f & G_TEXTUREPAINT);
-       else if(G.obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
+       else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
        else {
                v3d->flag &= ~V3D_NEEDBACKBUFDRAW;
                return;
@@ -1081,7 +1081,6 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
 #endif
 
        if(v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE;
-//     ar->win_swap &= ~WIN_BACK_OK;
        
        glDisable(GL_DITHER);
 
@@ -1872,7 +1871,7 @@ void drawview3dspace(Scene *scene, ARegion *ar, View3D *v3d)
        v3d->gridview= v3d->grid;
        
        if(v3d->view==0 || v3d->persp!=0) {
-               drawfloor(v3d);
+               drawfloor(scene, v3d);
                if(v3d->persp==2) {
                        if(scene->world) {
                                if(scene->world->mode & WO_STARS) {
@@ -1927,21 +1926,21 @@ void drawview3dspace(Scene *scene, ARegion *ar, View3D *v3d)
                                draw_dupli_objects(scene, ar, v3d, base);
                        }
                        if((base->flag & SELECT)==0) {
-                               if(base->object!=G.obedit) 
+                               if(base->object!=scene->obedit) 
                                        draw_object(scene, ar, v3d, base, 0);
                        }
                }
        }
        
 //     retopo= retopo_mesh_check() || retopo_curve_check();
-//     sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !G.obedit;
+//     sculptparticle= (G.f & (G_SCULPTMODE|G_PARTICLEEDIT)) && !obedit;
        if(retopo)
                view3d_update_depths(ar, v3d);
        
        /* draw selected and editmode */
        for(base= scene->base.first; base; base= base->next) {
                if(v3d->lay & base->lay) {
-                       if (base->object==G.obedit || ( base->flag & SELECT) ) 
+                       if (base->object==scene->obedit || ( base->flag & SELECT) ) 
                                draw_object(scene, ar, v3d, base, 0);
                }
        }
@@ -1954,7 +1953,7 @@ void drawview3dspace(Scene *scene, ARegion *ar, View3D *v3d)
        
        if(G.moving) {
 //             BIF_drawConstraint();
-//             if(G.obedit || (G.f & G_PARTICLEEDIT))
+//             if(obedit || (G.f & G_PARTICLEEDIT))
 //                     BIF_drawPropCircle(); // only editmode and particles have proportional edit
 //             BIF_drawSnap();
        }
@@ -2025,7 +2024,7 @@ void drawview3dspace(Scene *scene, ARegion *ar, View3D *v3d)
                // XXX addafterqueue(ar->win, BACKBUFDRAW, 1);
        }
        // test for backbuf select
-       if(G.obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) {
+       if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT)) {
                
                v3d->flag |= V3D_NEEDBACKBUFDRAW;
                // XXX if(afterqtest(ar->win, BACKBUFDRAW)==0) {
index a5b9e4832013f28641fcd8c04cc7b682aad0f6cd..a5ea2a83b77c25b04da52f597770ae9fd4b1d5e6 100644 (file)
@@ -755,6 +755,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
        View3D *v3d= sa->spacedata.first;
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
+       Object *obedit= CTX_data_edit_object(C);
        float size, min[3], max[3], afm[3];
        int ok=0;
 
@@ -780,7 +781,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
        }
 
 
-       if(G.obedit) {
+       if(obedit) {
 // XXX         ok = minmax_verts(min, max);    /* only selected */
        }
        else if(ob && (ob->flag & OB_POSEMODE)) {
@@ -1452,12 +1453,12 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
        ARegion *ar= CTX_wm_region(C);
        View3D *v3d= (View3D *)CTX_wm_space_data(C);
        float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
-       short mx, my, lr_click=0, mval[2];
-       short ctrl= 0; // XXX
+       short mx, my, mval[2];
+//     short ctrl= 0; // XXX
        
        fp= give_cursor(scene, v3d);
        
-       if(G.obedit && ctrl) lr_click= 1;
+//     if(obedit && ctrl) lr_click= 1;
        VECCOPY(oldcurs, fp);
        
        mx= event->x - ar->winrct.xmin;
@@ -1484,12 +1485,12 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
                fp[2]= (v3d->persinv[0][2]*dx + v3d->persinv[1][2]*dy+ v3d->persinv[2][2]*fz)-v3d->ofs[2];
        }
        
-       if(lr_click) {
-               // XXX          if(G.obedit->type==OB_MESH) add_click_mesh();
-               //              else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
-               //              else if (G.obedit->type==OB_ARMATURE) addvert_armature();
-               VECCOPY(fp, oldcurs);
-       }
+//     if(lr_click) {
+               // XXX          if(obedit->type==OB_MESH) add_click_mesh();
+               //              else if ELEM(obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
+               //              else if (obedit->type==OB_ARMATURE) addvert_armature();
+//             VECCOPY(fp, oldcurs);
+//     }
        // XXX notifier for scene */
        ED_region_tag_redraw(ar);
        
@@ -1812,7 +1813,7 @@ void viewmoveNDOF(Scene *scene, View3D *v3d, int mode)
        v3d->view = 0;
 //printf("passing here \n");
 //
-       if (G.obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) {
+       if (scene->obedit==NULL && ob && !(ob->flag & OB_POSEMODE)) {
                use_sel = 1;
        }
 
index 06eb00d75c8db8bd53da8501b349ef0d48360af2..3de551a516a0949f09b451ae623eee717f0b41b3 100644 (file)
@@ -73,6 +73,7 @@
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
+#include "BIF_transform.h"
 
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
@@ -5445,7 +5446,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event)
                                em->selectmode= SCE_SELECT_VERTEX;
                        scene->selectmode= em->selectmode;
                        EM_selectmode_set(em);
-                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
                        ED_undo_push(C, "Selectmode Set: Vertex");
                }
                break;
@@ -5459,7 +5460,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event)
                        }
                        scene->selectmode= em->selectmode;
                        EM_selectmode_set(em);
-                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
                        ED_undo_push(C, "Selectmode Set: Edge");
                }
                break;
@@ -5473,7 +5474,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event)
                        }
                        scene->selectmode= em->selectmode;
                        EM_selectmode_set(em);
-                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
                        ED_undo_push(C, "Selectmode Set: Face");
                }
                break;  
index 33ac9a649682fcf3a020118f1c9f367b76a9915d..8fa54c7c7addcc1b93772f2825adb02e940067e4 100644 (file)
@@ -569,10 +569,10 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m
        for (ebone=G.edbo.first; ebone; ebone=ebone->next) {
 
                VECCOPY(vec, ebone->head);
-               Mat4MulVecfl(G.obedit->obmat, vec);
+               Mat4MulVecfl(vc->obedit->obmat, vec);
                project_short(vc->ar, vc->v3d, vec, sco1);
                VECCOPY(vec, ebone->tail);
-               Mat4MulVecfl(G.obedit->obmat, vec);
+               Mat4MulVecfl(vc->obedit->obmat, vec);
                project_short(vc->ar, vc->v3d, vec, sco2);
                
                didpoint= 0;
@@ -649,7 +649,7 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select)
 
 void view3d_lasso_select(ViewContext *vc, short mcords[][2], short moves, short select)
 {
-       if(G.obedit==NULL) {
+       if(vc->obedit==NULL) {
                if(FACESEL_PAINT_TEST)
                        do_lasso_select_facemode(vc, mcords, moves, select);
                else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))
@@ -659,13 +659,13 @@ void view3d_lasso_select(ViewContext *vc, short mcords[][2], short moves, short
                else  
                        do_lasso_select_objects(vc, mcords, moves, select);
        }
-       else if(G.obedit->type==OB_MESH) {
+       else if(vc->obedit->type==OB_MESH) {
                do_lasso_select_mesh(vc, mcords, moves, select);
-       } else if(G.obedit->type==OB_CURVE || G.obedit->type==OB_SURF) 
+       } else if(vc->obedit->type==OB_CURVE || vc->obedit->type==OB_SURF) 
                do_lasso_select_curve(vc, mcords, moves, select);
-       else if(G.obedit->type==OB_LATTICE) 
+       else if(vc->obedit->type==OB_LATTICE) 
                do_lasso_select_lattice(vc, mcords, moves, select);
-       else if(G.obedit->type==OB_ARMATURE)
+       else if(vc->obedit->type==OB_ARMATURE)
                do_lasso_select_armature(vc, mcords, moves, select);
 
        BIF_undo_push("Lasso select");
@@ -934,7 +934,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter)
        
        /* This block uses the control key to make the object selected by its center point rather then its contents */
        /* XXX later on, in editmode do not activate */
-       if(G.obedit==NULL && obcenter) {
+       if(vc.obedit==NULL && obcenter) {
                
                /* note; shift+alt goes to group-flush-selecting */
                /* XXX solve */
@@ -1088,7 +1088,7 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter)
        /* so, do we have something selected? */
        if(basact) {
                
-               if(G.obedit) {
+               if(vc.obedit) {
                        /* only do select */
                        deselectall_except(scene, basact);
                        ED_base_object_select(basact, BA_SELECT);
@@ -1287,6 +1287,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        ScrArea *sa= CTX_wm_area(C);
        View3D *v3d= sa->spacedata.first;
+       Object *obedit= CTX_data_edit_object(C);
        rcti rect;
        Base *base;
        MetaElem *ml;
@@ -1305,29 +1306,29 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
        rect.xmax= RNA_int_get(op->ptr, "xmax");
        rect.ymax= RNA_int_get(op->ptr, "ymax");
        
-       if(G.obedit==NULL && (FACESEL_PAINT_TEST)) {
+       if(obedit==NULL && (FACESEL_PAINT_TEST)) {
 // XXX         face_borderselect();
                return OPERATOR_FINISHED;
        }
-       else if(G.obedit==NULL && (G.f & G_PARTICLEEDIT)) {
+       else if(obedit==NULL && (G.f & G_PARTICLEEDIT)) {
 // XXX         PE_borderselect();
                return OPERATOR_FINISHED;
        }
        
-       if(G.obedit) {
-               if(G.obedit->type==OB_MESH) {
-                       Mesh *me= G.obedit->data;
+       if(obedit) {
+               if(obedit->type==OB_MESH) {
+                       Mesh *me= obedit->data;
                        vc.em= me->edit_mesh;
                        do_mesh_box_select(&vc, &rect, (val==LEFTMOUSE));
 //                     if (EM_texFaceCheck())
-                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
                        
                }
-               else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
+               else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) {
                        do_nurbs_box_select(&vc, &rect, val==LEFTMOUSE);
 //                     allqueue(REDRAWVIEW3D, 0);
                }
-               else if(G.obedit->type==OB_MBALL) {
+               else if(obedit->type==OB_MBALL) {
                        hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
                        
                        ml= NULL; // XXX editelems.first;
@@ -1350,7 +1351,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
                                ml= ml->next;
                        }
                }
-               else if(G.obedit->type==OB_ARMATURE) {
+               else if(obedit->type==OB_ARMATURE) {
                        EditBone *ebone;
                        
                        /* clear flag we use to detect point was affected */
@@ -1403,7 +1404,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
                        }
                        
                }
-               else if(G.obedit->type==OB_LATTICE) {
+               else if(obedit->type==OB_LATTICE) {
                        do_lattice_box_select(&vc, &rect, val==LEFTMOUSE);
                }
        }
index 1949db88d280910ca3c4f8f86dae040730022429..1986203f8399416f0f8fb14e9f1f91200eaeedb8 100644 (file)
@@ -1018,10 +1018,10 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b
        glPushName(-1);
        code= 1;
        
-       if(G.obedit && G.obedit->type==OB_MBALL) {
+       if(vc->obedit && vc->obedit->type==OB_MBALL) {
                draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
        }
-       else if ((G.obedit && G.obedit->type==OB_ARMATURE)) {
+       else if ((vc->obedit && vc->obedit->type==OB_ARMATURE)) {
                draw_object(scene, ar, v3d, BASACT, DRAW_PICKING|DRAW_CONSTCOLOR);
        }
        else {
@@ -1139,13 +1139,13 @@ void initlocalview(Scene *scene, ARegion *ar, View3D *v3d)
                ok= 0;
        }
        else {
-               if(G.obedit) {
-                       minmax_object(G.obedit, min, max);
+               if(scene->obedit) {
+                       minmax_object(scene->obedit, min, max);
                        
                        ok= 1;
                
                        BASACT->lay |= locallay;
-                       G.obedit->lay= BASACT->lay;
+                       scene->obedit->lay= BASACT->lay;
                }
                else {
                        base= FIRSTBASE;
@@ -1203,7 +1203,7 @@ void initlocalview(Scene *scene, ARegion *ar, View3D *v3d)
                        if( base->lay & locallay ) {
                                base->lay-= locallay;
                                if(base->lay==0) base->lay= v3d->layact;
-                               if(base->object != G.obedit) base->flag |= SELECT;
+                               if(base->object != scene->obedit) base->flag |= SELECT;
                                base->object->lay= base->lay;
                        }
                        base= base->next;
@@ -1260,7 +1260,7 @@ void endlocalview(Scene *scene, ScrArea *sa)
                        if( base->lay & locallay ) {
                                base->lay-= locallay;
                                if(base->lay==0) base->lay= v3d->layact;
-                               if(base->object != G.obedit) {
+                               if(base->object != scene->obedit) {
                                        base->flag |= SELECT;
                                        base->object->flag |= SELECT;
                                }
index b7322e3142e83a9cf5e5921bb5721c21dc280dc4..584e2e9c4c1e916ad62c4ea857c7ee9c225caf6b 100644 (file)
@@ -132,7 +132,7 @@ static void helpline(TransInfo *t, float *vec)
        
        VECCOPY(vecrot, vec);
        if(t->flag & T_EDIT) {
-               Object *ob=G.obedit;
+               Object *ob= t->obedit;
                if(ob) Mat4MulVecfl(ob->obmat, vecrot);
        }
        else if(t->flag & T_POSE) {
@@ -1126,8 +1126,8 @@ void initManipulator(int mode)
        Trans.mode = mode;
        
        /* automatic switch to scaling bone envelopes */
-       if(mode==TFM_RESIZE && G.obedit && G.obedit->type==OB_ARMATURE) {
-               bArmature *arm= G.obedit->data;
+       if(mode==TFM_RESIZE && t->obedit && t->obedit->type==OB_ARMATURE) {
+               bArmature *arm= t->obedit->data;
                if(arm->drawtype==ARM_ENVELOPE)
                        mode= TFM_BONE_ENVELOPE;
        }
@@ -1721,8 +1721,8 @@ int Warp(TransInfo *t, short mval[2])
        VECCOPY(cursor, curs);
        VECCOPY(gcursor, cursor);       
        if (t->flag & T_EDIT) {
-               VecSubf(cursor, cursor, G.obedit->obmat[3]);
-               VecSubf(gcursor, gcursor, G.obedit->obmat[3]);
+               VecSubf(cursor, cursor, t->obedit->obmat[3]);
+               VecSubf(gcursor, gcursor, t->obedit->obmat[3]);
                Mat3MulVecfl(t->data->smtx, gcursor);
        }
        Mat4MulVecfl(t->viewmat, cursor);
@@ -1894,7 +1894,7 @@ int Shear(TransInfo *t, short mval[2])
                if (td->flag & TD_SKIP)
                        continue;
 
-               if (G.obedit) {
+               if (t->obedit) {
                        float mat3[3][3];
                        Mat3MulMat3(mat3, totmat, td->mtx);
                        Mat3MulMat3(tmat, td->smtx, mat3);
@@ -1937,7 +1937,7 @@ void initResize(TransInfo *t)
        t->flag |= T_NULL_ONE;
        t->num.flag |= NUM_NULL_ONE;
        t->num.flag |= NUM_AFFECT_ALL;
-       if (!G.obedit) {
+       if (!t->obedit) {
                t->flag |= T_NO_ZERO;
                t->num.flag |= NUM_NO_ZERO;
        }
@@ -2916,7 +2916,7 @@ int Translation(TransInfo *t, short mval[2])
 void initShrinkFatten(TransInfo *t) 
 {
        // If not in mesh edit mode, fallback to Resize
-       if (G.obedit==NULL || G.obedit->type != OB_MESH) {
+       if (t->obedit==NULL || t->obedit->type != OB_MESH) {
                initResize(t);
        }
        else {
@@ -3834,7 +3834,7 @@ void initMirror(TransInfo *t)
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
 
        t->flag |= T_NULL_ONE;
-       if (!G.obedit) {
+       if (!t->obedit) {
                t->flag |= T_NO_ZERO;
        }
 }
index 94c4ffa1497aa11ef8fe8d1ddbc45bfdc3e0477c..cdde416ef9ab4f9f560f012d6171fccfa4a87b2b 100644 (file)
@@ -489,7 +489,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
 void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
        if (t->flag & T_EDIT) {
                float obmat[3][3];
-               Mat3CpyMat4(obmat, G.obedit->obmat);
+               Mat3CpyMat4(obmat, t->scene->obedit->obmat);
                setConstraint(t, obmat, mode|CON_LOCAL, text);
        }
        else {
@@ -748,8 +748,8 @@ void BIF_drawPropCircle()
                BIF_ThemeColor(TH_GRID);
                
                /* if editmode we need to go into object space */
-               if(G.obedit && t->spacetype == SPACE_VIEW3D)
-                       mymultmatrix(G.obedit->obmat);
+               if(t->scene->obedit && t->spacetype == SPACE_VIEW3D)
+                       mymultmatrix(t->scene->obedit->obmat);
                
                mygetmatrix(tmat);
                Mat4Invert(imat, tmat);
@@ -759,7 +759,7 @@ void BIF_drawPropCircle()
                set_inverted_drawing(0);
                
                /* if editmode we restore */
-               if(G.obedit && t->spacetype == SPACE_VIEW3D)
+               if(t->scene->obedit && t->spacetype == SPACE_VIEW3D)
                        myloadmatrix(G.vd->viewmat);
 #endif
        }
index de368dcd1dc5ffba2084bc326bcf5cb6dbd0aa2f..020d5143911e80903ed4ed7802995261ac2a2457 100644 (file)
@@ -1968,7 +1968,7 @@ static float *get_crazy_mapped_editverts(TransInfo *t)
        }
 
        /* now get the cage */
-       dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH);
+       dm= editmesh_get_derived_cage(t->obedit, me->edit_mesh, CD_MASK_BAREMESH);
 
        vertexcos= MEM_mallocN(3*sizeof(float)*G.totvert, "vertexcos map");
        dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos);
@@ -2183,7 +2183,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
                        if(modifiers_isDeformed(t->obedit)) {
                                /* check if we can use deform matrices for modifier from the
                                   start up to stack, they are more accurate than quats */
-                               totleft= editmesh_get_first_deform_matrices(em, &defmats, &defcos);
+                               totleft= editmesh_get_first_deform_matrices(t->obedit, em, &defmats, &defcos);
 
                                /* if we still have more modifiers, also do crazyspace
                                   correction with quats, relative to the coordinates after
@@ -3950,8 +3950,7 @@ static void recalc_all_ipos(void)
 void special_aftertrans_update(TransInfo *t)
 {
        Object *ob;
-       Base *base;
-       short redrawipo=0, resetslowpar=1;
+//     short redrawipo=0, resetslowpar=1;
        int cancelled= (t->state == TRANS_CANCEL);
        short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0;
        
@@ -4000,7 +3999,6 @@ void special_aftertrans_update(TransInfo *t)
                        for (ale= anim_data.first; ale; ale= ale->next) {
                                Object *nob= ANIM_nla_mapping_get(&ac, ale);
                                Ipo *ipo= ale->key_data;
-                               IpoCurve *icu;
                                
                                if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && 
                                     ((cancelled == 0) || (duplicate)) )
index 56aad813b50b0117d95f43a302aabe031886f6aa..5d96b16751c305464e4819e0d9da9ec1c705a292 100644 (file)
@@ -241,7 +241,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
        }
 }
 
-/* assumes G.obedit set to mesh object */
+/* assumes obedit set to mesh object */
 static void editmesh_apply_to_mirror(TransInfo *t)
 {
        TransData *td = t->data;
@@ -429,8