[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59728] trunk/blender/source/blender: fix [#36412] Pivot of active element switches to last selected face after duplicating vertices .
Campbell Barton
ideasman42 at gmail.com
Mon Sep 2 06:39:48 CEST 2013
Revision: 59728
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59728
Author: campbellbarton
Date: 2013-09-02 04:39:48 +0000 (Mon, 02 Sep 2013)
Log Message:
-----------
fix [#36412] Pivot of active element switches to last selected face after duplicating vertices.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
trunk/blender/source/blender/bmesh/operators/bmo_dupe.c
trunk/blender/source/blender/editors/mesh/editmesh_tools.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2013-09-02 04:36:41 UTC (rev 59727)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2013-09-02 04:39:48 UTC (rev 59728)
@@ -1177,8 +1177,9 @@
{"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 */
+ {"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}},
- {"vert_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'}},
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h 2013-09-02 04:36:41 UTC (rev 59727)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h 2013-09-02 04:39:48 UTC (rev 59728)
@@ -335,6 +335,11 @@
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) \
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.c 2013-09-02 04:36:41 UTC (rev 59727)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.c 2013-09-02 04:39:48 UTC (rev 59728)
@@ -602,6 +602,44 @@
}
}
+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);
Modified: trunk/blender/source/blender/bmesh/operators/bmo_dupe.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_dupe.c 2013-09-02 04:36:41 UTC (rev 59727)
+++ trunk/blender/source/blender/bmesh/operators/bmo_dupe.c 2013-09-02 04:39:48 UTC (rev 59728)
@@ -75,6 +75,7 @@
* Copy an existing edge from one bmesh to another.
*/
static BMEdge *bmo_edge_copy(BMOperator *op,
+ BMOpSlot *slot_edgemap_out,
BMOpSlot *slot_boundarymap_out,
BMesh *bm_dst, BMesh *bm_src,
BMEdge *e_src,
@@ -105,7 +106,9 @@
/* Create a new edge */
e_dst = BM_edge_create(bm_dst, e_dst_v1, e_dst_v2, NULL, BM_CREATE_SKIP_CD);
-
+ BMO_slot_map_elem_insert(op, slot_edgemap_out, e_src, e_dst);
+ BMO_slot_map_elem_insert(op, slot_edgemap_out, e_dst, e_src);
+
/* add to new/old edge map if necassary */
if (rlen < 2) {
/* not sure what non-manifold cases of greater then three
@@ -192,9 +195,11 @@
BMOpSlot *slot_boundary_map_out = BMO_slot_get(op->slots_out, "boundary_map.out");
BMOpSlot *slot_isovert_map_out = BMO_slot_get(op->slots_out, "isovert_map.out");
- BMOpSlot *slot_face_map_out = BMO_slot_get(op->slots_out, "face_map.out");
- BMOpSlot *slot_vert_map_out = BMO_slot_get(op->slots_out, "vert_map.out");
+ BMOpSlot *slot_vert_map_out = BMO_slot_get(op->slots_out, "vert_map.out");
+ BMOpSlot *slot_edge_map_out = BMO_slot_get(op->slots_out, "edge_map.out");
+ BMOpSlot *slot_face_map_out = BMO_slot_get(op->slots_out, "face_map.out");
+
/* initialize pointer hashes */
vhash = BLI_ghash_ptr_new("bmesh dupeops v");
ehash = BLI_ghash_ptr_new("bmesh dupeops e");
@@ -248,7 +253,8 @@
BMO_elem_flag_enable(bm_src, e->v2, DUPE_DONE);
}
/* now copy the actual edge */
- bmo_edge_copy(op, slot_boundary_map_out, bm_dst, bm_src, e, vhash, ehash);
+ bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
+ bm_dst, bm_src, e, vhash, ehash);
BMO_elem_flag_enable(bm_src, e, DUPE_DONE);
}
}
@@ -267,7 +273,8 @@
/* edge pass */
BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
if (!BMO_elem_flag_test(bm_src, e, DUPE_DONE)) {
- bmo_edge_copy(op, slot_boundary_map_out, bm_dst, bm_src, e, vhash, ehash);
+ bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
+ bm_dst, bm_src, e, vhash, ehash);
BMO_elem_flag_enable(bm_src, e, DUPE_DONE);
}
}
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-09-02 04:36:41 UTC (rev 59727)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-09-02 04:39:48 UTC (rev 59728)
@@ -892,15 +892,31 @@
{
Object *ob = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(ob);
+ BMesh *bm = em->bm;
BMOperator bmop;
+ ListBase bm_selected_store = {NULL, NULL};
+ /* de-select all would clear otherwise */
+ SWAP(ListBase, bm->selected, bm_selected_store);
+
EDBM_op_init(em, &bmop, op, "duplicate geom=%hvef", BM_ELEM_SELECT);
- BMO_op_exec(em->bm, &bmop);
+ BMO_op_exec(bm, &bmop);
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ /* rebuild editselection */
+ bm->selected = bm_selected_store;
+
+ if (bm->selected.first) {
+ BMOpSlot *slot_vert_map_out = BMO_slot_get(bmop.slots_out, "vert_map.out");
+ BMOpSlot *slot_edge_map_out = BMO_slot_get(bmop.slots_out, "edge_map.out");
+ BMOpSlot *slot_face_map_out = BMO_slot_get(bmop.slots_out, "face_map.out");
+
+ BMO_mesh_selected_remap(bm, slot_vert_map_out, slot_edge_map_out, slot_face_map_out);
+ }
+
if (!EDBM_op_finish(em, &bmop, op, true)) {
return OPERATOR_CANCELLED;
}
More information about the Bf-blender-cvs
mailing list