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-07-22 12:12:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-07-22 12:12:50 +0400
commit7398c4977644efc7da06cf7e705d2b9d752b2706 (patch)
treea79997c05d2ffed49c1ab180548cdf272f63ac3e /source/blender/bmesh
parentbb1503417b14489dfaf38813bfe6e64e7fef0350 (diff)
add support for BM_mesh_calc_face_groups to use vertex connectivity (not currently used yet)
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c47
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h2
-rw-r--r--source/blender/bmesh/operators/bmo_normals.c8
3 files changed, 41 insertions, 16 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index ef5ed06b61a..720997fcef8 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -1771,7 +1771,7 @@ float BM_mesh_calc_volume(BMesh *bm, bool is_signed)
* \return The number of groups found.
*/
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
- void *user_data, bool (*filter_fn)(BMEdge *, void *user_data))
+ bool (*filter_fn)(BMElem *, void *user_data), void *user_data, const char htype)
{
#ifdef DEBUG
int group_index_len = 1;
@@ -1798,6 +1798,8 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde
STACK_INIT(group_array);
+ BLI_assert(((htype & ~(BM_VERT | BM_EDGE)) == 0) && (htype != 0));
+
/* init the array */
BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
BM_elem_index_set(f, i); /* set_inline */
@@ -1846,17 +1848,40 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde
fg[1]++;
/* done */
- /* search for other faces */
- l_iter = l_first = BM_FACE_FIRST_LOOP(f);
- do {
- BMLoop *l_other = l_iter->radial_next;
- if ((l_other != l_iter) && filter_fn(l_iter->e, user_data)) {
- if (BM_elem_flag_test(l_other->f, BM_ELEM_TAG) == false) {
- BM_elem_flag_enable(l_other->f, BM_ELEM_TAG);
- STACK_PUSH(fstack, l_other->f);
+ if (htype & BM_EDGE) {
+ /* search for other faces */
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ BMLoop *l_radial_iter = l_iter->radial_next;
+ if ((l_radial_iter != l_iter) && filter_fn((BMElem *)l_iter->e, user_data)) {
+ do {
+ BMFace *f_other = l_radial_iter->f;
+ if (BM_elem_flag_test(f_other, BM_ELEM_TAG) == false) {
+ BM_elem_flag_enable(f_other, BM_ELEM_TAG);
+ STACK_PUSH(fstack, f_other);
+ }
+ } while ((l_radial_iter = l_radial_iter->radial_next) != l_iter);
}
- }
- } while ((l_iter = l_iter->next) != l_first);
+ } while ((l_iter = l_iter->next) != l_first);
+ }
+
+ if (htype & BM_VERT) {
+ BMIter liter;
+ /* search for other faces */
+ l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+ do {
+ if (filter_fn((BMElem *)l_iter->v, user_data)) {
+ BMLoop *l_other;
+ BM_ITER_ELEM (l_other, &liter, l_iter, BM_LOOPS_OF_LOOP) {
+ BMFace *f_other = l_other->f;
+ if (BM_elem_flag_test(f_other, BM_ELEM_TAG) == false) {
+ BM_elem_flag_enable(f_other, BM_ELEM_TAG);
+ STACK_PUSH(fstack, f_other);
+ }
+ }
+ }
+ } while ((l_iter = l_iter->next) != l_first);
+ }
}
group_curr++;
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index 94dae1d1d23..f62de692778 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -116,7 +116,7 @@ bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
float BM_mesh_calc_volume(BMesh *bm, bool is_signed);
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
- void *user_data, bool (*filter_fn)(BMEdge *, void *user_data));
+ bool (*filter_fn)(BMElem *, void *user_data), void *user_data, const char htype);
/* not really any good place to put this */
float bmesh_subd_falloff_calc(const int falloff, float val);
diff --git a/source/blender/bmesh/operators/bmo_normals.c b/source/blender/bmesh/operators/bmo_normals.c
index 4291fc22793..9d86e7ab275 100644
--- a/source/blender/bmesh/operators/bmo_normals.c
+++ b/source/blender/bmesh/operators/bmo_normals.c
@@ -40,9 +40,9 @@
#define FACE_FLIP (1 << 1)
#define FACE_TEMP (1 << 2)
-static bool bmo_recalc_normal_edge_filter_cb(BMEdge *e, void *UNUSED(user_data))
+static bool bmo_recalc_normal_edge_filter_cb(BMElem *ele, void *UNUSED(user_data))
{
- return BM_edge_is_manifold(e);
+ return BM_edge_is_manifold((BMEdge *)ele);
}
/**
@@ -115,7 +115,7 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
do {
BMLoop *l_other = l_iter->radial_next;
- if ((l_other != l_iter) && bmo_recalc_normal_edge_filter_cb(l_iter->e, NULL)) {
+ if ((l_other != l_iter) && bmo_recalc_normal_edge_filter_cb((BMElem *)l_iter->e, NULL)) {
if (!BMO_elem_flag_test(bm, l_other->f, FACE_TEMP)) {
BMO_elem_flag_enable(bm, l_other->f, FACE_TEMP);
BMO_elem_flag_set(bm, l_other->f, FACE_FLIP, (l_other->v == l_iter->v) != flip_state);
@@ -153,7 +153,7 @@ void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
int (*group_index)[2];
const int group_tot = BM_mesh_calc_face_groups(bm, groups_array, &group_index,
- NULL, bmo_recalc_normal_edge_filter_cb);
+ bmo_recalc_normal_edge_filter_cb, NULL, BM_EDGE);
int i;