diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-05-18 12:46:04 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-05-18 12:46:04 +0400 |
commit | 0ba863de29ad6768260e1b4e67f3eec9c8ae4c81 (patch) | |
tree | b1c606be25678a749abcb46a5877d8ec262c15ba /source/blender | |
parent | 166c270f060e0ffadbc53c27afb112f294e7425e (diff) |
renamed BMTessMesh to BMEditMesh, did some more monkeywork, cleaned up the more serious warnings, and also non-backbuffered selection sortof works now, though it still needs plenty of work.
Diffstat (limited to 'source/blender')
41 files changed, 360 insertions, 490 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 0365d2b5a94..8df30b1eaf5 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -52,12 +52,12 @@ struct MTFace; struct Object; struct Scene; struct Mesh; -struct BMTessMesh; +struct BMEditMesh; struct ModifierData; struct MCol; struct ColorBand; struct GPUVertexAttribs; -struct BMTessMesh; +struct BMEditMesh; /* number of sub-elements each mesh element has (for interpolation) */ #define SUB_ELEMS_VERT 0 @@ -433,7 +433,7 @@ DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask); -DerivedMesh *getEditDerivedBMesh(struct BMTessMesh *em, struct Object *ob, +DerivedMesh *getEditDerivedBMesh(struct BMEditMesh *em, struct Object *ob, float (*vertexCos)[3]); DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index); @@ -448,17 +448,17 @@ DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Ob float (*vertCos)[3], CustomDataMask dataMask); -DerivedMesh *editbmesh_get_derived_base(struct Object *, struct BMTessMesh *em); +DerivedMesh *editbmesh_get_derived_base(struct Object *, struct BMEditMesh *em); DerivedMesh *editbmesh_get_derived_cage(struct Scene *scene, struct Object *, - struct BMTessMesh *em, CustomDataMask dataMask); + struct BMEditMesh *em, CustomDataMask dataMask); DerivedMesh *editbmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *, - struct BMTessMesh *em, DerivedMesh **final_r, + struct BMEditMesh *em, DerivedMesh **final_r, CustomDataMask dataMask); -void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMTessMesh *em, CustomDataMask dataMask); +void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em, CustomDataMask dataMask); /* returns an array of deform matrices for crazyspace correction, and the number of modifiers left */ -int editbmesh_get_first_deform_matrices(struct Object *, struct BMTessMesh *em, float (**deformmats)[3][3], +int editbmesh_get_first_deform_matrices(struct Object *, struct BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float input, float *fr, float *fg, float *fb); diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index f40d3dae087..d4fee61f9c6 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -38,7 +38,7 @@ #include "BKE_DerivedMesh.h" struct DerivedMesh; -struct BMTessMesh; +struct BMEditMesh; struct EditMesh; struct Mesh; struct Object; @@ -55,8 +55,8 @@ struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob); /* creates a CDDerivedMesh from the given EditMesh */ struct DerivedMesh *CDDM_from_editmesh(struct EditMesh *em, struct Mesh *me); -/* creates a CDDerivedMesh from the given BMTessMesh */ -DerivedMesh *CDDM_from_BMTessMesh(struct BMTessMesh *em, struct Mesh *me); +/* creates a CDDerivedMesh from the given BMEditMesh */ +DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me); /* Copies the given DerivedMesh with verts, faces & edges stored as * custom element data. diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 042b3b3046c..b2f533649e3 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -131,7 +131,10 @@ int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to void mesh_layers_menu_concat(struct CustomData *data, int type, char *str); int mesh_layers_menu(struct CustomData *data, int type); - +/*accessor functions for editmesh, all access to editmesh must + go through them!*/ +struct EditMesh *EM_GetEditMesh(struct Mesh *me); +void EM_EndEditMesh(struct Mesh *me, struct EditMesh *em); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index ce3b5c02873..9637b659ece 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -43,7 +43,7 @@ struct ListBase; struct LinkNode; struct bArmature; struct ModifierData; -struct BMTessMesh; +struct BMEditMesh; typedef enum { /* Should not be used, only for None modifier type */ @@ -131,13 +131,13 @@ typedef struct ModifierTypeInfo { */ void (*deformVertsEM)( struct ModifierData *md, struct Object *ob, - struct BMTessMesh *editData, struct DerivedMesh *derivedData, + struct BMEditMesh *editData, struct DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts); /* Set deform matrix per vertex for crazyspace correction */ void (*deformMatricesEM)( struct ModifierData *md, struct Object *ob, - struct BMTessMesh *editData, struct DerivedMesh *derivedData, + struct BMEditMesh *editData, struct DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); /********************* Non-deform modifier functions *********************/ @@ -175,7 +175,7 @@ typedef struct ModifierTypeInfo { */ struct DerivedMesh *(*applyModifierEM)( struct ModifierData *md, struct Object *ob, - struct BMTessMesh *editData, + struct BMEditMesh *editData, struct DerivedMesh *derivedData); diff --git a/source/blender/blenkernel/BKE_tessmesh.h b/source/blender/blenkernel/BKE_tessmesh.h index f8b1dfff222..4bffd37e24e 100644 --- a/source/blender/blenkernel/BKE_tessmesh.h +++ b/source/blender/blenkernel/BKE_tessmesh.h @@ -20,7 +20,7 @@ typedef struct BMEditSelection the entire derivedmesh and modifier system works with this structure, and not BMesh. Mesh->editbmesh will store a pointer to this structure.*/ -typedef struct BMTessMesh { +typedef struct BMEditMesh { struct BMesh *bm; /*we store tesselations as triplets of three loops, @@ -50,9 +50,11 @@ typedef struct BMTessMesh { /*selection mode*/ int selectmode, totfacesel, totvertsel, totedgesel; -} BMTessMesh; -void TM_RecalcTesselation(BMTessMesh *tm); -BMTessMesh *TM_Create(BMesh *bm); -BMTessMesh *TM_Copy(BMTessMesh *tm); -void TM_Free(BMTessMesh *em); + int mat_nr; +} BMEditMesh; + +void TM_RecalcTesselation(BMEditMesh *tm); +BMEditMesh *TM_Create(BMesh *bm); +BMEditMesh *TM_Copy(BMEditMesh *tm); +void TM_Free(BMEditMesh *em); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 48e16639f45..f5eb628ffe6 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1413,7 +1413,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, Modifier return dm; } -static float *get_editbmesh_orco_verts(BMTessMesh *em) +static float *get_editbmesh_orco_verts(BMEditMesh *em) { BMIter iter; BMVert *eve; @@ -1434,13 +1434,13 @@ static float *get_editbmesh_orco_verts(BMTessMesh *em) return orco; } -static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMTessMesh *em) +static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em) { DerivedMesh *dm; float (*orco)[3]; if(em) { - dm= CDDM_from_BMTessMesh(em, me); + dm= CDDM_from_BMEditMesh(em, me); orco= (float(*)[3])get_editbmesh_orco_verts(em); } else { @@ -1455,7 +1455,7 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMTessMesh *em) return dm; } -static void add_orco_dm(Object *ob, BMTessMesh *em, DerivedMesh *dm, DerivedMesh *orcodm) +static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm, DerivedMesh *orcodm) { float (*orco)[3], (*layerorco)[3]; int totvert; @@ -1725,7 +1725,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos BLI_linklist_free(datamasks, NULL); } -static float (*editbmesh_getVertexCos(BMTessMesh *em, int *numVerts_r))[3] +static float (*editbmesh_getVertexCos(BMEditMesh *em, int *numVerts_r))[3] { int i, numVerts = *numVerts_r = em->bm->totvert; float (*cos)[3]; @@ -1759,7 +1759,7 @@ static int editbmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm) return 1; } -static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMTessMesh *em, DerivedMesh **cage_r, +static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, DerivedMesh **cage_r, DerivedMesh **final_r, CustomDataMask dataMask) { @@ -1842,7 +1842,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMTessMesh *em, D } } else { - dm = CDDM_from_BMTessMesh(em, ob->data); + dm = CDDM_from_BMEditMesh(em, ob->data); if(deformedVerts) { CDDM_apply_vert_coords(dm, deformedVerts); @@ -2107,7 +2107,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) } -static void editbmesh_build_data(Scene *scene, Object *obedit, BMTessMesh *em, CustomDataMask dataMask) +static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask) { float min[3], max[3]; @@ -2141,7 +2141,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMTessMesh *em, C em->derivedCage->needsFree = 0; } -void makeDerivedMesh(Scene *scene, Object *ob, BMTessMesh *em, CustomDataMask dataMask) +void makeDerivedMesh(Scene *scene, Object *ob, BMEditMesh *em, CustomDataMask dataMask) { if (em) { editbmesh_build_data(scene, ob, em, dataMask); @@ -2224,7 +2224,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob, /***/ -DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, BMTessMesh *em, DerivedMesh **final_r, +DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, BMEditMesh *em, DerivedMesh **final_r, CustomDataMask dataMask) { /* if there's no derived mesh or the last data mask used doesn't include @@ -2238,7 +2238,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, return em->derivedCage; } -DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMTessMesh *em, CustomDataMask dataMask) +DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh *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 @@ -2250,7 +2250,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMTessMesh return em->derivedCage; } -DerivedMesh *editbmesh_get_derived_base(Object *obedit, BMTessMesh *em) +DerivedMesh *editbmesh_get_derived_base(Object *obedit, BMEditMesh *em) { return getEditDerivedBMesh(em, obedit, NULL); } @@ -2314,7 +2314,7 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) /* ********* crazyspace *************** */ -int editbmesh_get_first_deform_matrices(Object *ob, BMTessMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) +int editbmesh_get_first_deform_matrices(Object *ob, BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) { ModifierData *md; DerivedMesh *dm; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 08fead3b23f..bd99893bc37 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -449,7 +449,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl Scene *sce = NULL; Group *group = NULL; GroupObject * go = NULL; - BMTessMesh *em; + BMEditMesh *em; float vec[3], no[3], pmat[4][4]; int lay, totvert, a, oblay; @@ -564,7 +564,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa Scene *sce = NULL; Group *group = NULL; GroupObject *go = NULL; - BMTessMesh *em; + BMEditMesh *em; float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */ /* simple preventing of too deep nested groups */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e6e144acbe5..7476d2f5fda 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1084,7 +1084,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, } } -DerivedMesh *CDDM_from_BMTessMesh(BMTessMesh *em, Mesh *me) +DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *me) { DerivedMesh *dm = CDDM_new(em->bm->totvert, em->bm->totedge, em->tottri); CDDerivedMesh *cddm = (CDDerivedMesh*)dm; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b238116f0a1..5adbcadcf39 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -66,6 +66,7 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_idprop.h" +#include "BKE_mesh.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index c0e5d51d8c7..b89fca5c4dc 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -89,9 +89,9 @@ #include "bmesh.h" -BMTessMesh *TM_Create(BMesh *bm) +BMEditMesh *TM_Create(BMesh *bm) { - BMTessMesh *tm = MEM_callocN(sizeof(BMTessMesh), "tm"); + BMEditMesh *tm = MEM_callocN(sizeof(BMEditMesh), "tm"); tm->bm = bm; @@ -100,9 +100,9 @@ BMTessMesh *TM_Create(BMesh *bm) return tm; } -BMTessMesh *TM_Copy(BMTessMesh *tm) +BMEditMesh *TM_Copy(BMEditMesh *tm) { - BMTessMesh *tm2 = MEM_mallocN(sizeof(BMTessMesh), "tm2"); + BMEditMesh *tm2 = MEM_mallocN(sizeof(BMEditMesh), "tm2"); *tm2 = *tm; tm2->bm = BM_Copy_Mesh(tm->bm); @@ -110,7 +110,7 @@ BMTessMesh *TM_Copy(BMTessMesh *tm) return tm2; } -void TM_RecalcTesselation(BMTessMesh *tm) +void TM_RecalcTesselation(BMEditMesh *tm) { BMesh *bm = tm->bm; BMLoop **looptris = NULL; @@ -147,8 +147,8 @@ void TM_RecalcTesselation(BMTessMesh *tm) tm->looptris = looptris; } -/*does not free the BMTessMesh struct itself*/ -void TM_Free(BMTessMesh *em) +/*does not free the BMEditMesh struct itself*/ +void TM_Free(BMEditMesh *em) { if(em->derivedFinal) { if (em->derivedFinal!=em->derivedCage) { @@ -188,7 +188,7 @@ typedef struct EditDerivedBMesh { DerivedMesh dm; Object *ob; - BMTessMesh *tc; + BMEditMesh *tc; float (*vertexCos)[3]; float (*vertexNos)[3]; @@ -1132,7 +1132,7 @@ static void bmDM_release(DerivedMesh *dm) } } -DerivedMesh *getEditDerivedBMesh(BMTessMesh *em, Object *ob, +DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *ob, float (*vertexCos)[3]) { EditDerivedBMesh *bmdm = MEM_callocN(sizeof(*bmdm), "bmdm"); diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index ae423cdd3aa..660a02bcb9e 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -2490,7 +2490,7 @@ static void write_videoscape_mesh(Scene *scene, Object *ob, char *str) fclose(fp); - if (em) EM_EndEditMesh(em); + if (em) EM_EndEditMesh(me, em); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2296ec5ecf6..c96f0af0ffa 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -197,12 +197,12 @@ static void curveModifier_deformVerts( } static void curveModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); curveModifier_deformVerts(md, ob, dm, vertexCos, numVerts); @@ -289,12 +289,12 @@ static void latticeModifier_deformVerts( } static void latticeModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); latticeModifier_deformVerts(md, ob, dm, vertexCos, numVerts); @@ -350,7 +350,7 @@ static DerivedMesh *subsurfModifier_applyModifier( } static DerivedMesh *subsurfModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { SubsurfModifierData *smd = (SubsurfModifierData*) md; @@ -1648,7 +1648,7 @@ static DerivedMesh *arrayModifier_applyModifier( } static DerivedMesh *arrayModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return arrayModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -2071,7 +2071,7 @@ static DerivedMesh *mirrorModifier_applyModifier( } static DerivedMesh *mirrorModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return mirrorModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -3294,7 +3294,7 @@ static DerivedMesh *edgesplitModifier_applyModifier( } static DerivedMesh *edgesplitModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return edgesplitModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -3378,7 +3378,7 @@ static DerivedMesh *bevelModifier_applyModifier( } static DerivedMesh *bevelModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return bevelModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -3705,13 +3705,13 @@ static void displaceModifier_deformVerts( } static void displaceModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm; if(derivedData) dm = CDDM_copy(derivedData); - else dm = CDDM_from_BMTessMesh(editData, ob->data); + else dm = CDDM_from_BMEditMesh(editData, ob->data); CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); @@ -4036,7 +4036,7 @@ static DerivedMesh *uvprojectModifier_applyModifier( } static DerivedMesh *uvprojectModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return uvprojectModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -4386,13 +4386,13 @@ static void smoothModifier_deformVerts( } static void smoothModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm; if(derivedData) dm = CDDM_copy(derivedData); - else dm = CDDM_from_BMTessMesh(editData, ob->data); + else dm = CDDM_from_BMEditMesh(editData, ob->data); CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); @@ -4967,14 +4967,14 @@ static void castModifier_deformVerts( } static void castModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; CastModifierData *cmd = (CastModifierData *)md; if (!dm && ob->type == OB_MESH) - dm = CDDM_from_BMTessMesh(editData, ob->data); + dm = CDDM_from_BMEditMesh(editData, ob->data); if (cmd->type == MOD_CAST_TYPE_CUBOID) { castModifier_cuboid_do(cmd, ob, dm, vertexCos, numVerts); @@ -5374,7 +5374,7 @@ static void waveModifier_deformVerts( } static void waveModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm; @@ -5383,7 +5383,7 @@ static void waveModifier_deformVertsEM( if(!wmd->texture && !wmd->defgrp_name[0] && !(wmd->flag & MOD_WAVE_NORM)) dm = derivedData; else if(derivedData) dm = CDDM_copy(derivedData); - else dm = CDDM_from_BMTessMesh(editData, ob->data); + else dm = CDDM_from_BMEditMesh(editData, ob->data); if(wmd->flag & MOD_WAVE_NORM) { CDDM_apply_vert_coords(dm, vertexCos); @@ -5474,13 +5474,13 @@ static void armatureModifier_deformVerts( } static void armatureModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData*) md; DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, numVerts, amd->deformflag, NULL, amd->defgrp_name); @@ -5489,14 +5489,14 @@ static void armatureModifier_deformVertsEM( } static void armatureModifier_deformMatricesEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData*) md; DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); @@ -5692,12 +5692,12 @@ static void hookModifier_deformVerts( } static void hookModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); hookModifier_deformVerts(md, ob, derivedData, vertexCos, numVerts); @@ -6269,12 +6269,12 @@ static void particleSystemModifier_deformVerts( * updates is coded */ #if 0 static void particleSystemModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if(!derivedData) dm = CDDM_from_BMTessMesh(editData, ob->data); + if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data); particleSystemModifier_deformVerts(md, ob, dm, vertexCos, numVerts); @@ -6490,7 +6490,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier( return result; } static DerivedMesh *particleInstanceModifier_applyModifierEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData) { return particleInstanceModifier_applyModifier(md, ob, derivedData, 0, 1); @@ -7539,7 +7539,7 @@ static void meshdeformModifier_do( { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; Mesh *me= ob->data; - BMTessMesh *bem = me->edit_btmesh; + BMEditMesh *bem = me->edit_btmesh; DerivedMesh *tmpdm, *cagedm; MDeformVert *dvert = NULL; MDeformWeight *dw; @@ -7707,13 +7707,13 @@ static void meshdeformModifier_deformVerts( } static void meshdeformModifier_deformVertsEM( - ModifierData *md, Object *ob, BMTessMesh *editData, + ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm; if(!derivedData && ob->type == OB_MESH) - dm = CDDM_from_BMTessMesh(editData, ob->data); + dm = CDDM_from_BMEditMesh(editData, ob->data); else dm = derivedData; @@ -7863,7 +7863,7 @@ static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, Derived dm->release(dm); } -static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, BMTessMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = NULL; CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(md); @@ -7871,7 +7871,7 @@ static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, BMTes if(dataMask) { if(derivedData) dm = CDDM_copy(derivedData); - else if(ob->type==OB_MESH) dm = CDDM_from_BMTessMesh(editData, ob->data); + else if(ob->type==OB_MESH) dm = CDDM_from_BMEditMesh(editData, ob->data); else if(ob->type==OB_LATTICE) dm = NULL; else return; @@ -7978,7 +7978,7 @@ static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, Deriv } -static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, BMTessMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = NULL; CustomDataMask dataMask = simpledeformModifier_requiredDataMask(md); @@ -7987,7 +7987,7 @@ static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, BMT if(dataMask) { if(derivedData) dm = CDDM_copy(derivedData); - else if(ob->type==OB_MESH) dm = CDDM_from_BMTessMesh(editData, ob->data); + else if(ob->type==OB_MESH) dm = CDDM_from_BMEditMesh(editData, ob->data); else if(ob->type==OB_LATTICE) dm = NULL; else return; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ccf7993796c..2c851a1115a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2297,7 +2297,7 @@ void object_handle_update(Scene *scene, Object *ob) /* includes all keys and modifiers */ if(ob->type==OB_MESH) { - BMTessMesh *em = ((Mesh*)ob->data)->edit_btmesh; + BMEditMesh *em = ((Mesh*)ob->data)->edit_btmesh; // here was vieweditdatamask? XXX if(ob==scene->obedit) { diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 92d1f0d1a19..66cc92a19af 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -48,6 +48,8 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_subsurf.h" +#include "BKE_mesh.h" +#include "BKE_tessmesh.h" #include "BLI_arithb.h" #include "BLI_kdtree.h" @@ -96,14 +98,13 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c static DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDataMask dataMask) { Mesh *me= ob->data; - EditMesh *em = EM_GetEditMesh(me); + BMEditMesh *em = me->edit_btmesh; if (em) { DerivedMesh *final = NULL; editbmesh_get_derived_cage_and_final(scene, ob, em, &final, dataMask); - EM_EndEditMesh(me, em); return final; } else diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index a6940689bb4..b0653a3fd90 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -298,6 +298,8 @@ void BM_Data_Interp_From_Verts(struct BMesh *bm, struct BMVert *v1, struct BMVer void BM_Data_Facevert_Edgeinterp(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, struct BMEdge *e1, float fac); //void bmesh_data_interp_from_face(struct BMesh *bm, struct BMFace *source, struct BMFace *target); +/*computes the centroid of a face, using the center of the bounding box*/ +int BM_Compute_Face_Center(BMesh *bm, BMFace *f, float center[3]); /*convert an editmesh to a bmesh*/ BMesh *editmesh_to_bmesh(struct EditMesh *em); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index a2d080da3f2..54144cbebcd 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -168,6 +168,26 @@ static int compute_poly_center(float center[3], float *area, float (*verts)[3], return 0; } +/* +computes center of face in 3d. uses center of bounding box. +*/ + +int BM_Compute_Face_Center(BMesh *bm, BMFace *f, float center[3]) +{ + BMIter iter; + BMLoop *l; + float min[3], max[3]; + int i; + + INIT_MINMAX(min, max); + l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); + for (i=0; l; l=BMIter_Step(&iter), i++) { + DO_MINMAX(l->v->co, min, max); + } + + VECADD(center, min, max); + VECMUL(center, 0.5f); +} /* * COMPUTE POLY PLANE diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 4e2daea842c..97664c65af8 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -47,6 +47,11 @@ struct MCol; struct UvVertMap; struct UvMapVert; struct CustomData; +struct BMEditSelection; +struct BMesh; +struct BMVert; +struct BMEdge; +struct BMFace; // edge and face flag both #define EM_FGON 2 @@ -73,22 +78,25 @@ struct CustomData; /*recalculate tesselations for ngons*/ void EDBM_Tesselate(struct EditMesh *em); void EDBM_MakeEditBMesh(struct Scene *scene, struct Object *ob); -void EDBM_FreeEditBMesh(struct BMTessMesh *tm); -void EDBM_LoadEditBMesh(struct Object *ob, struct Mesh *me); -void EDBM_init_index_arrays(struct BMTessMesh *tm, int forvert, int foredge, int forface); -void EDBM_free_index_arrays(struct BMTessMesh *tm); -struct BMVert *EDBM_get_vert_for_index(struct BMTessMesh *tm, int index); -struct BMEdge *EDBM_get_edge_for_index(struct BMTessMesh *tm, int index); -struct BMFace *EDBM_get_face_for_index(struct BMTessMesh *tm, int index); -struct BMFace *EDBM_get_actFace(struct BMTessMesh *em, int sloppy); -void EDBM_selectmode_flush(struct BMTessMesh *em); +void EDBM_FreeEditBMesh(struct BMEditMesh *tm); +void EDBM_LoadEditBMesh(struct Scene *scene, struct Object *ob); +void EDBM_init_index_arrays(struct BMEditMesh *tm, int forvert, int foredge, int forface); +void EDBM_free_index_arrays(struct BMEditMesh *tm); +struct BMVert *EDBM_get_vert_for_index(struct BMEditMesh *tm, int index); +struct BMEdge *EDBM_get_edge_for_index(struct BMEditMesh *tm, int index); +struct BMFace *EDBM_get_face_for_index(struct BMEditMesh *tm, int index); +struct BMFace *EDBM_get_actFace(struct BMEditMesh *em, int sloppy); +void EDBM_selectmode_flush(struct BMEditMesh *em); +int EDBM_get_actSelection(struct BMEditMesh *em, struct BMEditSelection *ese); +void EDBM_editselection_center(struct BMEditMesh *em, float *center, struct BMEditSelection *ese); +void EDBM_editselection_plane(struct BMEditMesh *em, float *plane, struct BMEditSelection *ese); /* meshtools.c */ -intptr_t mesh_octree_table(struct Object *ob, struct BMTessMesh *em, float *co, char mode); -struct EditVert *editmesh_get_x_mirror_vert(struct Object *ob, struct EditMesh *em, float *co); +intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co, char mode); +struct BMVert *editmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, float *co); int mesh_get_x_mirror_vert(struct Object *ob, int index); -int *mesh_get_x_mirror_faces(struct Object *ob, struct EditMesh *em); +int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em); /* mesh_ops.c */ void ED_operatortypes_mesh(void); @@ -97,11 +105,6 @@ void ED_keymap_mesh(struct wmWindowManager *wm); /* editmesh.c */ -/*accessor functions for editmesh, all access to editmesh must - go through them!*/ -struct EditMesh *EM_GetEditMesh(struct Mesh *me); -void EM_EndEditMesh(struct Mesh *me, struct EditMesh *em); - void ED_spacetypes_init(void); void ED_keymap_mesh(struct wmWindowManager *wm); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 10975b0dee1..4170158e3b4 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -39,7 +39,7 @@ struct Nurb; struct BezTriple; struct BMVert; struct BMEdge; -struct BMTessMesh; +struct BMEditMesh; struct BMFace; struct ImBuf; struct Scene; @@ -53,7 +53,7 @@ typedef struct ViewContext { struct ARegion *ar; struct View3D *v3d; struct RegionView3D *rv3d; - struct BMTessMesh *em; + struct BMEditMesh *em; short mval[2]; } ViewContext; diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index b258f6efff7..4a0679bd748 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -90,7 +90,7 @@ #include "mesh_intern.h" #include "bmesh.h" -void EDBM_RecalcNormals(BMTessMesh *em) +void EDBM_RecalcNormals(BMEditMesh *em) { } @@ -194,6 +194,7 @@ void EDBM_MakeEditBMesh(Scene *scene, Object *ob) bm = editmesh_to_bmesh(em); me->edit_btmesh = TM_Create(bm); + me->edit_btmesh->selectmode = scene->selectmode; free_editMesh(em); } @@ -207,13 +208,13 @@ void EDBM_LoadEditBMesh(Scene *scene, Object *ob) free_editMesh(em); } -void EDBM_FreeEditBMesh(BMTessMesh *tm) +void EDBM_FreeEditBMesh(BMEditMesh *tm) { BM_Free_Mesh(tm->bm); TM_Free(tm); } -void EDBM_init_index_arrays(BMTessMesh *tm, int forvert, int foredge, int forface) +void EDBM_init_index_arrays(BMEditMesh *tm, int forvert, int foredge, int forface) { if (forvert) { BMIter iter; @@ -230,7 +231,7 @@ void EDBM_init_index_arrays(BMTessMesh *tm, int forvert, int foredge, int forfac if (foredge) { BMIter iter; - BMVert *ele; + BMEdge *ele; int i=0; tm->edge_index = MEM_mallocN(sizeof(void**)*tm->bm->totedge, "tm->edge_index"); @@ -243,7 +244,7 @@ void EDBM_init_index_arrays(BMTessMesh *tm, int forvert, int foredge, int forfac if (forface) { BMIter iter; - BMVert *ele; + BMFace *ele; int i=0; tm->face_index = MEM_mallocN(sizeof(void**)*tm->bm->totface, "tm->face_index"); @@ -255,7 +256,7 @@ void EDBM_init_index_arrays(BMTessMesh *tm, int forvert, int foredge, int forfac } } -void EDBM_free_index_arrays(BMTessMesh *tm) +void EDBM_free_index_arrays(BMEditMesh *tm) { if (tm->vert_index) { MEM_freeN(tm->vert_index); @@ -273,28 +274,28 @@ void EDBM_free_index_arrays(BMTessMesh *tm) } } -BMVert *EDBM_get_vert_for_index(BMTessMesh *tm, int index) +BMVert *EDBM_get_vert_for_index(BMEditMesh *tm, int index) { return tm->vert_index?tm->vert_index[index]:NULL; } -BMEdge *EDBM_get_edge_for_index(BMTessMesh *tm, int index) +BMEdge *EDBM_get_edge_for_index(BMEditMesh *tm, int index) { return tm->edge_index?tm->edge_index[index]:NULL; } -BMFace *EDBM_get_face_for_index(BMTessMesh *tm, int index) +BMFace *EDBM_get_face_for_index(BMEditMesh *tm, int index) { return tm->face_index?tm->face_index[index]:NULL; } /* this replaces the active flag used in uv/face mode */ -void EDBM_set_actFace(BMTessMesh *em, BMFace *efa) +void EDBM_set_actFace(BMEditMesh *em, BMFace *efa) { em->act_face = efa; } -BMFace *EDBM_get_actFace(BMTessMesh *em, int sloppy) +BMFace *EDBM_get_actFace(BMEditMesh *em, int sloppy) { if (em->act_face) { return em->act_face; @@ -325,13 +326,15 @@ BMFace *EDBM_get_actFace(BMTessMesh *em, int sloppy) } -void EDBM_selectmode_flush(BMTessMesh *em) +void EDBM_selectmode_flush(BMEditMesh *em) { } -int EDBM_get_actSelection(BMTessMesh *em, BMEditSelection *ese) +int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese) { + ese->data = NULL; + return 0; #if 0 EditSelection *ese_last = em->selected.last; EditFace *efa = EM_get_actFace(em, 0); @@ -362,7 +365,7 @@ int EDBM_get_actSelection(BMTessMesh *em, BMEditSelection *ese) } /* ********* Selection History ************ */ -static int EDBM_check_selection(BMTessMesh *em, void *data) +static int EDBM_check_selection(BMEditMesh *em, void *data) { #if 0 EditSelection *ese; @@ -375,7 +378,7 @@ static int EDBM_check_selection(BMTessMesh *em, void *data) #endif } -void EDBM_remove_selection(BMTessMesh *em, void *data, int type) +void EDBM_remove_selection(BMEditMesh *em, void *data) { #if 0 EditSelection *ese; @@ -388,7 +391,7 @@ void EDBM_remove_selection(BMTessMesh *em, void *data, int type) #endif } -void EDBM_store_selection(BMTessMesh *em, void *data, int type) +void EDBM_store_selection(BMEditMesh *em, void *data) { #if 0 EditSelection *ese; @@ -401,7 +404,7 @@ void EDBM_store_selection(BMTessMesh *em, void *data, int type) #endif } -void EDBM_validate_selections(BMTessMesh *em) +void EDBM_validate_selections(BMEditMesh *em) { #if 0 EditSelection *ese, *nextese; @@ -418,7 +421,32 @@ void EDBM_validate_selections(BMTessMesh *em) #endif } -static void EDBM_strip_selections(BMTessMesh *em) +void EDBM_clear_flag_all(BMEditMesh *em, int flag) +{ + BMIter iter; + BMHeader *ele; + int i, type; + + for (i=0; i<3; i++) { + switch (i) { + case 0: + type = BM_VERTS_OF_MESH; + break; + case 1: + type = BM_EDGES_OF_MESH; + break; + case 2: + type = BM_FACES_OF_MESH; + break; + } + ele = BMIter_New(&iter, em->bm, type, NULL); + for ( ; ele; ele=BMIter_Step(&iter)) { + BM_ClearHFlag(ele, flag); + } + } +} + +static void EDBM_strip_selections(BMEditMesh *em) { #if 0 EditSelection *ese, *nextese; @@ -456,31 +484,28 @@ EM_editselection_center EM_editselection_normal EM_editselection_plane */ -void EDBM_editselection_center(float *center, BMEditSelection *ese) +void EDBM_editselection_center(BMEditMesh *em, float *center, BMEditSelection *ese) { -#if 0 if (ese->type==EDITVERT) { - EditVert *eve= ese->data; + BMVert *eve= ese->data; VecCopyf(center, eve->co); } else if (ese->type==EDITEDGE) { - EditEdge *eed= ese->data; + BMEdge *eed= ese->data; VecAddf(center, eed->v1->co, eed->v2->co); VecMulf(center, 0.5); } else if (ese->type==EDITFACE) { - EditFace *efa= ese->data; - VecCopyf(center, efa->cent); + BMFace *efa= ese->data; + BM_Compute_Face_Center(em->bm, efa, center); } -#endif } void EDBM_editselection_normal(float *normal, BMEditSelection *ese) { -#if 0 if (ese->type==EDITVERT) { - EditVert *eve= ese->data; + BMVert *eve= ese->data; VecCopyf(normal, eve->no); } else if (ese->type==EDITEDGE) { - EditEdge *eed= ese->data; + BMEdge *eed= ese->data; float plane[3]; /* need a plane to correct the normal */ float vec[3]; /* temp vec storage */ @@ -496,37 +521,35 @@ void EDBM_editselection_normal(float *normal, BMEditSelection *ese) Normalize(normal); } else if (ese->type==EDITFACE) { - EditFace *efa= ese->data; - VecCopyf(normal, efa->n); + BMFace *efa= ese->data; + VecCopyf(normal, efa->no); } -#endif } /* Calculate a plane that is rightangles to the edge/vert/faces normal also make the plane run allong an axis that is related to the geometry, because this is used for the manipulators Y axis.*/ -void EDBM_editselection_plane(float *plane, BMEditSelection *ese) +void EDBM_editselection_plane(BMEditMesh *em, float *plane, BMEditSelection *ese) { -#if 0 if (ese->type==EDITVERT) { - EditVert *eve= ese->data; + BMVert *eve= ese->data; float vec[3]={0,0,0}; if (ese->prev) { /*use previously selected data to make a usefull vertex plane */ - EM_editselection_center(vec, ese->prev); + EDBM_editselection_center(em, vec, ese->prev); VecSubf(plane, vec, eve->co); } else { /* make a fake plane thats at rightangles to the normal we cant make a crossvec from a vec thats the same as the vec unlikely but possible, so make sure if the normal is (0,0,1) that vec isnt the same or in the same direction even.*/ - if (eve->no[0]<0.5) vec[0]=1; + if (eve->no[0]<0.5) vec[0]=1; else if (eve->no[1]<0.5) vec[1]=1; - else vec[2]=1; + else vec[2]=1; Crossf(plane, eve->no, vec); } } else if (ese->type==EDITEDGE) { - EditEdge *eed= ese->data; + BMEdge *eed= ese->data; /*the plane is simple, it runs allong the edge however selecting different edges can swap the direction of the y axis. @@ -539,8 +562,21 @@ void EDBM_editselection_plane(float *plane, BMEditSelection *ese) VecSubf(plane, eed->v1->co, eed->v2->co); } else if (ese->type==EDITFACE) { - EditFace *efa= ese->data; - float vec[3]; + BMFace *efa= ese->data; + float vec[3] = {0.0f, 0.0f, 0.0f}; + + /*for now, use face normal*/ + + /* make a fake plane thats at rightangles to the normal + we cant make a crossvec from a vec thats the same as the vec + unlikely but possible, so make sure if the normal is (0,0,1) + that vec isnt the same or in the same direction even.*/ + if (efa->no[0]<0.5) vec[0]=1.0f; + else if (efa->no[1]<0.5) vec[1]=1.0f; + else vec[2]=1.0f; + Crossf(plane, efa->no, vec); +#if 0 + if (efa->v4) { /*if its a quad- set the plane along the 2 longest edges.*/ float vecA[3], vecB[3]; VecSubf(vecA, efa->v4->co, efa->v3->co); @@ -567,7 +603,7 @@ void EDBM_editselection_plane(float *plane, BMEditSelection *ese) if (plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2] < vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]) VecCopyf(plane, vec); } +#endif } Normalize(plane); -#endif } diff --git a/source/blender/editors/mesh/bmeshutils_mods.c b/source/blender/editors/mesh/bmeshutils_mods.c index 61eb776a584..69426fdb8c1 100644 --- a/source/blender/editors/mesh/bmeshutils_mods.c +++ b/source/blender/editors/mesh/bmeshutils_mods.c @@ -29,7 +29,7 @@ /* -BMTessMesh_mods.c, UI level access, no geometry changes +BMEditMesh_mods.c, UI level access, no geometry changes */ @@ -98,7 +98,7 @@ static int pupmenu() {return 0;} /* ****************************** MIRROR **************** */ -void EDBM_select_mirrored(Object *obedit, BMTessMesh *em) +void EDBM_select_mirrored(Object *obedit, BMEditMesh *em) { #if 0 //BMESH_TODO if(em->selectmode & SCE_SELECT_VERTEX) { @@ -106,7 +106,7 @@ void EDBM_select_mirrored(Object *obedit, BMTessMesh *em) for(eve= em->verts.first; eve; eve= eve->next) { if(eve->f & SELECT) { - v1= BMTessMesh_get_x_mirror_vert(obedit, em, eve->co); + v1= BMEditMesh_get_x_mirror_vert(obedit, em, eve->co); if(v1) { eve->f &= ~SELECT; v1->f |= SELECT; @@ -363,7 +363,7 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, int x, int y static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int index) { - BMTessMesh *em= (BMTessMesh *)handle; + BMEditMesh *em= (BMEditMesh *)handle; BMIter iter; BMVert *eve = BMIter_AtIndex(em->bm, BM_VERTS_OF_MESH, NULL, index-1); @@ -613,7 +613,7 @@ static BMFace *EDBM_findnearestface(ViewContext *vc, int *dist) */ static int unified_findnearest(ViewContext *vc, BMVert **eve, BMEdge **eed, BMFace **efa) { - BMTessMesh *em= vc->em; + BMEditMesh *em= vc->em; int dist= 75; *eve= NULL; @@ -673,7 +673,7 @@ static EnumPropertyItem prop_simface_types[] = { *0.5 so smaller faces arnt ALWAYS selected with a thresh of 1.0 */ #define SCALE_CMP(a,b) ((a+a*thresh >= b) && (a-(a*thresh*0.5) <= b)) -static int similar_face_select__internal(Scene *scene, BMTessMesh *em, int mode) +static int similar_face_select__internal(Scene *scene, BMEditMesh *em, int mode) { #if 0 //BMESH_TODO BMFace *efa, *base_efa=NULL; @@ -808,7 +808,7 @@ static int similar_face_select__internal(Scene *scene, BMTessMesh *em, int mode) /* selects quads in loop direction of indicated edge */ /* only flush over edges with valence <= 2 */ -void faceloop_select(BMTessMesh *em, BMEdge *startedge, int select) +void faceloop_select(BMEditMesh *em, BMEdge *startedge, int select) { #if 0 //BMESH_TODO BMEdge *eed; @@ -890,7 +890,7 @@ void faceloop_select(BMTessMesh *em, BMEdge *startedge, int select) - if edge no face: - has vertices with valence 2 */ -static void edgeloop_select(BMTessMesh *em, BMEdge *starteed, int select) +static void edgeloop_select(BMEditMesh *em, BMEdge *starteed, int select) { BMesh *bm = em->bm; BMEdge *e; @@ -914,7 +914,7 @@ static void edgeloop_select(BMTessMesh *em, BMEdge *starteed, int select) /* Almostly exactly the same code as faceloop select */ -static void edgering_select(BMTessMesh *em, BMEdge *startedge, int select) +static void edgering_select(BMEditMesh *em, BMEdge *startedge, int select) { #if 0 //BMESH_TODO BMEdge *eed; @@ -986,7 +986,7 @@ static int loop_multiselect(bContext *C, wmOperator *op) { #if 0 //BMESH_TODO Object *obedit= CTX_data_edit_object(C); - BMTessMesh *em= EM_GetBMTessMesh(((Mesh *)obedit->data)); + BMEditMesh *em= EM_GetBMEditMesh(((Mesh *)obedit->data)); BMEdge *eed; BMEdge **edarray; int edindex, edfirstcount; @@ -1025,9 +1025,9 @@ static int loop_multiselect(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - EM_EndBMTessMesh(obedit->data, em); - return OPERATOR_FINISHED; + EM_EndBMEditMesh(obedit->data, em); #endif + return OPERATOR_FINISHED; } void MESH_OT_select_loop_multi(wmOperatorType *ot) @@ -1057,7 +1057,7 @@ static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring { #if 0 //BMESH_TODO ViewContext vc; - BMTessMesh *em; + BMEditMesh *em; BMEdge *eed; int select= 1; int dist= 50; @@ -1135,7 +1135,7 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2]) { #if 0 //BMESH_TODO ViewContext vc; - BMTessMesh *em; + BMEditMesh *em; BMEdge *eed; int dist= 50; @@ -1236,11 +1236,10 @@ void MESH_OT_select_path_shortest(wmOperatorType *ot) /* gets called via generic mouse select operator */ void mouse_mesh(bContext *C, short mval[2], short extend) { -#if 0 //BMESH_TODO ViewContext vc; - BMVert *eve; - BMEdge *eed; - BMFace *efa; + BMVert *eve = NULL; + BMEdge *eed = NULL; + BMFace *efa = NULL; /* setup view context for argument to callbacks */ em_setup_viewcontext(C, &vc); @@ -1249,41 +1248,43 @@ void mouse_mesh(bContext *C, short mval[2], short extend) if(unified_findnearest(&vc, &eve, &eed, &efa)) { - if(extend==0) EM_clear_flag_all(vc.em, SELECT); + if(extend==0) EDBM_clear_flag_all(vc.em, BM_SELECT); if(efa) { /* set the last selected face */ - EM_set_actFace(vc.em, efa); + EDBM_set_actFace(vc.em, efa); - if( (efa->f & SELECT)==0 ) { + if(!BM_TestHFlag(efa, BM_SELECT)) { EDBM_store_selection(vc.em, efa); + BM_Select(vc.em->bm, efa, 1); } else if(extend) { EDBM_remove_selection(vc.em, efa); + BM_Select(vc.em->bm, efa, 1); } } else if(eed) { - if((eed->f & SELECT)==0) { + if(!BM_TestHFlag(efa, BM_SELECT)) { EDBM_store_selection(vc.em, eed); - EM_select_edge(eed, 1); + BM_Select(vc.em->bm, eed, 1); } else if(extend) { EDBM_remove_selection(vc.em, eed); - EM_select_edge(eed, 0); + BM_Select(vc.em->bm, eed, 0); } } else if(eve) { - if((eve->f & SELECT)==0) { - eve->f |= SELECT; + if(!BM_TestHFlag(eve, BM_SELECT)) { EDBM_store_selection(vc.em, eve); + BM_Select(vc.em->bm, eve, 1); } else if(extend){ EDBM_remove_selection(vc.em, eve); - eve->f &= ~SELECT; + BM_Select(vc.em->bm, eve, 0); } } - EM_selectmode_flush(vc.em); + EDBM_selectmode_flush(vc.em); // if (EM_texFaceCheck()) { @@ -1295,5 +1296,4 @@ void mouse_mesh(bContext *C, short mval[2], short extend) } WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit); -#endif } diff --git a/source/blender/editors/mesh/editdeform.c b/source/blender/editors/mesh/editdeform.c index 1bf81f125fb..d6dd9522a6f 100644 --- a/source/blender/editors/mesh/editdeform.c +++ b/source/blender/editors/mesh/editdeform.c @@ -114,7 +114,7 @@ void sel_verts_defgroup (Object *obedit, int select) if(select) EM_select_flush(em); // vertices to edges/faces else EM_deselect_flush(em); - EM_EndEditMesh(em, me); + EM_EndEditMesh(me, em); } break; case OB_LATTICE: diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index f9135b205a7..af6716d8fb9 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1763,6 +1763,7 @@ static void *editMesh_to_undoMesh(void *emv) return um; #endif + return NULL; } static void undoMesh_to_editMesh(void *umv, void *emv) @@ -1891,26 +1892,32 @@ static void *getEditMesh(bContext *C) /*undo simply makes copies of a bmesh*/ static void *editbtMesh_to_undoMesh(void *emv) { +#if 0 return TM_Copy(emv); +#endif } static void undoMesh_to_editbtMesh(void *umv, void *emv) { - BMTessMesh *bm1 = umv, *bm2 = emv; +#if 0 + BMEditMesh *bm1 = umv, *bm2 = emv; BM_Free_Mesh_Data(bm2->bm); TM_Free(bm2); *bm2 = *TM_Copy(bm1); +#endif } static void free_undo(void *umv) { - BMTessMesh *em = umv; +#if 0 + BMEditMesh *em = umv; BM_Free_Mesh_Data(em->bm); TM_Free(em); +#endif } /* and this is all the undo system needs to know */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index b5e6c3f5504..7213df60e14 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -100,6 +100,7 @@ static int pupmenu() {return 0;} void EM_select_mirrored(Object *obedit, EditMesh *em) { +#if 0 if(em->selectmode & SCE_SELECT_VERTEX) { EditVert *eve, *v1; @@ -113,6 +114,7 @@ void EM_select_mirrored(Object *obedit, EditMesh *em) } } } +#endif } void EM_automerge(int update) @@ -1713,255 +1715,10 @@ void MESH_OT_select_loop_multi(wmOperatorType *ot) /* ***************** MAIN MOUSE SELECTION ************** */ -/* ***************** loop select (non modal) ************** */ - -static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring) -{ - ViewContext vc; - EditMesh *em; - EditEdge *eed; - int select= 1; - int dist= 50; - - em_setup_viewcontext(C, &vc); - vc.mval[0]= mval[0]; - vc.mval[1]= mval[1]; - em= vc.em; - - eed= findnearestedge(&vc, &dist); - if(eed) { - if(extend==0) EM_clear_flag_all(em, SELECT); - - if((eed->f & SELECT)==0) select=1; - else if(extend) select=0; - - if(em->selectmode & SCE_SELECT_FACE) { - faceloop_select(em, eed, select); - } - else if(em->selectmode & SCE_SELECT_EDGE) { - if(ring) - edgering_select(em, eed, select); - else - edgeloop_select(em, eed, select); - } - else if(em->selectmode & SCE_SELECT_VERTEX) { - if(ring) - edgering_select(em, eed, select); - else - edgeloop_select(em, eed, select); - } - - EM_selectmode_flush(em); -// if (EM_texFaceCheck()) - - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit); - } -} - -static int mesh_select_loop_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - - view3d_operator_needs_opengl(C); - - mouse_mesh_loop(C, event->mval, RNA_boolean_get(op->ptr, "extend"), - RNA_boolean_get(op->ptr, "ring")); - - /* cannot do tweaks for as long this keymap is after transform map */ - return OPERATOR_FINISHED; -} - -#if 0 //moved to bmeshutils_mods.c -void MESH_OT_select_loop(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Loop Select"; - ot->idname= "MESH_OT_select_loop"; - - /* api callbacks */ - ot->invoke= mesh_select_loop_invoke; - ot->poll= ED_operator_editmesh; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* properties */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); - RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", ""); -} -#endif - /* ******************* mesh shortest path select, uses prev-selected edge ****************** */ -/* since you want to create paths with multiple selects, it doesn't have extend option */ -static void mouse_mesh_shortest_path(bContext *C, short mval[2]) -{ - ViewContext vc; - EditMesh *em; - EditEdge *eed; - int dist= 50; - - em_setup_viewcontext(C, &vc); - vc.mval[0]= mval[0]; - vc.mval[1]= mval[1]; - em= vc.em; - - eed= findnearestedge(&vc, &dist); - if(eed) { - Mesh *me= vc.obedit->data; - int path = 0; - - if (em->selected.last) { - EditSelection *ese = em->selected.last; - - if(ese && ese->type == EDITEDGE) { - EditEdge *eed_act; - eed_act = (EditEdge*)ese->data; - if (eed_act != eed) { - if (edgetag_shortest_path(vc.scene, em, eed_act, eed)) { - EM_remove_selection(em, eed_act, EDITEDGE); - path = 1; - } - } - } - } - if (path==0) { - int act = (edgetag_context_check(vc.scene, eed)==0); - edgetag_context_set(vc.scene, eed, act); /* switch the edge option */ - } - - EM_selectmode_flush(em); - - /* even if this is selected it may not be in the selection list */ - if(edgetag_context_check(vc.scene, eed)==0) - EM_remove_selection(em, eed, EDITEDGE); - else - EM_store_selection(em, eed, EDITEDGE); - - /* force drawmode for mesh */ - switch (vc.scene->toolsettings->edge_mode) { - - case EDGE_MODE_TAG_SEAM: - me->drawflag |= ME_DRAWSEAMS; - break; - case EDGE_MODE_TAG_SHARP: - me->drawflag |= ME_DRAWSHARP; - break; - case EDGE_MODE_TAG_CREASE: - me->drawflag |= ME_DRAWCREASES; - break; - case EDGE_MODE_TAG_BEVEL: - me->drawflag |= ME_DRAWBWEIGHTS; - break; - } - - DAG_object_flush_update(vc.scene, vc.obedit, OB_RECALC_DATA); - - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit); - } -} - - -static int mesh_shortest_path_select_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - - view3d_operator_needs_opengl(C); - - mouse_mesh_shortest_path(C, event->mval); - - return OPERATOR_FINISHED; -} - -#if 0 //moved to bmeshutils_mods.c -void MESH_OT_select_path_shortest(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Shortest Path Select"; - ot->idname= "MESH_OT_select_path_shortest"; - - /* api callbacks */ - ot->invoke= mesh_shortest_path_select_invoke; - ot->poll= ED_operator_editmesh; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* properties */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); -} -#endif - /* ************************************************** */ - -#if 0 //moved to bmeshutils_mods.c -/* here actual select happens */ -/* gets called via generic mouse select operator */ -void mouse_mesh(bContext *C, short mval[2], short extend) -{ - ViewContext vc; - EditVert *eve; - EditEdge *eed; - EditFace *efa; - - /* setup view context for argument to callbacks */ - em_setup_viewcontext(C, &vc); - vc.mval[0]= mval[0]; - vc.mval[1]= mval[1]; - - if(unified_findnearest(&vc, &eve, &eed, &efa)) { - - if(extend==0) EM_clear_flag_all(vc.em, SELECT); - - if(efa) { - /* set the last selected face */ - EM_set_actFace(vc.em, efa); - - if( (efa->f & SELECT)==0 ) { - EM_store_selection(vc.em, efa, EDITFACE); - EM_select_face_fgon(vc.em, efa, 1); - } - else if(extend) { - EM_remove_selection(vc.em, efa, EDITFACE); - EM_select_face_fgon(vc.em, efa, 0); - } - } - else if(eed) { - if((eed->f & SELECT)==0) { - EM_store_selection(vc.em, eed, EDITEDGE); - EM_select_edge(eed, 1); - } - else if(extend) { - EM_remove_selection(vc.em, eed, EDITEDGE); - EM_select_edge(eed, 0); - } - } - else if(eve) { - if((eve->f & SELECT)==0) { - eve->f |= SELECT; - EM_store_selection(vc.em, eve, EDITVERT); - } - else if(extend){ - EM_remove_selection(vc.em, eve, EDITVERT); - eve->f &= ~SELECT; - } - } - - EM_selectmode_flush(vc.em); - -// if (EM_texFaceCheck()) { - - 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, vc.obedit); - -} -#endif - /* *********** select linked ************* */ /* for use with selectconnected_delimit_mesh only! */ @@ -4075,10 +3832,11 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *o static int smooth_vertex(bContext *C, wmOperator *op) { +#if 0 //BMESH_TODO Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); Mesh *me= obedit->data; - EditMesh *em= me; + EditMesh *em= EM_GetEditMesh(me); EditVert *eve, *eve_mir = NULL; EditEdge *eed; @@ -4215,6 +3973,7 @@ static int smooth_vertex(bContext *C, wmOperator *op) // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); EM_EndEditMesh(obedit->data, em); +#endif return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 7a37cf6f5df..0342a39f855 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4759,6 +4759,7 @@ static void mesh_rip_setface(EditMesh *em, EditFace *sefa) /* based on mouse cursor position, it defines how is being ripped */ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) { +#if 0 //BMESH_TODO ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= ar->regiondata; Object *obedit= CTX_data_edit_object(C); @@ -4967,6 +4968,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) // XXX scene->proportional = prop; EM_EndEditMesh(obedit->data, em); +#endif return OPERATOR_FINISHED; } @@ -5034,6 +5036,7 @@ void shape_propagate(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op) void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock) { +#if 0 //BMESH_TODO EditVert *ev = NULL; short mval[2], curval[2], event = 0, finished = 0, canceled = 0, fullcopy=0 ; float perc = 0; @@ -5110,6 +5113,7 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock } } return; +#endif } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index d618b524010..e71f4c7ce0b 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -40,7 +40,10 @@ struct bContext; struct wmOperatorType; struct ViewContext; +struct BMEditMesh; struct BMesh; +struct BMEdge; +struct BMFace; #define UVCOPY(t, s) memcpy(t, s, 2 * sizeof(float)); @@ -55,9 +58,14 @@ int EDBM_CallOpfSilent(EditMesh *em, char *fmt, ...); if any errors are raised by bmesh, it displays the error to the user and returns 0 (and does not convert). otherwise, it converts the bmesh back into the editmesh, and returns 1.*/ -int EDBM_Finish(struct BMesh *bm, EditMesh *em, +int EDBM_Finish(struct BMesh *bm, struct EditMesh *em, struct wmOperator *op, int report); +void EDBM_clear_flag_all(struct BMEditMesh *em, int flag); +void EDBM_set_actFace(struct BMEditMesh *em, struct BMFace *efa); +void EDBM_store_selection(struct BMEditMesh *em, void *data); +void EDBM_validate_selections(struct BMEditMesh *em); +void EDBM_remove_selection(struct BMEditMesh *em, void *data); /* ******************** editface.c */ @@ -206,7 +214,7 @@ void editmesh_select_by_material(EditMesh *em, int index); void righthandfaces(EditMesh *em, int select); /* makes faces righthand turning */ void EM_select_more(EditMesh *em); void selectconnected_mesh_all(EditMesh *em); -void faceloop_select(EditMesh *em, EditEdge *startedge, int select); +void faceloop_select(struct BMEditMesh *em, struct BMEdge *startedge, int select); /** * findnearestvert diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index ebcd82c6a70..f5e3f12bc6d 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -46,6 +46,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "RNA_access.h" #include "RNA_define.h" diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index f737e1a927f..6f4560be895 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -703,7 +703,7 @@ static struct { /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ -intptr_t mesh_octree_table(Object *ob, BMTessMesh *em, float *co, char mode) +intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) { MocNode **bt; @@ -777,7 +777,7 @@ intptr_t mesh_octree_table(Object *ob, BMTessMesh *em, float *co, char mode) BMIter iter; eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for (; eve; eve=BMIter_Step) { + for (; eve; eve=BMIter_Step(&iter)) { mesh_octree_add_nodes(MeshOctree.table, eve->co, MeshOctree.offs, MeshOctree.div, (intptr_t)(eve)); } } @@ -833,7 +833,7 @@ int mesh_get_x_mirror_vert(Object *ob, int index) return mesh_octree_table(ob, NULL, vec, 'u'); } -EditVert *editmesh_get_x_mirror_vert(Object *ob, EditMesh *em, float *co) +BMVert *editmesh_get_x_mirror_vert(Object *ob, BMEditMesh *em, float *co) { float vec[3]; intptr_t poinval; @@ -901,7 +901,7 @@ static int mirror_facecmp(void *a, void *b) return (mirror_facerotation((MFace*)a, (MFace*)b) == -1); } -int *mesh_get_x_mirror_faces(Object *ob, EditMesh *em) +int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em) { Mesh *me= ob->data; MVert *mv, *mvert= me->mvert; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 3838acf94c3..4df50d01fb1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -51,6 +51,7 @@ #include "BKE_report.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "WM_api.h" #include "WM_types.h" diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index 80ace5500b8..c7b2f1bd360 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -47,6 +47,7 @@ #include "BKE_image.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_image/image_panels.c b/source/blender/editors/space_image/image_panels.c index b6da7415f1f..29ddbd569e4 100644 --- a/source/blender/editors/space_image/image_panels.c +++ b/source/blender/editors/space_image/image_panels.c @@ -59,6 +59,7 @@ #include "BKE_packedFile.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "RE_pipeline.h" diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index db8bdbdacc8..1530a97d5a7 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -49,6 +49,7 @@ #include "BKE_image.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ac649bc4cb6..ff501fbc6f7 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1371,7 +1371,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb static void draw_dm_face_normals__mapFunc(void *userData, int index, float *cent, float *no) { Scene *scene= ((void **)userData)[0]; - BMTessMesh *em = ((void **)userData)[1]; + BMEditMesh *em = ((void **)userData)[1]; BMFace *efa = EDBM_get_face_for_index(em, index); if (!BM_TestHFlag(efa, BM_HIDDEN)) { @@ -1381,7 +1381,7 @@ static void draw_dm_face_normals__mapFunc(void *userData, int index, float *cent cent[2] + no[2]*scene->editbutsize); } } -static void draw_dm_face_normals(BMTessMesh *tm, Scene *scene, DerivedMesh *dm) +static void draw_dm_face_normals(BMEditMesh *tm, Scene *scene, DerivedMesh *dm) { void *ptrs[2] = {scene, tm}; @@ -1393,14 +1393,14 @@ static void draw_dm_face_normals(BMTessMesh *tm, Scene *scene, DerivedMesh *dm) static void draw_dm_face_centers__mapFunc(void *userData, int index, float *cent, float *no) { BMFace *efa = EDBM_get_face_for_index(((void **)userData)[0], index); - BMTessMesh *em = ((void **)userData)[0]; + BMEditMesh *em = ((void **)userData)[0]; int sel = *(((int **)userData)[1]); if (!BM_TestHFlag(efa, BM_HIDDEN) && BM_TestHFlag(efa, BM_SELECT)==sel) { bglVertex3fv(cent); } } -static void draw_dm_face_centers(BMTessMesh *em, DerivedMesh *dm, int sel) +static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, int sel) { void *ptrs[2] = {em, &sel}; @@ -1412,7 +1412,7 @@ static void draw_dm_face_centers(BMTessMesh *em, DerivedMesh *dm, int sel) static void draw_dm_vert_normals__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s) { Scene *scene= ((void **)userData)[0]; - BMTessMesh *em = ((void **)userData)[1]; + BMEditMesh *em = ((void **)userData)[1]; BMVert *eve = EDBM_get_vert_for_index(em, index); if (!BM_TestHFlag(eve, BM_HIDDEN)) { @@ -1429,7 +1429,7 @@ static void draw_dm_vert_normals__mapFunc(void *userData, int index, float *co, } } } -static void draw_dm_vert_normals(BMTessMesh *em, Scene *scene, DerivedMesh *dm) +static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, DerivedMesh *dm) { void *ptrs[2] = {scene, em}; @@ -1441,7 +1441,7 @@ static void draw_dm_vert_normals(BMTessMesh *em, Scene *scene, DerivedMesh *dm) /* Draw verts with color set based on selection */ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s) { - struct { BMTessMesh *em; int sel; BMVert *eve_act; } *data = userData; + struct { BMEditMesh *em; int sel; BMVert *eve_act; } *data = userData; BMVert *eve = EDBM_get_vert_for_index(data->em, index); if (!BM_TestHFlag(eve, BM_HIDDEN) && BM_TestHFlag(eve, BM_SELECT)==data->sel) { @@ -1465,9 +1465,9 @@ static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float * } } } -static void draw_dm_verts(BMTessMesh *em, DerivedMesh *dm, int sel, BMVert *eve_act) +static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, int sel, BMVert *eve_act) { - struct { BMTessMesh *em; int sel; BMVert *eve_act; } data; + struct { BMEditMesh *em; int sel; BMVert *eve_act; } data; data.sel = sel; data.eve_act = eve_act; data.em = em; @@ -1482,7 +1482,7 @@ static int draw_dm_edges_sel__setDrawOptions(void *userData, int index) { BMEdge *eed; //unsigned char **cols = userData, *col; - struct { BMTessMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } * data = userData; + struct { BMEditMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } * data = userData; unsigned char *col; eed = EDBM_get_edge_for_index(data->em, index); @@ -1506,10 +1506,10 @@ static int draw_dm_edges_sel__setDrawOptions(void *userData, int index) return 0; } } -static void draw_dm_edges_sel(BMTessMesh *em, DerivedMesh *dm, unsigned char *baseCol, +static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act) { - struct { BMTessMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } data; + struct { BMEditMesh *em; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; } data; data.baseCol = baseCol; data.selCol = selCol; @@ -1524,7 +1524,7 @@ static int draw_dm_edges__setDrawOptions(void *userData, int index) { return !BM_TestHFlag(EDBM_get_edge_for_index(userData, index), BM_HIDDEN); } -static void draw_dm_edges(BMTessMesh *em, DerivedMesh *dm) +static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em); } @@ -1546,7 +1546,7 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i col0[2] + (col1[2]-col0[2])*t, col0[3] + (col1[3]-col0[3])*t); } -static void draw_dm_edges_sel_interp(BMTessMesh *em, DerivedMesh *dm, +static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) { unsigned char *cols[2]; @@ -1566,7 +1566,7 @@ static int draw_dm_edges_seams__setDrawOptions(void *userData, int index) return !BM_TestHFlag(eed, BM_HIDDEN) && BM_TestHFlag(eed, BM_SEAM); } -static void draw_dm_edges_seams(BMTessMesh *em, DerivedMesh *dm) +static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em); } @@ -1578,7 +1578,7 @@ static int draw_dm_edges_sharp__setDrawOptions(void *userData, int index) return !BM_TestHFlag(eed, BM_HIDDEN) && BM_TestHFlag(eed, BM_SHARP); } -static void draw_dm_edges_sharp(BMTessMesh *em, DerivedMesh *dm) +static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) { dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em); } @@ -1588,7 +1588,7 @@ static void draw_dm_edges_sharp(BMTessMesh *em, DerivedMesh *dm) * return 2 for the active face so it renders with stipple enabled */ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *drawSmooth_r) { - struct { unsigned char *cols[3]; BMTessMesh *em; BMFace *efa_act; } *data = userData; + struct { unsigned char *cols[3]; BMEditMesh *em; BMFace *efa_act; } *data = userData; BMFace *efa = EDBM_get_face_for_index(data->em, index); unsigned char *col; @@ -1607,10 +1607,10 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *dra } /* also draws the active face */ -static void draw_dm_faces_sel(BMTessMesh *em, DerivedMesh *dm, unsigned char *baseCol, +static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, BMFace *efa_act) { - struct { unsigned char *cols[3]; BMTessMesh *em; BMFace *efa_act; } data; + struct { unsigned char *cols[3]; BMEditMesh *em; BMFace *efa_act; } data; data.cols[0] = baseCol; data.em = em; @@ -1632,7 +1632,7 @@ static int draw_dm_creases__setDrawOptions(void *userData, int index) return 0; } } -static void draw_dm_creases(BMTessMesh *em, DerivedMesh *dm) +static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) { glLineWidth(3.0); dm->drawMappedEdges(dm, draw_dm_creases__setDrawOptions, em); @@ -1659,7 +1659,7 @@ static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, floa bglVertex3fv(co); } } -static void draw_dm_bweights(BMTessMesh *em, Scene *scene, DerivedMesh *dm) +static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) { if (scene->selectmode & SCE_SELECT_VERTEX) { glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) + 2); @@ -1684,7 +1684,7 @@ static void draw_dm_bweights(BMTessMesh *em, Scene *scene, DerivedMesh *dm) /* EditMesh drawing routines*/ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, - BMTessMesh *em, DerivedMesh *cageDM, BMVert *eve_act) + BMEditMesh *em, DerivedMesh *cageDM, BMVert *eve_act) { int sel; @@ -1740,7 +1740,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, glPointSize(1.0); } -static void draw_em_fancy_edges(BMTessMesh *em, Scene *scene, View3D *v3d, +static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, Mesh *me, DerivedMesh *cageDM, short sel_only, BMEdge *eed_act) { @@ -1800,7 +1800,7 @@ static void draw_em_fancy_edges(BMTessMesh *em, Scene *scene, View3D *v3d, } static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, - Object *ob, BMTessMesh *em) + Object *ob, BMEditMesh *em) { #if 0 Mesh *me= ob->data; @@ -1991,7 +1991,7 @@ static int draw_em_fancy__setGLSLFaceOpts(void *userData, int index) } static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, - BMTessMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt) + BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt) { Mesh *me = ob->data; @@ -2400,7 +2400,7 @@ static int draw_mesh_object(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base Object *ob= base->object; Object *obedit= scene->obedit; Mesh *me= ob->data; - BMTessMesh *em= me->edit_btmesh; + BMEditMesh *em= me->edit_btmesh; int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha; if(obedit && ob!=obedit && ob->data==obedit->data) { @@ -5291,13 +5291,13 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float bglVertex3fv(co); } } -static void bbs_mesh_verts(BMTessMesh *em, DerivedMesh *dm, int offset) +static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) { void *ptrs[2] = {(void*)(intptr_t) offset, em}; glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) ); bglBegin(GL_POINTS); - dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, (void*)(intptr_t) offset); + dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, ptrs); bglEnd(); glPointSize(1.0); } @@ -5315,7 +5315,7 @@ static int bbs_mesh_wire__setDrawOptions(void *userData, int index) return 0; } } -static void bbs_mesh_wire(BMTessMesh *em, DerivedMesh *dm, int offset) +static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) { void *ptrs[2] = {(void*)(intptr_t) offset, em}; dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs); @@ -5345,7 +5345,7 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, float *cent, f } /* two options, facecolors or black */ -static void bbs_mesh_solid_EM(BMTessMesh *em, Scene *scene, View3D *v3d, +static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol) { void *ptrs[2] = {em, NULL}; //second one being null means to draw black @@ -5405,7 +5405,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec { if(ob == scene->obedit) { Mesh *me= ob->data; - BMTessMesh *em= me->edit_btmesh; + BMEditMesh *em= me->edit_btmesh; DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index bbcb8b3601d..322dc61ecf5 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -66,6 +66,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "BIF_gl.h" #include "BIF_transform.h" diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 39cf6bd5fb4..6db7ae19cd3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -150,7 +150,7 @@ static void BIF_undo_push() {} /* local prototypes */ -void EM_backbuf_checkAndSelectVerts(BMTessMesh *em, int select) +void EM_backbuf_checkAndSelectVerts(BMEditMesh *em, int select) { BMVert *eve; BMIter iter; @@ -166,7 +166,7 @@ void EM_backbuf_checkAndSelectVerts(BMTessMesh *em, int select) } } -void EM_backbuf_checkAndSelectEdges(BMTessMesh *em, int select) +void EM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select) { BMEdge *eed; BMIter iter; @@ -182,7 +182,7 @@ void EM_backbuf_checkAndSelectEdges(BMTessMesh *em, int select) } } -void EM_backbuf_checkAndSelectFaces(BMTessMesh *em, int select) +void EM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select) { BMFace *efa; BMIter iter; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 62909db0478..52b23f7e00e 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -192,7 +192,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; - BMTessMesh *em= me->edit_btmesh; + BMEditMesh *em= me->edit_btmesh; BMesh *bm = em->bm; int proptrans= 0; @@ -877,7 +877,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *op) BMEditSelection ese; if (EDBM_get_actSelection(me->edit_btmesh, &ese)) { - EDBM_editselection_center(curs, &ese); + EDBM_editselection_center(me->edit_btmesh, curs, &ese); } Mat4MulVecfl(obedit->obmat, curs); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index f331d1e42b7..85657f96fd1 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2014,7 +2014,7 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, } #undef TAN_MAKE_VEC -static void set_crazyspace_quats(BMTessMesh *em, float *origcos, float *mappedcos, float *quats) +static void set_crazyspace_quats(BMEditMesh *em, float *origcos, float *mappedcos, float *quats) { #if 0 BMVert *eve, *prev; @@ -2115,7 +2115,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) { Scene *scene = CTX_data_scene(C); TransData *tob = NULL; - BMTessMesh *em = ((Mesh *)t->obedit->data)->edit_btmesh; + BMEditMesh *em = ((Mesh *)t->obedit->data)->edit_btmesh; BMesh *bm = em->bm; BMVert *eve; BMVert **nears = NULL; @@ -4649,7 +4649,7 @@ void special_aftertrans_update(TransInfo *t) if (t->obedit->type == OB_MESH) { - BMTessMesh *em = ((Mesh *)t->obedit->data)->edit_btmesh; + BMEditMesh *em = ((Mesh *)t->obedit->data)->edit_btmesh; /* table needs to be created for each edit command, since vertices can move etc */ mesh_octree_table(t->obedit, em, NULL, 'e'); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 2f077d15e03..21e18f09882 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -463,7 +463,7 @@ void recalcData(TransInfo *t) DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); } else { - BMTessMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh; + BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh; /* mirror modifier clipping? */ if(t->state != TRANS_CANCEL) { /* TRANSFORM_FIX_ME */ diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 46488184436..a14ac9272a0 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -558,7 +558,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac if(ob->type==OB_MESH) { Mesh *me= ob->data; - BMTessMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMEditSelection ese; float vec[3]= {0,0,0}; @@ -567,7 +567,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac if (activeOnly && EDBM_get_actSelection(em, &ese)) { EDBM_editselection_normal(normal, &ese); - EDBM_editselection_plane(plane, &ese); + EDBM_editselection_plane(em, plane, &ese); switch (ese.type) { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 89981963e6f..0ce29075b61 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -71,6 +71,8 @@ #include "BKE_object.h" #include "BKE_anim.h" /* for duplis */ #include "BKE_context.h" +#include "BKE_tessmesh.h" +#include "BKE_mesh.h" #include "ED_armature.h" #include "ED_image.h" @@ -1110,7 +1112,7 @@ int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float return retval; } -int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, EditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth) +int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[][4], float ray_start[3], float ray_normal[3], short mval[2], float *loc, float *no, int *dist, float *depth) { int retval = 0; int totvert = dm->getNumVerts(dm); @@ -1157,11 +1159,11 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { index_array = dm->getFaceDataArray(dm, CD_ORIGINDEX); - EM_init_index_arrays(em, 0, 0, 1); + EDBM_init_index_arrays(em, 0, 0, 1); } for( i = 0; i < totface; i++) { - EditFace *efa = NULL; + BMFace *efa = NULL; MFace *f = faces + i; test = 1; /* reset for every face */ @@ -1183,11 +1185,22 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E } else { - efa = EM_get_face_for_index(index); + efa = EDBM_get_face_for_index(em, index); - if (efa && (efa->h || (efa->v1->f & SELECT) || (efa->v2->f & SELECT) || (efa->v3->f & SELECT) || (efa->v4 && efa->v4->f & SELECT))) + if (efa && BM_TestHFlag(efa, BM_HIDDEN)) { test = 0; + } else if (efa) { + BMIter iter; + BMLoop *l; + + l = BMIter_New(&iter, em->bm, BM_LOOPS_OF_FACE, efa); + for ( ; l; l=BMIter_Step(&iter)) { + if (BM_TestHFlag(l->v, BM_SELECT)) { + test = 0; + break; + } + } } } } @@ -1215,7 +1228,7 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { - EM_free_index_arrays(); + EDBM_free_index_arrays(em); } break; } @@ -1229,11 +1242,11 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); - EM_init_index_arrays(em, 1, 0, 0); + EDBM_init_index_arrays(em, 1, 0, 0); } for( i = 0; i < totvert; i++) { - EditVert *eve = NULL; + BMVert *eve = NULL; MVert *v = verts + i; test = 1; /* reset for every vert */ @@ -1255,9 +1268,9 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E } else { - eve = EM_get_vert_for_index(index); + eve = EDBM_get_vert_for_index(em, index); - if (eve && (eve->h || (eve->f & SELECT))) + if (eve && (BM_TestHFlag(eve, BM_HIDDEN) || BM_TestHFlag(eve, BM_SELECT))) { test = 0; } @@ -1273,7 +1286,7 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { - EM_free_index_arrays(); + EDBM_free_index_arrays(em); } break; } @@ -1289,11 +1302,11 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX); - EM_init_index_arrays(em, 0, 1, 0); + EDBM_init_index_arrays(em, 0, 1, 0); } for( i = 0; i < totedge; i++) { - EditEdge *eed = NULL; + BMEdge *eed = NULL; MEdge *e = edges + i; test = 1; /* reset for every vert */ @@ -1315,9 +1328,11 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E } else { - eed = EM_get_edge_for_index(index); + eed = EDBM_get_edge_for_index(em, index); - if (eed && (eed->h || (eed->v1->f & SELECT) || (eed->v2->f & SELECT))) + if (eed && (BM_TestHFlag(eed, BM_HIDDEN) || + BM_TestHFlag(eed->v1, BM_SELECT) || + BM_TestHFlag(eed->v2, BM_SELECT))) { test = 0; } @@ -1333,7 +1348,7 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E if (em != NULL) { - EM_free_index_arrays(); + EDBM_free_index_arrays(em); } break; } @@ -1349,7 +1364,7 @@ int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obma int retval = 0; if (ob->type == OB_MESH) { - EditMesh *em; + BMEditMesh *em; DerivedMesh *dm; if (editobject) @@ -1617,6 +1632,7 @@ int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase Object *ob = dupli_ob->ob; if (ob->type == OB_MESH) { +#if 0 //BMESH_TODO DerivedMesh *dm; int val; @@ -1625,6 +1641,7 @@ int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase retval = retval || val; dm->release(dm); +#endif } } @@ -1632,7 +1649,7 @@ int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase } if (ob->type == OB_MESH) { - EditMesh *em; + BMEditMesh *em; DerivedMesh *dm = NULL; int val; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index afdc4602fcc..74ffc0b0725 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -40,6 +40,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "BLI_arithb.h" #include "BLI_editVert.h" diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 7146ac84152..6f2a10bd5a9 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -70,7 +70,7 @@ typedef struct Mesh { struct Mesh *texcomesh; struct MSelect *mselect; - struct BMTessMesh *edit_btmesh; /* not saved in file! */ + struct BMEditMesh *edit_btmesh; /* not saved in file! */ struct CustomData vdata, edata, fdata; |