[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53900] trunk/blender/source/blender/ blenkernel/intern/pbvh_bmesh.c: dyntopo optimization - fast path for edges with 2 faces using it, was counting the edge-faces then using an iterator,
Campbell Barton
ideasman42 at gmail.com
Sat Jan 19 01:17:17 CET 2013
Revision: 53900
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53900
Author: campbellbarton
Date: 2013-01-19 00:17:10 +0000 (Sat, 19 Jan 2013)
Log Message:
-----------
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()
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c
Modified: trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c 2013-01-18 23:20:17 UTC (rev 53899)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh_bmesh.c 2013-01-19 00:17:10 UTC (rev 53900)
@@ -439,8 +439,18 @@
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 @@
/* 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;
More information about the Bf-blender-cvs
mailing list