Commit: 4e2aea5efea31262ce46240baa0511e85a021332 Author: Campbell Barton Date: Wed Mar 20 15:05:25 2019 +1100 Branches: master https://developer.blender.org/rB4e2aea5efea31262ce46240baa0511e85a021332
DRW: minor optimization for edit-mesh conversion Finding visible connected elements is often a direct lookup when they're not connected to hidden geometry. Add inline wrappers that avoid a function call, gives minor speedup creating GPU edit-mesh data. =================================================================== M source/blender/draw/intern/draw_cache_impl_mesh.c =================================================================== diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 3e1b6b6c020..4e064111245 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -84,6 +84,40 @@ enum { DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE = (1 << 1), }; +/* ---------------------------------------------------------------------- */ +/** \name BMesh Inline Wrappers + * \{ */ + +/** + * Wrapper for #BM_vert_find_first_loop_visible + * since most of the time this can be accessed directly without a function call. + */ +BLI_INLINE BMLoop *bm_vert_find_first_loop_visible_inline(BMVert *v) +{ + if (v->e) { + BMLoop *l = v->e->l; + if (l && !BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { + return l->v == v ? l : l->next; + } + return BM_vert_find_first_loop_visible(v); + } + return NULL; +} + +BLI_INLINE BMLoop *bm_edge_find_first_loop_visible_inline(BMEdge *e) +{ + if (e->l) { + BMLoop *l = e->l; + if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { + return l; + } + return BM_edge_find_first_loop_visible(e); + } + return NULL; +} + +/** \} */ + /* ---------------------------------------------------------------------- */ /** \name Mesh/BMesh Interface (direct access to basic data). * \{ */ @@ -3426,8 +3460,8 @@ static void mesh_create_loops_lines( if (!BM_elem_flag_test(bm_edge, BM_ELEM_HIDDEN) && bm_edge->l != NULL) { - BMLoop *bm_loop1 = BM_vert_find_first_loop_visible(bm_edge->v1); - BMLoop *bm_loop2 = BM_vert_find_first_loop_visible(bm_edge->v2); + BMLoop *bm_loop1 = bm_vert_find_first_loop_visible_inline(bm_edge->v1); + BMLoop *bm_loop2 = bm_vert_find_first_loop_visible_inline(bm_edge->v2); int v1 = BM_elem_index_get(bm_loop1); int v2 = BM_elem_index_get(bm_loop2); if (v1 > v2) { @@ -3669,7 +3703,7 @@ static void mesh_create_edit_loops_points_lines(MeshRenderData *rdata, GPUIndexB BMEdge *eed; BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - BMLoop *l = BM_edge_find_first_loop_visible(eed); + BMLoop *l = bm_edge_find_first_loop_visible_inline(eed); if (l != NULL) { int v1 = BM_elem_index_get(eed->l); int v2 = BM_elem_index_get(eed->l->next); @@ -3683,7 +3717,7 @@ static void mesh_create_edit_loops_points_lines(MeshRenderData *rdata, GPUIndexB BMVert *eve; BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - BMLoop *l = BM_vert_find_first_loop_visible(eve); + BMLoop *l = bm_vert_find_first_loop_visible_inline(eve); if (l != NULL) { int v = BM_elem_index_get(l); GPU_indexbuf_add_generic_vert(&elb_vert, v); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs