From 1be2888bf0210e510ca65a7b86e5350ea85ab9f1 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 28 Mar 2019 16:10:15 +0100 Subject: [PATCH] Fix T62717: Switching Shading Modes During Sculpting Switching shader modes to material or render during a sculpting session showed the model when the sculptsession was started. The user needed to click that forced an update of the sculptsession. In `sculpt_flush_update` the eevee drawing mesh is not updated when workbench engine is used. --- source/blender/makesrna/intern/rna_space.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5a9598818de..78b702dfd0b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -643,7 +643,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value ED_view3d_from_m4(mat, rv3d->ofs, rv3d->viewquat, &rv3d->dist); } -static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) { ID *id = ptr->id.data; if (GS(id->name) == ID_SCE) { @@ -661,12 +661,25 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *UNUSED(scene), Poi DEG_id_tag_update(&ma->id, ID_RECALC_SHADING); } + View3DShading *shading = (View3DShading*)ptr->data; + if (shading->type == OB_MATERIAL || + (shading->type == OB_RENDER && (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) == 0 || + strcmp(scene->r.engine, RE_engine_id_CYCLES)))) { + /* When switching from workbench to render or material mode the geometry of any + * active sculpt session needs to be recalculated. */ + for (Object *ob = bmain->objects.first; ob ; ob = ob->id.next) { + if (ob->sculpt) { + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } + } + } + bScreen *screen = ptr->id.data; for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - if (&v3d->shading == ptr->data) { + if (&v3d->shading == shading) { ED_view3d_shade_update(bmain, v3d, sa); return; }