forked from bartvdbraak/blender
BMesh: BM_face_exists no longer uses return arg
Just return the face or NULL, like BM_edge_exists(), Also for BM_face_exists_overlap & bm_face_exists_tri_from_loop_vert. No functional changes. Old code did some partial overlap checks where this made some sense, but it's since been removed.
This commit is contained in:
parent
1b1d6ce131
commit
fc9fa07c0e
@ -148,8 +148,7 @@ BLI_INLINE void bm_face_as_array_index_tri(BMFace *f, int r_index[3])
|
||||
*
|
||||
* Its assumed that \a l_radial_first is never forming the target face.
|
||||
*/
|
||||
static bool bm_face_exists_tri_from_loop_vert(
|
||||
BMLoop *l_radial_first, BMVert *v_opposite, BMFace **r_face_existing)
|
||||
static BMFace *bm_face_exists_tri_from_loop_vert(BMLoop *l_radial_first, BMVert *v_opposite)
|
||||
{
|
||||
BLI_assert(!ELEM(v_opposite, l_radial_first->v, l_radial_first->next->v, l_radial_first->prev->v));
|
||||
if (l_radial_first->radial_next != l_radial_first) {
|
||||
@ -157,12 +156,11 @@ static bool bm_face_exists_tri_from_loop_vert(
|
||||
do {
|
||||
BLI_assert(l_radial_iter->f->len == 3);
|
||||
if (l_radial_iter->prev->v == v_opposite) {
|
||||
*r_face_existing = l_radial_iter->f;
|
||||
return true;
|
||||
return l_radial_iter->f;
|
||||
}
|
||||
} while ((l_radial_iter = l_radial_iter->radial_next) != l_radial_first);
|
||||
}
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -519,7 +517,7 @@ static BMFace *pbvh_bmesh_face_create(
|
||||
PBVHNode *node = &bvh->nodes[node_index];
|
||||
|
||||
/* ensure we never add existing face */
|
||||
BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
|
||||
BLI_assert(!BM_face_exists(v_tri, 3));
|
||||
|
||||
BMFace *f = BM_face_create(bvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
|
||||
f->head.hflag = f_example->head.hflag;
|
||||
@ -1313,18 +1311,17 @@ static void pbvh_bmesh_collapse_edge(
|
||||
* deletion as well. Prevents extraneous "flaps" from being
|
||||
* created. */
|
||||
#if 0
|
||||
if (UNLIKELY(BM_face_exists(v_tri, 3, &existing_face)))
|
||||
if (UNLIKELY(existing_face = BM_face_exists(v_tri, 3)))
|
||||
#else
|
||||
if (UNLIKELY(bm_face_exists_tri_from_loop_vert(l->next, v_conn, &existing_face)))
|
||||
if (UNLIKELY(existing_face = bm_face_exists_tri_from_loop_vert(l->next, v_conn)))
|
||||
#endif
|
||||
{
|
||||
BLI_assert(existing_face);
|
||||
BLI_buffer_append(deleted_faces, BMFace *, existing_face);
|
||||
}
|
||||
else {
|
||||
BMVert *v_tri[3] = {v_conn, l->next->v, l->prev->v};
|
||||
|
||||
BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
|
||||
BLI_assert(!BM_face_exists(v_tri, 3));
|
||||
BMEdge *e_tri[3];
|
||||
PBVHNode *n = pbvh_bmesh_node_from_face(bvh, f);
|
||||
int ni = n - bvh->nodes;
|
||||
|
@ -444,13 +444,10 @@ BMFace *BM_face_create(
|
||||
|
||||
if (create_flag & BM_CREATE_NO_DOUBLE) {
|
||||
/* Check if face already exists */
|
||||
const bool is_overlap = BM_face_exists(verts, len, &f);
|
||||
if (is_overlap) {
|
||||
f = BM_face_exists(verts, len);
|
||||
if (f != NULL) {
|
||||
return f;
|
||||
}
|
||||
else {
|
||||
BLI_assert(f == NULL);
|
||||
}
|
||||
}
|
||||
|
||||
f = bm_face_create__internal(bm);
|
||||
|
@ -1925,7 +1925,7 @@ BMEdge *BM_edge_find_double(BMEdge *e)
|
||||
*
|
||||
* \note there used to be a BM_face_exists_overlap function that checks for partial overlap.
|
||||
*/
|
||||
bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
|
||||
BMFace *BM_face_exists(BMVert **varr, int len)
|
||||
{
|
||||
if (varr[0]->e) {
|
||||
BMEdge *e_iter, *e_first;
|
||||
@ -1964,10 +1964,7 @@ bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
|
||||
}
|
||||
|
||||
if (i_walk == len) {
|
||||
if (r_existface) {
|
||||
*r_existface = l_iter_radial->f;
|
||||
}
|
||||
return true;
|
||||
return l_iter_radial->f;
|
||||
}
|
||||
}
|
||||
} while ((l_iter_radial = l_iter_radial->radial_next) != l_first_radial);
|
||||
@ -1976,10 +1973,7 @@ bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface)
|
||||
} while ((e_iter = BM_DISK_EDGE_NEXT(e_iter, varr[0])) != e_first);
|
||||
}
|
||||
|
||||
if (r_existface) {
|
||||
*r_existface = NULL;
|
||||
}
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -2122,26 +2116,21 @@ bool BM_face_exists_multi_edge(BMEdge **earr, int len)
|
||||
* \note The face may contain other verts \b not in \a varr.
|
||||
*
|
||||
* \note Its possible there are more than one overlapping faces,
|
||||
* in this case the first one found will be assigned to \a r_f_overlap.
|
||||
* in this case the first one found will be returned.
|
||||
*
|
||||
* \param varr Array of unordered verts.
|
||||
* \param len \a varr array length.
|
||||
* \param r_f_overlap The overlapping face to return.
|
||||
* \return Success
|
||||
* \return The face or NULL.
|
||||
*/
|
||||
|
||||
bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
|
||||
BMFace *BM_face_exists_overlap(BMVert **varr, const int len)
|
||||
{
|
||||
BMIter viter;
|
||||
BMFace *f;
|
||||
int i;
|
||||
bool is_overlap = false;
|
||||
BMFace *f_overlap = NULL;
|
||||
LinkNode *f_lnk = NULL;
|
||||
|
||||
if (r_f_overlap) {
|
||||
*r_f_overlap = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* check flag isn't already set */
|
||||
for (i = 0; i < len; i++) {
|
||||
@ -2155,10 +2144,7 @@ bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
|
||||
BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
|
||||
if (BM_ELEM_API_FLAG_TEST(f, _FLAG_OVERLAP) == 0) {
|
||||
if (len <= BM_verts_in_face_count(varr, len, f)) {
|
||||
if (r_f_overlap)
|
||||
*r_f_overlap = f;
|
||||
|
||||
is_overlap = true;
|
||||
f_overlap = f;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2172,7 +2158,7 @@ bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap)
|
||||
BM_ELEM_API_FLAG_DISABLE((BMFace *)f_lnk->link, _FLAG_OVERLAP);
|
||||
}
|
||||
|
||||
return is_overlap;
|
||||
return f_overlap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,12 +135,12 @@ BMLoop *BM_face_find_longest_loop(BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNUL
|
||||
BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
BMEdge *BM_edge_find_double(BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface) ATTR_NONNULL(1);
|
||||
BMFace* BM_face_exists(BMVert **varr, int len) ATTR_NONNULL(1);
|
||||
|
||||
bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
bool BM_face_exists_multi_edge(BMEdge **earr, int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overlap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
|
||||
BMFace *BM_face_exists_overlap(BMVert **varr, const int len) ATTR_WARN_UNUSED_RESULT;
|
||||
bool BM_face_exists_overlap_subset(BMVert **varr, const int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
int BM_face_share_face_count(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
@ -398,7 +398,8 @@ static void bridge_loop_pair(
|
||||
|
||||
if (v_b != v_b_next) {
|
||||
BMVert *v_arr[4] = {v_a, v_b, v_b_next, v_a_next};
|
||||
if (BM_face_exists(v_arr, 4, &f) == false) {
|
||||
f = BM_face_exists(v_arr, 4);
|
||||
if (f == NULL) {
|
||||
/* copy if loop data if its is missing on one ring */
|
||||
f = BM_face_create_verts(bm, v_arr, 4, NULL, BM_CREATE_NOP, true);
|
||||
|
||||
@ -411,7 +412,8 @@ static void bridge_loop_pair(
|
||||
}
|
||||
else {
|
||||
BMVert *v_arr[3] = {v_a, v_b, v_a_next};
|
||||
if (BM_face_exists(v_arr, 3, &f) == false) {
|
||||
f = BM_face_exists(v_arr, 3);
|
||||
if (f == NULL) {
|
||||
/* fan-fill a triangle */
|
||||
f = BM_face_create_verts(bm, v_arr, 3, NULL, BM_CREATE_NOP, true);
|
||||
|
||||
|
@ -136,7 +136,7 @@ void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op)
|
||||
i++;
|
||||
} while ((v != f_verts[0]));
|
||||
|
||||
if (BM_face_exists(f_verts, i, NULL) == false) {
|
||||
if (!BM_face_exists(f_verts, i)) {
|
||||
BMFace *f;
|
||||
|
||||
/* don't use calc_edges option because we already have the edges */
|
||||
|
@ -119,7 +119,8 @@ static void hull_output_triangles(BMesh *bm, GSet *hull_triangles)
|
||||
};
|
||||
BMFace *f, *example = NULL;
|
||||
|
||||
if (BM_face_exists(t->v, 3, &f)) {
|
||||
f = BM_face_exists(t->v, 3);
|
||||
if (f != NULL) {
|
||||
/* If the operator is run with "use_existing_faces"
|
||||
* disabled, but an output face in the hull is the
|
||||
* same as a face in the existing mesh, it should not
|
||||
|
@ -160,7 +160,7 @@ finally:
|
||||
}
|
||||
|
||||
if (STACK_SIZE(edges) >= 3) {
|
||||
if (!BM_face_exists(verts, STACK_SIZE(edges), NULL)) {
|
||||
if (!BM_face_exists(verts, STACK_SIZE(edges))) {
|
||||
BMFace *f_new = BM_face_create(bm, verts, edges, STACK_SIZE(edges), f, BM_CREATE_NOP);
|
||||
BLI_assert(f_new != f);
|
||||
|
||||
|
@ -74,7 +74,7 @@ static bool bm_vert_dissolve_fan_test(BMVert *v)
|
||||
((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) ||
|
||||
((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1)))
|
||||
{
|
||||
if (!BM_face_exists(varr, tot_edge, NULL)) {
|
||||
if (!BM_face_exists(varr, tot_edge)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u
|
||||
}
|
||||
|
||||
/* face should never exist */
|
||||
BLI_assert(BM_face_exists(f_verts, f_verts[3] ? 4 : 3, &f) == false);
|
||||
BLI_assert(!BM_face_exists(f_verts, f_verts[3] ? 4 : 3));
|
||||
|
||||
f = BM_face_create_verts(bm, f_verts, f_verts[3] ? 4 : 3, f_example, BM_CREATE_NOP, true);
|
||||
|
||||
|
@ -1139,7 +1139,6 @@ BMEdge *EDBM_verts_mirror_get_edge(BMEditMesh *em, BMEdge *e)
|
||||
|
||||
BMFace *EDBM_verts_mirror_get_face(BMEditMesh *em, BMFace *f)
|
||||
{
|
||||
BMFace *f_mirr = NULL;
|
||||
BMVert **v_mirr_arr = BLI_array_alloca(v_mirr_arr, f->len);
|
||||
|
||||
BMLoop *l_iter, *l_first;
|
||||
@ -1152,8 +1151,7 @@ BMFace *EDBM_verts_mirror_get_face(BMEditMesh *em, BMFace *f)
|
||||
}
|
||||
} while ((l_iter = l_iter->next) != l_first);
|
||||
|
||||
BM_face_exists(v_mirr_arr, f->len, &f_mirr);
|
||||
return f_mirr;
|
||||
return BM_face_exists(v_mirr_arr, f->len);
|
||||
}
|
||||
|
||||
void EDBM_verts_mirror_cache_clear(BMEditMesh *em, BMVert *v)
|
||||
|
@ -2233,7 +2233,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
}
|
||||
|
||||
/* check if the face exists */
|
||||
if (BM_face_exists(vert_array, vert_seq_len, NULL)) {
|
||||
if (BM_face_exists(vert_array, vert_seq_len) != NULL) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"faces.new(verts): face already exists");
|
||||
goto cleanup;
|
||||
@ -2426,7 +2426,8 @@ static PyObject *bpy_bmfaceseq_get__method(BPy_BMElemSeq *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (BM_face_exists(vert_array, vert_seq_len, &f)) {
|
||||
f = BM_face_exists(vert_array, vert_seq_len);
|
||||
if (f != NULL) {
|
||||
ret = BPy_BMFace_CreatePyObject(bm, f);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user