diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 17a06bbb9ac..5bb30ab6d40 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -192,7 +192,7 @@ struct UvVertMap *EDBM_make_uv_vert_map(struct BMEditMesh *em, int selected, int void EM_add_data_layer(struct BMEditMesh *em, struct CustomData *data, int type, const char *name); void EM_free_data_layer(struct BMEditMesh *em, struct CustomData *data, int type); -void EDBM_toggle_select_all(struct BMEditMesh *em); +void EDBM_select_toggle_all(struct BMEditMesh *em); void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag); void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); void EDBM_select_mirrored(struct Object *obedit, struct BMEditMesh *em, int extend); diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 9d2229b52f4..691889bb1a8 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -39,7 +39,6 @@ set(INC_SYS set(SRC bmesh_select.c - bmesh_selecthistory.c bmesh_tools.c bmesh_utils.c editface.c diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index b7a122ed988..67b3e8a99c0 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -1662,6 +1662,13 @@ void EDBM_deselect_by_material(BMEditMesh *em, const short index, const short se } } +void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */ +{ + if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + else + EDBM_flag_enable_all(em, BM_ELEM_SELECT); +} void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ { diff --git a/source/blender/editors/mesh/bmesh_selecthistory.c b/source/blender/editors/mesh/bmesh_selecthistory.c deleted file mode 100644 index c912813ac63..00000000000 --- a/source/blender/editors/mesh/bmesh_selecthistory.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2004 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* ********* Selection History ************ */ - -#include "BKE_tessmesh.h" - - -/* these wrap equivalent bmesh functions. I'm in two minds of it we should - * just use the bm functions directly; on the one hand, there's no real - * need (at the moment) to wrap them, but on the other hand having these - * wrapped avoids a confusing mess of mixing BM_ and EDBM_ namespaces. */ - -void EDBM_editselection_center(BMEditMesh *em, float *center, BMEditSelection *ese) -{ - BM_editselection_center(em->bm, center, ese); -} - -void EDBM_editselection_normal(float *normal, BMEditSelection *ese) -{ - BM_editselection_normal(normal, ese); -} - -/* Calculate a plane that is rightangles to the edge/vert/faces normal - * also make the plane run along an axis that is related to the geometry, - * because this is used for the manipulators Y axis. */ -void EDBM_editselection_plane(BMEditMesh *em, float *plane, BMEditSelection *ese) -{ - BM_editselection_plane(em->bm, plane, ese); -} - -void EDBM_remove_selection(BMEditMesh *em, BMElem *ele) -{ - BM_select_history_remove(em->bm, ele); -} - -void EDBM_store_selection(BMEditMesh *em, BMElem *ele) -{ - BM_select_history_store(em->bm, ele); -} - -void EDBM_validate_selections(BMEditMesh *em) -{ - BM_select_history_validate(em->bm); -} diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 2561487d663..96ac10ecf4a 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -639,14 +639,6 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot) /* ******************** (de)select all operator **************** */ -void EDBM_toggle_select_all(BMEditMesh *em) /* exported for UV */ -{ - if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) - EDBM_flag_disable_all(em, BM_ELEM_SELECT); - else - EDBM_flag_enable_all(em, BM_ELEM_SELECT); -} - static int edbm_select_all_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -655,7 +647,7 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op) switch (action) { case SEL_TOGGLE: - EDBM_toggle_select_all(em); + EDBM_select_toggle_all(em); break; case SEL_SELECT: EDBM_flag_enable_all(em, BM_ELEM_SELECT); @@ -1426,38 +1418,6 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate edge around"); } -/* swap is 0 or 1, if 1 it hides not selected */ -void EDBM_hide_mesh(BMEditMesh *em, int swap) -{ - BMIter iter; - BMElem *ele; - int itermode; - - if (em == NULL) return; - - if (em->selectmode & SCE_SELECT_VERTEX) - itermode = BM_VERTS_OF_MESH; - else if (em->selectmode & SCE_SELECT_EDGE) - itermode = BM_EDGES_OF_MESH; - else - itermode = BM_FACES_OF_MESH; - - BM_ITER(ele, &iter, em->bm, itermode, NULL) { - if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ swap) - BM_elem_hide_set(em->bm, ele, TRUE); - } - - EDBM_selectmode_flush(em); - - /* original hide flushing comment (OUTDATED): - * hide happens on least dominant select mode, and flushes up, not down! (helps preventing errors in subsurf) */ - /* - vertex hidden, always means edge is hidden too - * - edge hidden, always means face is hidden too - * - face hidden, only set face hide - * - then only flush back down what's absolute hidden - */ - -} static int edbm_hide_exec(bContext *C, wmOperator *op) { @@ -1490,49 +1450,6 @@ void MESH_OT_hide(wmOperatorType *ot) RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); } - -void EDBM_reveal_mesh(BMEditMesh *em) -{ - const char iter_types[3] = {BM_VERTS_OF_MESH, - BM_EDGES_OF_MESH, - BM_FACES_OF_MESH}; - - int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX), - (em->selectmode & SCE_SELECT_EDGE), - (em->selectmode & SCE_SELECT_FACE), - }; - - BMIter iter; - BMElem *ele; - int i; - - /* Use tag flag to remember what was hidden before all is revealed. - * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ - for (i = 0; i < 3; i++) { - BM_ITER(ele, &iter, em->bm, iter_types[i], NULL) { - BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_HIDDEN)); - } - } - - /* Reveal everything */ - EDBM_flag_disable_all(em, BM_ELEM_HIDDEN); - - /* Select relevant just-revealed elements */ - for (i = 0; i < 3; i++) { - if (!sels[i]) { - continue; - } - - BM_ITER(ele, &iter, em->bm, iter_types[i], NULL) { - if (BM_elem_flag_test(ele, BM_ELEM_TAG)) { - BM_elem_select_set(em->bm, ele, TRUE); - } - } - } - - EDBM_selectmode_flush(em); -} - static int edbm_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/bmesh_utils.c b/source/blender/editors/mesh/bmesh_utils.c index 9bff0e7310c..560025b12a6 100644 --- a/source/blender/editors/mesh/bmesh_utils.c +++ b/source/blender/editors/mesh/bmesh_utils.c @@ -1151,3 +1151,119 @@ void EDBM_ApplyMirrorCache(BMEditMesh *em, const int sel_from, const int sel_to) } } } + + +/* swap is 0 or 1, if 1 it hides not selected */ +void EDBM_hide_mesh(BMEditMesh *em, int swap) +{ + BMIter iter; + BMElem *ele; + int itermode; + + if (em == NULL) return; + + if (em->selectmode & SCE_SELECT_VERTEX) + itermode = BM_VERTS_OF_MESH; + else if (em->selectmode & SCE_SELECT_EDGE) + itermode = BM_EDGES_OF_MESH; + else + itermode = BM_FACES_OF_MESH; + + BM_ITER(ele, &iter, em->bm, itermode, NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ swap) + BM_elem_hide_set(em->bm, ele, TRUE); + } + + EDBM_selectmode_flush(em); + + /* original hide flushing comment (OUTDATED): + * hide happens on least dominant select mode, and flushes up, not down! (helps preventing errors in subsurf) */ + /* - vertex hidden, always means edge is hidden too + * - edge hidden, always means face is hidden too + * - face hidden, only set face hide + * - then only flush back down what's absolute hidden + */ +} + + +void EDBM_reveal_mesh(BMEditMesh *em) +{ + const char iter_types[3] = {BM_VERTS_OF_MESH, + BM_EDGES_OF_MESH, + BM_FACES_OF_MESH}; + + int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX), + (em->selectmode & SCE_SELECT_EDGE), + (em->selectmode & SCE_SELECT_FACE), + }; + + BMIter iter; + BMElem *ele; + int i; + + /* Use tag flag to remember what was hidden before all is revealed. + * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ + for (i = 0; i < 3; i++) { + BM_ITER(ele, &iter, em->bm, iter_types[i], NULL) { + BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_HIDDEN)); + } + } + + /* Reveal everything */ + EDBM_flag_disable_all(em, BM_ELEM_HIDDEN); + + /* Select relevant just-revealed elements */ + for (i = 0; i < 3; i++) { + if (!sels[i]) { + continue; + } + + BM_ITER(ele, &iter, em->bm, iter_types[i], NULL) { + if (BM_elem_flag_test(ele, BM_ELEM_TAG)) { + BM_elem_select_set(em->bm, ele, TRUE); + } + } + } + + EDBM_selectmode_flush(em); +} + +/* * Selection History ***************************************************** */ +/* these wrap equivalent bmesh functions. I'm in two minds of it we should + * just use the bm functions directly; on the one hand, there's no real + * need (at the moment) to wrap them, but on the other hand having these + * wrapped avoids a confusing mess of mixing BM_ and EDBM_ namespaces. */ + +void EDBM_editselection_center(BMEditMesh *em, float *center, BMEditSelection *ese) +{ + BM_editselection_center(em->bm, center, ese); +} + +void EDBM_editselection_normal(float *normal, BMEditSelection *ese) +{ + BM_editselection_normal(normal, ese); +} + +/* Calculate a plane that is rightangles to the edge/vert/faces normal + * also make the plane run along an axis that is related to the geometry, + * because this is used for the manipulators Y axis. */ +void EDBM_editselection_plane(BMEditMesh *em, float *plane, BMEditSelection *ese) +{ + BM_editselection_plane(em->bm, plane, ese); +} + +void EDBM_remove_selection(BMEditMesh *em, BMElem *ele) +{ + BM_select_history_remove(em->bm, ele); +} + +void EDBM_store_selection(BMEditMesh *em, BMElem *ele) +{ + BM_select_history_store(em->bm, ele); +} + +void EDBM_validate_selections(BMEditMesh *em) +{ + BM_select_history_validate(em->bm); +} +/* end select history */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index f3ca618b547..6066ea759a0 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1610,7 +1610,7 @@ static void select_all_perform(bContext *C, int action) switch (action) { case SEL_TOGGLE: - EDBM_toggle_select_all(BMEdit_FromObject(obedit)); + EDBM_select_toggle_all(BMEdit_FromObject(obedit)); break; case SEL_SELECT: EDBM_flag_enable_all(em, BM_ELEM_SELECT);