From 5ea93cdd7bac2426477b007645cb44103ac20940 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 30 Mar 2022 10:45:01 +0200 Subject: [PATCH] Prevent crash in DashboardItemInstruments when using dates before 2000 (closes #1878). Remove the padding images from New Horizons that screw up the instruments timing --- .../scene/solarsystem/missions/newhorizons/pluto.asset | 2 +- .../dashboard/dashboarditeminstruments.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index 234234b79c..b6456a2a5a 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -27,7 +27,7 @@ local images = asset.syncedResource({ Name = "Pluto Images", Type = "HttpSynchronization", Identifier = "newhorizons_plutoencounter_pluto_images", - Version = 1 + Version = 2 }) local plutoRadius = 1.173E6 diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 87f549dd7b..f9f27d4931 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -131,8 +131,9 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) { double previous = sequencer.prevCaptureTime(currentTime); double next = sequencer.nextCaptureTime(currentTime); - double remaining = sequencer.nextCaptureTime(currentTime) - currentTime; - const float t = static_cast(1.0 - remaining / (next - previous)); + double remaining = next - currentTime; + float t = static_cast(1.0 - remaining / (next - previous)); + t = std::clamp(t, 0.f, 1.f); if (remaining > 0.0) { RenderFont(