fix: remove duplicate zone weather, consolidate RNG, name star constants

- weather: remove duplicate setZoneWeather(15) for Dustwallow Marsh —
  second call silently overwrote the first with different parameters
- weather: replace duplicate static RNG in getRandomPosition() with
  shared weatherRng() to avoid redundant generator state
- starfield: extract day/night cycle thresholds into named constants
  (kDuskStart/kNightStart/kDawnStart/kDawnEnd/kFadeDuration)
- skybox: replace while-loop time wrapping with std::fmod — avoids
  O(n) iterations on large time jumps
This commit is contained in:
Kelsi 2026-03-30 14:38:30 -07:00
parent 086f32174f
commit 74f0ba010a
3 changed files with 23 additions and 20 deletions

View file

@ -13,6 +13,14 @@
namespace wowee {
namespace rendering {
// Day/night cycle thresholds (hours, 24h clock) for star visibility.
// Stars fade in over 2 hours at dusk, stay full during night, fade out at dawn.
static constexpr float kDuskStart = 18.0f; // stars begin fading in
static constexpr float kNightStart = 20.0f; // full star visibility
static constexpr float kDawnStart = 4.0f; // stars begin fading out
static constexpr float kDawnEnd = 6.0f; // stars fully gone
static constexpr float kFadeDuration = 2.0f;
StarField::StarField() = default;
StarField::~StarField() {
@ -303,22 +311,20 @@ void StarField::destroyStarBuffers() {
}
float StarField::getStarIntensity(float timeOfDay) const {
// Full night: 20:004:00
if (timeOfDay >= 20.0f || timeOfDay < 4.0f) {
// Full night
if (timeOfDay >= kNightStart || timeOfDay < kDawnStart) {
return 1.0f;
}
// Fade in at dusk: 18:0020:00
else if (timeOfDay >= 18.0f && timeOfDay < 20.0f) {
return (timeOfDay - 18.0f) / 2.0f; // 0 → 1 over 2 hours
// Fade in at dusk
if (timeOfDay >= kDuskStart) {
return (timeOfDay - kDuskStart) / kFadeDuration;
}
// Fade out at dawn: 4:006:00
else if (timeOfDay >= 4.0f && timeOfDay < 6.0f) {
return 1.0f - (timeOfDay - 4.0f) / 2.0f; // 1 → 0 over 2 hours
// Fade out at dawn
if (timeOfDay < kDawnEnd) {
return 1.0f - (timeOfDay - kDawnStart) / kFadeDuration;
}
// Daytime: no stars
else {
return 0.0f;
}
return 0.0f;
}
} // namespace rendering