From 92df5ba10ff52f2ef8a5a0d5add9e787ffe1decc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 10 Mar 2025 13:34:34 +0100 Subject: [PATCH] Fix #135650: Workbench: Missing update changing shading pop-over settings This was previously taken care of by the `view_update` callback. Nowadays, the best way is to manually check for changes inside the engine. --- .../draw/engines/workbench/workbench_state.cc | 72 ++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/workbench/workbench_state.cc b/source/blender/draw/engines/workbench/workbench_state.cc index 759eb855a10..ee9104dec94 100644 --- a/source/blender/draw/engines/workbench/workbench_state.cc +++ b/source/blender/draw/engines/workbench/workbench_state.cc @@ -24,6 +24,73 @@ namespace blender::workbench { +/* Used for update detection on the render settings. */ +static bool operator!=(const View3DShading &a, const View3DShading &b) +{ + /* Only checks the properties that are actually used by workbench. */ + if (a.type != b.type) { + return true; + } + if (a.color_type != b.color_type) { + return true; + } + if (a.flag != b.flag) { + return true; + } + if (a.light != b.light) { + return true; + } + if (a.background_type != b.background_type) { + return true; + } + if (a.cavity_type != b.cavity_type) { + return true; + } + if (a.wire_color_type != b.wire_color_type) { + return true; + } + if (StringRefNull(a.studio_light) != StringRefNull(b.studio_light)) { + return true; + } + if (StringRefNull(a.matcap) != StringRefNull(b.matcap)) { + return true; + } + if (a.shadow_intensity != b.shadow_intensity) { + return true; + } + if (float3(a.single_color) != float3(b.single_color)) { + return true; + } + if (a.studiolight_rot_z != b.studiolight_rot_z) { + return true; + } + if (float3(a.object_outline_color) != float3(b.object_outline_color)) { + return true; + } + if (a.xray_alpha != b.xray_alpha) { + return true; + } + if (a.xray_alpha_wire != b.xray_alpha_wire) { + return true; + } + if (a.cavity_valley_factor != b.cavity_valley_factor) { + return true; + } + if (a.cavity_ridge_factor != b.cavity_ridge_factor) { + return true; + } + if (float3(a.background_color) != float3(b.background_color)) { + return true; + } + if (a.curvature_ridge_factor != b.curvature_ridge_factor) { + return true; + } + if (a.curvature_valley_factor != b.curvature_valley_factor) { + return true; + } + return false; +} + void SceneState::init(bool scene_updated, Object *camera_ob /*=nullptr*/) { bool reset_taa = reset_taa_next_sample || scene_updated; @@ -95,9 +162,8 @@ void SceneState::init(bool scene_updated, Object *camera_ob /*=nullptr*/) /* Disable shading options that aren't supported in transparency mode. */ shading.flag &= ~(V3D_SHADING_SHADOW | V3D_SHADING_CAVITY | V3D_SHADING_DEPTH_OF_FIELD); } - if (SHADING_XRAY_ENABLED(shading) != SHADING_XRAY_ENABLED(previous_shading) || - shading.flag != previous_shading.flag) - { + + if (shading != previous_shading) { reset_taa = true; }