From bfc4e77f16efbd829b89fa281001771739107dd4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 21:34:50 +0100 Subject: [PATCH] Windscreen bugs: counted from none once the rain or the snow stops, none in winter [skip ci] The insects were counted all the time the vehicle drove, so a glass turning to mat_bugs_windscreen after snow or rain (or after winter) showed at once all it had met meanwhile. Now the count stays at none in winter and while it rains or snows (the rain or the snow washes them off), and what the blades left of them before is forgotten. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD --- rendering/opengl46/opengl46renderer.cpp | 15 +++++++++++++-- rendering/vulkan14/vulkan14frame.cpp | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index 504462a03..7fe24f7bb 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -1657,8 +1657,19 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode) m_wiperbugs = 0.0; } // the insects the vehicle meets (mat_bugs_windscreen): none below 20 km/h, above it the more the faster, counted in seconds of - // driving at 100 km/h - if (owner != nullptr) + // driving at 100 km/h. none in winter, and the rain or the snow washes them off: once it stops (and out of winter) the glass + // gets them anew from none, and what the blades left of them before is forgotten + auto const insects{(Global.Season != "winter:") && (Global.Weather != "rain:") && (Global.Weather != "snow:")}; + if (false == insects) + { + if (m_wiperbugs > 0.0) + { + scene_ubs.wiper_bugs_out = glm::vec4{-1.}; + scene_ubs.wiper_bugs_return = glm::vec4{-1.}; + } + m_wiperbugs = 0.0; + } + else if (owner != nullptr) m_wiperbugs += Timer::GetDeltaTime() * std::max(std::abs(owner->MoverParameters->V) * 3.6 - 20.0, 0.0) / 80.0; scene_ubs.rain_wind.w = static_cast(m_wiperbugs); // the rain the glass meets (mat_rain_windscreen): counted in seconds of the heaviest rain standing still, more at speed (the diff --git a/rendering/vulkan14/vulkan14frame.cpp b/rendering/vulkan14/vulkan14frame.cpp index 14be5ab8a..bb54f97d0 100644 --- a/rendering/vulkan14/vulkan14frame.cpp +++ b/rendering/vulkan14/vulkan14frame.cpp @@ -1512,8 +1512,19 @@ void vulkan14_renderer::render_viewport(std::size_t const Index) m_wiperbugs = 0.0; } // the insects the vehicle meets (mat_bugs_windscreen): none below 20 km/h, above it the more the faster, counted in seconds of - // driving at 100 km/h - if (owner != nullptr) + // driving at 100 km/h. none in winter, and the rain or the snow washes them off: once it stops (and out of winter) the glass + // gets them anew from none, and what the blades left of them before is forgotten + auto const insects{(Global.Season != "winter:") && (Global.Weather != "rain:") && (Global.Weather != "snow:")}; + if (false == insects) + { + if (m_wiperbugs > 0.0) + { + scene_ubs.wiper_bugs_out = glm::vec4{-1.}; + scene_ubs.wiper_bugs_return = glm::vec4{-1.}; + } + m_wiperbugs = 0.0; + } + else if (owner != nullptr) m_wiperbugs += Timer::GetDeltaTime() * std::max(std::abs(owner->MoverParameters->V) * 3.6 - 20.0, 0.0) / 80.0; scene_ubs.rain_wind.w = static_cast(m_wiperbugs); // the rain the glass meets (mat_rain_windscreen): counted in seconds of the heaviest rain standing still, more at speed (the