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/blenkernel/intern | |
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/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/BME_conversions.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 48 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 19 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/exotic.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires-firstlevel.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 6 |
13 files changed, 66 insertions, 87 deletions
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 2129042bdc2..da6ab7ea816 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -343,26 +343,22 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em) { BME_model_end(bm); return bm; } -/* adds the geometry in the bmesh to G.editMesh (does not free G.editMesh) +/* adds the geometry in the bmesh to editMesh (does not free editMesh) * if td != NULL, the transdata will be mapped to the EditVert's co */ -EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) { +void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) { BME_Vert *v1; BME_Edge *e; BME_Poly *f; BME_TransData *vtd; - EditMesh *em; EditVert *eve1, *eve2, *eve3, *eve4, **evlist; EditEdge *eed; EditFace *efa; int totvert, len, i, numTex, numCol; - em = G.editMesh; - - if (em == NULL) return NULL; - + if (em == NULL) return; CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&bm->edata, &em->edata, CD_MASK_BMESH, CD_CALLOC, 0); @@ -438,9 +434,6 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) { MEM_freeN(evlist); - //XXX countall(); - - return em; } /* Adds the geometry found in dm to bm diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3b0d90a0540..1636859d29b 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -629,7 +629,7 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if(draw) { if (draw==2) { /* enabled with stipple */ glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(0); //XXX stipple_quarttone); + glPolygonStipple(stipple_quarttone); } glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT); @@ -666,7 +666,7 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if(draw) { if (draw==2) { /* enabled with stipple */ glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(0); //XXX stipple_quarttone); + glPolygonStipple(stipple_quarttone); } glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT); @@ -2396,12 +2396,11 @@ static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm) return 1; } -static void editmesh_calc_modifiers(DerivedMesh **cage_r, +static void editmesh_calc_modifiers(EditMesh *em, DerivedMesh **cage_r, DerivedMesh **final_r, CustomDataMask dataMask) { Object *ob = G.obedit; - EditMesh *em = G.editMesh; ModifierData *md; float (*deformedVerts)[3] = NULL; CustomDataMask mask; @@ -2742,12 +2741,10 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask) } } -static void editmesh_build_data(CustomDataMask dataMask) +static void editmesh_build_data(EditMesh *em, CustomDataMask dataMask) { float min[3], max[3]; - EditMesh *em = G.editMesh; - clear_mesh_caches(G.obedit); if (em->derivedFinal) { @@ -2763,7 +2760,7 @@ static void editmesh_build_data(CustomDataMask dataMask) em->derivedCage = NULL; } - editmesh_calc_modifiers(&em->derivedCage, &em->derivedFinal, dataMask); + editmesh_calc_modifiers(em, &em->derivedCage, &em->derivedFinal, dataMask); em->lastDataMask = dataMask; INIT_MINMAX(min, max); @@ -2778,10 +2775,10 @@ static void editmesh_build_data(CustomDataMask dataMask) em->derivedCage->needsFree = 0; } -void makeDerivedMesh(Object *ob, CustomDataMask dataMask) +void makeDerivedMesh(Object *ob, EditMesh *em, CustomDataMask dataMask) { - if (ob==G.obedit) { - editmesh_build_data(dataMask); + if (em) { + editmesh_build_data(em, dataMask); } else { mesh_build_data(ob, dataMask); } @@ -2953,35 +2950,35 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob, /***/ -DerivedMesh *editmesh_get_derived_cage_and_final(DerivedMesh **final_r, +DerivedMesh *editmesh_get_derived_cage_and_final(EditMesh *em, DerivedMesh **final_r, CustomDataMask dataMask) { /* if there's no derived mesh or the last data mask used doesn't include * the data we need, rebuild the derived mesh */ - if(!G.editMesh->derivedCage || - (G.editMesh->lastDataMask & dataMask) != dataMask) - editmesh_build_data(dataMask); + if(!em->derivedCage || + (em->lastDataMask & dataMask) != dataMask) + editmesh_build_data(em, dataMask); - *final_r = G.editMesh->derivedFinal; - return G.editMesh->derivedCage; + *final_r = em->derivedFinal; + return em->derivedCage; } -DerivedMesh *editmesh_get_derived_cage(CustomDataMask dataMask) +DerivedMesh *editmesh_get_derived_cage(EditMesh *em, CustomDataMask dataMask) { /* if there's no derived mesh or the last data mask used doesn't include * the data we need, rebuild the derived mesh */ - if(!G.editMesh->derivedCage || - (G.editMesh->lastDataMask & dataMask) != dataMask) - editmesh_build_data(dataMask); + if(!em->derivedCage || + (em->lastDataMask & dataMask) != dataMask) + editmesh_build_data(em, dataMask); - return G.editMesh->derivedCage; + return em->derivedCage; } -DerivedMesh *editmesh_get_derived_base(void) +DerivedMesh *editmesh_get_derived_base(EditMesh *em) { - return getEditMeshDerivedMesh(G.editMesh, G.obedit, NULL); + return getEditMeshDerivedMesh(em, G.obedit, NULL); } @@ -3043,10 +3040,9 @@ float *mesh_get_mapped_verts_nors(Object *ob) /* ********* crazyspace *************** */ -int editmesh_get_first_deform_matrices(float (**deformmats)[3][3], float (**deformcos)[3]) +int editmesh_get_first_deform_matrices(EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) { Object *ob = G.obedit; - EditMesh *em = G.editMesh; ModifierData *md; DerivedMesh *dm; int i, a, numleft = 0, numVerts = 0; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 26afa0967c1..953222960f2 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -434,28 +434,27 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], int level, int animated) { Object *ob, *ob_iter; - Mesh *me; + Mesh *me= par->data; Base *base = NULL; - float vec[3], no[3], pmat[4][4]; - int lay, totvert, a, oblay; DerivedMesh *dm; struct vertexDupliData vdd; Scene *sce = NULL; Group *group = NULL; GroupObject * go = NULL; + float vec[3], no[3], pmat[4][4]; + int lay, totvert, a, oblay; Mat4CpyMat4(pmat, par->obmat); /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; - if(par==G.obedit) - dm= editmesh_get_derived_cage(CD_MASK_BAREMESH); + if(me->edit_mesh) + dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH); else dm= mesh_get_derived_deform(par, CD_MASK_BAREMESH); if(G.rendering) { - me= par->data; vdd.orco= (float(*)[3])get_mesh_orco_verts(par); transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0); } @@ -544,7 +543,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma Base *base = NULL; DupliObject *dob; DerivedMesh *dm; - Mesh *me; + Mesh *me= par->data; MTFace *mtface; MFace *mface; MVert *mvert; @@ -560,9 +559,10 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma Mat4CpyMat4(pmat, par->obmat); - if(par==G.obedit) { + if(me->edit_mesh) { int totvert; - dm= editmesh_get_derived_cage(CD_MASK_BAREMESH); + + dm= editmesh_get_derived_cage(me->edit_mesh, CD_MASK_BAREMESH); totface= dm->getNumFaces(dm); mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp"); @@ -580,7 +580,6 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float par_space_ma } if(G.rendering) { - me= (Mesh*)par->data; orco= (float(*)[3])get_mesh_orco_verts(par); transform_mesh_orco_verts(me, orco, me->totvert, 0); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 0dd9a34b0c1..7b1406146a4 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -185,15 +185,10 @@ void free_blender(void) free_nodesystem(); } -static EditMesh theEditMesh; - void initglobals(void) { memset(&G, 0, sizeof(Global)); - memset(&theEditMesh, 0, sizeof(theEditMesh)); - G.editMesh = &theEditMesh; - U.savetime= 1; G.main= MEM_callocN(sizeof(Main), "initglobals"); @@ -228,10 +223,7 @@ static void clear_global(void) free_main(G.main); /* free all lib data */ if (G.obedit) { -// freeNurblist(&editNurb); -// free_editMesh(G.editMesh); // free_editText(); -// free_editArmature(); } // free_vertexpaint(); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 97a22f9d002..82b1c71e56a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -44,6 +44,7 @@ #include "DNA_object_types.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_lattice_types.h" #include "DNA_scene_types.h" @@ -536,6 +537,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) { DerivedMesh *dm; + Mesh *me= ob->data; float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; @@ -549,9 +551,9 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) if (dgroup < 0) return; /* get DerivedMesh */ - if ((G.obedit == ob) && (G.editMesh)) { + if (me->edit_mesh) { /* target is in editmode, so get a special derived mesh */ - dm = CDDM_from_editmesh(G.editMesh, ob->data); + dm = CDDM_from_editmesh(me->edit_mesh, ob->data); } else { /* when not in EditMode, this should exist */ @@ -621,7 +623,7 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) } /* free temporary DerivedMesh created (in EditMode case) */ - if (G.editMesh) { + if (me->edit_mesh) { if (dm) dm->release(dm); } } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index f4fef115990..1e45c68a0b8 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -387,15 +387,6 @@ struct Object *CTX_data_edit_object(const bContext *C) return ctx_data_pointer_get(C, CTX_data_edit_object); } -struct EditMesh *CTX_data_edit_mesh(const bContext *C) -{ - return ctx_data_pointer_get(C, CTX_data_edit_mesh); -} - -ListBase *CTX_data_edit_armature(const bContext *C) -{ - return ctx_data_pointer_get(C, CTX_data_edit_armature); -} /* data evaluation */ diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index c8648e19c2d..4fe862e5f52 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -2577,8 +2577,8 @@ void write_stl(char *str) static void write_videoscape_mesh(Object *ob, char *str) { - EditMesh *em = G.editMesh; Mesh *me; + EditMesh *em = me->edit_mesh; Material *ma; MFace *mface; FILE *fp; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 07a1a5c5f44..f531c2c5337 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -142,6 +142,7 @@ void free_mesh(Mesh *me) if(me->bb) MEM_freeN(me->bb); if(me->mselect) MEM_freeN(me->mselect); + if(me->edit_mesh) MEM_freeN(me->edit_mesh); if(me->mr) multires_free(me->mr); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index eebd5e6d056..38e8b1b1abe 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -7553,20 +7553,21 @@ static void meshdeformModifier_do( float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; - float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3]; - int a, b, totvert, totcagevert, defgrp_index; + Mesh *me= ob->data; DerivedMesh *tmpdm, *cagedm; MDeformVert *dvert = NULL; MDeformWeight *dw; MVert *cagemvert; - + float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; + float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3]; + int a, b, totvert, totcagevert, defgrp_index; + if(!mmd->object || (!mmd->bindcos && !mmd->needbind)) return; /* get cage derivedmesh */ - if(mmd->object == G.obedit) { - tmpdm= editmesh_get_derived_cage_and_final(&cagedm, 0); + if(me->edit_mesh) { + tmpdm= editmesh_get_derived_cage_and_final(me->edit_mesh, &cagedm, 0); if(tmpdm) tmpdm->release(tmpdm); } diff --git a/source/blender/blenkernel/intern/multires-firstlevel.c b/source/blender/blenkernel/intern/multires-firstlevel.c index 8c667a9ecf0..0c21cefa9a0 100644 --- a/source/blender/blenkernel/intern/multires-firstlevel.c +++ b/source/blender/blenkernel/intern/multires-firstlevel.c @@ -83,16 +83,16 @@ void multires_update_customdata(MultiresLevel *lvl1, EditMesh *em, CustomData *s if(CustomData_has_layer(src, type)) { if(em) { - EditVert *eve= G.editMesh->verts.first; - EditFace *efa= G.editMesh->faces.first; + EditVert *eve= em->verts.first; + EditFace *efa= em->faces.first; CustomData_copy(src, dst, cdmask(type), CD_CALLOC, tot); for(i=0; i<tot; ++i) { if(type == CD_MDEFORMVERT) { - CustomData_from_em_block(&G.editMesh->vdata, dst, eve->data, i); + CustomData_from_em_block(&em->vdata, dst, eve->data, i); eve= eve->next; } else if(type == CD_MTFACE) { - CustomData_from_em_block(&G.editMesh->fdata, dst, efa->data, i); + CustomData_from_em_block(&em->fdata, dst, efa->data, i); efa= efa->next; } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 96e81c604fa..99e4083f68d 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -274,7 +274,7 @@ static void multires_col_avg2(MultiresCol *avg, MultiresCol *c1, MultiresCol *c2 void multires_load_cols(Mesh *me) { MultiresLevel *lvl= BLI_findlink(&me->mr->levels,me->mr->current-1), *cur; - EditMesh *em= G.obedit ? G.editMesh : NULL; + EditMesh *em= me->edit_mesh; CustomData *src= em ? &em->fdata : &me->fdata; EditFace *efa= NULL; unsigned i,j; @@ -346,7 +346,7 @@ void multires_load_cols(Mesh *me) void multires_create(Object *ob, Mesh *me) { MultiresLevel *lvl; - EditMesh *em= G.obedit ? G.editMesh : NULL; + EditMesh *em= me->edit_mesh; EditVert *eve= NULL; EditFace *efa= NULL; EditEdge *eed= NULL; @@ -954,7 +954,7 @@ static void multires_update_colors(Mesh *me, EditMesh *em) void multires_update_levels(Mesh *me, const int render) { - EditMesh *em= (!render && G.obedit) ? G.editMesh : NULL; + EditMesh *em= render ? NULL : me->edit_mesh; multires_update_first_level(me, em); multires_update_vertices(me, em); @@ -964,7 +964,7 @@ void multires_update_levels(Mesh *me, const int render) static void check_colors(Mesh *me) { - CustomData *src= G.obedit ? &G.editMesh->fdata : &me->fdata; + CustomData *src= me->edit_mesh ? &me->edit_mesh->fdata : &me->fdata; const char col= CustomData_has_layer(src, CD_MCOL); /* Check if vertex colors have been deleted or added */ @@ -1014,8 +1014,8 @@ void multires_to_mcol(MultiresColFace *f, MCol mcol[4]) void multires_level_to_mesh(Object *ob, Mesh *me, const int render) { MultiresLevel *lvl= BLI_findlink(&me->mr->levels,me->mr->current-1); + EditMesh *em= render ? NULL : me->edit_mesh; int i; - EditMesh *em= (!render && G.obedit) ? G.editMesh : NULL; if(em) return; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 51069c7d3ea..e52a4a4f8e0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1665,8 +1665,10 @@ static void give_parvert(Object *par, int nr, float *vec) vec[0]=vec[1]=vec[2]= 0.0f; if(par->type==OB_MESH) { - if(G.obedit && (par->data==G.obedit->data)) { - EditMesh *em = G.editMesh; + Mesh *me= par->data; + + if(me->edit_mesh) { + EditMesh *em = me->edit_mesh; EditVert *eve; for(eve= em->verts.first; eve; eve= eve->next) { @@ -2307,7 +2309,7 @@ void object_handle_update(Object *ob) /* includes all keys and modifiers */ if(ob->type==OB_MESH) { - makeDerivedMesh(ob, get_viewedit_datamask()); + makeDerivedMesh(ob, NULL, get_viewedit_datamask()); } else if(ob->type==OB_MBALL) { makeDispListMBall(ob); diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index ab98fb1f007..81788cd24a8 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -93,10 +93,12 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c //TODO is anyfunction that does this? returning the derivedFinal witouth we caring if its in edit mode or not? DerivedMesh *object_get_derived_final(Object *ob, CustomDataMask dataMask) { - if (ob==G.obedit) + Mesh *me= ob->data; + + if (me->edit_mesh) { DerivedMesh *final = NULL; - editmesh_get_derived_cage_and_final(&final, dataMask); + editmesh_get_derived_cage_and_final(me->edit_mesh, &final, dataMask); return final; } else |