diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-16 10:40:38 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-16 10:40:38 +0300 |
commit | bc66cd9868746ce92dd6de004a8b8e6a0188defe (patch) | |
tree | 709174bdf08407a7c06d9fd4c10b3523ab3487b0 /source/blender/draw/intern/draw_cache_extract_mesh.cc | |
parent | 3574f2730d2a42cda2881d26209b8dc53b1d2047 (diff) |
Fix T94865: GPU subdiv crash switching to texpaint area
The crash is due to the fact that GPU subdivision extraction routines
for edit data (including UVs) only worked for BMesh. However, a Mesh
based version is still needed for texture painting. This adds the
missing components. This also ensures all data are properly initialized
(at least the ones revealed by the bug).
Diffstat (limited to 'source/blender/draw/intern/draw_cache_extract_mesh.cc')
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 117ce2a2817..fe55778527b 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -848,6 +848,7 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, } MeshRenderData mr; + memset(&mr, 0, sizeof(MeshRenderData)); draw_subdiv_init_mesh_render_data(subdiv_cache, &mr, ts); mesh_render_data_update_loose_geom(&mr, mbc, MR_ITER_LEDGE | MR_ITER_LVERT, MR_DATA_LOOSE_GEOM); @@ -860,9 +861,25 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, extractor->init_subdiv(subdiv_cache, &mr, cache, buffer, data); - if (extractor->iter_subdiv) { - for (uint i = 0; i < subdiv_cache->num_subdiv_quads; i++) { - extractor->iter_subdiv(subdiv_cache, &mr, data, i); + if (extractor->iter_subdiv_mesh || extractor->iter_subdiv_bm) { + int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; + if (subdiv_cache->bm) { + for (uint i = 0; i < subdiv_cache->num_subdiv_quads; i++) { + /* Multiply by 4 to have the start index of the quad's loop, as subdiv_loop_poly_index is + * based on the subdivision loops. */ + const int poly_origindex = subdiv_loop_poly_index[i * 4]; + const BMFace *efa = bm_original_face_get(&mr, poly_origindex); + extractor->iter_subdiv_bm(subdiv_cache, &mr, data, i, efa); + } + } + else { + for (uint i = 0; i < subdiv_cache->num_subdiv_quads; i++) { + /* Multiply by 4 to have the start index of the quad's loop, as subdiv_loop_poly_index is + * based on the subdivision loops. */ + const int poly_origindex = subdiv_loop_poly_index[i * 4]; + const MPoly *mp = &mr.mpoly[poly_origindex]; + extractor->iter_subdiv_mesh(subdiv_cache, &mr, data, i, mp); + } } } |