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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user