diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-11 07:24:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-11 07:24:26 +0300 |
commit | bf455c2ca98ff3062a733ad357f2c2c43ffda5df (patch) | |
tree | e2c7168b580371fb0b41da7623552d9cff90acab /source/blender/draw/intern | |
parent | fb79357b3e914eac49fc92735e34a84460fd248d (diff) |
DRW: avoid edit-mode layer lookups for freestyle
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 8b124ce6e9e..8d901e9a05f 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -182,6 +182,10 @@ typedef struct MeshRenderData { int bweight; int *uv; int *vcol; +#ifdef WITH_FREESTYLE + int freestyle_edge; + int freestyle_face; +#endif } offset; struct { @@ -445,6 +449,11 @@ static MeshRenderData *mesh_render_data_create_ex( rdata->eve_act = BM_mesh_active_vert_get(bm); rdata->cd.offset.crease = CustomData_get_offset(&bm->edata, CD_CREASE); rdata->cd.offset.bweight = CustomData_get_offset(&bm->edata, CD_BWEIGHT); + +#ifdef WITH_FREESTYLE + rdata->cd.offset.freestyle_edge = CustomData_get_offset(&bm->edata, CD_FREESTYLE_EDGE); + rdata->cd.offset.freestyle_face = CustomData_get_offset(&bm->pdata, CD_FREESTYLE_FACE); +#endif } if (types & (MR_DATATYPE_DVERT)) { bm_ensure_types |= BM_VERT; @@ -1372,12 +1381,11 @@ static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace * fflag |= VFLAG_FACE_SELECTED; #ifdef WITH_FREESTYLE - BMesh *bm = rdata->edit_bmesh->bm; - if (CustomData_has_layer(&bm->pdata, CD_FREESTYLE_FACE)) { - FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE); - - if (ffa->flag & FREESTYLE_FACE_MARK) + if (rdata->cd.offset.freestyle_face != -1) { + const FreestyleFace *ffa = BM_ELEM_CD_GET_VOID_P(efa, rdata->cd.offset.freestyle_face); + if (ffa->flag & FREESTYLE_FACE_MARK) { fflag |= VFLAG_FACE_FREESTYLE; + } } #endif @@ -1402,16 +1410,6 @@ static void mesh_render_data_edge_flag( if (!BM_elem_flag_test(eed, BM_ELEM_SMOOTH)) eattr->e_flag |= VFLAG_EDGE_SHARP; -#ifdef WITH_FREESTYLE - BMesh *bm = rdata->edit_bmesh->bm; - if (CustomData_has_layer(&bm->edata, CD_FREESTYLE_EDGE)) { - FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE); - - if (fed->flag & FREESTYLE_EDGE_MARK) - eattr->e_flag |= VFLAG_EDGE_FREESTYLE; - } -#endif - /* Use a byte for value range */ if (rdata->cd.offset.crease != -1) { float crease = BM_ELEM_CD_GET_FLOAT(eed, rdata->cd.offset.crease); @@ -1427,6 +1425,15 @@ static void mesh_render_data_edge_flag( eattr->bweight = (uchar)(bweight * 255.0f); } } + +#ifdef WITH_FREESTYLE + if (rdata->cd.offset.freestyle_edge != -1) { + const FreestyleEdge *fed = BM_ELEM_CD_GET_VOID_P(eed, rdata->cd.offset.freestyle_edge); + if (fed->flag & FREESTYLE_EDGE_MARK) { + eattr->e_flag |= VFLAG_EDGE_FREESTYLE; + } + } +#endif } static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *eve) |