From 01a2634d610296f68c3411a3fef6a54a821886e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Sep 2013 04:39:48 +0000 Subject: fix [#36412] Pivot of active element switches to last selected face after duplicating vertices. --- source/blender/bmesh/intern/bmesh_opdefines.c | 3 +- source/blender/bmesh/intern/bmesh_operator_api.h | 5 ++++ source/blender/bmesh/intern/bmesh_operators.c | 38 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) (limited to 'source/blender/bmesh/intern') diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index b3054a11e56..e6291cac241 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1177,8 +1177,9 @@ static BMOpDefine bmo_duplicate_def = { {"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* facemap maps from source faces to dupe * faces, and from dupe faces to source faces */ - {"face_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, {"vert_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, + {"edge_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, + {"face_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, {"boundary_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, {"isovert_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}}, {{'\0'}}, diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index 3bfb05221ba..7de158f3c29 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -335,6 +335,11 @@ void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag); +void BMO_mesh_selected_remap(BMesh *bm, + BMOpSlot *slot_vert_map, + BMOpSlot *slot_edge_map, + BMOpSlot *slot_face_map); + /* copies the values from another slot to the end of the output slot */ #define BMO_slot_buffer_append(op_src, slots_src, slot_name_src, \ op_dst, slots_dst, slot_name_dst) \ diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 836001468a2..a3843b683be 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -602,6 +602,44 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty } } +void BMO_mesh_selected_remap(BMesh *bm, + BMOpSlot *slot_vert_map, + BMOpSlot *slot_edge_map, + BMOpSlot *slot_face_map) +{ + if (bm->selected.first) { + BMEditSelection *ese, *ese_next; + BMOpSlot *slot_elem_map; + + for (ese = bm->selected.first; ese; ese = ese_next) { + ese_next = ese->next; + + switch (ese->htype) { + case BM_VERT: slot_elem_map = slot_vert_map; break; + case BM_EDGE: slot_elem_map = slot_edge_map; break; + default: slot_elem_map = slot_face_map; break; + } + + ese->ele = BMO_slot_map_elem_get(slot_elem_map, ese->ele); + + if (UNLIKELY((ese->ele == NULL) || + (BM_elem_flag_test(ese->ele, BM_ELEM_SELECT) == false))) + { + BLI_remlink(&bm->selected, ese); + MEM_freeN(ese); + } + } + } + + if (bm->act_face) { + BMFace *f = BMO_slot_map_elem_get(slot_face_map, bm->act_face); + if (f) { + bm->act_face = f; + } + } +} + + int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); -- cgit v1.2.3