argument for CDDM_from_BMEditMesh() so creating tessface data is optional, no functio...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 18 Jan 2012 15:09:27 +0000 (15:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 18 Jan 2012 15:09:27 +0000 (15:09 +0000)
16 files changed:
source/blender/blenkernel/BKE_cdderivedmesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/constraint.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_opdefines.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_edgesplit.c
source/blender/modifiers/intern/MOD_lattice.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_weightvgproximity.c

index 15d1dce4e8de4291b8bf0a9752ce998cedde4347..569524aa2d482a3df5fcec0ba4ecf9ce8c37647c 100644 (file)
@@ -57,7 +57,7 @@ int CDDM_Check(struct DerivedMesh *dm);
 struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
 
 /* creates a CDDerivedMesh from the given BMEditMesh */
-DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps);
+DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps, int use_tessface);
 
 /* merge verts  */
 DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap);
index 98d73a2a93bfa717a32a4eec500ed2ca3a2a4c75..059297f392af14b5a39f717976105a34627e7f1f 100644 (file)
@@ -807,7 +807,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, 0);
+       if(em) dm= CDDM_from_BMEditMesh(em, me, FALSE, TRUE);
        else dm= CDDM_from_mesh(me, ob);
 
        orco= get_orco_coords_dm(ob, em, layer, &free);
@@ -1680,7 +1680,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
                                }
 
                        } else {
-                               dm = CDDM_from_BMEditMesh(em, ob->data, 0);
+                               dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, TRUE);
 
                                if(deformedVerts) {
                                        CDDM_apply_vert_coords(dm, deformedVerts);
index 4f83bcf7e7fae897d36b8993c5a0baedf0f2dbd5..184943490f2013336d40e07987e4ae60b6ac7788 100644 (file)
@@ -945,7 +945,6 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
                        else dvert = NULL;
                } else
                        dvert = NULL;
-
                if(armature_def_nr >= 0 && dvert) {
                        armature_weight= defvert_find_weight(dvert, armature_def_nr);
 
index 40a552278a66344362249e9f6fc65ea8ca7e5677..3746e089538fa3d08b9b91c8be19d7eef82270e4 100644 (file)
@@ -1963,7 +1963,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata,
        }
 }
 
-DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps)
+DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps, int use_tessface)
 {
        DerivedMesh *dm = CDDM_new(em->bm->totvert, em->bm->totedge, 
                               em->tottri, em->bm->totloop, em->bm->totface);
@@ -1980,7 +1980,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
        MPoly *mpoly = cddm->mpoly;
        int numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
        int numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
-       int *index, *polyindex, add_orig;
+       int *index, add_orig;
        int has_crease, has_edge_bweight, has_vert_bweight;
        CustomDataMask mask;
        unsigned int i, j;
@@ -2009,7 +2009,9 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
                         CD_CALLOC, dm->numPolyData);
        
        /*add tesselation mface layers*/
-       CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+       if (use_tessface) {
+               CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
+       }
 
        index = dm->getVertDataArray(dm, CD_ORIGINDEX);
 
@@ -2056,27 +2058,32 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
        }
        bm->elem_index_dirty &= ~BM_EDGE;
 
-       BM_ElemIndex_Ensure(bm, BM_FACE);
+       /* avoid this where possiblem, takes extra memory */
+       if (use_tessface) {
+               int *polyindex;
 
-       polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
-       index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
-       for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
-               MFace *mf = &mface[i];
-               BMLoop **l = em->looptris[i];
-               efa = l[0]->f;
+               BM_ElemIndex_Ensure(bm, BM_FACE);
 
-               mf->v1 = BM_GetIndex(l[0]->v);
-               mf->v2 = BM_GetIndex(l[1]->v);
-               mf->v3 = BM_GetIndex(l[2]->v);
-               mf->v4 = 0;
-               mf->mat_nr = efa->mat_nr;
-               mf->flag = BM_Face_Flag_To_MEFlag(efa);
-               
-               *index = add_orig ? BM_GetIndex(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
-               *polyindex = BM_GetIndex(efa);
+               polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
+               index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+               for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
+                       MFace *mf = &mface[i];
+                       BMLoop **l = em->looptris[i];
+                       efa = l[0]->f;
 
-               loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
-               test_index_face(mf, &dm->faceData, i, 3);
+                       mf->v1 = BM_GetIndex(l[0]->v);
+                       mf->v2 = BM_GetIndex(l[1]->v);
+                       mf->v3 = BM_GetIndex(l[2]->v);
+                       mf->v4 = 0;
+                       mf->mat_nr = efa->mat_nr;
+                       mf->flag = BM_Face_Flag_To_MEFlag(efa);
+
+                       *index = add_orig ? BM_GetIndex(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX);
+                       *polyindex = BM_GetIndex(efa);
+
+                       loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex);
+                       test_index_face(mf, &dm->faceData, i, 3);
+               }
        }
        
        index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
@@ -2086,6 +2093,8 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
                BMLoop *l;
                MPoly *mp = &mpoly[i];
 
+               BM_SetIndex(efa, i); /* set_inline */
+
                mp->totloop = efa->len;
                mp->flag = BM_Face_Flag_To_MEFlag(efa);
                mp->loopstart = j;
@@ -2104,6 +2113,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
 
                if (add_orig) *index = i;
        }
+       bm->elem_index_dirty &= ~BM_FACE;
 
        return dm;
 }
index 029911d26d7f3a7601a9e09ca30b9e4427f84217..5babb6261779740a31aea5070648053ab361b43d 100644 (file)
@@ -454,7 +454,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, 0);
+               dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, TRUE);
                freeDM= 1;
        }
        else {
index 876866cfa0a91a553de954838c7f0a9fdc48e06d..2565dd0f649b7a8b6e663b2c26bfb79b247b0196 100644 (file)
@@ -375,7 +375,7 @@ static void bmesh_set_mdisps_space(BMesh *bm, int from, int to)
        if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) {
                Object *ob = bm->ob;
                BMEditMesh *em = BMEdit_Create(bm);
-               DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, 1);
+               DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, TRUE);
                MDisps *mdisps;
                BMFace *f;
                BMIter iter;
index fe4f3680aaf1cc2845981f9a4ac5eb716af2a369..d0d85f7fb0dcec77ba14e95bde735e2d235473a8 100644 (file)
@@ -159,7 +159,7 @@ static BMOpDefine def_edgerotate = {
        "edgerotate",
        {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges
         {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges
-        {BMOP_OPSLOT_INT, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise
+        {BMOP_OPSLOT_INT, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise
        {0} /*null-terminating sentinel*/,
        },
        bmesh_edgerotate_exec,
index 55a2cab4a76820622455caf5ed95b157c9514bc6..fe5893d0911cadb1d3d7d44c2bb2851f96227e94 100644 (file)
@@ -142,7 +142,7 @@ static void deformVertsEM(
        ArmatureModifierData *amd = (ArmatureModifierData*) md;
        DerivedMesh *dm = derivedData;
 
-       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
        modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
 
@@ -166,7 +166,7 @@ static void deformMatricesEM(
        ArmatureModifierData *amd = (ArmatureModifierData*) md;
        DerivedMesh *dm = derivedData;
 
-       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
        armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
                              amd->deformflag, NULL, amd->defgrp_name);
index 3c599d6eafda1e993edb3c516b57689336aea1b9..73c4903b277102f35920837270e0e600d093c81f 100644 (file)
@@ -389,7 +389,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
        BMO_pop(em->bm);
 
        BMEdit_RecalcTesselation(em);
-       cddm = CDDM_from_BMEditMesh(em, NULL, 0);
+       cddm = CDDM_from_BMEditMesh(em, NULL, FALSE, TRUE);
 
        BMEdit_Free(em);
        MEM_freeN(em);
index 1a3f8cdb7f383f6d9189d27ff842a9fce6b7becc..7e57369776277b1055a2381db2df352cf1968172 100644 (file)
@@ -159,7 +159,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
                cddm->release(cddm);
        }
 
-       cddm = CDDM_from_BMEditMesh(em, NULL, 1);
+       cddm = CDDM_from_BMEditMesh(em, NULL, TRUE, TRUE);
        BMEdit_Free(em);
        MEM_freeN(em);
 
index 945c5c5a5835c7db7c611b8a33b3a7e0b4b9a3f1..ab9b509ee9c1ef06153d779332a12d5ad9a14ead 100644 (file)
@@ -129,7 +129,7 @@ static void deformVertsEM(
 {
        DerivedMesh *dm = derivedData;
 
-       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
 
index 2984a387fd88a505244f6c5a9e2ff1970afea9fa..da5e9ccc45fc906e40e4532866fef9a01d7fbdc5 100644 (file)
@@ -108,7 +108,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
                cddm->release(cddm);
        }
        
-       cddm = CDDM_from_BMEditMesh(em, NULL, 1);
+       cddm = CDDM_from_BMEditMesh(em, NULL, TRUE, TRUE);
        BMEdit_Free(em);
        MEM_freeN(em);
        
index 605c057c85574a35d890fc93cebc4cc55ac34bc2..2e8b5e3e6f3b33db76156e5406725a0e174c052c 100644 (file)
@@ -124,7 +124,7 @@ static void deformVertsEM(
 {
        DerivedMesh *dm = derivedData;
 
-       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
 
index 7fdbea19cfbca86223111a41de4bd43d636cf94a..e9b60f33fa27511ce62978d97bddee893f7bf001 100644 (file)
@@ -185,7 +185,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, 0);
+               if(em) dm= CDDM_from_BMEditMesh(em, ob->data, FALSE, TRUE);
                else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob);
 
                if(vertexCos) {
index 5961fae1abac77cb503c77046bf83ff675cd9aa4..d20a914a5315ea6eab2903eb8dfe341bd95c80e3 100644 (file)
@@ -338,7 +338,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
 
        if(use_dm) {
                if(!derivedData)
-                       dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+                       dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, TRUE);
        }
 
        deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
index 732a46cb8b62a63269bc0acd5157f445691e86e8..022aa150d493572542eba632de7ae697d204f718 100644 (file)
@@ -451,7 +451,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, 0);
+                                               target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, TRUE);
                                        else
                                                target_dm = CDDM_from_mesh(me, obr);
                                }