diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-31 20:11:42 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-31 20:11:42 +0300 |
commit | c9b60a7b64c75bf999cb8390b328aa42e7a5f53f (patch) | |
tree | ebd8dc28b62913d6fa7d675c6d21ac31c5c3119e /source/blender/editors/transform | |
parent | b65a3e9337ac1d9c3870e0e04ee96090bc7e9b23 (diff) |
2.5
So, editmode mesh is back! :)
At the moment only TABkey works and mouse select, 1 vertex at a
time. More will follow of course.
Note for the devs:
- G.editMesh has been removed, be careful with old code.
- EditMesh now is property of Mesh itself
Although it means unlimited editmodes, for migration purposes we
better stick to 1 "obedit" per scene, which is in Context too
- G.obedit will get removed soon, so use CTX_data_edit_object(C)
Or if you can't, just scene->obedit for now
- Also removed the CTX_data_edit_mesh(), this has no meaning
anymore. EditMesh is not context senstitive anymore, only the
edit-object for time being is.
- Martin: I've already tucked some EditMesh pointer in T and
removed all G.editMesh there.
Diffstat (limited to 'source/blender/editors/transform')
7 files changed, 40 insertions, 34 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index bb333b2cfbb..b6212751c61 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -79,6 +79,7 @@ #include "BKE_action.h" /* get_action_frame */ //#include "BKE_bad_level_calls.h"/* popmenu and error */ #include "BKE_bmesh.h" +#include "BKE_context.h" #include "BKE_constraint.h" #include "BKE_global.h" #include "BKE_particle.h" @@ -94,6 +95,7 @@ #include "ED_view3d.h" #include "ED_screen.h" +#include "ED_util.h" #include "UI_view2d.h" #include "WM_types.h" @@ -1077,7 +1079,7 @@ void transformApply(TransInfo *t) } } -int transformEnd(TransInfo *t) +int transformEnd(bContext *C, TransInfo *t) { if (t->state != TRANS_RUNNING) { @@ -1095,16 +1097,16 @@ int transformEnd(TransInfo *t) viewRedrawPost(t); /* Undo as last, certainly after special_trans_update! */ -#if 0 // TRANSFORM_FIX_ME + if(t->state == TRANS_CANCEL) { - if(t->undostr) BIF_undo_push(t->undostr); + if(t->undostr) ED_undo_push(C, t->undostr); } else { - if(t->undostr) BIF_undo_push(t->undostr); - else BIF_undo_push(transform_to_undostr(t)); + if(t->undostr) ED_undo_push(C, t->undostr); + else ED_undo_push(C, transform_to_undostr(t)); } t->undostr= NULL; -#endif + return 1; } t->event = NULL; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index dc7949ed0ab..6e23fc5b1b3 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -238,7 +238,8 @@ typedef struct TransInfo { struct ScrArea *sa; struct ARegion *ar; struct Scene *scene; - struct wmEvent *event; /* last event, reset at the start of each transformApply and nulled at the transformEnd */ + struct wmEvent *event; /* last event, reset at the start of each transformApply and nulled at the transformEnd */ + struct EditMesh *em; /* get from context */ short mval[2]; /* current mouse position */ } TransInfo; @@ -343,7 +344,7 @@ void TFM_OT_transform(struct wmOperatorType *ot); void initTransform(struct bContext *C, struct TransInfo *t, int mode, int context, struct wmEvent *event); void transformEvent(TransInfo *t, struct wmEvent *event); void transformApply(TransInfo *t); -int transformEnd(TransInfo *t); +int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); void convertViewVec(TransInfo *t, float *vec, short dx, short dy); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index fc32ac5a846..5fda8acae88 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -345,7 +345,6 @@ static void createTransTexspace(bContext *C, TransInfo *t) static void createTransEdge(bContext *C, TransInfo *t) { #if 0 // TRANSFORM_FIX_ME TransData *td = NULL; - EditMesh *em = G.editMesh; EditEdge *eed; float mtx[3][3], smtx[3][3]; int count=0, countsel=0; @@ -1761,9 +1760,8 @@ void flushTransParticles(TransInfo *t) #define E_VEC(a) (vectors + (3 * (a)->tmp.l)) #define E_NEAR(a) (nears[((a)->tmp.l)]) #define THRESHOLD 0.0001f -static void editmesh_set_connectivity_distance(int total, float *vectors, EditVert **nears) +static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *vectors, EditVert **nears) { - EditMesh *em = G.editMesh; EditVert *eve; EditEdge *eed; int i= 0, done= 1; @@ -1874,9 +1872,8 @@ static void editmesh_set_connectivity_distance(int total, float *vectors, EditVe } /* loop-in-a-loop I know, but we need it! (ton) */ -static void get_face_center(float *cent, EditVert *eve) +static void get_face_center(float *cent, EditMesh *em, EditVert *eve) { - EditMesh *em = G.editMesh; EditFace *efa; for(efa= em->faces.first; efa; efa= efa->next) @@ -1890,7 +1887,7 @@ static void get_face_center(float *cent, EditVert *eve) //way to overwrite what data is edited with transform //static void VertsToTransData(TransData *td, EditVert *eve, BakeKey *key) -static void VertsToTransData(TransData *td, EditVert *eve) +static void VertsToTransData(TransData *td, EditMesh *em, EditVert *eve) { td->flag = 0; //if(key) @@ -1900,8 +1897,8 @@ static void VertsToTransData(TransData *td, EditVert *eve) VECCOPY(td->center, td->loc); // TRANSFORM_FIX_ME -// if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & SCE_SELECT_FACE)) -// get_face_center(td->center, eve); +// if(G.vd->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE)) + get_face_center(td->center, em, eve); VECCOPY(td->iloc, td->loc); // Setting normals @@ -1960,17 +1957,18 @@ static int modifiers_disable_subsurf_temporary(Object *ob) /* disable subsurf temporal, get mapped cos, and enable it */ static float *get_crazy_mapped_editverts(void) { + Mesh *me= G.obedit->data; DerivedMesh *dm; float *vertexcos; /* disable subsurf temporal, get mapped cos, and enable it */ if(modifiers_disable_subsurf_temporary(G.obedit)) { /* need to make new derivemesh */ - makeDerivedMesh(G.obedit, CD_MASK_BAREMESH); + makeDerivedMesh(G.obedit, me->edit_mesh, CD_MASK_BAREMESH); } /* now get the cage */ - dm= editmesh_get_derived_cage(CD_MASK_BAREMESH); + dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH); vertexcos= MEM_mallocN(3*sizeof(float)*G.totvert, "vertexcos map"); dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos); @@ -2001,9 +1999,8 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, } #undef TAN_MAKE_VEC -static void set_crazyspace_quats(float *origcos, float *mappedcos, float *quats) +static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos, float *quats) { - EditMesh *em = G.editMesh; EditVert *eve, *prev; EditFace *efa; float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4; @@ -2103,7 +2100,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) // TRANSFORM_FIX_ME #if 0 TransData *tob = NULL; - EditMesh *em = G.editMesh; + EditMesh *em = t->em; EditVert *eve; EditVert **nears = NULL; EditVert *eve_act = NULL; @@ -2158,8 +2155,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t) if (countsel==0) return; /* check active */ - if (G.editMesh->selected.last) { - EditSelection *ese = G.editMesh->selected.last; + if (em->selected.last) { + EditSelection *ese = em->selected.last; if ( ese->type == EDITVERT ) { eve_act = (EditVert *)ese->data; } @@ -2179,7 +2176,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) Mat3CpyMat4(mtx, G.obedit->obmat); Mat3Inv(smtx, mtx); - if(propmode) editmesh_set_connectivity_distance(t->total, vectors, nears); + if(propmode) editmesh_set_connectivity_distance(t->em, t->total, vectors, nears); /* detect CrazySpace [tm] */ if(propmode==0) { @@ -2195,7 +2192,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) if(totleft > 0) { mappedcos= get_crazy_mapped_editverts(); quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats"); - set_crazyspace_quats((float*)defcos, mappedcos, quats); + set_crazyspace_quats(t->em, (float*)defcos, mappedcos, quats); if(mappedcos) MEM_freeN(mappedcos); } @@ -2220,7 +2217,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { if(eve->h==0) { if(propmode || eve->f1) { - VertsToTransData(tob, eve); + VertsToTransData(t, tob, t->em, eve); /* selected */ if(eve->f1) tob->flag |= TD_SELECTED; @@ -2338,7 +2335,7 @@ static void createTransUVs(bContext *C, TransInfo *t) int propmode = t->flag & T_PROP_EDIT; int efa_s1,efa_s2,efa_s3,efa_s4; - EditMesh *em = G.editMesh; + EditMesh *em = t->em; EditFace *efa; if(is_uv_tface_editing_allowed()==0) return; @@ -2472,7 +2469,7 @@ void flushTransUVs(TransInfo *t) TransData2D *td; int a, width, height; Object *ob= OBACT; - EditMesh *em = G.editMesh; + EditMesh *em = t->em; float aspx, aspy, invx, invy; transform_aspect_ratio_tface_uv(&aspx, &aspy); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 25413d25b9d..e9f9d3b1ae7 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -667,6 +667,7 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event) Scene *sce = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); ScrArea *sa = CTX_wm_area(C); + Object *obedit = CTX_data_edit_object(C); /* moving: is shown in drawobject() (transform color) */ // TRANSFORM_FIX_ME @@ -677,6 +678,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event) t->scene = sce; t->sa = sa; t->ar = ar; + if (obedit->type==OB_MESH) + t->em = ((Mesh *)obedit->data)->edit_mesh; t->data = NULL; t->ext = NULL; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 31d90fba099..692c4a65bd7 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -236,7 +236,7 @@ int calc_manipulator_stats(ScrArea *sa) if((ob->lay & G.vd->lay)==0) return 0; if(G.obedit->type==OB_MESH) { - EditMesh *em = G.editMesh; + EditMesh *em = NULL; // TRANSFORM_FIX_ME EditVert *eve; EditSelection ese; float vec[3]= {0,0,0}; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index abd31801ca6..0e2e9851821 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -67,7 +67,7 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event) transformApply(t); - if (transformEnd(t)) + if (transformEnd(C, t)) { transformops_exit(C, op); return OPERATOR_FINISHED; @@ -84,7 +84,7 @@ static int transform_exec(bContext *C, wmOperator *op) transformApply(t); - transformEnd(t); + transformEnd(C, t); ED_region_tag_redraw(CTX_wm_region(C)); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 12a9c0e7214..7082f1a7459 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -54,6 +54,8 @@ //#include "BIF_space.h" //#include "BIF_toolbox.h" +#include "ED_mesh.h" + #include "transform.h" #if 0 // TRANSFORM_FIX_ME @@ -448,15 +450,16 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac ob= G.obedit; - if(G.obedit->type==OB_MESH) + if(ob->type==OB_MESH) { - EditMesh *em = G.editMesh; + Mesh *me= ob->data; + EditMesh *em = me->edit_mesh; EditVert *eve; EditSelection ese; float vec[3]= {0,0,0}; /* USE LAST SELECTED WITH ACTIVE */ - if (activeOnly && EM_get_actSelection(&ese)) + if (activeOnly && EM_get_actSelection(em, &ese)) { EM_editselection_normal(normal, &ese); EM_editselection_plane(plane, &ese); |