From 2a19139eee82d849a14dd7fbd054139a46bf20e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Bj=C3=B8rn=20Greve?= Date: Sat, 24 Feb 2024 13:15:19 +0800 Subject: [PATCH] Don't rerender shadows when only the directional light color changes. --- SourceFiles/MapRenderer.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SourceFiles/MapRenderer.h b/SourceFiles/MapRenderer.h index f3c9742..977866f 100644 --- a/SourceFiles/MapRenderer.h +++ b/SourceFiles/MapRenderer.h @@ -224,10 +224,19 @@ class MapRenderer void SetDirectionalLight(DirectionalLight new_directional_light) { - m_should_rerender_shadows = true; + // Compare the new direction with the current direction + if (m_directionalLight.direction.x != new_directional_light.direction.x || + m_directionalLight.direction.y != new_directional_light.direction.y || + m_directionalLight.direction.z != new_directional_light.direction.z) + { + m_should_rerender_shadows = true; // Set to true only if the direction has changed + } + m_directionalLight = new_directional_light; m_per_frame_cb_changed = true; } + + const DirectionalLight GetDirectionalLight() { return m_directionalLight; } void UpdateTerrainWaterLevel(float new_water_level)