diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-25 15:31:06 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-05-25 15:31:06 +0300 |
commit | 98b66dc040263966f76a92c46e7f7a9a3147936c (patch) | |
tree | d0736acea0d832fa259188401d727bc06e83d177 /source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc | |
parent | cb3b9358bfb482c1968bdd6d3e5d84101c4ecb77 (diff) |
Fix T96080: hiding elements does not work with GPU subdiv
Faces, edges, and vertices are still shown when GPU subdivision is
actived. This is because the related edit mode flags were ignored by the
subdivision code.
The flags are now passed to the various compute shaders mostly as part of
the extra coarse data, also used for e.g. selection. For loose edges, a
temporary buffer is created when extracting them. Loose vertices are
already taken into account as it reuses the routines for coarse mesh
extraction, although `MeshRenderData.use_hide` was not initialized,
which is fixed now.
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 | 27 |
1 files changed, 25 insertions, 2 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 ce3ca428469..3cecaf81b8a 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 @@ -160,7 +160,7 @@ static void extract_lines_init_subdiv(const DRWSubdivCache *subdiv_cache, } static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, - const MeshRenderData *UNUSED(mr), + const MeshRenderData *mr, void *buffer, void *UNUSED(data)) { @@ -169,8 +169,31 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, return; } + /* Update flags for loose edges, points are already handled. */ + static GPUVertFormat format; + if (format.attr_len == 0) { + GPU_vertformat_attr_add(&format, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); + } + + GPUVertBuf *flags = GPU_vertbuf_calloc(); + GPU_vertbuf_init_with_format(flags, &format); + + Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache); + GPU_vertbuf_data_alloc(flags, loose_edges.size()); + + uint *flags_data = static_cast<uint *>(GPU_vertbuf_get_data(flags)); + + const MEdge *medge = mr->medge; + + for (DRWSubdivLooseEdge edge : loose_edges) { + *flags_data++ = (medge[edge.coarse_edge_index].flag & ME_HIDE) != 0; + } + GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); - draw_subdiv_build_lines_loose_buffer(subdiv_cache, ibo, static_cast<uint>(loose_geom.edge_len)); + draw_subdiv_build_lines_loose_buffer( + subdiv_cache, ibo, flags, static_cast<uint>(loose_geom.edge_len)); + + GPU_vertbuf_discard(flags); } constexpr MeshExtract create_extractor_lines() |