mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge branch 'moonmoon' into 'master'
Change moon phase to an enum class See merge request OpenMW/openmw!381
This commit is contained in:
commit
8f68f08aee
@ -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";
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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<MWRender::MoonState::Phase>(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<MWRender::MoonState::Phase>((gameTime.getDay() / 3) % 8);
|
||||
else
|
||||
return ((gameTime.getDay() + 1) / 3) % 8;
|
||||
return static_cast<MWRender::MoonState::Phase>(((gameTime.getDay() + 1) / 3) % 8);
|
||||
}
|
||||
|
||||
inline float MoonModel::shadowBlend(float angle) const
|
||||
|
@ -261,7 +261,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user