diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 7ba490b92..070f941d6 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -941,10 +941,10 @@ public: Moon(osg::Group* parentNode, Resource::ImageManager& imageManager, float scaleFactor, Type type) : CelestialBody(parentNode, scaleFactor, 2) , mType(type) - , mPhase(MoonState::Phase_Unspecified) + , mPhase(MoonState::Phase::Unspecified) , mUpdater(new Updater(imageManager)) { - setPhase(MoonState::Phase_Full); + setPhase(MoonState::Phase::Full); setVisible(true); mGeom->addUpdateCallback(mUpdater); @@ -993,14 +993,14 @@ public: unsigned int getPhaseInt() const { - if (mPhase == MoonState::Phase_New) return 0; - else if (mPhase == MoonState::Phase_WaxingCrescent) return 1; - else if (mPhase == MoonState::Phase_WaningCrescent) return 1; - else if (mPhase == MoonState::Phase_FirstQuarter) return 2; - else if (mPhase == MoonState::Phase_ThirdQuarter) return 2; - else if (mPhase == MoonState::Phase_WaxingGibbous) return 3; - else if (mPhase == MoonState::Phase_WaningGibbous) return 3; - else if (mPhase == MoonState::Phase_Full) return 4; + if (mPhase == MoonState::Phase::New) return 0; + else if (mPhase == MoonState::Phase::WaxingCrescent) return 1; + else if (mPhase == MoonState::Phase::WaningCrescent) return 1; + else if (mPhase == MoonState::Phase::FirstQuarter) return 2; + else if (mPhase == MoonState::Phase::ThirdQuarter) return 2; + else if (mPhase == MoonState::Phase::WaxingGibbous) return 3; + else if (mPhase == MoonState::Phase::WaningGibbous) return 3; + else if (mPhase == MoonState::Phase::Full) return 4; return 0; } @@ -1090,14 +1090,14 @@ private: else textureName += "masser_"; - if (phase == MoonState::Phase_New) textureName += "new"; - else if(phase == MoonState::Phase_WaxingCrescent) textureName += "one_wax"; - else if(phase == MoonState::Phase_FirstQuarter) textureName += "half_wax"; - else if(phase == MoonState::Phase_WaxingGibbous) textureName += "three_wax"; - else if(phase == MoonState::Phase_WaningCrescent) textureName += "one_wan"; - else if(phase == MoonState::Phase_ThirdQuarter) textureName += "half_wan"; - else if(phase == MoonState::Phase_WaningGibbous) textureName += "three_wan"; - else if(phase == MoonState::Phase_Full) textureName += "full"; + if (phase == MoonState::Phase::New) textureName += "new"; + else if(phase == MoonState::Phase::WaxingCrescent) textureName += "one_wax"; + else if(phase == MoonState::Phase::FirstQuarter) textureName += "half_wax"; + else if(phase == MoonState::Phase::WaxingGibbous) textureName += "three_wax"; + else if(phase == MoonState::Phase::WaningCrescent) textureName += "one_wan"; + else if(phase == MoonState::Phase::ThirdQuarter) textureName += "half_wan"; + else if(phase == MoonState::Phase::WaningGibbous) textureName += "three_wan"; + else if(phase == MoonState::Phase::Full) textureName += "full"; textureName += ".dds"; diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 9727529d9..cf697bd44 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -99,17 +99,17 @@ namespace MWRender struct MoonState { - enum Phase + enum class Phase { - Phase_Full = 0, - Phase_WaningGibbous, - Phase_ThirdQuarter, - Phase_WaningCrescent, - Phase_New, - Phase_WaxingCrescent, - Phase_FirstQuarter, - Phase_WaxingGibbous, - Phase_Unspecified + Full = 0, + WaningGibbous, + ThirdQuarter, + WaningCrescent, + New, + WaxingCrescent, + FirstQuarter, + WaxingGibbous, + Unspecified }; float mRotationFromHorizon; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 2f054488b..6a4a227a4 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -370,7 +370,7 @@ MWRender::MoonState MoonModel::calculateState(const TimeStamp& gameTime) const { rotationFromHorizon, mAxisOffset, // Reverse engineered from Morrowind's scene graph rotation matrices. - static_cast(phase(gameTime)), + phase(gameTime), shadowBlend(rotationFromHorizon), earlyMoonShadowAlpha(rotationFromHorizon) * hourlyAlpha(gameTime.getHour()) }; @@ -439,17 +439,15 @@ inline float MoonModel::rotation(float hours) const return 15.0f * mSpeed * hours; } -inline unsigned int MoonModel::phase(const TimeStamp& gameTime) const +MWRender::MoonState::Phase MoonModel::phase(const TimeStamp& gameTime) const { // Morrowind starts with a full moon on 16 Last Seed and then begins to wane 17 Last Seed, working on 3 day phase cycle. - // Note: this is an internal helper, and as such we don't want to return MWRender::MoonState::Phase since we can't - // forward declare it (C++11 strongly typed enums solve this). // If the moon didn't rise yet today, use yesterday's moon phase. if(gameTime.getHour() < moonRiseHour(gameTime.getDay())) - return (gameTime.getDay() / 3) % 8; + return static_cast((gameTime.getDay() / 3) % 8); else - return ((gameTime.getDay() + 1) / 3) % 8; + return static_cast(((gameTime.getDay() + 1) / 3) % 8); } inline float MoonModel::shadowBlend(float angle) const diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 696f7c688..92f2ce6a4 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -24,6 +24,7 @@ namespace ESM namespace MWRender { class RenderingManager; + enum class MoonState::Phase; } namespace Loading @@ -261,7 +262,7 @@ namespace MWWorld float angle(const TimeStamp& gameTime) const; float moonRiseHour(unsigned int daysPassed) const; float rotation(float hours) const; - unsigned int phase(const TimeStamp& gameTime) const; + MWRender::MoonState::Phase phase(const TimeStamp& gameTime) const; float shadowBlend(float angle) const; float hourlyAlpha(float gameHour) const; float earlyMoonShadowAlpha(float angle) const;