diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-08-16 18:34:40 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-08-16 19:09:27 +0300 |
commit | b247588dc0f48f2fb713f6571ef0129a38760b00 (patch) | |
tree | 68fff9518b93ee3fdc5d99b23ba7d04a351ac98e /source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc | |
parent | 74d716ce23a64ed23b85e9c7a98f153f33dac952 (diff) |
Cleanup: some refactoring in mapped mesh extraction
* Flip the logic to first detect if we are dealing with an unmodified mesh
in editmode. And then if not, detect if we need a mapping or not.
* runtime.is_original is only valid for the bmesh wrapper. Rename it to clarify
that and only check it when the mesh is a bmesh wrapper.
* Remove MR_EXTRACT_MAPPED and instead check only for the existence of the
origindex arrays. Previously it would sometimes access those arrays without
MR_EXTRACT_MAPPED set, which according to a comment means they are invalid.
Differential Revision: https://developer.blender.org/D15676
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc index 6d989c3fe03..9c564c2cdda 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc @@ -58,14 +58,13 @@ static void extract_lines_iter_poly_mesh(const MeshRenderData *mr, GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); /* Using poly & loop iterator would complicate accessing the adjacent loop. */ const MLoop *mloop = mr->mloop; - if (mr->use_hide || (mr->extract_type == MR_EXTRACT_MAPPED) || (mr->e_origindex != nullptr)) { + if (mr->use_hide || (mr->e_origindex != nullptr)) { const int ml_index_last = mp->loopstart + (mp->totloop - 1); int ml_index = ml_index_last, ml_index_next = mp->loopstart; do { const MLoop *ml = &mloop[ml_index]; if (!((mr->use_hide && mr->hide_edge && mr->hide_edge[ml->e]) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->e_origindex) && - (mr->e_origindex[ml->e] == ORIGINDEX_NONE)))) { + ((mr->e_origindex) && (mr->e_origindex[ml->e] == ORIGINDEX_NONE)))) { GPU_indexbuf_set_line_verts(elb, ml->e, ml_index, ml_index_next); } else { @@ -110,8 +109,7 @@ static void extract_lines_iter_ledge_mesh(const MeshRenderData *mr, const int l_index_offset = mr->edge_len + ledge_index; const int e_index = mr->ledges[ledge_index]; if (!((mr->use_hide && mr->hide_edge && mr->hide_edge[med - mr->medge]) || - ((mr->extract_type == MR_EXTRACT_MAPPED) && (mr->e_origindex) && - (mr->e_origindex[e_index] == ORIGINDEX_NONE)))) { + ((mr->e_origindex) && (mr->e_origindex[e_index] == ORIGINDEX_NONE)))) { const int l_index = mr->loop_len + ledge_index * 2; GPU_indexbuf_set_line_verts(elb, l_index_offset, l_index, l_index + 1); } @@ -183,40 +181,41 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, switch (mr->extract_type) { case MR_EXTRACT_MESH: { - const bool *hide_edge = mr->hide_edge; - if (hide_edge) { - for (DRWSubdivLooseEdge edge : loose_edges) { - *flags_data++ = hide_edge[edge.coarse_edge_index]; + if (mr->e_origindex == nullptr) { + const bool *hide_edge = mr->hide_edge; + if (hide_edge) { + for (DRWSubdivLooseEdge edge : loose_edges) { + *flags_data++ = hide_edge[edge.coarse_edge_index]; + } } - } - else { - MutableSpan<uint>(flags_data, loose_edges.size()).fill(0); - } - break; - } - case MR_EXTRACT_MAPPED: { - if (mr->bm) { - for (DRWSubdivLooseEdge edge : loose_edges) { - const BMEdge *bm_edge = bm_original_edge_get(mr, edge.coarse_edge_index); - *flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0; + else { + MutableSpan<uint>(flags_data, loose_edges.size()).fill(0); } } else { - const bool *hide_edge = mr->hide_edge; - if (hide_edge) { + if (mr->bm) { for (DRWSubdivLooseEdge edge : loose_edges) { - int e = edge.coarse_edge_index; - - if (mr->e_origindex && mr->e_origindex[e] != ORIGINDEX_NONE) { - *flags_data++ = hide_edge[edge.coarse_edge_index]; - } - else { - *flags_data++ = false; - } + const BMEdge *bm_edge = bm_original_edge_get(mr, edge.coarse_edge_index); + *flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0; } } else { - MutableSpan<uint>(flags_data, loose_edges.size()).fill(0); + const bool *hide_edge = mr->hide_edge; + if (hide_edge) { + for (DRWSubdivLooseEdge edge : loose_edges) { + int e = edge.coarse_edge_index; + + if (mr->e_origindex && mr->e_origindex[e] != ORIGINDEX_NONE) { + *flags_data++ = hide_edge[edge.coarse_edge_index]; + } + else { + *flags_data++ = false; + } + } + } + else { + MutableSpan<uint>(flags_data, loose_edges.size()).fill(0); + } } } break; |