diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-09-29 09:33:02 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-09-29 09:33:02 +0300 |
commit | 0de9081e89f5f9cd4573062ab5e0e6442f9fa28d (patch) | |
tree | da2bf95c0716360fe3fe948d2d319a7642c97240 /source/blender/draw/intern | |
parent | bbc69563d0704a8269318d8699e7c2bf4edc91c2 (diff) |
Sculpt: fix missing nullptr check in pbvh draw
Check for nullptr when building mask vbos.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_pbvh.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 7b36cb16cac..432ebbe9452 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -533,12 +533,19 @@ struct PBVHBatches { case CD_PBVH_MASK_TYPE: { float *mask = static_cast<float *>(CustomData_get_layer(args->vdata, CD_PAINT_MASK)); - foreach_faces( - [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) { - *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = (uchar)(mask[vertex_i] * - 255.0f); - }); - + if (mask) { + foreach_faces( + [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) { + *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = (uchar)(mask[vertex_i] * + 255.0f); + }); + } + else { + foreach_faces( + [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri * /*tri*/) { + *static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = 0; + }); + } break; } case CD_PBVH_FSET_TYPE: { @@ -731,7 +738,7 @@ struct PBVHBatches { if (cd_mask == -1) { foreach_bmesh( - [&](BMLoop * /*l*/) { *static_cast<float *>(GPU_vertbuf_raw_step(&access)) = 255; }); + [&](BMLoop * /*l*/) { *static_cast<float *>(GPU_vertbuf_raw_step(&access)) = 0; }); } else { foreach_bmesh([&](BMLoop *l) { |