diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-19 04:17:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-19 04:17:10 +0400 |
commit | a8abc11e42fefd8e6192e3a9bcc185b6428d36f4 (patch) | |
tree | 13c47348545ac8fe463e0aad7a241c7872635d98 /source | |
parent | d4bf47350fd8cf8ef42dce150a6cf3bd5ba98c50 (diff) |
dyntopo optimization - fast path for edges with 2 faces using it, was counting the edge-faces then using an iterator,
instead use BM_edge_loop_pair()
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 7ffadde2f08..7b6ad622deb 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -439,8 +439,18 @@ static void pbvh_bmesh_face_remove(PBVH *bvh, BMFace *f) static void pbvh_bmesh_edge_loops(BLI_Buffer *buf, BMEdge *e) { - BLI_buffer_resize(buf, BM_edge_face_count(e)); - BM_iter_as_array(NULL, BM_LOOPS_OF_EDGE, e, buf->data, buf->count); + /* fast-path for most common case where an edge has 2 faces, + * no need to iterate twice. + * This assumes that the buffer */ + BMLoop **data = buf->data; + BLI_assert(buf->alloc_count >= 2); + if (LIKELY(BM_edge_loop_pair(e, &data[0], &data[1]))) { + buf->count = 2; + } + else { + BLI_buffer_resize(buf, BM_edge_face_count(e)); + BM_iter_as_array(NULL, BM_LOOPS_OF_EDGE, e, buf->data, buf->count); + } } static void pbvh_bmesh_node_drop_orig(PBVHNode *node) @@ -1003,9 +1013,10 @@ void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, int smooth_shading, /* Collapse short edges, subdivide long edges */ int BKE_pbvh_bmesh_update_topology(PBVH *bvh, PBVHTopologyUpdateMode mode, - const float center[3], float radius) + const float center[3], float radius) { - BLI_buffer_declare_static(BMFace *, edge_loops, BLI_BUFFER_NOP, 8); + /* 2 is enough for edge faces - manifold edge */ + BLI_buffer_declare_static(BMFace *, edge_loops, BLI_BUFFER_NOP, 2); BLI_buffer_declare_static(BMFace *, deleted_faces, BLI_BUFFER_NOP, 32); int modified = FALSE; |