diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-02 17:10:26 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-03-02 17:19:55 +0300 |
commit | 6883c47bb5930be5a95d1c2e8e06fce2d3b68681 (patch) | |
tree | 9c5fc32c03e6994a33827f2e7eaaa6d857f5554d /source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc | |
parent | 4a95c3466fafcd3e9116cd0d7fdcc63f2dc38bd2 (diff) |
Fix T94729: GPU subdivision does not support meshes without polygons
There are two issues revealed in the bug report:
- the GPU subdivision does not support meshes with only loose geometry
- the loose geometry is not subdivided
For the first case, checks are added to ensure we still fill the
buffers with loose geometry even if no polygons are present.
For the second case, this adds
`BKE_subdiv_mesh_interpolate_position_on_edge` which encapsulates the
loose vertex interpolation mechanism previously found in
`subdiv_mesh_vertex_of_loose_edge`.
The subdivided loose geometry is stored in a new specific data structure
`DRWSubdivLooseGeom` so as to not pollute `MeshExtractLooseGeom`. These
structures store the corresponding coarse element data, which will be
used for filling GPU buffers appropriately.
Differential Revision: https://developer.blender.org/D14171
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc index 8470a71059f..2d4e0a8e246 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc @@ -233,16 +233,17 @@ static GPUVertFormat *get_subdiv_edge_fac_format() } static void extract_edge_fac_init_subdiv(const DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, + const MeshRenderData *UNUSED(mr), struct MeshBatchCache *cache, void *buffer, void *UNUSED(data)) { + const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; GPUVertBuf *edge_idx = cache->final.buff.vbo.edge_idx; GPUVertBuf *pos_nor = cache->final.buff.vbo.pos_nor; GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buffer); GPU_vertbuf_init_build_on_device( - vbo, get_subdiv_edge_fac_format(), subdiv_cache->num_subdiv_loops + mr->loop_loose_len); + vbo, get_subdiv_edge_fac_format(), subdiv_cache->num_subdiv_loops + loose_geom.loop_len); /* Create a temporary buffer for the edge original indices if it was not requested. */ const bool has_edge_idx = edge_idx != nullptr; @@ -268,11 +269,11 @@ static void extract_edge_fac_init_subdiv(const DRWSubdivCache *subdiv_cache, static void extract_edge_fac_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *UNUSED(mr), - const MeshExtractLooseGeom *loose_geom, void *buffer, void *UNUSED(data)) { - if (loose_geom->edge_len == 0) { + const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; + if (loose_geom.edge_len == 0) { return; } @@ -282,7 +283,7 @@ static void extract_edge_fac_loose_geom_subdiv(const DRWSubdivCache *subdiv_cach GPU_vertbuf_use(vbo); uint offset = subdiv_cache->num_subdiv_loops; - for (int i = 0; i < loose_geom->edge_len; i++) { + for (int i = 0; i < loose_geom.edge_len; i++) { if (GPU_crappy_amd_driver()) { float loose_edge_fac[2] = {1.0f, 1.0f}; GPU_vertbuf_update_sub(vbo, offset * sizeof(float), sizeof(loose_edge_fac), loose_edge_fac); |