| 353 | } |
| 354 | |
| 355 | float Sky::dayCycle() const { |
| 356 | // Always middle of the night in orbit or warp space. |
| 357 | if (type() == SkyType::Orbital || type() == SkyType::Warp) |
| 358 | return 3.0f; |
| 359 | |
| 360 | // This will misbehave badly if dayTransitionTime is greater than dayLength / |
| 361 | // 2 |
| 362 | |
| 363 | float transitionTime = m_settings.queryFloat("dayTransitionTime") / 2; |
| 364 | float dayLength = Sky::dayLength(); |
| 365 | float timeOfDay = Sky::timeOfDay(); |
| 366 | |
| 367 | // timeOfDay() is defined such that 0.0 is mid-dawn. For convenience, shift |
| 368 | // the time of day forwards such that 0.0 is the beginning of the morning. |
| 369 | float shiftedTime = pfmod(timeOfDay + transitionTime / 2, dayLength); |
| 370 | |
| 371 | // There are 5 times here, beginning of the morning, end of the morning, |
| 372 | // beginning of the evening, end of the evening, and then the beginning of |
| 373 | // the morning again (wrapping around). |
| 374 | Array<float, 5> transitionPositions = { |
| 375 | 0.0f, transitionTime, dayLength / 2, dayLength / 2 + transitionTime, dayLength}; |
| 376 | // The values here are mid-night, mid-day, mid-day, mid-night, mid-night. |
| 377 | Array<float, 5> transitionValues = {-1.0f, 1.0f, 1.0f, 3.0f, 3.0f}; |
| 378 | |
| 379 | return pfmod(parametricInterpolate2( |
| 380 | transitionPositions, transitionValues, shiftedTime, SinWeightOperator<float>(), BoundMode::Clamp), |
| 381 | 4.0f); |
| 382 | } |
| 383 | |
| 384 | float Sky::skyAlpha() const { |
| 385 | if (m_skyType != SkyType::Atmospheric) { |
nothing calls this directly
no test coverage detected