BMesh: use typed filter callbacks (const args too)

This commit is contained in:
Campbell Barton
2015-11-28 13:37:02 +11:00
parent bafccb00de
commit a12fa185f8
5 changed files with 13 additions and 9 deletions

View File

@@ -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); \

View File

@@ -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);
}

View File

@@ -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,

View File

@@ -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);
}
/**

View File

@@ -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);