From d9ea72291fcaa0f8653e25e2a1d2eb8109835f3a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 Sep 2022 16:00:33 +0200 Subject: Fix T100842: Display Texture Paint UVs option in UV editor not working In 8cf52e8226cb we assumed that the UV IBO's are only needed in edit mode, however the UV lines also need to work in texture paint mode. So prefer to use bmesh when available to fix the original bug, but don't assume the face is hidden when there is no bmesh. Differential Revision: https://developer.blender.org/D15895 --- .../mesh_extractors/extract_mesh_ibo_edituv.cc | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc index f51c96af0b0..e2d939b18a1 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc @@ -212,9 +212,16 @@ static void extract_edituv_lines_iter_poly_mesh(const MeshRenderData *mr, const MLoop *mloop = mr->mloop; const int ml_index_end = mp->loopstart + mp->totloop; - const BMFace *efa = bm_original_face_get(mr, mp_index); - const bool mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true; - const bool mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false; + bool mp_hidden, mp_select; + if (mr->bm) { + const BMFace *efa = bm_original_face_get(mr, mp_index); + mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true; + mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false; + } + else { + mp_hidden = (mp->flag & ME_HIDE) != 0; + mp_select = (mp->flag & ME_FACE_SEL) != 0; + } for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) { const MLoop *ml = &mloop[ml_index]; @@ -285,9 +292,16 @@ static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_c MeshExtract_EditUvElem_Data *data = static_cast(_data); int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index); - const BMFace *efa = bm_original_face_get(mr, coarse_poly - mr->mpoly); - const bool mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true; - const bool mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false; + bool mp_hidden, mp_select; + if (mr->bm) { + const BMFace *efa = bm_original_face_get(mr, coarse_poly - mr->mpoly); + mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true; + mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false; + } + else { + mp_hidden = (coarse_poly->flag & ME_HIDE) != 0; + mp_select = (coarse_poly->flag & ME_FACE_SEL) != 0; + } uint start_loop_idx = subdiv_quad_index * 4; uint end_loop_idx = (subdiv_quad_index + 1) * 4; -- cgit v1.2.3