Fix T98866: GPU subdiv crash in edit mode with loose geometry

The BMesh case was missing when extracting the loose edges flags used for
display, so the code was crashing on unitialized `MEdge` pointer.
This commit is contained in:
Kévin Dietrich 2022-06-14 01:38:57 +02:00
parent 77b34a00f9
commit 67f5596f19
Notes: blender-bot 2023-02-14 07:25:46 +01:00
Referenced by issue #100906, Regression: Lag in sculpt mode when navigating around an object with modifiers
Referenced by issue #98891, Surface Deform modifier ignores shapekeys
Referenced by issue #98866, subdivion modifier crash on cage mode (EDIT MODE)
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
1 changed files with 12 additions and 4 deletions

View File

@ -183,10 +183,18 @@ static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache,
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;
if (mr->extract_type == MR_EXTRACT_MESH) {
const MEdge *medge = mr->medge;
for (DRWSubdivLooseEdge edge : loose_edges) {
*flags_data++ = (medge[edge.coarse_edge_index].flag & ME_HIDE) != 0;
}
}
else {
BMesh *bm = mr->bm;
for (DRWSubdivLooseEdge edge : loose_edges) {
const BMEdge *bm_edge = BM_edge_at_index(bm, edge.coarse_edge_index);
*flags_data++ = BM_elem_flag_test_bool(bm_edge, BM_ELEM_HIDDEN) != 0;
}
}
GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer);