BMesh: utility functions for visible element access

Needed for drawing code which skips hidden elements.
This commit is contained in:
Campbell Barton
2019-02-26 16:03:21 +11:00
parent 2986923f8c
commit 58a394073f
4 changed files with 51 additions and 0 deletions

View File

@@ -377,6 +377,13 @@ BMLoop *BM_vert_find_first_loop(BMVert *v)
{
return v->e ? bmesh_disk_faceloop_find_first(v->e, v) : NULL;
}
/**
* A version of #BM_vert_find_first_loop that ignores hidden loops.
*/
BMLoop *BM_vert_find_first_loop_visible(BMVert *v)
{
return v->e ? bmesh_disk_faceloop_find_first_visible(v->e, v) : NULL;
}
/**
* Returns true if the vertex is used in a given face.
@@ -1999,6 +2006,24 @@ BMEdge *BM_edge_find_double(BMEdge *e)
return NULL;
}
/**
* Only #BMEdge.l access us needed, however when we want the first visible loop,
* a utility function is needed.
*/
BMLoop *BM_edge_find_first_loop_visible(BMEdge *e)
{
if (e->l != NULL) {
BMLoop *l_iter, *l_first;
l_iter = l_first = e->l;
do {
if (!BM_elem_flag_test(l_iter->f, BM_ELEM_HIDDEN)) {
return l_iter;
}
} while ((l_iter = l_iter->radial_next) != l_first);
}
return NULL;
}
/**
* Given a set of vertices (varr), find out if
* there is a face with exactly those vertices

View File

@@ -42,7 +42,10 @@ BMLoop *BM_loop_other_edge_loop(BMLoop *l, BMVert *v) ATTR_WARN_UNUSED_RESULT AT
BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *BM_vert_find_first_loop(BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *BM_vert_find_first_loop_visible(BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *BM_edge_find_first_loop_visible(BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
bool BM_vert_pair_share_face_check(
BMVert *v_a, BMVert *v_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();

View File

@@ -347,6 +347,28 @@ BMLoop *bmesh_disk_faceloop_find_first(const BMEdge *e, const BMVert *v)
return NULL;
}
/**
* A version of #bmesh_disk_faceloop_find_first that ignores hidden faces.
*/
BMLoop *bmesh_disk_faceloop_find_first_visible(const BMEdge *e, const BMVert *v)
{
const BMEdge *e_iter = e;
do {
if (!BM_elem_flag_test(e_iter, BM_ELEM_HIDDEN)) {
if (e_iter->l != NULL) {
BMLoop *l_iter, *l_first;
l_iter = l_first = e_iter->l;
do {
if (!BM_elem_flag_test(l_iter->f, BM_ELEM_HIDDEN)) {
return (l_iter->v == v) ? l_iter : l_iter->next;
}
} while ((l_iter = l_iter->radial_next) != l_first);
}
}
} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e);
return NULL;
}
BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v)
{
BMEdge *e_find;

View File

@@ -45,6 +45,7 @@ int bmesh_disk_facevert_count_at_most(const BMVert *v, const int count_max)
int bmesh_disk_facevert_count(const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMEdge *bmesh_disk_faceedge_find_first(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *bmesh_disk_faceloop_find_first(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMLoop *bmesh_disk_faceloop_find_first_visible(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* RADIAL CYCLE MANAGMENT */