Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-03-02 17:10:26 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-03-02 17:19:55 +0300
commit6883c47bb5930be5a95d1c2e8e06fce2d3b68681 (patch)
tree9c5fc32c03e6994a33827f2e7eaaa6d857f5554d /source/blender/draw/intern/draw_cache_extract_mesh.cc
parent4a95c3466fafcd3e9116cd0d7fdcc63f2dc38bd2 (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/draw_cache_extract_mesh.cc')
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index 8b4962f24b0..fb791916b46 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -822,7 +822,27 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache,
extractors.append(&extract_fdots_pos);
}
- EXTRACT_ADD_REQUESTED(ibo, lines);
+ if (DRW_ibo_requested(mbuflist->ibo.lines_loose)) {
+ /* `ibo.lines_loose` require the `ibo.lines` buffer. */
+ if (mbuflist->ibo.lines == nullptr) {
+ DRW_ibo_request(nullptr, &mbuflist->ibo.lines);
+ }
+ const MeshExtract *extractor = DRW_ibo_requested(mbuflist->ibo.lines) ?
+ &extract_lines_with_lines_loose :
+ &extract_lines_loose_only;
+ extractors.append(extractor);
+ }
+ else if (DRW_ibo_requested(mbuflist->ibo.lines)) {
+ const MeshExtract *extractor;
+ if (mbuflist->ibo.lines_loose != nullptr) {
+ /* Update `ibo.lines_loose` as it depends on `ibo.lines`. */
+ extractor = &extract_lines_with_lines_loose;
+ }
+ else {
+ extractor = &extract_lines;
+ }
+ extractors.append(extractor);
+ }
EXTRACT_ADD_REQUESTED(ibo, edituv_points);
EXTRACT_ADD_REQUESTED(ibo, edituv_tris);
EXTRACT_ADD_REQUESTED(ibo, edituv_lines);
@@ -851,6 +871,7 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache,
mesh_render_data_update_looptris(mr, MR_ITER_LOOPTRI, MR_DATA_LOOPTRI);
mesh_render_data_update_loose_geom(mr, mbc, MR_ITER_LEDGE | MR_ITER_LVERT, MR_DATA_LOOSE_GEOM);
+ DRW_subdivide_loose_geom(subdiv_cache, mbc);
void *data_stack = MEM_mallocN(extractors.data_size_total(), __func__);
uint32_t data_offset = 0;
@@ -884,7 +905,7 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache,
}
if (extractor->iter_loose_geom_subdiv) {
- extractor->iter_loose_geom_subdiv(subdiv_cache, mr, &mbc->loose_geom, buffer, data);
+ extractor->iter_loose_geom_subdiv(subdiv_cache, mr, buffer, data);
}
if (extractor->finish_subdiv) {