Fix T81268: Crash when undo from Sculpt Mode to Edit Mode

This was introduced in 6c9ec1c893. The overlays can now be drawn when
PBVH drawing is not enabled, but the PBVH should still exist in the
SculptSession in order to draw them. Before, it was avoiding the crash
by checking use_pbvh as BKE_sculptsession_use_pbvh_draw also checks if
the PBVH exists.

Reviewed By: sergey

Maniphest Tasks: T81268

Differential Revision: https://developer.blender.org/D9044
This commit is contained in:
Pablo Dobarro 2020-10-01 19:18:12 +02:00
parent 8fbb6aa4ec
commit e41437b16e
Notes: blender-bot 2023-02-14 02:13:08 +01:00
Referenced by issue #81268, Crash on Undo from Sculpt mode to Edit mode
1 changed files with 20 additions and 9 deletions

View File

@ -54,15 +54,26 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
const bool use_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d);
if (pbvh_has_mask(pbvh) || pbvh_has_face_sets(pbvh)) {
if (use_pbvh) {
DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
}
else {
sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(ob->data);
if (sculpt_overlays) {
DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob);
}
if (!pbvh) {
/* It is possible to have SculptSession without PBVH. This happens, for example, when toggling
* object mode to sculpt then to edit mode. */
return;
}
if (!pbvh_has_mask(pbvh) && !pbvh_has_face_sets(pbvh)) {
/* The SculptSession and the PBVH can be created without a Mask datalayer or Face Set
* datalayer. (masks datalayers are created after using a mask tool), so in these cases there
* is nothing to draw. */
return;
}
if (use_pbvh) {
DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
}
else {
sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(ob->data);
if (sculpt_overlays) {
DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob);
}
}
}