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:
authorPablo Dobarro <pablodp606@gmail.com>2020-10-01 20:18:12 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-10-01 20:18:22 +0300
commite41437b16e6deda9fdc23ffd4baeaf912dc7052f (patch)
tree1213851104aad260bef55b4db5fa7561a480ed1d
parent8fbb6aa4ece9c65afbcd5c5e1aa8d58baaa825b3 (diff)
Fix T81268: Crash when undo from Sculpt Mode to Edit Mode
This was introduced in 6c9ec1c893f9. 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
-rw-r--r--source/blender/draw/engines/overlay/overlay_sculpt.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_sculpt.c b/source/blender/draw/engines/overlay/overlay_sculpt.c
index c6c617fd29b..a3860c9e25e 100644
--- a/source/blender/draw/engines/overlay/overlay_sculpt.c
+++ b/source/blender/draw/engines/overlay/overlay_sculpt.c
@@ -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);
}
}
}