Revent point overflow when viewing the solar system position far in the future (closes #3021)

This commit is contained in:
Alexander Bock
2024-02-10 09:05:28 +01:00
parent d67cabf578
commit 5e9af1bc13

View File

@@ -378,7 +378,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
}
// See how many points we need to drop
const int nNewPoints = static_cast<int>(floor(delta / secondsPerPoint));
const uint64_t nNewPoints = static_cast<uint64_t>(floor(delta / secondsPerPoint));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array
@@ -412,12 +412,13 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
// future
_firstPointTime += nNewPoints * secondsPerPoint;
return { false, true, nNewPoints };
return { false, true, static_cast<int>(nNewPoints) };
}
else {
// See how many new points needs to be generated. Delta is negative, so we need
// to invert the ratio
const int nNewPoints = -(static_cast<int>(floor(delta / secondsPerPoint)));
const uint64_t nNewPoints =
-(static_cast<uint64_t>(floor(delta / secondsPerPoint)));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array
@@ -453,7 +454,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
// The previously youngest point has become nNewPoints steps older
_lastPointTime -= nNewPoints * secondsPerPoint;
return { false, true, -nNewPoints };
return { false, true, static_cast<int>(-nNewPoints) };
}
}