transform was flushing the selection (inline), now skip this and use the selection...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 22 Jul 2013 10:44:24 +0000 (10:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 22 Jul 2013 10:44:24 +0000 (10:44 +0000)
flush the selection on entering editmode instead (since the selection mode can be changed with another mesh).
is other tools leave the selection incorrectly flushed, those will need to be fixed so transform works as expected.

source/blender/editors/include/ED_mesh.h
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_relations.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesrna/intern/rna_object.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index fd08039c24b2f71ed45faa7acf8570ab40d1254e..f24f9098fcd5e4034974a1296c1304420d8d6c11 100644 (file)
@@ -92,7 +92,7 @@ void EDBM_mesh_normals_update(struct BMEditMesh *em);
 void EDBM_mesh_clear(struct BMEditMesh *em);
 
 void EDBM_selectmode_to_scene(struct bContext *C);
-void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob);
+void EDBM_mesh_make(struct ToolSettings *ts, struct Object *ob);
 void EDBM_mesh_free(struct BMEditMesh *em);
 void EDBM_mesh_load(struct Object *ob);
 struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
index 63b44fb30d4870bda3abb16be188dac8162f43f0..f64ea569100df2b601c35a9126298e56278b8fdb 100644 (file)
@@ -341,7 +341,7 @@ void EDBM_selectmode_to_scene(bContext *C)
        WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene);
 }
 
-void EDBM_mesh_make(ToolSettings *ts, Scene *UNUSED(scene), Object *ob)
+void EDBM_mesh_make(ToolSettings *ts, Object *ob)
 {
        Mesh *me = ob->data;
        BMesh *bm;
@@ -368,8 +368,10 @@ void EDBM_mesh_make(ToolSettings *ts, Scene *UNUSED(scene), Object *ob)
 
        me->edit_btmesh->selectmode = me->edit_btmesh->bm->selectmode = ts->selectmode;
        me->edit_btmesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0;
-
        me->edit_btmesh->ob = ob;
+
+       /* we need to flush selection because the mode may have changed from when last in editmode */
+       EDBM_selectmode_flush(me->edit_btmesh);
 }
 
 void EDBM_mesh_load(Object *ob)
index 69049bd5a2642a5bcb411f4800b68631a0ba1f59..52a8ccc4aabc9607fd7134519d499d47d32d66b2 100644 (file)
@@ -567,7 +567,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
        obedit = base->object;
        me = obedit->data;
        if (me->edit_btmesh == NULL) {
-               EDBM_mesh_make(scene->toolsettings, scene, obedit);
+               EDBM_mesh_make(scene->toolsettings, obedit);
                exitmode = 1;
        }
        if (me->edit_btmesh == NULL)
index d0adfc20f79cd2a5c9ad4a540994ec544811da23..ed05d2a01a524b8fae17ea54e35b08c8f63c6644 100644 (file)
@@ -570,7 +570,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
        ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO);
 #else
        /* toggle editmode using lower level functions so this can be called from python */
-       EDBM_mesh_make(scene->toolsettings, scene, ob);
+       EDBM_mesh_make(scene->toolsettings, ob);
        EDBM_mesh_load(ob);
        EDBM_mesh_free(me->edit_btmesh);
        MEM_freeN(me->edit_btmesh);
index 784dddbfbf3f6fdc0fb780fb9e548c03217f8edc..9eaaf8fe1db7e328a68e9a897534cfe1463e2aed 100644 (file)
@@ -478,7 +478,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
                ok = 1;
                scene->obedit = ob;  /* context sees this */
 
-               EDBM_mesh_make(CTX_data_tool_settings(C), scene, ob);
+               EDBM_mesh_make(scene->toolsettings, ob);
 
                em = BKE_editmesh_from_object(ob);
                if (LIKELY(em)) {
index d739d8d330f90b449a2c227ccab589383bafeb18..c8baa0d84dcc0f1ed13b2372e8fdf770082617eb 100644 (file)
@@ -310,7 +310,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit, int *tot, int
                        BMEditMesh *em;
 
                        EDBM_mesh_load(obedit);
-                       EDBM_mesh_make(scene->toolsettings, scene, obedit);
+                       EDBM_mesh_make(scene->toolsettings, obedit);
 
                        em = me->edit_btmesh;
 
index f6fc21f94f5c24195727114c145dc69c1791576b..13fb46e35de9dcb7f46378fada4792d1d8b3c37b 100644 (file)
@@ -136,7 +136,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
                BMEditMesh *em;
 
                EDBM_mesh_load(obedit);
-               EDBM_mesh_make(scene->toolsettings, scene, obedit);
+               EDBM_mesh_make(scene->toolsettings, obedit);
 
                em = me->edit_btmesh;
 
index a089f0d4159aeb05aff21ce9758b15db149ed9b2..93e01d84eaf5017e18d7c87aa27c6c3d885181b4 100644 (file)
@@ -1943,6 +1943,8 @@ static BMElem *bm_vert_single_select_edge(BMVert *eve)
 static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx,
                              BMEditMesh *em, BMVert *eve, float *bweight)
 {
+       BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0);
+
        td->flag = 0;
        //if (key)
        //      td->loc = key->co;
@@ -2034,81 +2036,42 @@ static void createTransEditVerts(TransInfo *t)
        int count = 0, countsel = 0, a, totleft;
        int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
        int mirror = 0;
-       char *selstate = NULL;
        short selectmode = ts->selectmode;
        int cd_vert_bweight_offset = -1;
        bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
 
+       /* BMESH_TODO, writing into the index values is BAD!, means we cant
+        * use the values for vertex mirror - campbell */
+
        if (t->flag & T_MIRROR) {
                EDBM_verts_mirror_cache_begin(em, 0, false, (t->flag & T_PROP_EDIT) == 0, use_topology);
                mirror = 1;
        }
 
-       /* edge slide forces edge select */
-       if (t->mode == TFM_EDGE_SLIDE) {
-               selectmode = SCE_SELECT_EDGE;
-       }
-
-       /* BMESH_TODO, writing into the index values is BAD!, means we cant
-        * use the values for vertex mirror - campbell */
-
-       // transform now requires awareness for select mode, so we tag the f1 flags in verts
+       /* quick check if we can transform */
+       /* note: in prop mode we need at least 1 selected */
        if (selectmode & SCE_SELECT_VERTEX) {
-               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
-                       BM_elem_flag_set(eve, BM_ELEM_TAG, BM_elem_flag_test(eve, BM_ELEM_SELECT));
+               if (bm->totvertsel == 0) {
+                       goto cleanup;
                }
        }
        else if (selectmode & SCE_SELECT_EDGE) {
-               BMEdge *eed;
-
-               eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
-
-               eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL);
-               for (; eed; eed = BM_iter_step(&iter)) {
-                       if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
-                               BM_elem_flag_enable(eed->v1, BM_ELEM_TAG);
-                               BM_elem_flag_enable(eed->v2, BM_ELEM_TAG);
-                       }
+               if (bm->totvertsel == 0 || bm->totedgesel == 0) {
+                       goto cleanup;
                }
        }
-       else {
-               BMFace *efa;
-               eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for (; eve; eve = BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG);
-
-               efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL);
-               for (; efa; efa = BM_iter_step(&iter)) {
-                       if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
-                               BMIter liter;
-                               BMLoop *l;
-
-                               l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, efa);
-                               for (; l; l = BM_iter_step(&liter)) {
-                                       BM_elem_flag_enable(l->v, BM_ELEM_TAG);
-                               }
-                       }
+       else if (selectmode & SCE_SELECT_FACE) {
+               if (bm->totvertsel == 0 || bm->totfacesel == 0) {
+                       goto cleanup;
                }
        }
-
-       /* now we can count. we store selection state in selstate, since
-        * get_crazy_mapped_editverts messes up the index state of the
-        * verts*/
-       selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__);
-       eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-       for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
-               if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
-                       if (BM_elem_flag_test(eve, BM_ELEM_TAG)) {
-                               selstate[a] = 1;
-                               countsel++;
-                       }
-                       if (propmode) count++;
-               }
+       else {
+               BLI_assert(0);
        }
 
-       /* note: in prop mode we need at least 1 selected */
-       if (countsel == 0) {
-               goto cleanup;
+       countsel = bm->totvertsel;
+       if (propmode) {
+               count = bm->totvert;
        }
 
        /* check active */
@@ -2174,9 +2137,8 @@ static void createTransEditVerts(TransInfo *t)
 
        /* find out which half we do */
        if (mirror) {
-               eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL);
-               for (a = 0; eve; eve = BM_iter_step(&iter), a++) {
-                       if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0] != 0.0f) {
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
+                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && eve->co[0] != 0.0f) {
                                if (eve->co[0] < 0.0f) {
                                        t->mirror = -1;
                                        mirror = -1;
@@ -2188,7 +2150,7 @@ static void createTransEditVerts(TransInfo *t)
 
        BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
                if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
-                       if (propmode || selstate[a]) {
+                       if (propmode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
                                float *bweight = (cd_vert_bweight_offset != -1) ? BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : NULL;
                                
                                VertsToTransData(t, tob, tx, em, eve, bweight);
@@ -2196,7 +2158,8 @@ static void createTransEditVerts(TransInfo *t)
                                        tx++;
 
                                /* selected */
-                               if (selstate[a]) tob->flag |= TD_SELECTED;
+                               if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
+                                       tob->flag |= TD_SELECTED;
 
                                /* active */
                                if (eve == eve_act) tob->flag |= TD_ACTIVE;
@@ -2267,8 +2230,6 @@ cleanup:
                MEM_freeN(defmats);
        if (dists)
                MEM_freeN(dists);
-       
-       MEM_freeN(selstate);
 
        if (t->flag & T_MIRROR) {
                EDBM_verts_mirror_cache_end(em);
index 834fb6d7d72b36a29fa5d16894a5437840ccb883..e71d1d22c4b65215830212cdfa58741b552a3d73 100644 (file)
@@ -266,7 +266,7 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA
                switch (ob->type) {
                        case OB_MESH:
                                EDBM_mesh_load(ob);
-                               EDBM_mesh_make(scene->toolsettings, scene, ob);
+                               EDBM_mesh_make(scene->toolsettings, ob);
                                EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh);
                                BKE_editmesh_tessface_calc(((Mesh *)ob->data)->edit_btmesh);
                                break;
index 547ced6098f25e5acea5d67998d5d2571ef121b1..ca57299fe1eb628be72393cc061740e1ea6ae899 100644 (file)
@@ -140,7 +140,7 @@ struct wmWindowManager;
 /*new render funcs */
 void EDBM_selectmode_set(struct BMEditMesh *em) {STUB_ASSERT(0);}
 void EDBM_mesh_load(struct Object *ob) {STUB_ASSERT(0);}
-void EDBM_mesh_make(struct ToolSettings *ts, struct Scene *scene, struct Object *ob) {STUB_ASSERT(0);}
+void EDBM_mesh_make(struct ToolSettings *ts, struct Object *ob) {STUB_ASSERT(0);}
 void EDBM_mesh_normals_update(struct BMEditMesh *em) {STUB_ASSERT(0);}
 void *g_system;