diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-23 17:38:37 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-23 18:45:07 +0300 |
commit | 12becbf0dffe06b6f28c4cc444fe0312cf9249b9 (patch) | |
tree | fb7b54e30e9144021ba0714e0c2dd78eb8f5e928 /source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc | |
parent | e345686cb7f4a8ccdc10e85d4f05cded45850cf7 (diff) |
Mesh: Move selection flags to generic attributes
Using the attribute name semantics from T97452, this patch moves the
selection status of mesh elements from the `SELECT` of vertices, and
edges, and the `ME_FACE_SEL` of faces to generic boolean attribute
Storing this data as generic attributes can significantly simplify and
improve code, as described in T95965.
The attributes are called `.select_vert`, `.select_edge`, and
`.select_poly`. The `.` prefix means they are "UI attributes",so they
still contain original data edited by users, but they aren't meant to
be accessed procedurally by the user in arbitrary situations. They are
also be hidden in the spreadsheet and the attribute list.
Until 4.0, the attributes are still written to and read from the mesh
in the old way, so neither forward nor backward compatibility are
affected. This means memory requirements will be increased by one byte
per element when selection is used. When the flags are removed
completely, requirements will decrease.
Further notes:
* The `MVert` flag is empty at runtime now, so it can be ignored.
* `BMesh` is unchanged, otherwise the change would be much larger.
* Many tests have slightly different results, since the selection
attribute uses more generic propagation. Previously you couldn't
really rely on edit mode selections being propagated procedurally.
Now it mostly works as expected.
Similar to 2480b55f216c
Ref T95965
Differential Revision: https://developer.blender.org/D15795
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 | 10 |
1 files changed, 5 insertions, 5 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 2f2e59c8c3b..bf8dd1a51f8 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 @@ -220,7 +220,7 @@ static void extract_edituv_lines_iter_poly_mesh(const MeshRenderData *mr, } else { mp_hidden = (mr->hide_poly) ? mr->hide_poly[mp_index] : false; - mp_select = (mp->flag & ME_FACE_SEL) != 0; + mp_select = mr->select_poly && mr->select_poly[mp_index]; } for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) { @@ -291,16 +291,16 @@ static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_c { 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); - + const int coarse_poly_index = coarse_poly - mr->mpoly; bool mp_hidden, mp_select; if (mr->bm) { - const BMFace *efa = bm_original_face_get(mr, coarse_poly - mr->mpoly); + const BMFace *efa = bm_original_face_get(mr, coarse_poly_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 = (mr->hide_poly) ? mr->hide_poly[coarse_poly - mr->mpoly] : false; - mp_select = (coarse_poly->flag & ME_FACE_SEL) != 0; + mp_hidden = (mr->hide_poly) ? mr->hide_poly[coarse_poly_index] : false; + mp_select = mr->select_poly && mr->select_poly[coarse_poly_index]; } uint start_loop_idx = subdiv_quad_index * 4; |