Commit: a12fa185f8b098d89e13afe476e1c34b40d21f29
Author: Campbell Barton
Date:   Sat Nov 28 13:37:02 2015 +1100
Branches: master
https://developer.blender.org/rBa12fa185f8b098d89e13afe476e1c34b40d21f29

BMesh: use typed filter callbacks (const args too)

===================================================================

M       source/blender/bmesh/bmesh_class.h
M       source/blender/bmesh/intern/bmesh_construct.c
M       source/blender/bmesh/intern/bmesh_construct.h
M       source/blender/bmesh/operators/bmo_fill_attribute.c
M       source/blender/bmesh/operators/bmo_normals.c

===================================================================

diff --git a/source/blender/bmesh/bmesh_class.h 
b/source/blender/bmesh/bmesh_class.h
index 57107ed..16e8285 100644
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@ -309,7 +309,11 @@ enum {
 struct BPy_BMGeneric;
 extern void bpy_bm_generic_invalidate(struct BPy_BMGeneric *self);
 
-typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
+typedef bool (*BMElemFilterFunc)(const BMElem *, void *user_data);
+typedef bool (*BMVertFilterFunc)(const BMVert *, void *user_data);
+typedef bool (*BMEdgeFilterFunc)(const BMEdge *, void *user_data);
+typedef bool (*BMFaceFilterFunc)(const BMFace *, void *user_data);
+typedef bool (*BMLoopFilterFunc)(const BMLoop *, void *user_data);
 
 /* defines */
 #define BM_ELEM_CD_SET_INT(ele, offset, f) { CHECK_TYPE_NONCONST(ele); \
diff --git a/source/blender/bmesh/intern/bmesh_construct.c 
b/source/blender/bmesh/intern/bmesh_construct.c
index 7664108..3c2a85e 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -116,7 +116,7 @@ BMFace *BM_face_create_quad_tri(
  */
 void BM_face_copy_shared(
         BMesh *bm, BMFace *f,
-        BMElemFilterFunc filter_fn, void *user_data)
+        BMLoopFilterFunc filter_fn, void *user_data)
 {
        BMLoop *l_first;
        BMLoop *l_iter;
@@ -149,7 +149,7 @@ void BM_face_copy_shared(
                        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)) {
+                                       if ((filter_fn == NULL) || 
filter_fn(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);
                                        }
diff --git a/source/blender/bmesh/intern/bmesh_construct.h 
b/source/blender/bmesh/intern/bmesh_construct.h
index 2950367..ce8b8dd 100644
--- a/source/blender/bmesh/intern/bmesh_construct.h
+++ b/source/blender/bmesh/intern/bmesh_construct.h
@@ -38,7 +38,7 @@ BMFace *BM_face_create_quad_tri(
 
 void BM_face_copy_shared(
         BMesh *bm, BMFace *f,
-        BMElemFilterFunc filter_fn, void *user_data);
+        BMLoopFilterFunc filter_fn, void *user_data);
 
 BMFace *BM_face_create_ngon(
         BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, const int len,
diff --git a/source/blender/bmesh/operators/bmo_fill_attribute.c 
b/source/blender/bmesh/operators/bmo_fill_attribute.c
index 85bca74..233ed74 100644
--- a/source/blender/bmesh/operators/bmo_fill_attribute.c
+++ b/source/blender/bmesh/operators/bmo_fill_attribute.c
@@ -53,9 +53,9 @@ static bool bm_loop_is_all_radial_tag(BMLoop *l)
 /**
  * Callback to run on source-loops for #BM_face_copy_shared
  */
-static bool bm_loop_is_face_untag(BMElem *ele, void *UNUSED(user_data))
+static bool bm_loop_is_face_untag(const BMLoop *l, void *UNUSED(user_data))
 {
-       return (BM_elem_flag_test(((BMLoop *)ele)->f, BM_ELEM_TAG) == 0);
+       return (BM_elem_flag_test(l->f, BM_ELEM_TAG) == 0);
 }
 
 /**
diff --git a/source/blender/bmesh/operators/bmo_normals.c 
b/source/blender/bmesh/operators/bmo_normals.c
index 1f50feb..06ceece 100644
--- a/source/blender/bmesh/operators/bmo_normals.c
+++ b/source/blender/bmesh/operators/bmo_normals.c
@@ -41,9 +41,9 @@
 #define FACE_FLIP      (1 << 1)
 #define FACE_TEMP      (1 << 2)
 
-static bool bmo_recalc_normal_edge_filter_cb(BMElem *ele, void 
*UNUSED(user_data))
+static bool bmo_recalc_normal_edge_filter_cb(const BMElem *ele, void 
*UNUSED(user_data))
 {
-       return BM_edge_is_manifold((BMEdge *)ele);
+       return BM_edge_is_manifold((const BMEdge *)ele);
 }
 
 /**
@@ -229,7 +229,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((BMElem *)l_iter->e, NULL)) {
+                       if ((l_other != l_iter) && 
bmo_recalc_normal_edge_filter_cb((const 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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to