diff options
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc | 131 |
1 files changed, 98 insertions, 33 deletions
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 3a2b6d468d8..cd71beb1f02 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 @@ -110,28 +110,49 @@ static void extract_edituv_tris_init_subdiv(const DRWSubdivCache *subdiv_cache, data->sync_selection = (mr->toolsettings->uv_flag & UV_SYNC_SELECTION) != 0; } -static void extract_edituv_tris_iter_subdiv(const DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - void *_data, - uint subdiv_quad_index) +static void extract_edituv_tris_iter_subdiv_bm(const DRWSubdivCache *UNUSED(subdiv_cache), + const MeshRenderData *UNUSED(mr), + void *_data, + uint subdiv_quad_index, + const BMFace *coarse_quad) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); - int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; + const uint loop_idx = subdiv_quad_index * 4; + + edituv_tri_add(data, + BM_elem_flag_test(coarse_quad, BM_ELEM_HIDDEN) != 0, + BM_elem_flag_test(coarse_quad, BM_ELEM_SELECT) != 0, + loop_idx, + loop_idx + 1, + loop_idx + 2); + edituv_tri_add(data, + BM_elem_flag_test(coarse_quad, BM_ELEM_HIDDEN) != 0, + BM_elem_flag_test(coarse_quad, BM_ELEM_SELECT) != 0, + loop_idx, + loop_idx + 2, + loop_idx + 3); +} + +static void extract_edituv_tris_iter_subdiv_mesh(const DRWSubdivCache *UNUSED(subdiv_cache), + const MeshRenderData *UNUSED(mr), + void *_data, + uint subdiv_quad_index, + const MPoly *coarse_quad) +{ + MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); const uint loop_idx = subdiv_quad_index * 4; - const int poly_origindex = subdiv_loop_poly_index[loop_idx]; - BMFace *efa = bm_original_face_get(mr, poly_origindex); edituv_tri_add(data, - BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, - BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, + (coarse_quad->flag & ME_HIDE) != 0, + (coarse_quad->flag & ME_FACE_SEL) != 0, loop_idx, loop_idx + 1, loop_idx + 2); edituv_tri_add(data, - BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, - BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, + (coarse_quad->flag & ME_HIDE) != 0, + (coarse_quad->flag & ME_FACE_SEL) != 0, loop_idx, loop_idx + 2, loop_idx + 3); @@ -156,7 +177,8 @@ constexpr MeshExtract create_extractor_edituv_tris() extractor.iter_looptri_mesh = extract_edituv_tris_iter_looptri_mesh; extractor.finish = extract_edituv_tris_finish; extractor.init_subdiv = extract_edituv_tris_init_subdiv; - extractor.iter_subdiv = extract_edituv_tris_iter_subdiv; + extractor.iter_subdiv_bm = extract_edituv_tris_iter_subdiv_bm; + extractor.iter_subdiv_mesh = extract_edituv_tris_iter_subdiv_mesh; extractor.finish_subdiv = extract_edituv_tris_finish_subdiv; extractor.data_type = MR_DATA_NONE; extractor.data_size = sizeof(MeshExtract_EditUvElem_Data); @@ -253,28 +275,49 @@ static void extract_edituv_lines_init_subdiv(const DRWSubdivCache *subdiv_cache, data->sync_selection = (mr->toolsettings->uv_flag & UV_SYNC_SELECTION) != 0; } -static void extract_edituv_lines_iter_subdiv(const DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - void *_data, - uint subdiv_quad_index) +static void extract_edituv_lines_iter_subdiv_bm(const DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *_data, + uint subdiv_quad_index, + const BMFace *coarse_poly) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); - int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index); uint start_loop_idx = subdiv_quad_index * 4; uint end_loop_idx = (subdiv_quad_index + 1) * 4; + for (uint loop_idx = start_loop_idx; loop_idx < end_loop_idx; loop_idx++) { + const int edge_origindex = subdiv_loop_edge_index[loop_idx]; + const bool real_edge = (edge_origindex != -1 && + (mr->e_origindex == nullptr || + mr->e_origindex[edge_origindex] != ORIGINDEX_NONE)); + edituv_edge_add(data, + BM_elem_flag_test_bool(coarse_poly, BM_ELEM_HIDDEN) != 0 || !real_edge, + BM_elem_flag_test_bool(coarse_poly, BM_ELEM_SELECT) != 0, + loop_idx, + (loop_idx + 1 == end_loop_idx) ? start_loop_idx : (loop_idx + 1)); + } +} - const int poly_origindex = subdiv_loop_poly_index[start_loop_idx]; - BMFace *efa = bm_original_face_get(mr, poly_origindex); +static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *_data, + uint subdiv_quad_index, + const MPoly *coarse_poly) +{ + MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); + int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index); + uint start_loop_idx = subdiv_quad_index * 4; + uint end_loop_idx = (subdiv_quad_index + 1) * 4; for (uint loop_idx = start_loop_idx; loop_idx < end_loop_idx; loop_idx++) { const int edge_origindex = subdiv_loop_edge_index[loop_idx]; const bool real_edge = (edge_origindex != -1 && - mr->e_origindex[edge_origindex] != ORIGINDEX_NONE); + (mr->e_origindex == nullptr || + mr->e_origindex[edge_origindex] != ORIGINDEX_NONE)); edituv_edge_add(data, - BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) != 0 || !real_edge, - BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) != 0, + (coarse_poly->flag & ME_HIDE) != 0 || !real_edge, + (coarse_poly->flag & ME_FACE_SEL) != 0, loop_idx, (loop_idx + 1 == end_loop_idx) ? start_loop_idx : (loop_idx + 1)); } @@ -299,7 +342,8 @@ constexpr MeshExtract create_extractor_edituv_lines() extractor.iter_poly_mesh = extract_edituv_lines_iter_poly_mesh; extractor.finish = extract_edituv_lines_finish; extractor.init_subdiv = extract_edituv_lines_init_subdiv; - extractor.iter_subdiv = extract_edituv_lines_iter_subdiv; + extractor.iter_subdiv_bm = extract_edituv_lines_iter_subdiv_bm; + extractor.iter_subdiv_mesh = extract_edituv_lines_iter_subdiv_mesh; extractor.finish_subdiv = extract_edituv_lines_finish_subdiv; extractor.data_type = MR_DATA_NONE; extractor.data_size = sizeof(MeshExtract_EditUvElem_Data); @@ -390,28 +434,48 @@ static void extract_edituv_points_init_subdiv(const DRWSubdivCache *subdiv_cache data->sync_selection = (mr->toolsettings->uv_flag & UV_SYNC_SELECTION) != 0; } -static void extract_edituv_points_iter_subdiv(const DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - void *_data, - uint subdiv_quad_index) +static void extract_edituv_points_iter_subdiv_bm(const DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *_data, + uint subdiv_quad_index, + const BMFace *coarse_quad) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index); - int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; uint start_loop_idx = subdiv_quad_index * 4; uint end_loop_idx = (subdiv_quad_index + 1) * 4; for (uint i = start_loop_idx; i < end_loop_idx; i++) { const int vert_origindex = subdiv_loop_vert_index[i]; - const int poly_origindex = subdiv_loop_poly_index[i]; - BMFace *efa = bm_original_face_get(mr, poly_origindex); + const bool real_vert = (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && + vert_origindex != -1 && + mr->v_origindex[vert_origindex] != ORIGINDEX_NONE); + edituv_point_add(data, + (BM_elem_flag_test(coarse_quad, BM_ELEM_HIDDEN)) || !real_vert, + BM_elem_flag_test(coarse_quad, BM_ELEM_SELECT) != 0, + i); + } +} +static void extract_edituv_points_iter_subdiv_mesh(const DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *_data, + uint subdiv_quad_index, + const MPoly *coarse_quad) +{ + MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); + int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index); + + uint start_loop_idx = subdiv_quad_index * 4; + uint end_loop_idx = (subdiv_quad_index + 1) * 4; + for (uint i = start_loop_idx; i < end_loop_idx; i++) { + const int vert_origindex = subdiv_loop_vert_index[i]; const bool real_vert = (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && vert_origindex != -1 && mr->v_origindex[vert_origindex] != ORIGINDEX_NONE); edituv_point_add(data, - (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || !real_vert, - BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, + ((coarse_quad->flag & ME_HIDE) != 0) || !real_vert, + (coarse_quad->flag & ME_FACE_SEL) != 0, i); } } @@ -435,7 +499,8 @@ constexpr MeshExtract create_extractor_edituv_points() extractor.iter_poly_mesh = extract_edituv_points_iter_poly_mesh; extractor.finish = extract_edituv_points_finish; extractor.init_subdiv = extract_edituv_points_init_subdiv; - extractor.iter_subdiv = extract_edituv_points_iter_subdiv; + extractor.iter_subdiv_bm = extract_edituv_points_iter_subdiv_bm; + extractor.iter_subdiv_mesh = extract_edituv_points_iter_subdiv_mesh; extractor.finish_subdiv = extract_edituv_points_finish_subdiv; extractor.data_type = MR_DATA_NONE; extractor.data_size = sizeof(MeshExtract_EditUvElem_Data); |