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:
authorCampbell Barton <ideasman42@gmail.com>2013-08-18 15:44:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-18 15:44:51 +0400
commit19d3e230e6d0cc52ebd82a8b5d0efbbeb396a9cf (patch)
tree125f5abc45d82265a36ae7365813491e13634c1a
parentfa3481cf07d1f78791af2773b71013ab19fa180b (diff)
improved BM_face_copy_shared to copy from more possible connected loops and add filter function (not used yet).
-rw-r--r--source/blender/bmesh/bmesh_class.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c46
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.h3
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h2
-rw-r--r--source/blender/bmesh/operators/bmo_hull.c2
-rw-r--r--source/blender/bmesh/operators/bmo_inset.c2
6 files changed, 43 insertions, 14 deletions
diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h
index 0e4c014a06a..23e5c970823 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -254,6 +254,8 @@ enum {
struct BPy_BMGeneric;
extern void bpy_bm_generic_invalidate(struct BPy_BMGeneric *self);
+typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
+
/* defines */
#define BM_ELEM_CD_GET_VOID_P(ele, offset) \
(assert(offset != -1), (void *)((char *)(ele)->head.data + (offset)))
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index f5856ee94b3..aa37a684519 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -127,33 +127,61 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa
/**
* \brief copies face loop data from shared adjacent faces.
+ *
+ * \param filter_fn A function that filters the source loops before copying (don't always want to copy all)
+ *
* \note when a matching edge is found, both loops of that edge are copied
* this is done since the face may not be completely surrounded by faces,
- * this way: a quad with 2 connected quads on either side will still get all 4 loops updated */
-void BM_face_copy_shared(BMesh *bm, BMFace *f)
+ * this way: a quad with 2 connected quads on either side will still get all 4 loops updated
+ */
+void BM_face_copy_shared(BMesh *bm, BMFace *f,
+ BMElemFilterFunc filter_fn, void *user_data)
{
BMLoop *l_first;
BMLoop *l_iter;
+#ifdef DEBUG
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ BLI_assert(BM_ELEM_API_FLAG_TEST(l_iter, _FLAG_OVERLAP) == 0);
+ } while ((l_iter = l_iter->next) != l_first);
+#endif
+
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BMLoop *l_other = l_iter->radial_next;
if (l_other && l_other != l_iter) {
+ BMLoop *l_src[2];
+ BMLoop *l_dst[2] = {l_iter, l_iter->next};
+ unsigned int j;
+
if (l_other->v == l_iter->v) {
- bm_loop_attrs_copy(bm, bm, l_other, l_iter);
- bm_loop_attrs_copy(bm, bm, l_other->next, l_iter->next);
+ l_src[0] = l_other;
+ l_src[1] = l_other->next;
}
else {
- bm_loop_attrs_copy(bm, bm, l_other->next, l_iter);
- bm_loop_attrs_copy(bm, bm, l_other, l_iter->next);
+ l_src[0] = l_other->next;
+ l_src[1] = l_other;
}
- /* since we copy both loops of the shared edge, step over the next loop here */
- if ((l_iter = l_iter->next) == l_first) {
- break;
+
+ for (j = 0; j < 2; j++) {
+ BLI_assert(l_dst[j]->v == l_src[j]->v);
+ if (BM_ELEM_API_FLAG_TEST(l_dst[j], _FLAG_OVERLAP) == 0) {
+ if ((filter_fn == NULL) || filter_fn((BMElem *)l_src[j], user_data)) {
+ bm_loop_attrs_copy(bm, bm, l_src[j], l_dst[j]);
+ BM_ELEM_API_FLAG_ENABLE(l_dst[j], _FLAG_OVERLAP);
+ }
+ }
}
}
} while ((l_iter = l_iter->next) != l_first);
+
+
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ BM_ELEM_API_FLAG_DISABLE(l_iter, _FLAG_OVERLAP);
+ } while ((l_iter = l_iter->next) != l_first);
}
/**
diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h
index f0bd7b316e9..92ed3307523 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -36,7 +36,8 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm,
BMFace *BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4,
const BMFace *example, const bool no_double);
-void BM_face_copy_shared(BMesh *bm, BMFace *f);
+void BM_face_copy_shared(BMesh *bm, BMFace *f,
+ BMElemFilterFunc filter_fn, void *user_data);
BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, const int len, const int create_flag);
BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, const int create_flag,
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 38d30b2d005..e52e59102db 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -27,8 +27,6 @@
* \ingroup bmesh
*/
-typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
-
bool BM_vert_in_face(BMFace *f, BMVert *v);
int BM_verts_in_face_count(BMFace *f, BMVert **varr, int len);
bool BM_verts_in_face(BMFace *f, BMVert **varr, int len);
diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c
index 500e984f4c9..89da386c1cb 100644
--- a/source/blender/bmesh/operators/bmo_hull.c
+++ b/source/blender/bmesh/operators/bmo_hull.c
@@ -136,7 +136,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
/* Create new hull face */
f = BM_face_create_quad_tri_v(bm, t->v, 3, example, true);
- BM_face_copy_shared(bm, f);
+ BM_face_copy_shared(bm, f, NULL, NULL);
}
/* Mark face for 'geom.out' slot and select */
BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM);
diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c
index cffca91eabd..731b895a6b5 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -796,7 +796,7 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
#if 0
/* don't use this because face boundaries have no adjacent loops and won't be filled in.
* instead copy from the opposite side with the code below */
- BM_face_copy_shared(bm, f);
+ BM_face_copy_shared(bm, f, NULL, NULL);
#else
{
/* 2 inner loops on the edge between the new face and the original */