add CDDM_from_bmesh(), avoids using BMEditMesh in modifiers.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 24 Oct 2012 07:24:11 +0000 (07:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 24 Oct 2012 07:24:11 +0000 (07:24 +0000)
20 files changed:
source/blender/blenkernel/BKE_bmesh.h
source/blender/blenkernel/BKE_cdderivedmesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/constraint.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/tools/BME_bevel.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/modifiers/intern/MOD_armature.c
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_bevel.c
source/blender/modifiers/intern/MOD_curve.c
source/blender/modifiers/intern/MOD_decimate.c
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/modifiers/intern/MOD_lattice.c
source/blender/modifiers/intern/MOD_mirror.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_weightvgproximity.c

index 67b21eb764c4a2c62df827ddccf3410811805a09..8bfee836c0ddb7dd090b8b30fb02f0dda089f533 100644 (file)
@@ -99,7 +99,7 @@ typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
 
 struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v);
 void BME_free_transdata(struct BME_TransData_Head *td);
-struct BMesh *BME_bevel(struct BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle,
-                        BME_TransData_Head **rtd, int do_tessface);
+struct BMesh *BME_bevel(struct BMesh *bm, float value, int res, int options, int defgrp_index, float angle,
+                        BME_TransData_Head **rtd);
 
 #endif
index d7882d8e7eceb54784f94670081472851286f11f..2b2497f3f509358ed39f95bdd2aebd599cdca806 100644 (file)
@@ -55,8 +55,10 @@ int CDDM_Check(struct DerivedMesh *dm);
  * data to not overwrite the original */
 struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
 
+struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps);
+
 /* creates a CDDerivedMesh from the given BMEditMesh */
-DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps, int use_tessface);
+DerivedMesh *CDDM_from_editbmesh(struct BMEditMesh *em, int use_mdisps, int use_tessface);
 
 /* merge verts  */
 DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap);
index 49025ceaaa125451d4cb7df87821783b95833b15..4c4f7bdad80ac65ccc31568c0b1b6f47c7a35d68 100644 (file)
@@ -903,7 +903,7 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
        float (*orco)[3];
        int free;
 
-       if (em) dm = CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
+       if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
        else dm = CDDM_from_mesh(me, ob);
 
        orco = get_orco_coords_dm(ob, em, layer, &free);
@@ -1976,7 +1976,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
 
                        }
                        else {
-                               dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+                               dm = CDDM_from_editbmesh(em, FALSE, FALSE);
 
                                if (deformedVerts) {
                                        CDDM_apply_vert_coords(dm, deformedVerts);
index 7c13f041e98584def7e8c7a60df7114f64eeb31b..1f02ad1ea5a87412b7f1faec9cf1a54816f33a70 100644 (file)
@@ -1791,10 +1791,10 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase, int **orco
 }
 
 static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
-                                        int cdindex, BMLoop *l3[3],
+                                        int cdindex, const BMLoop *l3[3],
                                         int numCol, int numTex)
 {
-       BMLoop *l;
+       const BMLoop *l;
        BMFace *f = l3[0]->f;
        MTFace *texface;
        MTexPoly *texpoly;
@@ -1837,13 +1837,16 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
        }
 }
 
-DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps, int use_tessface)
+/* used for both editbmesh and bmesh */
+static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps,
+                                       /* EditBMesh vars for use_tessface */
+                                       int use_tessface,
+                                       const int em_tottri, const BMLoop *(*em_looptris)[3]
+                                       )
 {
-       BMesh *bm = em->bm;
-
        DerivedMesh *dm = CDDM_new(bm->totvert,
                                   bm->totedge,
-                                  use_tessface ? em->tottri : 0,
+                                  use_tessface ? em_tottri : 0,
                                   bm->totloop,
                                   bm->totface);
 
@@ -1889,7 +1892,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
        
        /* add tessellation mface layers */
        if (use_tessface) {
-               CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+               CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em_tottri);
        }
 
        index = dm->getVertDataArray(dm, CD_ORIGINDEX);
@@ -1955,7 +1958,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
                index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
                for (i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
                        MFace *mf = &mface[i];
-                       BMLoop **l = em->looptris[i];
+                       const BMLoop **l = em_looptris[i];
                        efa = l[0]->f;
 
                        mf->v1 = BM_elem_index_get(l[0]->v);
@@ -2005,6 +2008,20 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
        return dm;
 }
 
+struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps)
+{
+       return cddm_from_bmesh_ex(bm, use_mdisps, FALSE,
+                                 /* these vars are for editmesh only */
+                                 0, NULL);
+}
+
+DerivedMesh *CDDM_from_editbmesh(BMEditMesh *em, int use_mdisps, int use_tessface)
+{
+       return cddm_from_bmesh_ex(em->bm, use_mdisps,
+                                 /* editmesh */
+                                 use_tessface, em->tottri, (const BMLoop *(*)[3])em->looptris);
+}
+
 static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces)
 {
        CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm");
index fc0bf9f1291f3abd1c799f09105ecc3bde02e0c8..aef9ad633f794cd188f16354ee25861d3b3361fe 100644 (file)
@@ -432,7 +432,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[
        /* get DerivedMesh */
        if (em) {
                /* target is in editmode, so get a special derived mesh */
-               dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+               dm = CDDM_from_editbmesh(em, FALSE, FALSE);
                freeDM = 1;
        }
        else {
index 360e2c93de38037df635f0d5d11cf5d8dea3e744..32879caec713863af92438b37688978a1a49dd15 100644 (file)
@@ -295,7 +295,7 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from
        /* switch multires data out of tangent space */
        if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
                BMEditMesh *em = BMEdit_Create(bm, FALSE);
-               DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
+               DerivedMesh *dm = CDDM_from_editbmesh(em, TRUE, FALSE);
                MDisps *mdisps;
                BMFace *f;
                BMIter iter;
index 98f270abd163f7fe615c718455ce973582eb5c07..a632a4446ed2596525969e35e17f3c00b778afaa 100644 (file)
@@ -1096,10 +1096,9 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option
        return bm;
 }
 
-BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle,
-                 BME_TransData_Head **rtd, int do_tessface)
+BMesh *BME_bevel(BMesh *bm, float value, int res, int options, int defgrp_index, float angle,
+                 BME_TransData_Head **rtd)
 {
-       BMesh *bm = em->bm;
        BMVert *v;
        BMIter iter;
 
@@ -1126,12 +1125,6 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i
                BMO_pop(bm);
        }
 
-       /* possibly needed when running as a tool (which is no longer functional)
-        * but keep as an option for now */
-       if (do_tessface) {
-               BMEdit_RecalcTessellation(em);
-       }
-
        /* interactive preview? */
        if (rtd) {
                *rtd = td;
index 926b6cfe59e051dddd919e588ef7ae2c9bd14a1e..74d007e92c03472232cf604916303db839a51d1c 100644 (file)
@@ -408,7 +408,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
        smd.levels = scene->toolsettings->uv_subsurf_level;
        smd.subdivType = ME_CC_SUBSURF;
                
-       initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0);
+       initialDerived = CDDM_from_editbmesh(em, FALSE, FALSE);
        derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd,
                                                        NULL, SUBSURF_IN_EDIT_MODE);
 
index e6d86de45b444cdf659f9bb8938cc48c0f08d264..7219038b087f446f8a62184c958717ff111a3c6f 100644 (file)
@@ -135,13 +135,13 @@ static void deformVerts(ModifierData *md, Object *ob,
 }
 
 static void deformVertsEM(
-        ModifierData *md, Object *ob, struct BMEditMesh *editData,
+        ModifierData *md, Object *ob, struct BMEditMesh *em,
         DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
 {
        ArmatureModifierData *amd = (ArmatureModifierData *) md;
        DerivedMesh *dm = derivedData;
 
-       if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+       if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
 
        modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
 
@@ -158,14 +158,14 @@ static void deformVertsEM(
 }
 
 static void deformMatricesEM(
-        ModifierData *md, Object *ob, struct BMEditMesh *editData,
+        ModifierData *md, Object *ob, struct BMEditMesh *em,
         DerivedMesh *derivedData, float (*vertexCos)[3],
         float (*defMats)[3][3], int numVerts)
 {
        ArmatureModifierData *amd = (ArmatureModifierData *) md;
        DerivedMesh *dm = derivedData;
 
-       if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+       if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
 
        armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
                              amd->deformflag, NULL, amd->defgrp_name);
index 26682e3084103380826e723160288c1c57af9dda..7b699e5633c2349e350764fda8342e1212eb4218 100644 (file)
@@ -53,7 +53,8 @@
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
 
 #include "depsgraph_private.h"
 
@@ -310,7 +311,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                                           int UNUSED(initFlags))
 {
        DerivedMesh *result;
-       BMEditMesh *em = DM_to_editbmesh(dm, NULL, FALSE);
+       BMesh *bm = DM_to_bmesh(dm);
        BMOperator first_dupe_op, dupe_op, old_dupe_op, weld_op;
        BMVert **first_geom = NULL;
        int i, j, indexLen;
@@ -406,14 +407,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
         * cleaner way to do this. One possibility: a "mirror" BMOp would
         * certainly help by compressing it all into one top-level BMOp that
         * executes a lot of second-level BMOps. */
-       BMO_push(em->bm, NULL);
-       bmesh_edit_begin(em->bm, 0);
+       BMO_push(bm, NULL);
+       bmesh_edit_begin(bm, 0);
 
        if (amd->flags & MOD_ARR_MERGE)
-               BMO_op_init(em->bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+               BMO_op_init(bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
                            "weld_verts");
 
-       BMO_op_initf(em->bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+       BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
                     "duplicate geom=%avef");
        first_dupe_op = dupe_op;
 
@@ -424,11 +425,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                BMOIter oiter;
 
                if (j != 0) {
-                       BMO_op_initf(em->bm, &dupe_op,
+                       BMO_op_initf(bm, &dupe_op,
                                     (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
                                     "duplicate geom=%s", &old_dupe_op, "newout");
                }
-               BMO_op_exec(em->bm, &dupe_op);
+               BMO_op_exec(bm, &dupe_op);
 
                geom_slot = BMO_slot_get(&dupe_op, "geom");
                newout_slot = BMO_slot_get(&dupe_op, "newout");
@@ -443,14 +444,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                }
 
                /* apply transformation matrix */
-               BMO_ITER (v, &oiter, em->bm, &dupe_op, "newout", BM_VERT) {
+               BMO_ITER (v, &oiter, bm, &dupe_op, "newout", BM_VERT) {
                        mul_m4_v3(offset, v->co);
                }
 
                if (amd->flags & MOD_ARR_MERGE) {
                        /*calculate merge mapping*/
                        if (j == 0) {
-                               indexMap = find_doubles_index_map(em->bm, &dupe_op,
+                               indexMap = find_doubles_index_map(bm, &dupe_op,
                                                                  amd, &indexLen);
                        }
 
@@ -465,11 +466,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
 
                                /* check in case the target vertex (v2) is already marked
                                 * for merging */
-                               while ((v3 = BMO_slot_map_ptr_get(em->bm, &weld_op, "targetmap", v2))) {
+                               while ((v3 = BMO_slot_map_ptr_get(bm, &weld_op, "targetmap", v2))) {
                                        v2 = v3;
                                }
 
-                               BMO_slot_map_ptr_insert(em->bm, &weld_op, "targetmap", v, v2);
+                               BMO_slot_map_ptr_insert(bm, &weld_op, "targetmap", v, v2);
                        }
 
                        #undef _E
@@ -481,7 +482,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                        first_dupe_op = dupe_op;
                
                if (j >= 2)
-                       BMO_op_finish(em->bm, &old_dupe_op);
+                       BMO_op_finish(bm, &old_dupe_op);
                old_dupe_op = dupe_op;
        }
 
@@ -494,45 +495,44 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                 * loop) the offset between first and last is different from
                 * dupe X to dupe X+1. */
 
-               merge_first_last(em->bm, amd, &first_dupe_op, &dupe_op, &weld_op);
+               merge_first_last(bm, amd, &first_dupe_op, &dupe_op, &weld_op);
        }
 
        /* start capping */
        if (start_cap || end_cap) {
-               BM_mesh_elem_hflag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG, FALSE);
+               BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE);
 
                if (start_cap) {
                        float startoffset[4][4];
                        invert_m4_m4(startoffset, offset);
-                       bm_merge_dm_transform(em->bm, start_cap, startoffset, amd,
+                       bm_merge_dm_transform(bm, start_cap, startoffset, amd,
                                              &first_dupe_op, "geom", &weld_op);
                }
 
                if (end_cap) {
                        float endoffset[4][4];
                        mult_m4_m4m4(endoffset, offset, final_offset);
-                       bm_merge_dm_transform(em->bm, end_cap, endoffset, amd,
+                       bm_merge_dm_transform(bm, end_cap, endoffset, amd,
                                              &dupe_op, count == 1 ? "geom" : "newout", &weld_op);
                }
        }
        /* done capping */
 
        /* free remaining dupe operators */
-       BMO_op_finish(em->bm, &first_dupe_op);
+       BMO_op_finish(bm, &first_dupe_op);
        if (count > 2)
-               BMO_op_finish(em->bm, &dupe_op);
+               BMO_op_finish(bm, &dupe_op);
 
        /* run merge operator */
        if (amd->flags & MOD_ARR_MERGE) {
-               BMO_op_exec(em->bm, &weld_op);
-               BMO_op_finish(em->bm, &weld_op);
+               BMO_op_exec(bm, &weld_op);
+               BMO_op_finish(bm, &weld_op);
        }
 
        /* Bump the stack level back down to match the adjustment up above */
-       BMO_pop(em->bm);
+       BMO_pop(bm);
 
-       BLI_assert(em->looptris == NULL);
-       result = CDDM_from_BMEditMesh(em, NULL, FALSE, FALSE);
+       result = CDDM_from_bmesh(bm, FALSE);
 
        if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) {
                /* Update normals in case offset object has rotation. */
@@ -543,8 +543,8 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                CDDM_calc_normals(result);
        }
 
-       BMEdit_Free(em);
-       MEM_freeN(em);
+       BM_mesh_free(bm);
+
        if (indexMap)
                MEM_freeN(indexMap);
        if (first_geom)
index c3cae63971bdc66303f205f7e454f178be3b64e4..3e3bcb734911fc81a66c6485757857db2695cdd5 100644 (file)
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
 #include "BKE_mesh.h"
-
 #include "BKE_bmesh.h" /* only for defines */
 
+#include "bmesh.h"
+
 #include "DNA_object_types.h"
 
 #include "MEM_guardedalloc.h"
@@ -88,6 +88,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
        return dataMask;
 }
 
+// #define USE_BM_BEVEL_OP_AS_MOD
+
 #ifdef USE_BM_BEVEL_OP_AS_MOD
 
 #define EDGE_MARK   1
@@ -111,14 +113,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
 {
        DerivedMesh *result;
        BMesh *bm;
-       BMEditMesh *em;
        BMIter iter;
        BMEdge *e;
        BevelModifierData *bmd = (BevelModifierData *) md;
-       float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0);
+       float threshold = cos((bmd->bevel_angle + 0.00001f) * M_PI / 180.0f);
 
-       em = DM_to_editbmesh(dm, NULL, FALSE);
-       bm = em->bm;
+       bm = DM_to_bmesh(dm);
 
        BM_mesh_normals_update(bm, FALSE);
        BMO_push(bm, NULL);
@@ -148,10 +148,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
                     EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN) != 0, (bmd->flags & BME_BEVEL_DIST) != 0);
        BMO_pop(bm);
 
-       BLI_assert(em->looptris == NULL);
-       result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
-       BMEdit_Free(em);
-       MEM_freeN(em);
+       result = CDDM_from_bmesh(bm, TRUE);
+       BM_mesh_free(bm);
 
        return result;
 }
@@ -164,7 +162,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
                                   ModifierApplyFlag UNUSED(flag))
 {
        DerivedMesh *result;
-       BMEditMesh *em;
+       BMesh *bm;
 
        /*bDeformGroup *def;*/
        int /*i,*/ options, defgrp_index = -1;
@@ -181,12 +179,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
        }
 #endif
 
-       em = DM_to_editbmesh(derivedData, NULL, FALSE);
-       BME_bevel(em, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL, FALSE);
-       BLI_assert(em->looptris == NULL);
-       result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
-       BMEdit_Free(em);
-       MEM_freeN(em);
+       bm = DM_to_bmesh(derivedData);
+       BME_bevel(bm, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL);
+       result = CDDM_from_bmesh(bm, TRUE);
+       BM_mesh_free(bm);
 
        /* until we allow for dirty normal flag, always calc,
         * note: calculating on the CDDM is faster then the BMesh equivalent */
index 0ce4d74aebb14415ec06fe68871c11f5716123e7..3ef6b9bfcb816422e8cbb6bbc6462def99a5204d 100644 (file)
@@ -125,12 +125,12 @@ static void deformVerts(ModifierData *md, Object *ob,
 }
 
 static void deformVertsEM(
-        ModifierData *md, Object *ob, struct BMEditMesh *editData,
+        ModifierData *md, Object *ob, struct BMEditMesh *em,
         DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
 {
        DerivedMesh *dm = derivedData;
 
-       if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+       if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0);
 
index b7b9384b4e8134963f7cc48025427d225271e8b8..a80338760370f48e979454356de9b818605a19e1 100644 (file)
@@ -48,7 +48,6 @@
 #include "BKE_particle.h"
 #include "BKE_cdderivedmesh.h"
 
-#include "BKE_tessmesh.h"
 #include "bmesh.h"
 
 // #define USE_TIMEIT
@@ -97,7 +96,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 {
        DecimateModifierData *dmd = (DecimateModifierData *) md;
        DerivedMesh *dm = derivedData, *result = NULL;
-       BMEditMesh *em;
        BMesh *bm;
 
        float *vweights = NULL;
@@ -159,8 +157,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                }
        }
 
-       em = DM_to_editbmesh(dm, NULL, FALSE);
-       bm = em->bm;
+       bm = DM_to_bmesh(dm);
 
        switch (dmd->mode) {
                case MOD_DECIM_MODE_COLLAPSE:
@@ -188,18 +185,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 
        /* update for display only */
        dmd->face_count = bm->totface;
-
-       BLI_assert(em->looptris == NULL);
-       result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
-       BMEdit_Free(em);
-       MEM_freeN(em);
+       result = CDDM_from_bmesh(bm, FALSE);
+       BM_mesh_free(bm);
 
 #ifdef USE_TIMEIT
-        TIMEIT_END(decim);
+       TIMEIT_END(decim);
 #endif
 
-        CDDM_calc_normals(result);
-
        return result;
 }
 
index b1c3459bf5148b169cf47538d00c6b8499db1adf..be24f73502e39e6ff4b23c3fc6b02d2f012b160f 100644 (file)
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
 #include "BKE_mesh.h"
 
+#include "bmesh.h"
+
 #include "DNA_object_types.h"
 
 /* EdgeSplit */
@@ -61,13 +62,11 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
 {
        DerivedMesh *result;
        BMesh *bm;
-       BMEditMesh *em;
        BMIter iter;
        BMEdge *e;
        float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f);
 
-       em = DM_to_editbmesh(dm, NULL, FALSE);
-       bm = em->bm;
+       bm = DM_to_bmesh(dm);
 
        BM_mesh_normals_update(bm, FALSE);
        BMO_push(bm, NULL);
@@ -110,10 +109,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
 
        /* BM_mesh_validate(bm); */ /* for troubleshooting */
 
-       BLI_assert(em->looptris == NULL);
-       result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE);
-       BMEdit_Free(em);
-       MEM_freeN(em);
+       result = CDDM_from_bmesh(bm, TRUE);
+       BM_mesh_free(bm);
        
        return result;
 }
index d64ccf750b27339c57647903392a496cc85f0c39..a5c52c6c76adaa84338a27d994fba8e012373cca 100644 (file)
@@ -122,12 +122,12 @@ static void deformVerts(ModifierData *md, Object *ob,
 }
 
 static void deformVertsEM(
-        ModifierData *md, Object *ob, struct BMEditMesh *editData,
+        ModifierData *md, Object *ob, struct BMEditMesh *em,
         DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
 {
        DerivedMesh *dm = derivedData;
 
-       if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+       if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0);
 
index febc4190fdfd3f4d3f81252c15358f68f84d4ed4..83c678db7b384c3443bf914ff04bde20c17d1a12 100644 (file)
@@ -43,7 +43,8 @@
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_deform.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
 
 #include "MEM_guardedalloc.h"
 #include "depsgraph_private.h"
index af5de2e87383afae46438358a35c07ed4c01088d..ee0922d388bfcc1ff01ebd54104b280fa4b517e1 100644 (file)
@@ -77,7 +77,8 @@
 #include "BKE_DerivedMesh.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
-#include "BKE_tessmesh.h"
+
+#include "bmesh.h"
 
 #include "MOD_util.h"
 
@@ -1770,7 +1771,6 @@ static void skin_set_orig_indices(DerivedMesh *dm)
 static DerivedMesh *base_skin(DerivedMesh *origdm,
                               SkinModifierData *smd)
 {
-       BMEditMesh fake_em;
        DerivedMesh *result;
        MVertSkin *nodes;
        BMesh *bm;
@@ -1807,8 +1807,7 @@ static DerivedMesh *base_skin(DerivedMesh *origdm,
        if (!bm)
                return NULL;
        
-       fake_em.bm = bm;
-       result = CDDM_from_BMEditMesh(&fake_em, NULL, FALSE, FALSE);
+       result = CDDM_from_bmesh(bm, FALSE);
        BM_mesh_free(bm);
 
        CDDM_calc_edges(result);
@@ -1861,7 +1860,7 @@ static void copyData(ModifierData *md, ModifierData *target)
 
 static DerivedMesh *applyModifierEM(ModifierData *md,
                                     Object *UNUSED(ob),
-                                    BMEditMesh *UNUSED(em),
+                                    struct BMEditMesh *UNUSED(em),
                                     DerivedMesh *dm)
 {
        DerivedMesh *result;
index 3702db567ab6c14a67f5002c317c90e4fdc70943..6443a88a222e95d75dcee705542ea11b3df13209 100644 (file)
@@ -199,7 +199,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (*
                return dm;
 
        if (ob->type == OB_MESH) {
-               if (em) dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
+               if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE);
                else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob);
 
                if (vertexCos) {
index e8cd4f25789a5e05606b9d0933cdfbe42ad62398..c2a622315295ef97ce5c4cb3f05731580e29fe13 100644 (file)
@@ -337,7 +337,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
        }
 }
 
-static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData,
+static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *em,
                           DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
 {
        DerivedMesh *dm = derivedData;
@@ -345,7 +345,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
 
        if (use_dm) {
                if (!derivedData)
-                       dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
+                       dm = CDDM_from_editbmesh(em, FALSE, FALSE);
        }
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0);
index 1094cebba75b4e14b2bca717050e4809a3988022..e936e571a5bb23c45dbe7781a087f08d0921cb61 100644 (file)
@@ -460,7 +460,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
                                else if (obr->type == OB_MESH) {
                                        Mesh *me = (Mesh *)obr->data;
                                        if (me->edit_btmesh)
-                                               target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, FALSE);
+                                               target_dm = CDDM_from_editbmesh(me->edit_btmesh, FALSE, FALSE);
                                        else
                                                target_dm = CDDM_from_mesh(me, obr);
                                }