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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/bmesh/operators/bmo_connect_pair.c')
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c72
1 files changed, 53 insertions, 19 deletions
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index b497ab2f693..a0acf6ed2c5 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -51,6 +51,15 @@
#define CONNECT_EPS 0.0001f
#define VERT_OUT 1
+#define VERT_EXCLUDE 2
+
+/* typically hidden faces */
+#define FACE_EXCLUDE 2
+
+#define FACE_WALK_TEST(f) (CHECK_TYPE_INLINE(f, BMFace *), \
+ BMO_elem_flag_test(pc->bm_bmoflag, f, FACE_EXCLUDE) == 0)
+#define VERT_WALK_TEST(v) (CHECK_TYPE_INLINE(v, BMVert *), \
+ BMO_elem_flag_test(pc->bm_bmoflag, v, VERT_EXCLUDE) == 0)
// #define DEBUG_PRINT
@@ -59,6 +68,9 @@ typedef struct PathContext {
float matrix[3][3];
float axis_sep;
+ /* only to access BMO flags */
+ BMesh *bm_bmoflag;
+
BMVert *v_a, *v_b;
BLI_mempool *link_pool;
@@ -134,7 +146,7 @@ static void state_calc_co_pair(const PathContext *pc,
static bool state_link_find(PathLinkState *state, BMElem *ele)
{
PathLink *link = state->link_last;
- BLI_assert(ELEM3(ele->head.htype, BM_VERT, BM_EDGE, BM_FACE));
+ BLI_assert(ELEM(ele->head.htype, BM_VERT, BM_EDGE, BM_FACE));
if (link) {
do {
if (link->ele == ele) {
@@ -204,8 +216,9 @@ static void state_link_add(PathContext *pc, PathLinkState *state,
state->link_last = step_new;
}
-static PathLinkState *state_dupe_add(PathContext *pc,
- PathLinkState *state, const PathLinkState *state_orig)
+static PathLinkState *state_dupe_add(
+ PathContext *pc,
+ PathLinkState *state, const PathLinkState *state_orig)
{
state = MEM_mallocN(sizeof(*state), __func__);
*state = *state_orig;
@@ -214,16 +227,19 @@ static PathLinkState *state_dupe_add(PathContext *pc,
}
/* walk around the face edges */
-static PathLinkState *state_step__face_edges(PathContext *pc,
- PathLinkState *state, const PathLinkState *state_orig,
- BMLoop *l_iter, BMLoop *l_last)
+static PathLinkState *state_step__face_edges(
+ PathContext *pc,
+ PathLinkState *state, const PathLinkState *state_orig,
+ BMLoop *l_iter, BMLoop *l_last)
{
do {
if (state_isect_co_pair(pc, l_iter->v->co, l_iter->next->v->co)) {
BMElem *ele_next = (BMElem *)l_iter->e;
BMElem *ele_next_from = (BMElem *)l_iter->f;
- if (state_link_find(state, ele_next) == false) {
+ if (FACE_WALK_TEST((BMFace *)ele_next_from) &&
+ (state_link_find(state, ele_next) == false))
+ {
if (state_orig->link_last != state->link_last) {
state = state_dupe_add(pc, state, state_orig);
}
@@ -235,16 +251,19 @@ static PathLinkState *state_step__face_edges(PathContext *pc,
}
/* walk around the face verts */
-static PathLinkState *state_step__face_verts(PathContext *pc,
- PathLinkState *state, const PathLinkState *state_orig,
- BMLoop *l_iter, BMLoop *l_last)
+static PathLinkState *state_step__face_verts(
+ PathContext *pc,
+ PathLinkState *state, const PathLinkState *state_orig,
+ BMLoop *l_iter, BMLoop *l_last)
{
do {
if (state_isect_co_exact(pc, l_iter->v->co)) {
BMElem *ele_next = (BMElem *)l_iter->v;
BMElem *ele_next_from = (BMElem *)l_iter->f;
- if (state_link_find(state, ele_next) == false) {
+ if (FACE_WALK_TEST((BMFace *)ele_next_from) &&
+ state_link_find(state, ele_next) == false)
+ {
if (state_orig->link_last != state->link_last) {
state = state_dupe_add(pc, state, state_orig);
}
@@ -268,7 +287,9 @@ static bool state_step(PathContext *pc, PathLinkState *state)
BMLoop *l_start;
BM_ITER_ELEM (l_start, &liter, e, BM_LOOPS_OF_EDGE) {
- if (l_start->f != ele_from) {
+ if ((l_start->f != ele_from) &&
+ FACE_WALK_TEST(l_start->f))
+ {
/* very similar to block below */
if (BM_vert_in_face(l_start->f, pc->v_b)) {
if (state_orig.link_last != state->link_last) {
@@ -295,7 +316,9 @@ static bool state_step(PathContext *pc, PathLinkState *state)
BMLoop *l_start;
BM_ITER_ELEM (l_start, &liter, v, BM_LOOPS_OF_VERT) {
- if (l_start->f != ele_from) {
+ if ((l_start->f != ele_from) &&
+ FACE_WALK_TEST(l_start->f))
+ {
/* very similar to block above */
if (BM_vert_in_face(l_start->f, pc->v_b)) {
BMElem *ele_next = (BMElem *)pc->v_b;
@@ -324,8 +347,10 @@ static bool state_step(PathContext *pc, PathLinkState *state)
BMIter eiter;
BMEdge *e;
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
- if ((BMElem *)e != ele_from) {
- BMVert *v_other = BM_edge_other_vert(e, v);
+ BMVert *v_other = BM_edge_other_vert(e, v);
+ if (((BMElem *)e != ele_from) &&
+ VERT_WALK_TEST(v_other))
+ {
if (v_other == pc->v_b) {
BMElem *ele_next = (BMElem *)pc->v_b;
BMElem *ele_next_from = (BMElem *)e;
@@ -371,6 +396,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
return;
}
+ pc.bm_bmoflag = bm;
pc.v_a = ((BMVert **)op_verts_slot->data.p)[0];
pc.v_b = ((BMVert **)op_verts_slot->data.p)[1];
@@ -384,6 +410,10 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
printf("%s: v_b: %d\n", __func__, BM_elem_index_get(pc.v_b));
#endif
+ /* tag so we won't touch ever (typically hidden faces) */
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces_exclude", BM_FACE, FACE_EXCLUDE);
+ BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts_exclude", BM_VERT, VERT_EXCLUDE);
+
/* setup context */
{
BLI_listbase_clear(&pc.state_lb);
@@ -468,9 +498,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
BLI_remlink(&pc.state_lb, state);
MEM_freeN(state);
}
- else {
- found_all = false;
- }
+ found_all = false;
}
else {
/* didn't reach the end, remove it,
@@ -481,6 +509,11 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
}
if (found_all) {
+#ifdef DEBUG
+ for (state = pc.state_lb.first; state; state = state->next) {
+ BLI_assert(state->link_last->ele == (BMElem *)pc.v_b);
+ }
+#endif
break;
}
}
@@ -533,7 +566,8 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
* always connect even when resulting faces are degenerate [#39418] */
BMOperator op_sub;
BMO_op_initf(bm, &op_sub, 0,
- "connect_verts verts=%fv", VERT_OUT);
+ "connect_verts verts=%fv faces_exclude=%s",
+ VERT_OUT, op, "faces_exclude");
BMO_op_exec(bm, &op_sub);
BMO_slot_copy(&op_sub, slots_out, "edges.out",
op, slots_out, "edges.out");