summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-01-30 16:42:34 -0800
committerRider Linden <rider@lindenlab.com>2018-01-30 16:42:34 -0800
commit0bf50e2f8cfa5f3ccd6165ce935cf0fd9c174ced (patch)
tree4a161b5eaa5150775f13869d3d32ad5ae83d5904
parentfbd8a98300277bdbc1885c25eea290560fd8c6c1 (diff)
Cleanup on daycyle selection and stack. Move blenders into environment.
(Transition bronken, instant only. Shaddows moved based on region, not parcel)
-rw-r--r--indra/llinventory/llparcel.cpp15
-rw-r--r--indra/llinventory/llparcel.h16
-rw-r--r--indra/llinventory/llsettingsbase.cpp2
-rw-r--r--indra/llinventory/llsettingsbase.h17
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp160
-rw-r--r--indra/llinventory/llsettingsdaycycle.h50
-rw-r--r--indra/llinventory/llsettingssky.cpp2
-rw-r--r--indra/newview/llenvironment.cpp845
-rw-r--r--indra/newview/llenvironment.h149
-rw-r--r--indra/newview/llfloatereditdaycycle.cpp3
-rw-r--r--indra/newview/llfloatereditextdaycycle.cpp10
-rw-r--r--indra/newview/llfloatereditsky.cpp10
-rw-r--r--indra/newview/llfloatereditwater.cpp10
-rw-r--r--indra/newview/llfloaterenvironmentsettings.cpp34
-rw-r--r--indra/newview/llfloaterland.cpp27
-rw-r--r--indra/newview/llfloaterregioninfo.cpp15
-rw-r--r--indra/newview/llviewermenu.cpp21
-rw-r--r--indra/newview/llviewerregion.cpp4
-rw-r--r--indra/newview/llviewerregion.h17
19 files changed, 696 insertions, 711 deletions
diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp
index 411c35ed6b..0908613c10 100644
--- a/indra/llinventory/llparcel.cpp
+++ b/indra/llinventory/llparcel.cpp
@@ -231,12 +231,6 @@ void LLParcel::init(const LLUUID &owner_id,
setAllowGroupAVSounds(TRUE);
setAllowAnyAVSounds(TRUE);
setHaveNewParcelLimitData(FALSE);
-
- mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH);
- mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET);
- mIsDefaultDayCycle = true;
- mDayCycle.reset();
- mDayCycleHash = 0;
}
void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned)
@@ -1273,12 +1267,3 @@ U32 LLParcel::countExperienceKeyType( U32 type )
boost::end(mExperienceKeys | boost::adaptors::map_values),
std::bind2nd(std::equal_to<U32>(), type));
}
-
-void LLParcel::clearParcelDayCycleInfo()
-{
- mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH);
- mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET);
- mIsDefaultDayCycle = true;
- mDayCycle.reset();
- mDayCycleHash = 0;
-}
diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h
index 6bbd5a949d..6ef389d246 100644
--- a/indra/llinventory/llparcel.h
+++ b/indra/llinventory/llparcel.h
@@ -590,18 +590,6 @@ public:
LLUUID getPreviousOwnerID() const { return mPreviousOwnerID; }
BOOL getPreviouslyGroupOwned() const { return mPreviouslyGroupOwned; }
BOOL getSellWithObjects() const { return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; }
-
- S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; }
- S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; }
- bool getUsesDefaultDayCycle() const { return mIsDefaultDayCycle; }
- void setUsesDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; }
- LLSettingsDay::ptr_t getParcelDayCycle() const { return mDayCycle; }
- void setParcelDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; }
- size_t getParcelDayCycleHash() const { return mDayCycleHash; }
- void setParcelDayCycleHash(size_t hash) { mDayCycleHash = hash; }
- void clearParcelDayCycleInfo();
protected:
LLUUID mID;
@@ -677,11 +665,7 @@ protected:
BOOL mAllowGroupAVSounds;
BOOL mAllowAnyAVSounds;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
bool mIsDefaultDayCycle;
- LLSettingsDay::ptr_t mDayCycle;
- size_t mDayCycleHash;
public:
// HACK, make private
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index a35504e0e6..ffeae8677f 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -592,12 +592,12 @@ void LLSettingsBlender::update(F64Seconds timedelta)
{
LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon
mOnFinished(shared_from_this());
- mOnFinished.disconnect_all_slots(); // prevent from firing more than once.
return;
}
F64 blendf = fmod(mTimeSpent.value(), mSeconds.value()) / mSeconds.value();
+ //_WARNS("LAPRAS") << "blending at " << (blendf * 100.0f) << "%" << LL_ENDL;
mTarget->replaceSettings(mInitial->getSettings());
mTarget->blend(mFinal, blendf);
}
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index fa5fb7a763..f5146b1c27 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -253,7 +253,6 @@ public:
mFinal(endsetting),
mSeconds(seconds),
mOnFinished(),
- mBlendThreshold(DEFAULT_THRESHOLD),
mLastUpdate(0.0f),
mTimeSpent(0.0f)
{
@@ -264,11 +263,11 @@ public:
~LLSettingsBlender() {}
- void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 seconds )
+ void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds )
{
mInitial = initsetting;
mFinal = endsetting;
- mSeconds.value(seconds);
+ mSeconds = seconds;
mTarget->replaceSettings(mInitial->getSettings());
mTimeStart.value(LLDate::now().secondsSinceEpoch());
mLastUpdate = mTimeStart;
@@ -280,16 +279,6 @@ public:
return mOnFinished.connect(onfinished);
}
- void setUpdateThreshold(F64Seconds threshold)
- {
- mBlendThreshold = threshold;
- }
-
- F64Seconds getUpdateThreshold() const
- {
- return mBlendThreshold;
- }
-
LLSettingsBase::ptr_t getTarget() const
{
return mTarget;
@@ -306,13 +295,13 @@ public:
}
void update(F64Seconds time);
+
private:
LLSettingsBase::ptr_t mTarget;
LLSettingsBase::ptr_t mInitial;
LLSettingsBase::ptr_t mFinal;
F64Seconds mSeconds;
finish_signal_t mOnFinished;
- F64Seconds mBlendThreshold;
F64Seconds mLastUpdate;
F64Seconds mTimeSpent;
F64Seconds mTimeStart;
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 1b992ff313..9b0a6c1127 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -96,7 +96,6 @@ namespace
}
//=========================================================================
-const std::string LLSettingsDay::SETTING_DAYLENGTH("day_length");
const std::string LLSettingsDay::SETTING_KEYID("key_id");
const std::string LLSettingsDay::SETTING_KEYNAME("key_name");
const std::string LLSettingsDay::SETTING_KEYKFRAME("key_keyframe");
@@ -104,13 +103,13 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash");
const std::string LLSettingsDay::SETTING_TRACKS("tracks");
const std::string LLSettingsDay::SETTING_FRAMES("frames");
-const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 300); // 5 mins
-const S64 LLSettingsDay::DEFAULT_DAYLENGTH( 14400); // 4 hours
-const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
+const S64Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins
+const S64Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours
+const S64Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
-const S32 LLSettingsDay::MINIMUM_DAYOFFSET( 0);
-const S32 LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset)
-const S32 LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours
+const S64Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0);
+const S64Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset)
+const S64Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400); // 24 hours
const S32 LLSettingsDay::TRACK_WATER(0); // water track is 0
const S32 LLSettingsDay::TRACK_MAX(5); // 5 tracks, 4 skys, 1 water
@@ -119,18 +118,14 @@ const S32 LLSettingsDay::FRAME_MAX(56);
//=========================================================================
LLSettingsDay::LLSettingsDay(const LLSD &data) :
LLSettingsBase(data),
- mInitialized(false),
- mDayLength(DEFAULT_DAYLENGTH),
- mDayOffset(DEFAULT_DAYOFFSET)
+ mInitialized(false)
{
mDayTracks.resize(TRACK_MAX);
}
LLSettingsDay::LLSettingsDay() :
LLSettingsBase(),
- mInitialized(false),
- mDayLength(DEFAULT_DAYLENGTH),
- mDayOffset(DEFAULT_DAYOFFSET)
+ mInitialized(false)
{
mDayTracks.resize(TRACK_MAX);
}
@@ -287,7 +282,6 @@ LLSD LLSettingsDay::defaults()
LLSD dfltsetting;
dfltsetting[SETTING_NAME] = "_default_";
- dfltsetting[SETTING_DAYLENGTH] = static_cast<S32>(MINIMUM_DAYLENGTH);
dfltsetting[SETTING_TRACKS] = LLSDArray(
LLSDArray(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_"))
(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(0.0f))(SETTING_KEYNAME, "_default_")));
@@ -376,12 +370,10 @@ namespace
LLSD frame = (*itf).second;
std::string ftype = frame[LLSettingsBase::SETTING_TYPE];
- LL_WARNS("LAPRAS") << "Validating frame: " << frame << LL_ENDL;
if (ftype == "sky")
{
LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList();
LLSD res_sky = LLSettingsSky::settingValidation(frame, valid_sky);
- LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_sky << LL_ENDL;
if (res_sky["success"].asInteger() == 0)
{
@@ -395,7 +387,6 @@ namespace
{
LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList();
LLSD res_h2o = LLSettingsWater::settingValidation(frame, valid_h2o);
- LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_h2o << LL_ENDL;
if (res_h2o["success"].asInteger() == 0)
{
LL_WARNS("SETTINGS") << "Water setting named '" << (*itf).first << "' validation failed!: " << res_h2o << LL_ENDL;
@@ -457,23 +448,6 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track)
}
//=========================================================================
-F32 LLSettingsDay::secondsToKeyframe(S64Seconds seconds)
-{
- S64Seconds daylength = getDayLength();
- S64Seconds dayoffset = getDayOffset();
-
- return llclamp(static_cast<F32>((seconds.value() + dayoffset.value()) % daylength.value()) / static_cast<F32>(daylength.value()), 0.0f, 1.0f);
-}
-
-F64Seconds LLSettingsDay::keyframeToSeconds(F32 keyframe)
-{
- S64Seconds daylength = getDayLength();
- S64Seconds dayoffset = getDayOffset();
-
- return F64Seconds(static_cast<S64>(keyframe * static_cast<F32>(daylength.value())) - dayoffset.value());
-}
-
-//=========================================================================
void LLSettingsDay::startDayCycle()
{
F64Seconds now(LLDate::now().secondsSinceEpoch());
@@ -484,63 +458,11 @@ void LLSettingsDay::startDayCycle()
return;
}
- // water
- if (mDayTracks[0].empty())
- {
- mBlendedWater.reset();
- mWaterBlender.reset();
- }
- else if (mDayTracks[0].size() == 1)
- {
- mBlendedWater = boost::static_pointer_cast<LLSettingsWater>((*(mDayTracks[0].begin())).second);
- mWaterBlender.reset();
- }
- else
- {
- TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now);
-
- F64Seconds timespan = F64Seconds( getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first));
-
- mBlendedWater = getDefaultWater();
- mWaterBlender = boost::make_shared<LLSettingsBlender>(mBlendedWater,
- (*bounds.first).second, (*bounds.second).second, timespan);
- mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1));
- }
-
- // sky
- if (mDayTracks[1].empty())
- {
- mBlendedSky.reset();
- mSkyBlender.reset();
- }
- else if (mDayTracks[1].size() == 1)
- {
- mBlendedSky = boost::static_pointer_cast<LLSettingsSky>( (*(mDayTracks[1].begin())).second);
- mSkyBlender.reset();
- }
- else
- {
- TrackBound_t bounds = getBoundingEntries(mDayTracks[1], now);
- F64Seconds timespan = F64Seconds(getDayLength() * get_wrapping_distance((*bounds.first).first, (*bounds.second).first));
-
- mBlendedSky = getDefaultSky();
- mSkyBlender = boost::make_shared<LLSettingsBlender>(mBlendedSky,
- (*bounds.first).second, (*bounds.second).second, timespan);
- mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, 1, _1));
- }
}
void LLSettingsDay::updateSettings()
{
- static LLFrameTimer timer;
-
- F64Seconds delta(timer.getElapsedTimeAndResetF32());
-
- if (mSkyBlender)
- mSkyBlender->update(delta);
- if (mWaterBlender)
- mWaterBlender->update(delta);
}
//=========================================================================
@@ -565,30 +487,6 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno)
return keyframes;
}
-LLSettingsDay::TimeList_t LLSettingsDay::getTrackTimes(S32 trackno)
-{
- KeyframeList_t keyframes = getTrackKeyframes(trackno);
-
- if (keyframes.empty())
- return TimeList_t();
-
- TimeList_t times;
-
- times.reserve(keyframes.size());
- for (KeyframeList_t::iterator it = keyframes.begin(); it != keyframes.end(); ++it)
- {
- times.push_back(keyframeToSeconds(*it));
- }
-
- return times;
-}
-
-void LLSettingsDay::setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds)
-{
- F32 keyframe = secondsToKeyframe(seconds);
- setWaterAtKeyframe(water, keyframe);
-}
-
void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe)
{
mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water;
@@ -596,12 +494,6 @@ void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 ke
}
-void LLSettingsDay::setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track)
-{
- F32 keyframe = secondsToKeyframe(seconds);
- setSkyAtKeyframe(sky, keyframe, track);
-}
-
void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track)
{
if ((track < 1) || (track >= TRACK_MAX))
@@ -619,40 +511,4 @@ LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::Cyc
return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe));
}
-LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F64Seconds time)
-{
- F32 frame = secondsToKeyframe(time);
-
- return getBoundingEntries(track, frame);
-}
-
//=========================================================================
-void LLSettingsDay::onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender)
-{
- F64Seconds now(LLDate::now().secondsSinceEpoch());
- TrackBound_t bounds = getBoundingEntries(mDayTracks[track], now);
-
- F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
- F64Seconds timespan = F64Seconds(distance * getDayLength());
-
- LL_DEBUGS("DAYCYCLE") << "New sky blender. now=" << now <<
- " start=" << (*bounds.first).first << " end=" << (*bounds.second).first <<
- " span=" << timespan << LL_ENDL;
-
- mSkyBlender = boost::make_shared<LLSettingsBlender>(mBlendedSky,
- (*bounds.first).second, (*bounds.second).second, timespan);
- mSkyBlender->setOnFinished(boost::bind(&LLSettingsDay::onSkyTransitionDone, this, track, _1));
-}
-
-void LLSettingsDay::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender)
-{
- F64Seconds now(LLDate::now().secondsSinceEpoch());
- TrackBound_t bounds = getBoundingEntries(mDayTracks[0], now);
-
- F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
- F64Seconds timespan = F64Seconds(distance * getDayLength());
-
- mWaterBlender = boost::make_shared<LLSettingsBlender>(mBlendedWater,
- (*bounds.first).second, (*bounds.second).second, timespan);
- mWaterBlender->setOnFinished(boost::bind(&LLSettingsDay::onWaterTransitionDone, this, _1));
-}
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index 4a7bc02871..8a1634d674 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -39,7 +39,6 @@ typedef boost::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t;
class LLSettingsDay : public LLSettingsBase
{
public:
- static const std::string SETTING_DAYLENGTH;
static const std::string SETTING_KEYID;
static const std::string SETTING_KEYNAME;
static const std::string SETTING_KEYKFRAME;
@@ -47,13 +46,13 @@ public:
static const std::string SETTING_TRACKS;
static const std::string SETTING_FRAMES;
- static const S64 MINIMUM_DAYLENGTH;
- static const S64 DEFAULT_DAYLENGTH;
- static const S64 MAXIMUM_DAYLENGTH;
+ static const S64Seconds MINIMUM_DAYLENGTH;
+ static const S64Seconds DEFAULT_DAYLENGTH;
+ static const S64Seconds MAXIMUM_DAYLENGTH;
- static const S32 MINIMUM_DAYOFFSET;
- static const S32 DEFAULT_DAYOFFSET;
- static const S32 MAXIMUM_DAYOFFSET;
+ static const S64Seconds MINIMUM_DAYOFFSET;
+ static const S64Seconds DEFAULT_DAYOFFSET;
+ static const S64Seconds MAXIMUM_DAYOFFSET;
static const S32 TRACK_WATER;
static const S32 TRACK_MAX;
@@ -62,7 +61,6 @@ public:
typedef std::map<F32, LLSettingsBase::ptr_t> CycleTrack_t;
typedef std::vector<CycleTrack_t> CycleList_t;
typedef boost::shared_ptr<LLSettingsDay> ptr_t;
- typedef std::vector<S64Seconds> TimeList_t;
typedef std::vector<F32> KeyframeList_t;
typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t;
@@ -86,26 +84,12 @@ public:
//---------------------------------------------------------------------
KeyframeList_t getTrackKeyframes(S32 track);
- TimeList_t getTrackTimes(S32 track);
- void setWaterAtTime(const LLSettingsWaterPtr_t &water, S64Seconds seconds);
void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe);
-
- void setSkyAtTime(const LLSettingsSkyPtr_t &sky, S64Seconds seconds, S32 track);
void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track);
//---------------------------------------------------------------------
void startDayCycle();
- LLSettingsSkyPtr_t getCurrentSky() const
- {
- return mBlendedSky;
- }
-
- LLSettingsWaterPtr_t getCurrentWater() const
- {
- return mBlendedWater;
- }
-
virtual LLSettingsSkyPtr_t getDefaultSky() const = 0;
virtual LLSettingsWaterPtr_t getDefaultWater() const = 0;
@@ -121,11 +105,6 @@ public:
virtual validation_list_t getValidationList() const;
static validation_list_t validationList();
- S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64Seconds val ) { mDayLength = val; }
- S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64Seconds val) { mDayOffset = val; }
-
protected:
LLSettingsDay();
@@ -134,32 +113,19 @@ protected:
bool mInitialized;
private:
- LLSettingsBlender::ptr_t mSkyBlender; // convert to [] for altitudes
- LLSettingsBlender::ptr_t mWaterBlender;
-
- LLSettingsSkyPtr_t mBlendedSky;
- LLSettingsWaterPtr_t mBlendedWater;
-
CycleList_t mDayTracks;
F64Seconds mLastUpdateTime;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
-
- F32 secondsToKeyframe(S64Seconds seconds);
- F64Seconds keyframeToSeconds(F32 keyframe);
-
void parseFromLLSD(LLSD &data);
static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, F32 keyframe);
static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe);
TrackBound_t getBoundingEntries(CycleTrack_t &track, F32 keyframe);
- TrackBound_t getBoundingEntries(CycleTrack_t &track, F64Seconds time);
- void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender);
- void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
+// void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender);
+// void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
};
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index c02d99fb67..32b292e384 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -265,7 +265,7 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue();
dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue();
- dfltsetting[SETTING_BLOOM_TEXTUREID] = LLUUID::null;
+ dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1;
dfltsetting[SETTING_CLOUD_TEXTUREID] = LLUUID::null;
dfltsetting[SETTING_MOON_TEXTUREID] = IMG_MOON; // gMoonTextureID; // These two are returned by the login... wow!
dfltsetting[SETTING_SUN_TEXUTUREID] = IMG_SUN; // gSunTextureID;
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 25c7fb89db..db8fd570c0 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -83,28 +83,26 @@ LLEnvironment::LLEnvironment():
mDayCycleByName(),
mDayCycleById(),
mUserPrefs(),
- mSelectedEnvironment(ENV_LOCAL),
- mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
- mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET)
+ mSelectedEnvironment(LLEnvironment::ENV_LOCAL)
{
- mSetSkys.resize(ENV_END);
- mSetWater.resize(ENV_END);
- mSetDays.resize(ENV_END);
}
void LLEnvironment::initSingleton()
{
LLSettingsSky::ptr_t p_default_sky = LLSettingsVOSky::buildDefaultSky();
addSky(p_default_sky);
- mCurrentSky = p_default_sky;
LLSettingsWater::ptr_t p_default_water = LLSettingsVOWater::buildDefaultWater();
addWater(p_default_water);
- mCurrentWater = p_default_water;
LLSettingsDay::ptr_t p_default_day = LLSettingsVODay::buildDefaultDayCycle();
addDayCycle(p_default_day);
- mCurrentDay.reset();
+
+ mCurrentEnvironment = boost::make_shared<DayInstance>();
+ mCurrentEnvironment->setSky(p_default_sky);
+ mCurrentEnvironment->setWater(p_default_water);
+
+ mEnvironments[ENV_DEFAULT] = mCurrentEnvironment;
// LEGACY!
legacyLoadAllPresets();
@@ -181,17 +179,16 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data)
else
regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]);
- setSkyFor(ENV_REGION, LLSettingsSky::ptr_t());
- setWaterFor(ENV_REGION, LLSettingsWater::ptr_t());
- setDayFor(ENV_REGION, regionday);
+ clearEnvironment(ENV_PARCEL);
+ setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
- applyChosenEnvironment();
+ updateEnvironment();
}
//-------------------------------------------------------------------------
F32 LLEnvironment::getCamHeight() const
{
- return (mCurrentSky->getDomeOffset() * mCurrentSky->getDomeRadius());
+ return (mCurrentEnvironment->getSky()->getDomeOffset() * mCurrentEnvironment->getSky()->getDomeRadius());
}
F32 LLEnvironment::getWaterHeight() const
@@ -201,21 +198,191 @@ F32 LLEnvironment::getWaterHeight() const
bool LLEnvironment::getIsDayTime() const
{
- return mCurrentSky->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS;
+ return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS;
+}
+
+//-------------------------------------------------------------------------
+void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition)
+{
+ mSelectedEnvironment = env;
+ updateEnvironment(transition);
+}
+
+bool LLEnvironment::hasEnvironment(LLEnvironment::EnvSelection_t env)
+{
+ if ((env < ENV_EDIT) || (env >= ENV_DEFAULT) || (!mEnvironments[env]))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnvironment::EnvSelection_t env, bool create /*= false*/)
+{
+ DayInstance::ptr_t environment = mEnvironments[env];
+ if (!environment && create)
+ {
+ environment = boost::make_shared<DayInstance>();
+ mEnvironments[env] = environment;
+ }
+
+ return environment;
+}
+
+
+void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset)
+{
+ if ((env < ENV_EDIT) || (env >= ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL;
+ return;
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env, true);
+
+ environment->clear();
+ environment->setDay(pday, daylength, dayoffset);
+ environment->animate();
+ /*TODO: readjust environment*/
+}
+
+
+void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironment::fixedEnvironment_t fixed)
+{
+ if ((env < ENV_EDIT) || (env >= ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL;
+ return;
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env, true);
+
+ environment->clear();
+ environment->setSky((fixed.first) ? fixed.first : mEnvironments[ENV_DEFAULT]->getSky());
+ environment->setWater((fixed.second) ? fixed.second : mEnvironments[ENV_DEFAULT]->getWater());
+
+ /*TODO: readjust environment*/
+}
+
+
+void LLEnvironment::clearEnvironment(LLEnvironment::EnvSelection_t env)
+{
+ if ((env < ENV_EDIT) || (env >= ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to change invalid environment selection." << LL_ENDL;
+ return;
+ }
+
+ mEnvironments[env].reset();
+ /*TODO: readjust environment*/
}
-void LLEnvironment::setDayLength(S64Seconds seconds)
+LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelection_t env)
{
- mDayLength = seconds;
- if (mCurrentDay)
- mCurrentDay->setDayLength(mDayLength);
+ if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
+ return LLSettingsDay::ptr_t();
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env);
+
+ if (environment)
+ return environment->getDayCycle();
+
+ return LLSettingsDay::ptr_t();
+}
+
+S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env)
+{
+ if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
+ return S64Seconds(0);
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env);
+
+ if (environment)
+ return environment->getDayLength();
+
+ return S64Seconds(0);
+}
+
+S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env)
+{
+ if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
+ return S64Seconds(0);
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env);
+ if (environment)
+ return environment->getDayOffset();
+
+ return S64Seconds(0);
+}
+
+
+LLEnvironment::fixedEnvironment_t LLEnvironment::getEnvironmentFixed(LLEnvironment::EnvSelection_t env)
+{
+ if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
+ {
+ LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
+ return fixedEnvironment_t();
+ }
+
+ DayInstance::ptr_t environment = getEnvironmentInstance(env);
+
+ if (environment)
+ return fixedEnvironment_t(environment->getSky(), environment->getWater());
+
+ return fixedEnvironment_t();
+}
+
+LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance()
+{
+ for (S32 idx = mSelectedEnvironment; idx < ENV_DEFAULT; ++idx)
+ {
+ if (mEnvironments[idx])
+ return mEnvironments[idx];
+ }
+
+ return mEnvironments[ENV_DEFAULT];
+}
+
+
+void LLEnvironment::updateEnvironment(F64Seconds transition)
+{
+ DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance();
+
+ if (mCurrentEnvironment != pinstance)
+ {
+ LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky();
+ LLSettingsWater::ptr_t pwater = mCurrentEnvironment->getWater();
+
+ LLSettingsSky::ptr_t ptargetsky = psky->buildClone();
+ LLSettingsWater::ptr_t ptargetwater = pwater->buildClone();
+
+ LLSettingsBlender::ptr_t skyblend = boost::make_shared<LLSettingsBlender>(ptargetsky, psky, pinstance->getSky(), transition);
+ skyblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, true));
+ LLSettingsBlender::ptr_t waterblend = boost::make_shared<LLSettingsBlender>(ptargetwater, pwater, pinstance->getWater(), transition);
+ waterblend->setOnFinished(boost::bind(&LLEnvironment::onTransitionDone, this, _1, false));
+
+ pinstance->setBlenders(skyblend, waterblend);
+
+ mCurrentEnvironment = pinstance;
+
+ mCurrentEnvironment->animate();
+ }
}
-void LLEnvironment::setDayOffset(S64Seconds seconds)
+void LLEnvironment::onTransitionDone(const LLSettingsBlender::ptr_t &blender, bool isSky)
{
- mDayOffset = seconds;
- if (mCurrentDay)
- mCurrentDay->setDayOffset(seconds);
+ /*TODO: Test for both sky and water*/
+ mCurrentEnvironment->animate();
}
//-------------------------------------------------------------------------
@@ -227,21 +394,28 @@ void LLEnvironment::update(const LLViewerCamera * cam)
F32Seconds delta(timer.getElapsedTimeAndResetF32());
- if (mBlenderSky)
- mBlenderSky->update(delta);
- if (mBlenderWater)
- mBlenderWater->update(delta);
+ for (InstanceArray_t::iterator it = mEnvironments.begin(); it != mEnvironments.end(); ++it)
+ {
+ if (*it)
+ (*it)->update(delta);
+ }
// update clouds, sun, and general
updateCloudScroll();
- if (mCurrentDay)
- mCurrentDay->update();
-
- if (mCurrentSky)
- mCurrentSky->update();
- if (mCurrentWater)
- mCurrentWater->update();
+// if (mBlenderSky)
+// mBlenderSky->update(delta);
+// if (mBlenderWater)
+// mBlenderWater->update(delta);
+//
+//
+// if (mCurrentDay)
+// mCurrentDay->update();
+//
+// if (mCurrentEnvironment->getSky())
+// mCurrentEnvironment->getSky()->update();
+// if (mCurrentEnvironment->getWater())
+// mCurrentEnvironment->getWater()->update();
F32 camYaw = cam->getYaw();
@@ -277,10 +451,11 @@ void LLEnvironment::updateCloudScroll()
F64 delta_t = s_cloud_timer.getElapsedTimeAndResetF64();
- LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
- mCloudScrollDelta += cloud_delta;
-
-
+ if (mCurrentEnvironment->getSky())
+ {
+ LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentEnvironment->getSky()->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;
+ mCloudScrollDelta += cloud_delta;
+ }
}
@@ -352,11 +527,10 @@ void LLEnvironment::updateGLVariablesForSettings(LLGLSLShader *shader, const LLS
void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)
{
-
if (gPipeline.canUseWindLightShaders())
{
- updateGLVariablesForSettings(shader, mCurrentSky);
- updateGLVariablesForSettings(shader, mCurrentWater);
+ updateGLVariablesForSettings(shader, mCurrentEnvironment->getSky());
+ updateGLVariablesForSettings(shader, mCurrentEnvironment->getWater());
}
if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
@@ -374,237 +548,8 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)
}
shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength());
-
-
-}
-//--------------------------------------------------------------------------
-void LLEnvironment::selectSky(const std::string &name, F32Seconds transition)
-{
- LLSettingsSky::ptr_t next_sky = findSkyByName(name);
- if (!next_sky)
- {
- LL_WARNS("ENVIRONMENT") << "Unable to select sky with unknown name '" << name << "'" << LL_ENDL;
- return;
- }
-
- selectSky(next_sky, transition);
-}
-
-void LLEnvironment::selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition)
-{
- if (!sky)
- {
- mCurrentSky = mSelectedSky;
- mBlenderSky.reset();
- return;
- }
- mSelectedSky = sky;
- if (fabs(transition.value()) <= F_ALMOST_ZERO)
- {
- mBlenderSky.reset();
- mCurrentSky = sky;
- mCurrentSky->setDirtyFlag(true);
- mSelectedSky = sky;
- }
- else
- {
- LLSettingsSky::ptr_t skytarget = mCurrentSky->buildClone();
-
- mBlenderSky = boost::make_shared<LLSettingsBlender>( skytarget, mCurrentSky, sky, transition );
- mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::onSkyTransitionDone, this, _1));
- mCurrentSky = skytarget;
- mSelectedSky = sky;
- }
-}
-
-void LLEnvironment::onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender)
-{
- mCurrentSky = mSelectedSky;
- mBlenderSky.reset();
-}
-
-void LLEnvironment::selectWater(const std::string &name, F32Seconds transition)
-{
- LLSettingsWater::ptr_t next_water = findWaterByName(name);
-
- if (!next_water)
- {
- LL_WARNS("ENVIRONMENT") << "Unable to select water with unknown name '" << name << "'" << LL_ENDL;
- return;
- }
-
- selectWater(next_water, transition);
-}
-
-void LLEnvironment::selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition)
-{
- if (!water)
- {
- mCurrentWater = mSelectedWater;
- mBlenderWater.reset();
- return;
- }
- mSelectedWater = water;
- if (fabs(transition.value()) <= F_ALMOST_ZERO)
- {
- mBlenderWater.reset();
- mCurrentWater = water;
- mCurrentWater->setDirtyFlag(true);
- mSelectedWater = water;
- }
- else
- {
- LLSettingsWater::ptr_t watertarget = mCurrentWater->buildClone();
-
- mBlenderWater = boost::make_shared<LLSettingsBlender>(watertarget, mCurrentWater, water, transition);
- mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::onWaterTransitionDone, this, _1));
- mCurrentWater = watertarget;
- mSelectedWater = water;
- }
-}
-
-void LLEnvironment::onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender)
-{
- mCurrentWater = mSelectedWater;
- mBlenderWater.reset();
-}
-
-void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transition)
-{
- LLSettingsDay::ptr_t next_daycycle = findDayCycleByName(name);
-
- if (!next_daycycle)
- {
- LL_WARNS("ENVIRONMENT") << "Unable to select daycycle with unknown name '" << name << "'" << LL_ENDL;
- return;
- }
-
- selectDayCycle(next_daycycle, transition);
-}
-
-void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition)
-{
- if (!daycycle || (daycycle == mCurrentDay))
- {
- return;
- }
-
- mCurrentDay = daycycle;
- mCurrentDay->setDayLength(mDayLength);
- mCurrentDay->setDayOffset(mDayOffset);
-
- daycycle->startDayCycle();
- selectWater(daycycle->getCurrentWater(), transition);
- selectSky(daycycle->getCurrentSky(), transition);
-}
-
-
-void LLEnvironment::setSelectedEnvironment(EnvSelection_t env)
-{
- if (env == mSelectedEnvironment)
- { // No action to take
- return;
- }
-
- mSelectedEnvironment = env;
- applyChosenEnvironment();
-}
-
-void LLEnvironment::applyChosenEnvironment()
-{
- mSelectedSky.reset();
- mSelectedWater.reset();
- mSelectedDay.reset();
-
- for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx)
- {
- if (mSetDays[idx] && !mSelectedSky && !mSelectedWater)
- selectDayCycle(mSetDays[idx]);
- if (mSetSkys[idx] && !mSelectedSky)
- selectSky(mSetSkys[idx]);
- if (mSetWater[idx] && !mSelectedWater)
- selectWater(mSetWater[idx]);
- if (mSelectedSky && mSelectedWater)
- return;
- }
-
- if (!mSelectedSky)
- selectSky("Default");
- if (!mSelectedWater)
- selectWater("Default");
-}
-
-LLSettingsSky::ptr_t LLEnvironment::getChosenSky() const
-{
- for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx)
- {
- if (mSetSkys[idx])
- return mSetSkys[idx];
- }
-
- return LLSettingsSky::ptr_t();
-}
-
-LLSettingsWater::ptr_t LLEnvironment::getChosenWater() const
-{
- for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx)
- {
- if (mSetWater[idx])
- return mSetWater[idx];
- }
-
- return LLSettingsWater::ptr_t();
-}
-
-LLSettingsDay::ptr_t LLEnvironment::getChosenDay() const
-{
- for (S32 idx = mSelectedEnvironment; idx < ENV_END; ++idx)
- {
- if (mSetDays[idx])
- return mSetDays[idx];
- }
-
- return LLSettingsDay::ptr_t();
-}
-
-void LLEnvironment::setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky)
-{
- mSetSkys[env] = sky;
-}
-
-LLSettingsSky::ptr_t LLEnvironment::getSkyFor(EnvSelection_t env) const
-{
- return mSetSkys[env];
-}
-
-void LLEnvironment::setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water)
-{
- mSetWater[env] = water;
-}
-
-LLSettingsWater::ptr_t LLEnvironment::getWaterFor(EnvSelection_t env) const
-{
- return mSetWater[env];
-}
-
-void LLEnvironment::setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day)
-{
- mSetDays[env] = day;
-}
-
-LLSettingsDay::ptr_t LLEnvironment::getDayFor(EnvSelection_t env) const
-{
- return mSetDays[env];
-}
-
-void LLEnvironment::clearUserSettings()
-{
- mSetSkys[ENV_LOCAL].reset();
- mSetWater[ENV_LOCAL].reset();
- mSetDays[ENV_LOCAL].reset();
}
-
LLEnvironment::list_name_id_t LLEnvironment::getSkyList() const
{
list_name_id_t list;
@@ -778,42 +723,6 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const
}
-void LLEnvironment::selectAgentEnvironment()
-{
- S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH);
- S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET);
- LLSettingsDay::ptr_t pday;
-
- // TODO: Test if editing environment has been set.
-
- // TODO: Test if agent has local environment set.
-
- LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
- LLViewerRegion *pRegion = gAgent.getRegion();
-
- if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle())
- {
- day_length = pRegion->getDayLength();
- day_offset = pRegion->getDayOffset();
- pday = pRegion->getRegionDayCycle();
- }
- else
- {
- day_length = parcel->getDayLength();
- day_offset = parcel->getDayOffset();
- pday = parcel->getParcelDayCycle();
- }
-
- if (getDayLength() != day_length)
- setDayLength(day_length);
-
- if (getDayOffset() != day_offset)
- setDayOffset(day_offset);
-
- if (pday)
- selectDayCycle(pday);
-}
-
void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo)
{
LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL;
@@ -824,48 +733,65 @@ void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentI
if (envinfo->mParcelId == INVALID_PARCEL_ID)
{ // the returned info applies to an entire region.
- LLViewerRegion *pRegion = gAgent.getRegion();
-
- pRegion->setDayLength(envinfo->mDayLength);
- pRegion->setDayOffset(envinfo->mDayOffset);
- pRegion->setIsDefaultDayCycle(envinfo->mIsDefault);
- if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash)
- {
- pRegion->setRegionDayCycle(pday);
- pRegion->setRegionDayCycleHash(envinfo->mDayHash);
- }
-
+ LL_WARNS("LAPRAS") << "Setting Region environment" << LL_ENDL;
+ setEnvironment(ENV_REGION, pday, envinfo->mDayLength, envinfo->mDayOffset);
if (parcel_id != INVALID_PARCEL_ID)
- { // We requested a parcel environment but got back the region's. If this is the parcel we are in
- // clear it out.
- LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
-
- if (parcel->getLocalID() == parcel_id)
- {
- parcel->clearParcelDayCycleInfo();
- }
+ {
+ LL_WARNS("LAPRAS") << "Had requested parcel environment #" << parcel_id << " but got region." << LL_ENDL;
+ clearEnvironment(ENV_PARCEL);
}
+// LLViewerRegion *pRegion = gAgent.getRegion();
+//
+// pRegion->setDayLength(envinfo->mDayLength);
+// pRegion->setDayOffset(envinfo->mDayOffset);
+// pRegion->setIsDefaultDayCycle(envinfo->mIsDefault);
+// if (pRegion->getRegionDayCycleHash() != envinfo->mDayHash)
+// {
+// pRegion->setRegionDayCycle(pday);
+// pRegion->setRegionDayCycleHash(envinfo->mDayHash);
+// }
+//
+// if (parcel_id != INVALID_PARCEL_ID)
+// { // We requested a parcel environment but got back the region's. If this is the parcel we are in
+// // clear it out.
+// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
+//
+// if (parcel->getLocalID() == parcel_id)
+// {
+// parcel->clearParcelDayCycleInfo();
+// }
+// }
}
else
{
LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
- if (parcel->getLocalID() == parcel_id)
+ LL_WARNS("LAPRAS") << "Have parcel environment #" << envinfo->mParcelId << LL_ENDL;
+ if (parcel && (parcel->getLocalID() != parcel_id))
{
- parcel->setDayLength(envinfo->mDayLength);
- parcel->setDayOffset(envinfo->mDayOffset);
- parcel->setUsesDefaultDayCycle(envinfo->mIsDefault);
- if (parcel->getParcelDayCycleHash() != envinfo->mDayHash)
- {
- parcel->setParcelDayCycle(pday);
- parcel->setParcelDayCycleHash(envinfo->mDayHash);
- }
-
+ LL_WARNS("ENVIRONMENT") << "Requested parcel #" << parcel_id << " agent is on " << parcel->getLocalID() << LL_ENDL;
+ return;
}
+
+ setEnvironment(ENV_PARCEL, pday, envinfo->mDayLength, envinfo->mDayOffset);
+// LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
+//
+// if (parcel->getLocalID() == parcel_id)
+// {
+// parcel->setDayLength(envinfo->mDayLength);
+// parcel->setDayOffset(envinfo->mDayOffset);
+// parcel->setUsesDefaultDayCycle(envinfo->mIsDefault);
+// if (parcel->getParcelDayCycleHash() != envinfo->mDayHash)
+// {
+// parcel->setParcelDayCycle(pday);
+// parcel->setParcelDayCycleHash(envinfo->mDayHash);
+// }
+//
+// }
}
/*TODO: track_altitudes*/
- selectAgentEnvironment();
+ updateEnvironment();
}
//=========================================================================
@@ -1337,3 +1263,250 @@ void LLEnvironment::legacyLoadAllPresets()
}
}
}
+
+//=========================================================================
+namespace
+{
+ inline F32 get_wrapping_distance(F32 begin, F32 end)
+ {
+ if (begin < end)
+ {
+ return end - begin;
+ }
+ else if (begin > end)
+ {
+ return 1.0 - (begin - end);
+ }
+
+ return 0;
+ }
+
+ LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key)
+ {
+ if (collection.empty())
+ return collection.end();
+
+ LLSettingsDay::CycleTrack_t::iterator it = collection.upper_bound(key);
+
+ if (it == collection.end())
+ { // wrap around
+ it = collection.begin();
+ }
+
+ return it;
+ }
+
+ LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key)
+ {
+ if (collection.empty())
+ return collection.end();
+
+ LLSettingsDay::CycleTrack_t::iterator it = collection.lower_bound(key);
+
+ if (it == collection.end())
+ { // all keyframes are lower, take the last one.
+ --it; // we know the range is not empty
+ }
+ else if ((*it).first > key)
+ { // the keyframe we are interested in is smaller than the found.
+ if (it == collection.begin())
+ it = collection.end();
+ --it;
+ }
+
+ return it;
+ }
+
+ LLSettingsDay::TrackBound_t get_bounding_entries(LLSettingsDay::CycleTrack_t &track, F32 keyframe)
+ {
+ return LLSettingsDay::TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe));
+ }
+
+}
+//=========================================================================
+
+
+LLEnvironment::DayInstance::DayInstance() :
+ mDayCycle(),
+ mSky(),
+ mWater(),
+ mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
+ mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET),
+ mBlenderSky(),
+ mBlenderWater(),
+ mInitialized(false),
+ mType(TYPE_INVALID)
+{ }
+
+void LLEnvironment::DayInstance::update(F64Seconds delta)
+{
+ if (!mInitialized)
+ initialize();
+
+ if (mBlenderSky)
+ mBlenderSky->update(delta);
+ if (mBlenderWater)
+ mBlenderWater->update(delta);
+
+ if (mSky)
+ mSky->update();
+ if (mWater)
+ mWater->update();
+}
+
+void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset)
+{
+ if (mType == TYPE_FIXED)
+ LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL;
+ mType = TYPE_CYCLED;
+ mInitialized = false;
+
+ mDayCycle = pday;
+ mDayLength = daylength;
+ mDayOffset = dayoffset;
+
+ mBlenderSky.reset();
+ mBlenderWater.reset();
+
+ mSky = LLSettingsVOSky::buildDefaultSky();
+ mWater = LLSettingsVOWater::buildDefaultWater();
+
+ animate();
+}
+
+
+void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky)
+{
+ if (mType == TYPE_CYCLED)
+ LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL;
+ mType = TYPE_FIXED;
+ mInitialized = false;
+
+ mSky = psky;
+ mBlenderSky.reset();
+}
+
+void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater)
+{
+ if (mType == TYPE_CYCLED)
+ LL_WARNS("ENVIRONMENT") << "Cycled day instance changed to FIXED" << LL_ENDL;
+ mType = TYPE_FIXED;
+ mInitialized = false;
+
+ mWater = pwater;
+ mBlenderWater.reset();
+}
+
+void LLEnvironment::DayInstance::initialize()
+{
+ mInitialized = true;
+
+ if (!mWater)
+ mWater = LLSettingsVOWater::buildDefaultWater();
+ if (!mSky)
+ mSky = LLSettingsVOSky::buildDefaultSky();
+}
+
+void LLEnvironment::DayInstance::clear()
+{
+ mType = TYPE_INVALID;
+ mDayCycle.reset();
+ mSky.reset();
+ mWater.reset();
+ mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH;
+ mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET;
+ mBlenderSky.reset();
+ mBlenderWater.reset();
+}
+
+void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend)
+{
+ mBlenderSky = skyblend;
+ mBlenderWater = waterblend;
+}
+
+F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds)
+{
+ F64 frame = static_cast<F64>(seconds.value() % mDayLength.value()) / static_cast<F64>(mDayLength.value());
+
+ return llclamp(frame, 0.0, 1.0);
+}
+
+void LLEnvironment::DayInstance::animate()
+{
+ F64Seconds now(LLDate::now().secondsSinceEpoch());
+
+ now += mDayOffset;
+
+ if (!mDayCycle)
+ return;
+
+ LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0);
+
+ if (wtrack.empty())
+ {
+ mWater.reset();
+ mBlenderWater.reset();
+ }
+ else if (wtrack.size() == 1)
+ {
+ mWater = boost::static_pointer_cast<LLSettingsWater>((*(wtrack.begin())).second);
+ mBlenderWater.reset();
+ }
+ else
+ {
+ LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, secondsToKeyframe(now));
+ F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+
+ mWater = boost::static_pointer_cast<LLSettingsVOWater>((*bounds.first).second)->buildClone();
+ mBlenderWater = boost::make_shared<LLSettingsBlender>(mWater,
+ (*bounds.first).second, (*bounds.second).second, timespan);
+ mBlenderWater->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 0, _1));
+ }
+
+ // Day track 1 only for the moment
+ // sky
+ LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1);
+
+ if (track.empty())
+ {
+ mSky.reset();
+ mBlenderSky.reset();
+ }
+ else if (track.size() == 1)
+ {
+ mSky = boost::static_pointer_cast<LLSettingsSky>((*(track.begin())).second);
+ mBlenderSky.reset();
+ }
+ else
+ {
+ LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now));
+ F64Seconds timespan = mDayLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+
+ mSky = boost::static_pointer_cast<LLSettingsVOSky>((*bounds.first).second)->buildClone();
+ mBlenderSky = boost::make_shared<LLSettingsBlender>(mSky,
+ (*bounds.first).second, (*bounds.second).second, timespan);
+ mBlenderSky->setOnFinished(boost::bind(&LLEnvironment::DayInstance::onTrackTransitionDone, this, 1, _1));
+ }
+}
+
+void LLEnvironment::DayInstance::onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender)
+{
+ LL_WARNS("LAPRAS") << "onTrackTransitionDone for " << trackno << LL_ENDL;
+ F64Seconds now(LLDate::now().secondsSinceEpoch());
+
+ now += mDayOffset;
+
+ LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(trackno);
+
+ LLSettingsDay::TrackBound_t bounds = get_bounding_entries(track, secondsToKeyframe(now));
+
+ F32 distance = get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
+ F64Seconds timespan = mDayLength * distance;
+
+ LL_WARNS("LAPRAS") << "New sky blender. now=" << now <<
+ " start=" << (*bounds.first).first << " end=" << (*bounds.second).first <<
+ " span=" << timespan << LL_ENDL;
+
+ blender->reset((*bounds.first).second, (*bounds.second).second, timespan);
+}
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 451bab5f9e..4230f76862 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -77,9 +77,11 @@ public:
enum EnvSelection_t
{
+ ENV_EDIT,
ENV_LOCAL,
ENV_PARCEL,
ENV_REGION,
+ ENV_DEFAULT,
ENV_END
};
@@ -116,6 +118,8 @@ public:
std::string mDayCycleName;
};
+ typedef std::pair<LLSettingsSky::ptr_t, LLSettingsWater::ptr_t> fixedEnvironment_t;
+
typedef std::map<std::string, LLSettingsBase::ptr_t> namedSettingMap_t;
typedef std::pair<std::string, LLUUID> name_id_t;
typedef std::vector<name_id_t> list_name_id_t;
@@ -130,56 +134,35 @@ public:
bool canEdit() const;
- LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentSky; }
- LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentWater; }
+ LLSettingsSky::ptr_t getCurrentSky() const { return mCurrentEnvironment->getSky(); }
+ LLSettingsWater::ptr_t getCurrentWater() const { return mCurrentEnvironment->getWater(); }
void update(const LLViewerCamera * cam);
void updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
void updateShaderUniforms(LLGLSLShader *shader);
- void addSky(const LLSettingsSky::ptr_t &sky);
- void addWater(const LLSettingsWater::ptr_t &sky);
- void addDayCycle(const LLSettingsDay::ptr_t &day);
+ void setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT);
+ EnvSelection_t getSelectedEnvironment() const { return mSelectedEnvironment; }
- void selectSky(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectSky(const LLSettingsSky::ptr_t &sky, F32Seconds transition = TRANSITION_DEFAULT);
- void selectWater(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectWater(const LLSettingsWater::ptr_t &water, F32Seconds transition = TRANSITION_DEFAULT);
- void selectDayCycle(const std::string &name, F32Seconds transition = TRANSITION_DEFAULT);
- void selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition = TRANSITION_DEFAULT);
+ bool hasEnvironment(EnvSelection_t env);
+ void setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+ void setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed);
+ void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); }
+ void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); }
+ void clearEnvironment(EnvSelection_t env);
+ LLSettingsDay::ptr_t getEnvironmentDay(EnvSelection_t env);
+ S64Seconds getEnvironmentDayLength(EnvSelection_t env);
+ S64Seconds getEnvironmentDayOffset(EnvSelection_t env);
+ fixedEnvironment_t getEnvironmentFixed(EnvSelection_t env);
+ LLSettingsSky::ptr_t getEnvironmentFixedSky(EnvSelection_t env) { return getEnvironmentFixed(env).first; };
+ LLSettingsWater::ptr_t getEnvironmentFixedWater(EnvSelection_t env) { return getEnvironmentFixed(env).second; };
- void setUserSky(const LLSettingsSky::ptr_t &sky)
- {
- setSkyFor(ENV_LOCAL, sky);
- }
- void setUserWater(const LLSettingsWater::ptr_t &water)
- {
- setWaterFor(ENV_LOCAL, water);
- }
- void setUserDaycycle(const LLSettingsDay::ptr_t &day)
- {
- setDayFor(ENV_LOCAL, day);
- }
+ void updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT);
- void setSelectedEnvironment(EnvSelection_t env);
- EnvSelection_t getSelectedEnvironment() const
- {
- return mSelectedEnvironment;
- }
- void applyChosenEnvironment();
- LLSettingsSky::ptr_t getChosenSky() const;
- LLSettingsWater::ptr_t getChosenWater() const;
- LLSettingsDay::ptr_t getChosenDay() const;
-
- void setSkyFor(EnvSelection_t env, const LLSettingsSky::ptr_t &sky);
- LLSettingsSky::ptr_t getSkyFor(EnvSelection_t env) const;
- void setWaterFor(EnvSelection_t env, const LLSettingsWater::ptr_t &water);
- LLSettingsWater::ptr_t getWaterFor(EnvSelection_t env) const;
- void setDayFor(EnvSelection_t env, const LLSettingsDay::ptr_t &day);
- LLSettingsDay::ptr_t getDayFor(EnvSelection_t env) const;
-
- void clearUserSettings();
+ void addSky(const LLSettingsSky::ptr_t &sky);
+ void addWater(const LLSettingsWater::ptr_t &sky);
+ void addDayCycle(const LLSettingsDay::ptr_t &day);
list_name_id_t getSkyList() const;
list_name_id_t getWaterList() const;
@@ -199,14 +182,10 @@ public:
inline F32 getSceneLightStrength() const { return mSceneLightStrength; }
inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; }
- inline LLVector4 getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); }
- inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); }
+ inline LLVector4 getLightDirection() const { return ((mCurrentEnvironment->getSky()) ? LLVector4(mCurrentEnvironment->getSky()->getLightDirection(), 0.0f) : LLVector4()); }
+ inline LLVector4 getClampedLightDirection() const { return LLVector4(mCurrentEnvironment->getSky()->getClampedLightDirection(), 0.0f); }
inline LLVector4 getRotatedLight() const { return mRotatedLight; }
- inline S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64Seconds seconds);
- inline S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64Seconds seconds);
//-------------------------------------------
connection_t setSkyListChange(const change_signal_t::slot_type& cb);
connection_t setWaterListChange(const change_signal_t::slot_type& cb);
@@ -229,6 +208,62 @@ protected:
virtual void initSingleton();
private:
+ class DayInstance
+ {
+ public:
+ enum InstanceType_t
+ {
+ TYPE_INVALID,
+ TYPE_FIXED,
+ TYPE_CYCLED
+ };
+ typedef boost::shared_ptr<DayInstance> ptr_t;
+
+ DayInstance();
+
+ void update(F64Seconds);
+
+ void setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+ void setSky(const LLSettingsSky::ptr_t &psky);
+ void setWater(const LLSettingsWater::ptr_t &pwater);
+
+ void initialize();
+ bool isInitialized();
+
+ void clear();
+
+ LLSettingsDay::ptr_t getDayCycle() const { return mDayCycle; }
+ LLSettingsSky::ptr_t getSky() const { return mSky; }
+ LLSettingsWater::ptr_t getWater() const { return mWater; }
+ S64Seconds getDayLength() const { return mDayLength; }
+ S64Seconds getDayOffset() const { return mDayOffset; }
+
+ void animate();
+
+ void setBlenders(const LLSettingsBlender::ptr_t &skyblend, const LLSettingsBlender::ptr_t &waterblend);
+
+ private:
+ LLSettingsDay::ptr_t mDayCycle;
+ LLSettingsSky::ptr_t mSky;
+ LLSettingsWater::ptr_t mWater;
+
+ InstanceType_t mType;
+ bool mInitialized;
+
+ S64Seconds mDayLength;
+ S64Seconds mDayOffset;
+
+ LLSettingsBlender::ptr_t mBlenderSky;
+ LLSettingsBlender::ptr_t mBlenderWater;
+
+
+ F64 secondsToKeyframe(S64Seconds seconds);
+
+ void onTrackTransitionDone(S32 trackno, const LLSettingsBlender::ptr_t &blender);
+ };
+ typedef std::array<DayInstance::ptr_t, ENV_END> InstanceArray_t;
+
+
static const F32 SUN_DELTA_YAW;
static const F32 NIGHTTIME_ELEVATION_COS;
@@ -236,6 +271,11 @@ private:
LLVector2 mCloudScrollDelta; // cumulative cloud delta
+ InstanceArray_t mEnvironments;
+
+ EnvSelection_t mSelectedEnvironment;
+ DayInstance::ptr_t mCurrentEnvironment;
+
LLSettingsSky::ptr_t mSelectedSky;
LLSettingsWater::ptr_t mSelectedWater;
LLSettingsDay::ptr_t mSelectedDay;
@@ -243,20 +283,12 @@ private:
LLSettingsBlender::ptr_t mBlenderSky;
LLSettingsBlender::ptr_t mBlenderWater;
- LLSettingsSky::ptr_t mCurrentSky;
- LLSettingsWater::ptr_t mCurrentWater;
LLSettingsDay::ptr_t mCurrentDay;
- EnvSelection_t mSelectedEnvironment;
-
typedef std::vector<LLSettingsSky::ptr_t> SkyList_t;
typedef std::vector<LLSettingsWater::ptr_t> WaterList_t;
typedef std::vector<LLSettingsDay::ptr_t> DayList_t;
- SkyList_t mSetSkys;
- WaterList_t mSetWater;
- DayList_t mSetDays;
-
namedSettingMap_t mSkysByName;
AssetSettingMap_t mSkysById;
@@ -275,11 +307,9 @@ private:
change_signal_t mWaterListChange;
change_signal_t mDayCycleListChange;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
+ DayInstance::ptr_t getEnvironmentInstance(EnvSelection_t env, bool create = false);
- void onSkyTransitionDone(const LLSettingsBlender::ptr_t &blender);
- void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
+ DayInstance::ptr_t getSelectedEnvironmentInstance();
//void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);
@@ -308,6 +338,7 @@ private:
void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment);
+ void onTransitionDone(const LLSettingsBlender::ptr_t &, bool isSky);
//=========================================================================
void legacyLoadAllPresets();
LLSD legacyLoadPreset(const std::string& path);
diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp
index efeec72f6e..4ddedbf7df 100644
--- a/indra/newview/llfloatereditdaycycle.cpp
+++ b/indra/newview/llfloatereditdaycycle.cpp
@@ -114,7 +114,8 @@ void LLFloaterEditDayCycle::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().updateEnvironment();
}
}
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 76c275e47c..0beb856456 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -98,7 +98,8 @@ void LLFloaterEditExtDayCycle::onClose(bool app_quitting)
if (!app_quitting) // there's no point to change environment if we're quitting
{
/* TODO: don't restore this environment. We may have gotten here from land or region. */
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().updateEnvironment();
}
}
@@ -106,12 +107,13 @@ void LLFloaterEditExtDayCycle::onVisibilityChange(BOOL new_visibility)
{
if (new_visibility)
{
- LLEnvironment::instance().selectDayCycle(mEditDay, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditDay, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_EDIT);
}
else
{
/* TODO: don't restore this environment. We may have gotten here from land or region. */
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -125,7 +127,7 @@ void LLFloaterEditExtDayCycle::onDayPresetChanged()
if (pday)
{
pday = pday->buildClone();
- LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_INSTANT);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, pday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
mEditDay = pday;
}
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp
index ab9cb81db5..1574e73caa 100644
--- a/indra/newview/llfloatereditsky.cpp
+++ b/indra/newview/llfloatereditsky.cpp
@@ -125,7 +125,8 @@ void LLFloaterEditSky::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -644,7 +645,8 @@ void LLFloaterEditSky::onSkyPresetSelected()
}
psky = psky->buildClone();
- LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, psky);
+ mEditSettings = psky;
syncControls();
enableEditing(true);
@@ -677,7 +679,7 @@ void LLFloaterEditSky::onSaveConfirmed()
if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue())
{
LL_DEBUGS("Windlight") << name << " is now the new preferred sky preset" << LL_ENDL;
- LLEnvironment::instance().setUserSky(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
}
closeFloater();
@@ -686,7 +688,7 @@ void LLFloaterEditSky::onSaveConfirmed()
void LLFloaterEditSky::onBtnSave()
{
LLEnvironment::instance().addSky(mEditSettings);
- LLEnvironment::instance().setUserSky(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
closeFloater();
}
diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp
index 6b218d5008..4d8ffdef21 100644
--- a/indra/newview/llfloatereditwater.cpp
+++ b/indra/newview/llfloatereditwater.cpp
@@ -111,7 +111,8 @@ void LLFloaterEditWater::onClose(bool app_quitting)
{
if (!app_quitting) // there's no point to change environment if we're quitting
{
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
}
@@ -428,7 +429,8 @@ void LLFloaterEditWater::onWaterPresetSelected()
}
pwater = pwater->buildClone();
- LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, pwater);
+ mEditSettings = pwater;
syncControls();
enableEditing(true);
@@ -460,7 +462,7 @@ void LLFloaterEditWater::onSaveConfirmed()
if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue())
{
LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << LL_ENDL;
- LLEnvironment::instance().setUserWater(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
}
closeFloater();
@@ -469,7 +471,7 @@ void LLFloaterEditWater::onSaveConfirmed()
void LLFloaterEditWater::onBtnSave()
{
LLEnvironment::instance().addWater(mEditSettings);
- LLEnvironment::instance().setUserWater(mEditSettings);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, mEditSettings);
closeFloater();
}
diff --git a/indra/newview/llfloaterenvironmentsettings.cpp b/indra/newview/llfloaterenvironmentsettings.cpp
index 9a41d434ee..b7bf6918fe 100644
--- a/indra/newview/llfloaterenvironmentsettings.cpp
+++ b/indra/newview/llfloaterenvironmentsettings.cpp
@@ -84,7 +84,7 @@ void LLFloaterEnvironmentSettings::onOpen(const LLSD& key)
void LLFloaterEnvironmentSettings::onClose(bool app_quitting)
{
if (!app_quitting)
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().updateEnvironment();
}
@@ -124,23 +124,24 @@ void LLFloaterEnvironmentSettings::onBtnOK()
{
bool use_region_settings = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
if (use_region_settings)
{
- LLEnvironment::instance().clearUserSettings();
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_PARCEL);
}
else
{
- LLEnvironment::instance().clearUserSettings();
-
bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
if (!use_fixed_sky)
{
+
std::string day_cycle = mDayCyclePresetCombo->getValue().asString();
LLSettingsDay::ptr_t day = LLEnvironment::instance().findDayCycleByName(day_cycle);
if (day)
{
- LLEnvironment::instance().setDayFor(LLEnvironment::ENV_LOCAL, day);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, day, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
}
}
else
@@ -151,9 +152,9 @@ void LLFloaterEnvironmentSettings::onBtnOK()
LLSettingsSky::ptr_t sky = LLEnvironment::instance().findSkyByName(sky_preset);
LLSettingsWater::ptr_t water = LLEnvironment::instance().findWaterByName(water_preset);
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, sky);
- LLEnvironment::instance().setWaterFor(LLEnvironment::ENV_LOCAL, water);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, LLEnvironment::fixedEnvironment_t(sky, water));
}
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
#if 0
@@ -183,11 +184,12 @@ void LLFloaterEnvironmentSettings::onBtnCancel()
void LLFloaterEnvironmentSettings::refresh()
{
- LLSettingsDay::ptr_t day = LLEnvironment::instance().getChosenDay();
- LLSettingsSky::ptr_t sky = LLEnvironment::instance().getChosenSky();
- LLSettingsWater::ptr_t water = LLEnvironment::instance().getChosenWater();
+ LLEnvironment::fixedEnvironment_t fixed = LLEnvironment::instance().getEnvironmentFixed(LLEnvironment::ENV_EDIT);
+
+ LLSettingsDay::ptr_t day = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_EDIT);
+ LLSettingsSky::ptr_t sky = fixed.first;
+ LLSettingsWater::ptr_t water = fixed.second;
-
bool use_region_settings = true;
bool use_fixed_sky = !day;
@@ -239,18 +241,18 @@ void LLFloaterEnvironmentSettings::apply()
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName(sky_preset);
if (psky)
- LLEnvironment::instance().selectSky(psky, LLEnvironment::TRANSITION_FAST);
- }
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ }
else
{
LLSettingsDay::ptr_t pday = LLEnvironment::instance().findDayCycleByName(day_cycle);
if (pday)
- LLEnvironment::instance().selectDayCycle(pday, LLEnvironment::TRANSITION_FAST);
- }
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET);
+ }
LLSettingsWater::ptr_t pwater = LLEnvironment::instance().findWaterByName(water_preset);
if (pwater)
- LLEnvironment::instance().selectWater(pwater, LLEnvironment::TRANSITION_FAST);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, pwater);
}
}
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 18bf4a47b3..39dada1984 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -3283,8 +3283,19 @@ void LLPanelLandEnvironment::refresh()
F64Hours daylength;
F64Hours dayoffset;
- daylength = parcel->getDayLength();
- dayoffset = parcel->getDayOffset();
+ LLEnvironment::EnvSelection_t env = LLEnvironment::ENV_PARCEL;
+
+ if (!LLEnvironment::instance().hasEnvironment(env))
+ env = LLEnvironment::ENV_REGION;
+
+ daylength = LLEnvironment::instance().getEnvironmentDayLength(env);
+ dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(env);
+
+ LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(env);
+
+ mEditingDayCycle = pday->buildClone();
+
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_EDIT, mEditingDayCycle, daylength, dayoffset);
if (dayoffset.value() > 12.0)
dayoffset = dayoffset - F32Hours(24.0f);
@@ -3292,19 +3303,11 @@ void LLPanelLandEnvironment::refresh()
mDayLengthSlider->setValue(daylength.value());
mDayOffsetSlider->setValue(dayoffset.value());
- mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1);
+ //mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1);
+ mRegionSettingsRadioGroup->setSelectedIndex(1);
setControlsEnabled(owner_or_god);
- if (!parcel->getUsesDefaultDayCycle())
- mEditingDayCycle = parcel->getParcelDayCycle()->buildClone();
- else
- {
- LLViewerRegion* regionp = LLViewerParcelMgr::getInstance()->getSelectionRegion();
- if (regionp)
- mEditingDayCycle = regionp->getRegionDayCycle()->buildClone();
- }
-
}
void LLPanelLandEnvironment::doApply()
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index bf965afbe1..272ac8a1bb 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -3395,22 +3395,25 @@ bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region)
F64Hours daylength;
F64Hours dayoffset;
- daylength = region->getDayLength();
- dayoffset = region->getDayOffset();
+ daylength = LLEnvironment::instance().getEnvironmentDayLength(LLEnvironment::ENV_REGION);
+ dayoffset = LLEnvironment::instance().getEnvironmentDayOffset(LLEnvironment::ENV_REGION);
if (dayoffset.value() > 12.0)
- dayoffset = dayoffset - F32Hours(24.0f);
+ dayoffset = dayoffset - F64Hours(24.0f);
mDayLengthSlider->setValue(daylength.value());
mDayOffsetSlider->setValue(dayoffset.value());
- mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1);
+ //mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1);
+ mRegionSettingsRadioGroup->setSelectedIndex(1);
setControlsEnabled(owner_or_god_or_manager);
mLastRegion = region;
- if (region->getRegionDayCycle())
- mEditingDayCycle = region->getRegionDayCycle()->buildClone();
+ LLSettingsDay::ptr_t pday = LLEnvironment::instance().getEnvironmentDay(LLEnvironment::ENV_REGION);
+
+ if (pday)
+ mEditingDayCycle = pday->buildClone();
return true;
}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 647489666f..456c080f8a 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -8392,29 +8392,34 @@ class LLWorldEnvSettings : public view_listener_t
if (tod == "sunrise")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunrise");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "noon")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midday");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "sunset")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Sunset");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else if (tod == "midnight")
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().findSkyByName("Midnight");
- LLEnvironment::instance().setSkyFor(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_LOCAL, psky);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
}
else
{
- LLEnvironment::instance().clearUserSettings();
- }
+ LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL);
+ LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL);
+ }
- LLEnvironment::instance().applyChosenEnvironment();
+ LLEnvironment::instance().updateEnvironment();
return true;
}
};
@@ -8426,7 +8431,7 @@ class LLWorldEnableEnvSettings : public view_listener_t
bool result = false;
std::string tod = userdata.asString();
- LLSettingsSky::ptr_t sky = LLEnvironment::instance().getSkyFor(LLEnvironment::ENV_LOCAL);
+ LLSettingsSky::ptr_t sky = LLEnvironment::instance().getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL);
if (!sky)
{
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 1dda516ca4..b272595d79 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -535,9 +535,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
mInvisibilityCheckHistory(-1),
mPaused(FALSE),
mRegionCacheHitCount(0),
- mRegionCacheMissCount(0),
- mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
- mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET)
+ mRegionCacheMissCount(0)
{
mWidth = region_width_meters;
mImpl->mOriginGlobal = from_region_handle(handle);
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 71d4d85ade..1628c3620a 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -390,17 +390,6 @@ public:
static BOOL isNewObjectCreationThrottleDisabled() { return sNewObjectCreationThrottle < 0; }
- S64Seconds getDayLength() const { return mDayLength; }
- void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; }
- S64Seconds getDayOffset() const { return mDayOffset; }
- void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; }
- bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; }
- void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; }
- LLSettingsDay::ptr_t getRegionDayCycle() const { return mDayCycle; }
- void setRegionDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; }
- size_t getRegionDayCycleHash() const { return mDayCycleHash; }
- void setRegionDayCycleHash(size_t hash) { mDayCycleHash = hash; }
-
private:
void addToVOCacheTree(LLVOCacheEntry* entry);
LLViewerObject* addNewObject(LLVOCacheEntry* entry);
@@ -540,12 +529,6 @@ private:
typedef std::map<U32, std::vector<U32> > orphan_list_t;
orphan_list_t mOrphanMap;
- S64Seconds mDayLength;
- S64Seconds mDayOffset;
- bool mIsDefaultDayCycle;
- LLSettingsDay::ptr_t mDayCycle;
- size_t mDayCycleHash;
-
class CacheMissItem
{
public: