diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-11 03:41:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-11 03:41:24 +0300 |
commit | 92a494ed51ec6301cb9ba07a8c4f8f59db8ab33e (patch) | |
tree | e0aaaf19e18933b35cfcdb3ffff9c09ec515a2ba /source/blender | |
parent | 121c94b0829e57503bf90167e6e903f2fb55e328 (diff) |
DRW: remove redundant editmode mesh tessellation
Also re-order logic so loop indices are ensured to be valid.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index bcdf3a3cf08..aa96984f5d3 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -421,17 +421,7 @@ static MeshRenderData *mesh_render_data_create_ex( bm_ensure_types |= BM_EDGE; } if (types & MR_DATATYPE_LOOPTRI) { - BKE_editmesh_tessface_calc(embm); - int tottri = embm->tottri; - rdata->mlooptri = MEM_mallocN(sizeof(*rdata->mlooptri) * embm->tottri, __func__); - for (int index = 0; index < tottri ; index ++ ) { - BMLoop **bmtri = embm->looptris[index]; - MLoopTri *mtri = &rdata->mlooptri[index]; - mtri->tri[0] = BM_elem_index_get(bmtri[0]); - mtri->tri[1] = BM_elem_index_get(bmtri[1]); - mtri->tri[2] = BM_elem_index_get(bmtri[2]); - } - rdata->tri_len = tottri; + bm_ensure_types |= BM_LOOP; } if (types & MR_DATATYPE_LOOP) { int totloop = bm->totloop; @@ -465,6 +455,22 @@ static MeshRenderData *mesh_render_data_create_ex( BM_mesh_elem_index_ensure(bm, bm_ensure_types); BM_mesh_elem_table_ensure(bm, bm_ensure_types & ~BM_LOOP); + + if (types & MR_DATATYPE_LOOPTRI) { + /* Edit mode ensures this is valid, no need to calculate. */ + BLI_assert((bm->totloop == 0) || (embm->looptris != NULL)); + int tottri = embm->tottri; + rdata->mlooptri = MEM_mallocN(sizeof(*rdata->mlooptri) * embm->tottri, __func__); + for (int index = 0; index < tottri ; index ++ ) { + BMLoop **bmtri = embm->looptris[index]; + MLoopTri *mtri = &rdata->mlooptri[index]; + mtri->tri[0] = BM_elem_index_get(bmtri[0]); + mtri->tri[1] = BM_elem_index_get(bmtri[1]); + mtri->tri[2] = BM_elem_index_get(bmtri[2]); + } + rdata->tri_len = tottri; + } + if (types & MR_DATATYPE_OVERLAY) { rdata->loose_vert_len = rdata->loose_edge_len = 0; |