From e89f09a77474a8384f4e7cf0809ea975d367b24e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Mar 2012 16:56:42 +0000 Subject: [PATCH] fast-path for BM_edge_is_manifold, BM_edge_is_boundary functions. --- source/blender/bmesh/intern/bmesh_queries.c | 29 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 28c370f51eb..7338da927ac 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -348,27 +348,50 @@ int BM_vert_is_manifold(BMesh *UNUSED(bm), BMVert *v) * Tests whether or not this edge is manifold. * A manifold edge either has 1 or 2 faces attached to it. */ + +#if 1 /* fast path for checking manifold */ +int BM_edge_is_manifold(BMesh *UNUSED(bm), BMEdge *e) +{ + const BMLoop *l = e->l; + return (l && ((l->radial_next == l) || /* 1 face user */ + (l->radial_next->radial_next == l))); /* 2 face users */ +} +#else int BM_edge_is_manifold(BMesh *UNUSED(bm), BMEdge *e) { int count = BM_edge_face_count(e); - if (count != 2 && count != 1) { + if (count == 2 || count == 1) { + return TRUE; + } + else { return FALSE; } - return TRUE; } +#endif /** * Tests whether or not an edge is on the boundary * of a shell (has one face associated with it) */ + +#if 1 /* fast path for checking boundry */ +int BM_edge_is_boundary(BMEdge *e) +{ + const BMLoop *l = e->l; + return (l && (l->radial_next == l)); +} +#else int BM_edge_is_boundary(BMEdge *e) { int count = BM_edge_face_count(e); if (count == 1) { return TRUE; } - return FALSE; + else { + return FALSE; + } } +#endif /** * Counts the number of edges two faces share (if any)