Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-02-26 16:34:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-26 16:42:47 +0400
commitb5b1ce9d212208bbbf8342839e9c6edcf9e266c1 (patch)
treeb30a23bf7e197747d63cbd05778503685384453a /source
parent8a5221750e73b48ea204bde7a489bc11e49770a6 (diff)
BMesh: add overwrite option to BM_mesh_elem_hflag_enable/disable_test
Diffstat (limited to 'source')
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c53
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.h4
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
5 files changed, 39 insertions, 26 deletions
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 833a556e46c..eff3cf220f3 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -900,7 +900,7 @@ bool BM_select_history_active_get(BMesh *bm, BMEditSelection *ese)
}
void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hflag,
- const bool respecthide, const char hflag_test)
+ const bool respecthide, const bool overwrite, const char hflag_test)
{
const char iter_types[3] = {BM_VERTS_OF_MESH,
BM_EDGES_OF_MESH,
@@ -908,6 +908,8 @@ void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hfl
const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE};
+ const char hflag_nosel = hflag & ~BM_ELEM_SELECT;
+
int i;
BLI_assert((htype & ~BM_ALL_NOLOOP) == 0);
@@ -946,17 +948,22 @@ void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hfl
ele = BM_iter_new(&iter, bm, iter_types[i], NULL);
for ( ; ele; ele = BM_iter_step(&iter)) {
- if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
- continue;
+ if (UNLIKELY(respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN))) {
+ /* pass */
}
- if (hflag_test && !BM_elem_flag_test(ele, hflag_test)) {
- continue;
+ else if (!hflag_test || BM_elem_flag_test(ele, hflag_test)) {
+ if (hflag & BM_ELEM_SELECT) {
+ BM_elem_select_set(bm, ele, false);
+ }
+ BM_elem_flag_disable(ele, hflag);
}
-
- if (hflag & BM_ELEM_SELECT) {
- BM_elem_select_set(bm, ele, false);
+ else if (overwrite) {
+ /* no match! */
+ if (hflag & BM_ELEM_SELECT) {
+ BM_elem_select_set(bm, ele, true);
+ }
+ BM_elem_flag_enable(ele, hflag_nosel);
}
- BM_elem_flag_disable(ele, hflag);
}
}
}
@@ -964,7 +971,7 @@ void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hfl
}
void BM_mesh_elem_hflag_enable_test(BMesh *bm, const char htype, const char hflag,
- const bool respecthide, const char hflag_test)
+ const bool respecthide, const bool overwrite, const char hflag_test)
{
const char iter_types[3] = {BM_VERTS_OF_MESH,
BM_EDGES_OF_MESH,
@@ -996,17 +1003,23 @@ void BM_mesh_elem_hflag_enable_test(BMesh *bm, const char htype, const char hfla
ele = BM_iter_new(&iter, bm, iter_types[i], NULL);
for ( ; ele; ele = BM_iter_step(&iter)) {
- if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
- continue;
+ if (UNLIKELY(respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN))) {
+ /* pass */
}
- if (hflag_test && !BM_elem_flag_test(ele, hflag_test)) {
- continue;
+ else if (!hflag_test || BM_elem_flag_test(ele, hflag_test)) {
+ /* match! */
+ if (hflag & BM_ELEM_SELECT) {
+ BM_elem_select_set(bm, ele, true);
+ }
+ BM_elem_flag_enable(ele, hflag_nosel);
}
-
- if (hflag & BM_ELEM_SELECT) {
- BM_elem_select_set(bm, ele, true);
+ else if (overwrite) {
+ /* no match! */
+ if (hflag & BM_ELEM_SELECT) {
+ BM_elem_select_set(bm, ele, false);
+ }
+ BM_elem_flag_disable(ele, hflag);
}
- BM_elem_flag_enable(ele, hflag_nosel);
}
}
}
@@ -1016,14 +1029,14 @@ void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hfla
const bool respecthide)
{
/* call with 0 hflag_test */
- BM_mesh_elem_hflag_disable_test(bm, htype, hflag, respecthide, 0);
+ BM_mesh_elem_hflag_disable_test(bm, htype, hflag, respecthide, false, 0);
}
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag,
const bool respecthide)
{
/* call with 0 hflag_test */
- BM_mesh_elem_hflag_enable_test(bm, htype, hflag, respecthide, 0);
+ BM_mesh_elem_hflag_enable_test(bm, htype, hflag, respecthide, false, 0);
}
/***************** Mesh Hiding stuff *********** */
diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h
index f23eac61278..99456ea2c98 100644
--- a/source/blender/bmesh/intern/bmesh_marking.h
+++ b/source/blender/bmesh/intern/bmesh_marking.h
@@ -44,9 +44,9 @@ void BM_face_hide_set(BMFace *f, const bool hide);
void BM_elem_select_set(BMesh *bm, BMElem *ele, const bool select);
void BM_mesh_elem_hflag_enable_test(BMesh *bm, const char htype, const char hflag,
- const bool respecthide, const char hflag_test);
+ const bool respecthide, const bool overwrite, const char hflag_test);
void BM_mesh_elem_hflag_disable_test(BMesh *bm, const char htype, const char hflag,
- const bool respecthide, const char hflag_test);
+ const bool respecthide, const bool overwrite, const char hflag_test);
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag,
const bool respecthide);
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index 57a85f1162d..cc26d6079a9 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -143,7 +143,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op)
* note: call after de-select to avoid selection flushing */
EDBM_selectmode_disable(scene, em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE);
- BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_TAG);
+ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
BM_mesh_select_mode_flush(em->bm);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index f8b50d4e5c7..189eafee6a1 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2580,7 +2580,7 @@ static bool mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BM
BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, false);
/* sel -> tag */
- BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, true, BM_ELEM_SELECT);
+ BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, true, false, BM_ELEM_SELECT);
return (mesh_separate_tagged(bmain, scene, base_old, bm_old) != NULL);
}
@@ -3757,7 +3757,7 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_TAG);
+ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
EDBM_update_generic(em, true, true);
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 8e980bdd4d2..ff2a2fcc156 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -3802,7 +3802,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *UNUSED(op))
}
/* re-select tagged faces */
- BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, TRUE, BM_ELEM_TAG);
+ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);