summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingsbase.cpp57
-rw-r--r--indra/llinventory/llsettingsbase.h90
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp102
-rw-r--r--indra/llinventory/llsettingsdaycycle.h90
-rw-r--r--indra/llinventory/llsettingssky.cpp661
-rw-r--r--indra/llinventory/llsettingssky.h270
-rw-r--r--indra/llinventory/llsettingswater.cpp19
-rw-r--r--indra/llinventory/llsettingswater.h33
8 files changed, 704 insertions, 618 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index d8e337e231..76b1e0b2a6 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -35,7 +35,7 @@
//=========================================================================
namespace
{
- const F64 BREAK_POINT = 0.5;
+ const LLSettingsBase::TrackPosition BREAK_POINT = 0.5;
}
//=========================================================================
@@ -272,7 +272,8 @@ size_t LLSettingsBase::getHash() const
LLSD hash_settings = llsd_shallow(getSettings(),
LLSDMap(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false)("*", true));
- return boost::hash<LLSD>{}(hash_settings);
+ boost::hash<LLSD> hasher;
+ return hasher(hash_settings);
}
bool LLSettingsBase::validate()
@@ -340,17 +341,35 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
validated.insert(validateType.getName());
// Fields for specific settings.
- for (auto &test: validations)
+ for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv)
{
- if (!test.verify(settings))
+#ifdef VALIDATION_DEBUG
+ LLSD oldvalue;
+ if (settings.has((*itv).getName()))
+ {
+ oldvalue = llsd_clone(mSettings[(*itv).getName()]);
+ }
+#endif
+
+ if (!(*itv).verify(settings))
{
std::stringstream errtext;
- errtext << "Settings LLSD fails validation and could not be corrected for '" << test.getName() << "'!\n";
+ errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!\n";
errors.append( errtext.str() );
isValid = false;
}
- validated.insert(test.getName());
+ validated.insert((*itv).getName());
+
+#ifdef VALIDATION_DEBUG
+ if (!oldvalue.isUndefined())
+ {
+ if (!compare_llsd(settings[(*itv).getName()], oldvalue))
+ {
+ LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL;
+ }
+ }
+#endif
}
// strip extra entries
@@ -366,9 +385,9 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
}
}
- for (const std::string &its: strip)
+ for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its)
{
- settings.erase(its);
+ settings.erase(*its);
}
return LLSDMap("success", LLSD::Boolean(isValid))
@@ -533,19 +552,20 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range)
}
//=========================================================================
-void LLSettingsBlender::update(F64 blendf)
+void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf)
{
- setPosition(blendf);
+ setBlendFactor(blendf);
}
-F64 LLSettingsBlender::setPosition(F64 blendf)
+F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in)
{
+ LLSettingsBase::TrackPosition blendf = blendf_in;
if (blendf >= 1.0)
{
triggerComplete();
return 1.0;
}
- blendf = llclamp(blendf, 0.0, 1.0);
+ blendf = llclamp(blendf, 0.0f, 1.0f);
mTarget->replaceSettings(mInitial->getSettings());
if (!mFinal || (mInitial == mFinal) || (blendf == 0.0))
@@ -565,14 +585,14 @@ void LLSettingsBlender::triggerComplete()
}
//-------------------------------------------------------------------------
-F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const
+LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const
{
- return fmod(spanpos, spanlen) / spanlen;
+ return LLSettingsBase::BlendFactor(fmod((F64)spanpos, (F64)spanlen) / (F64)spanlen);
}
-void LLSettingsBlenderTimeDelta::update(F64 timedelta)
+void LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& timedelta)
{
- mTimeSpent += F64Seconds(timedelta);
+ mTimeSpent += timedelta;
if (mTimeSpent > mBlendSpan)
{
@@ -580,8 +600,7 @@ void LLSettingsBlenderTimeDelta::update(F64 timedelta)
return;
}
- F64 blendf = calculateBlend(mTimeSpent.value(), mBlendSpan.value());
- // Note no clamp here.
+ LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan);
- setPosition(blendf);
+ update(blendf);
}
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 1ef7df79ad..374a2ec246 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -41,11 +41,15 @@
#include "llquaternion.h"
#include "v4color.h"
#include "v3color.h"
+#include "llunits.h"
#include "llinventorysettings.h"
+#define PTR_NAMESPACE std
+#define SETTINGS_OVERRIDE override
+
class LLSettingsBase :
- public std::enable_shared_from_this<LLSettingsBase>,
+ public PTR_NAMESPACE::enable_shared_from_this<LLSettingsBase>,
private boost::noncopyable
{
friend class LLEnvironment;
@@ -54,6 +58,10 @@ class LLSettingsBase :
friend std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings);
public:
+ typedef F64Seconds Seconds;
+ typedef F64 BlendFactor;
+ typedef F32 TrackPosition; // 32-bit as these are stored in LLSD as such
+
static const std::string SETTING_ID;
static const std::string SETTING_NAME;
static const std::string SETTING_HASH;
@@ -61,7 +69,7 @@ public:
typedef std::map<std::string, S32> parammapping_t;
- typedef std::shared_ptr<LLSettingsBase> ptr_t;
+ typedef PTR_NAMESPACE::shared_ptr<LLSettingsBase> ptr_t;
virtual ~LLSettingsBase() { };
@@ -104,12 +112,17 @@ public:
//---------------------------------------------------------------------
//
- inline void setValue(const std::string &name, const LLSD &value)
+ inline void setLLSD(const std::string &name, const LLSD &value)
{
mSettings[name] = value;
mDirty = true;
}
+ inline void setValue(const std::string &name, const LLSD &value)
+ {
+ setLLSD(name, value);
+ }
+
inline LLSD getValue(const std::string &name, const LLSD &deflt = LLSD()) const
{
if (!mSettings.has(name))
@@ -117,6 +130,11 @@ public:
return mSettings[name];
}
+ inline void setValue(const std::string &name, F32 v)
+ {
+ setLLSD(name, LLSD::Real(v));
+ }
+
inline void setValue(const std::string &name, const LLVector2 &value)
{
setValue(name, value.getValue());
@@ -147,7 +165,7 @@ public:
setValue(name, value.getValue());
}
- inline F64 getBlendFactor() const
+ inline BlendFactor getBlendFactor() const
{
return mBlendedFactor;
}
@@ -162,7 +180,7 @@ public:
(const_cast<LLSettingsBase *>(this))->updateSettings();
}
- virtual void blend(const ptr_t &end, F64 blendf) = 0;
+ virtual void blend(const ptr_t &end, BlendFactor blendf) = 0;
virtual bool validate();
@@ -217,8 +235,8 @@ protected:
typedef std::set<std::string> stringset_t;
// combining settings objects. Customize for specific setting types
- virtual void lerpSettings(const LLSettingsBase &other, F64 mix);
- LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, F64 mix) const;
+ virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix);
+ LLSD interpolateSDMap(const LLSD &settings, const LLSD &other, BlendFactor mix) const;
/// when lerping between settings, some may require special handling.
/// Get a list of these key to be skipped by the default settings lerp.
@@ -245,24 +263,26 @@ protected:
LLSD cloneSettings() const;
- inline void setBlendFactor(F64 blendfactor)
+ inline void setBlendFactor(BlendFactor blendfactor)
{
mBlendedFactor = blendfactor;
}
+ void markDirty() { mDirty = true; }
+
private:
bool mDirty;
LLSD combineSDMaps(const LLSD &first, const LLSD &other) const;
- F64 mBlendedFactor;
+ BlendFactor mBlendedFactor;
};
-class LLSettingsBlender : public std::enable_shared_from_this<LLSettingsBlender>
+class LLSettingsBlender : public PTR_NAMESPACE::enable_shared_from_this<LLSettingsBlender>
{
public:
- typedef std::shared_ptr<LLSettingsBlender> ptr_t;
+ typedef PTR_NAMESPACE::shared_ptr<LLSettingsBlender> ptr_t;
typedef boost::signals2::signal<void(const ptr_t )> finish_signal_t;
typedef boost::signals2::connection connection_t;
@@ -282,7 +302,7 @@ public:
virtual ~LLSettingsBlender() {}
- virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 /*span*/ = 1.0)
+ virtual void reset( LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition&)
{
// note: the 'span' reset parameter is unused by the base class.
if (!mInitial)
@@ -297,17 +317,17 @@ public:
mTarget->replaceSettings(mInitial->getSettings());
}
- LLSettingsBase::ptr_t getTarget() const
+ LLSettingsBase::ptr_t getTarget() const
{
return mTarget;
}
- LLSettingsBase::ptr_t getInitial() const
+ LLSettingsBase::ptr_t getInitial() const
{
return mInitial;
}
- LLSettingsBase::ptr_t getFinal() const
+ LLSettingsBase::ptr_t getFinal() const
{
return mFinal;
}
@@ -317,10 +337,16 @@ public:
return mOnFinished.connect(onfinished);
}
- virtual void update(F64 blendf);
- virtual F64 setPosition(F64 blendf);
+ virtual void update(const LLSettingsBase::BlendFactor& blendf);
+ virtual void applyTimeDelta(const LLSettingsBase::Seconds& delta)
+ {
+ llassert(false);
+ // your derived class needs to implement an override of this func
+ }
+
+ virtual F64 setBlendFactor(const LLSettingsBase::BlendFactor& position);
- virtual void switchTrack(S32 trackno, F64 position = -1.0) { /*NoOp*/ }
+ virtual void switchTrack(S32 trackno, const LLSettingsBase::TrackPosition& position) { /*NoOp*/ }
protected:
void triggerComplete();
@@ -336,13 +362,13 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
{
public:
LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target,
- const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) :
+ const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, LLSettingsBase::Seconds blend_span) :
LLSettingsBlender(target, initsetting, endsetting),
- mBlendSpan(seconds),
+ mBlendSpan(blend_span),
mLastUpdate(0.0f),
mTimeSpent(0.0f)
{
- mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch());
+ mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch());
mLastUpdate = mTimeStart;
}
@@ -350,25 +376,25 @@ public:
{
}
- virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) override
+ virtual void reset(LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::TrackPosition& blend_span) SETTINGS_OVERRIDE
{
- LLSettingsBlender::reset(initsetting, endsetting, span);
+ LLSettingsBlender::reset(initsetting, endsetting, blend_span);
- mBlendSpan.value(span);
- mTimeStart.value(LLDate::now().secondsSinceEpoch());
+ mBlendSpan = blend_span;
+ mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch());
mLastUpdate = mTimeStart;
- mTimeSpent.value(0.0f);
+ mTimeSpent = LLSettingsBase::Seconds(0.0);
}
- virtual void update(F64 timedelta) override;
+ virtual void applyTimeDelta(const LLSettingsBase::Seconds& timedelta) SETTINGS_OVERRIDE;
protected:
- F64 calculateBlend(F64 spanpos, F64 spanlen) const;
+ LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const;
- F64Seconds mBlendSpan;
- F64Seconds mLastUpdate;
- F64Seconds mTimeSpent;
- F64Seconds mTimeStart;
+ LLSettingsBase::TrackPosition mBlendSpan;
+ LLSettingsBase::Seconds mLastUpdate;
+ LLSettingsBase::Seconds mTimeSpent;
+ LLSettingsBase::Seconds mTimeStart;
};
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 60e962b612..e000b8f03f 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -42,7 +42,22 @@ namespace
LLTrace::BlockTimerStatHandle FTM_BLEND_WATERVALUES("Blending Water Environment");
LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERVALUES("Update Water Environment");
- LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, F32 key)
+ template<typename T>
+ inline T get_wrapping_distance(T begin, T end)
+ {
+ if (begin < end)
+ {
+ return end - begin;
+ }
+ else if (begin > end)
+ {
+ return T(1.0) - (begin - end);
+ }
+
+ return 0;
+ }
+
+ LLSettingsDay::CycleTrack_t::iterator get_wrapping_atafter(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key)
{
if (collection.empty())
return collection.end();
@@ -57,7 +72,7 @@ namespace
return it;
}
- LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, F32 key)
+ LLSettingsDay::CycleTrack_t::iterator get_wrapping_atbefore(LLSettingsDay::CycleTrack_t &collection, const LLSettingsBase::TrackPosition& key)
{
if (collection.empty())
return collection.end();
@@ -89,20 +104,20 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash");
const std::string LLSettingsDay::SETTING_TRACKS("tracks");
const std::string LLSettingsDay::SETTING_FRAMES("frames");
-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 LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins
+const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours
+const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
-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 LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0);
+const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600); // +16 hours == -8 hours (SLT time offset)
+const LLSettingsDay::Seconds 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
const S32 LLSettingsDay::FRAME_MAX(56);
// *LAPRAS* Change when Agni
-const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb");
+static const LLUUID DEFAULT_ASSET_ID("94d296c2-6e05-963c-6b62-671199121dbb");
//=========================================================================
LLSettingsDay::LLSettingsDay(const LLSD &data) :
@@ -136,20 +151,20 @@ LLSD LLSettingsDay::getSettings() const
LLSD tracks(LLSD::emptyArray());
- for (auto &track: mDayTracks)
+ for (CycleList_t::const_iterator itTrack = mDayTracks.begin(); itTrack != mDayTracks.end(); ++itTrack)
{
LLSD trackout(LLSD::emptyArray());
- for (auto &frame: track)
+ for (CycleTrack_t::const_iterator itFrame = (*itTrack).begin(); itFrame != (*itTrack).end(); ++itFrame)
{
- F32 frame_time = frame.first;
- LLSettingsBase::ptr_t data = frame.second;
+ F32 frame = (*itFrame).first;
+ LLSettingsBase::ptr_t data = (*itFrame).second;
size_t datahash = data->getHash();
std::stringstream keyname;
keyname << datahash;
- trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame_time))(SETTING_KEYNAME, keyname.str())));
+ trackout.append(LLSD(LLSDMap(SETTING_KEYKFRAME, LLSD::Real(frame))(SETTING_KEYNAME, keyname.str())));
in_use[keyname.str()] = data;
}
tracks.append(trackout);
@@ -157,12 +172,12 @@ LLSD LLSettingsDay::getSettings() const
settings[SETTING_TRACKS] = tracks;
LLSD frames(LLSD::emptyMap());
- for (auto &used_frame: in_use)
+ for (std::map<std::string, LLSettingsBase::ptr_t>::iterator itFrame = in_use.begin(); itFrame != in_use.end(); ++itFrame)
{
- LLSD framesettings = llsd_clone(used_frame.second->getSettings(),
+ LLSD framesettings = llsd_clone((*itFrame).second->getSettings(),
LLSDMap("*", true)(SETTING_NAME, false)(SETTING_ID, false)(SETTING_HASH, false));
- frames[used_frame.first] = framesettings;
+ frames[(*itFrame).first] = framesettings;
}
settings[SETTING_FRAMES] = frames;
@@ -212,7 +227,7 @@ bool LLSettingsDay::initialize()
LLSD curtrack = tracks[i];
for (LLSD::array_const_iterator it = curtrack.beginArray(); it != curtrack.endArray(); ++it)
{
- F32 keyframe = (*it)[SETTING_KEYKFRAME].asReal();
+ LLSettingsBase::TrackPosition keyframe = LLSettingsBase::TrackPosition((*it)[SETTING_KEYKFRAME].asReal());
keyframe = llclamp(keyframe, 0.0f, 1.0f);
LLSettingsBase::ptr_t setting;
@@ -223,7 +238,7 @@ bool LLSettingsDay::initialize()
setting = used[(*it)[SETTING_KEYNAME]];
if (setting && setting->getSettingType() != "water")
{
- LL_WARNS("SETTINGS", "DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
+ LL_WARNS("DAYCYCLE") << "Water track referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
setting.reset();
}
}
@@ -232,7 +247,7 @@ bool LLSettingsDay::initialize()
setting = used[(*it)[SETTING_KEYNAME]];
if (setting && setting->getSettingType() != "sky")
{
- LL_WARNS("SETTINGS", "DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
+ LL_WARNS("DAYCYCLE") << "Sky track #" << i << " referencing " << setting->getSettingType() << " frame at " << keyframe << "." << LL_ENDL;
setting.reset();
}
}
@@ -246,10 +261,6 @@ bool LLSettingsDay::initialize()
hassky |= true;
mDayTracks[i][keyframe] = setting;
}
- else
- {
- LL_WARNS("SETTINGS", "DAYCYCLE") << "Skipping frame on track #" << i << " at time index " << keyframe << LL_ENDL;
- }
}
}
@@ -350,7 +361,7 @@ namespace
continue;
}
- F32 frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal();
+ LLSettingsBase::TrackPosition frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal();
if ((frame < 0.0) || (frame > 1.0))
{
frame = llclamp(frame, 0.0f, 1.0f);
@@ -468,14 +479,11 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track)
//=========================================================================
void LLSettingsDay::startDayCycle()
{
- F64Seconds now(LLDate::now().secondsSinceEpoch());
-
if (!mInitialized)
{
LL_WARNS("DAYCYCLE") << "Attempt to start day cycle on uninitialized object." << LL_ENDL;
return;
}
-
}
@@ -497,15 +505,15 @@ LLSettingsDay::KeyframeList_t LLSettingsDay::getTrackKeyframes(S32 trackno)
keyframes.reserve(track.size());
- for (auto &frame: track)
+ for (CycleTrack_t::iterator it = track.begin(); it != track.end(); ++it)
{
- keyframes.push_back(frame.first);
+ keyframes.push_back((*it).first);
}
return keyframes;
}
-bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame)
+bool LLSettingsDay::moveTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame)
{
if ((trackno < 0) || (trackno >= TRACK_MAX))
{
@@ -525,6 +533,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame)
LLSettingsBase::ptr_t base = iter->second;
track.erase(iter);
track[llclamp(new_frame, 0.0f, 1.0f)] = base;
+ track[new_frame] = base;
return true;
}
@@ -532,7 +541,7 @@ bool LLSettingsDay::moveTrackKeyframe(S32 trackno, F32 old_frame, F32 new_frame)
}
-bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame)
+bool LLSettingsDay::removeTrackKeyframe(S32 trackno, const LLSettingsBase::TrackPosition& frame)
{
if ((trackno < 0) || (trackno >= TRACK_MAX))
{
@@ -552,17 +561,18 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame)
return false;
}
-void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe)
+void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe)
{
setSettingsAtKeyframe(water, keyframe, TRACK_WATER);
}
-LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) const
+LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const
{
- return std::dynamic_pointer_cast<LLSettingsWater>(getSettingsAtKeyframe(keyframe, TRACK_WATER));
+ LLSettingsBase* p = getSettingsAtKeyframe(keyframe, TRACK_WATER).get();
+ return LLSettingsWater::ptr_t((LLSettingsWater*)p);
}
-void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyframe, S32 track)
+void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track)
{
if ((track < 1) || (track >= TRACK_MAX))
{
@@ -573,7 +583,7 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyfra
setSettingsAtKeyframe(sky, keyframe, track);
}
-LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) const
+LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const
{
if ((track < 1) || (track >= TRACK_MAX))
{
@@ -581,10 +591,10 @@ LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) co
return LLSettingsSky::ptr_t();
}
- return std::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track));
+ return PTR_NAMESPACE::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track));
}
-void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track)
+void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track)
{
if ((track < 0) || (track >= TRACK_MAX))
{
@@ -596,7 +606,7 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings,
setDirtyFlag(true);
}
-LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) const
+LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const
{
if ((track < 0) || (track >= TRACK_MAX))
{
@@ -625,20 +635,24 @@ void LLSettingsDay::clearTrack(S32 track)
mDayTracks[track].clear();
}
-
-F32 LLSettingsDay::getUpperBoundFrame(S32 track, F32 keyframe)
+LLSettingsBase::TrackPosition LLSettingsDay::getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe)
{
return get_wrapping_atafter(mDayTracks[track], keyframe)->first;
}
-F32 LLSettingsDay::getLowerBoundFrame(S32 track, F32 keyframe)
+LLSettingsBase::TrackPosition LLSettingsDay::getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe)
{
return get_wrapping_atbefore(mDayTracks[track], keyframe)->first;
}
-LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe)
+LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe)
{
return TrackBound_t(get_wrapping_atbefore(track, keyframe), get_wrapping_atafter(track, keyframe));
}
+LLUUID LLSettingsDay::GetDefaultAssetId()
+{
+ return DEFAULT_ASSET_ID;
+}
+
//=========================================================================
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index 6fb48225c7..cc6e27b296 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -35,12 +35,15 @@ class LLSettingsSky;
// These are alias for LLSettingsWater::ptr_t and LLSettingsSky::ptr_t respectively.
// Here for definitions only.
-typedef std::shared_ptr<LLSettingsWater> LLSettingsWaterPtr_t;
-typedef std::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t;
+typedef PTR_NAMESPACE::shared_ptr<LLSettingsWater> LLSettingsWaterPtr_t;
+typedef PTR_NAMESPACE::shared_ptr<LLSettingsSky> LLSettingsSkyPtr_t;
class LLSettingsDay : public LLSettingsBase
{
public:
+ // 32-bit as LLSD only supports that width at present
+ typedef S32Seconds Seconds;
+
static const std::string SETTING_KEYID;
static const std::string SETTING_KEYNAME;
static const std::string SETTING_KEYKFRAME;
@@ -48,25 +51,24 @@ public:
static const std::string SETTING_TRACKS;
static const std::string SETTING_FRAMES;
- static const S64Seconds MINIMUM_DAYLENGTH;
- static const S64Seconds DEFAULT_DAYLENGTH;
- static const S64Seconds MAXIMUM_DAYLENGTH;
-
- static const S64Seconds MINIMUM_DAYOFFSET;
- static const S64Seconds DEFAULT_DAYOFFSET;
- static const S64Seconds MAXIMUM_DAYOFFSET;
+ static const Seconds MINIMUM_DAYLENGTH;
+ static const Seconds DEFAULT_DAYLENGTH;
+ static const Seconds MAXIMUM_DAYLENGTH;
- static const S32 TRACK_WATER;
- static const S32 TRACK_MAX;
- static const S32 FRAME_MAX;
+ static const Seconds MINIMUM_DAYOFFSET;
+ static const Seconds DEFAULT_DAYOFFSET;
+ static const Seconds MAXIMUM_DAYOFFSET;
- static const LLUUID DEFAULT_ASSET_ID;
+ static const S32 TRACK_WATER;
+ static const S32 TRACK_MAX;
+ static const S32 FRAME_MAX;
- typedef std::map<F32, LLSettingsBase::ptr_t> CycleTrack_t;
- typedef std::vector<CycleTrack_t> CycleList_t;
- typedef std::shared_ptr<LLSettingsDay> ptr_t;
- typedef std::vector<F32> KeyframeList_t;
- typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t;
+ typedef std::map<LLSettingsBase::TrackPosition, LLSettingsBase::ptr_t> CycleTrack_t;
+ typedef std::vector<CycleTrack_t> CycleList_t;
+ typedef PTR_NAMESPACE::shared_ptr<LLSettingsDay> ptr_t;
+ typedef PTR_NAMESPACE::weak_ptr<LLSettingsDay> wptr_t;
+ typedef std::vector<LLSettingsBase::TrackPosition> KeyframeList_t;
+ typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t;
//---------------------------------------------------------------------
LLSettingsDay(const LLSD &data);
@@ -75,30 +77,31 @@ public:
bool initialize();
virtual ptr_t buildClone() = 0;
- virtual LLSD getSettings() const override;
- virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_DAYCYCLE; }
+ virtual LLSD getSettings() const SETTINGS_OVERRIDE;
+ virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_DAYCYCLE; }
//---------------------------------------------------------------------
- virtual std::string getSettingType() const override { return std::string("daycycle"); }
+ virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("daycycle"); }
// Settings status
- virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) override;
+ virtual void blend(const LLSettingsBase::ptr_t &other, F64 mix) SETTINGS_OVERRIDE;
static LLSD defaults();
//---------------------------------------------------------------------
KeyframeList_t getTrackKeyframes(S32 track);
- bool moveTrackKeyframe(S32 track, F32 old_frame, F32 new_frame);
- bool removeTrackKeyframe(S32 track, F32 frame);
-
- void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe);
- LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe) const;
- void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track);
- LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track) const;
- void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track);
- LLSettingsBase::ptr_t getSettingsAtKeyframe(F32 keyframe, S32 track) const;
+ bool moveTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& old_frame, const LLSettingsBase::TrackPosition& new_frame);
+ bool removeTrackKeyframe(S32 track, const LLSettingsBase::TrackPosition& frame);
+
+ void setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, const LLSettingsBase::TrackPosition& keyframe);
+ LLSettingsWaterPtr_t getWaterAtKeyframe(const LLSettingsBase::TrackPosition& keyframe) const;
+ void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, const LLSettingsBase::TrackPosition& keyframe, S32 track);
+ LLSettingsSkyPtr_t getSkyAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const;
+ void setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, const LLSettingsBase::TrackPosition& keyframe, S32 track);
+ LLSettingsBase::ptr_t getSettingsAtKeyframe(const LLSettingsBase::TrackPosition& keyframe, S32 track) const;
void clearTrack(S32 track);
+
//---------------------------------------------------------------------
void startDayCycle();
@@ -111,36 +114,33 @@ public:
void setInitialized(bool value = true) { mInitialized = value; }
CycleTrack_t & getCycleTrack(S32 track);
- virtual validation_list_t getValidationList() const override;
+ virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE;
static validation_list_t validationList();
- virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); }
+ virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); }
- F32 getUpperBoundFrame(S32 track, F32 keyframe);
- F32 getLowerBoundFrame(S32 track, F32 keyframe);
+ LLSettingsBase::TrackPosition getUpperBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe);
+ LLSettingsBase::TrackPosition getLowerBoundFrame(S32 track, const LLSettingsBase::TrackPosition& keyframe);
+
+ static LLUUID GetDefaultAssetId();
protected:
LLSettingsDay();
- virtual void updateSettings() override;
+ virtual void updateSettings() SETTINGS_OVERRIDE;
bool mInitialized;
private:
CycleList_t mDayTracks;
- F64Seconds mLastUpdateTime;
+ LLSettingsBase::Seconds mLastUpdateTime;
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);
-
-// void onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender);
-// void onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
-
+ static CycleTrack_t::iterator getEntryAtOrBefore(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe);
+ static CycleTrack_t::iterator getEntryAtOrAfter(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe);
+ TrackBound_t getBoundingEntries(CycleTrack_t &track, const LLSettingsBase::TrackPosition& keyframe);
};
#endif
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index f578660095..95502f47c3 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -32,26 +32,26 @@
#include "llfasttimer.h"
#include "v3colorutil.h"
+static const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees
+static const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD);
+static const LLVector3 DUE_EAST = LLVector3::x_axis;
//=========================================================================
namespace
{
- const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0);
- const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f);
- const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f);
-
LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment");
- LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment");
+ LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment");
+}
- LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude);
- void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude);
+static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude)
+{
+ LLQuaternion quat;
+ quat.setEulerAngles(0.0f, -altitude, azimuth);
+ return quat;
}
const F32 LLSettingsSky::DOME_OFFSET(0.96f);
const F32 LLSettingsSky::DOME_RADIUS(15000.f);
-const F32 LLSettingsSky::NIGHTTIME_ELEVATION(-8.0f); // degrees
-const F32 LLSettingsSky::NIGHTTIME_ELEVATION_COS((F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD));
-
//=========================================================================
const std::string LLSettingsSky::SETTING_AMBIENT("ambient");
const std::string LLSettingsSky::SETTING_BLUE_DENSITY("blue_density");
@@ -106,16 +106,42 @@ const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR("exp_s
const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM("linear_term");
const std::string LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM("constant_term");
-const LLUUID LLSettingsSky::DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver
-const LLUUID LLSettingsSky::DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver
-const LLUUID LLSettingsSky::DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b");
-
// *LAPRAS* Change when Agni!
-const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749");
+static const LLUUID DEFAULT_SUN_ID("cce0f112-878f-4586-a2e2-a8f104bba271"); // dataserver
+static const LLUUID DEFAULT_MOON_ID("d07f6eed-b96a-47cd-b51d-400ad4a1c428"); // dataserver
+static const LLUUID DEFAULT_CLOUD_ID("1dc1368f-e8fe-f02d-a08d-9d9f11c1af6b");
+static const LLUUID DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749");
+
+const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze");
namespace
{
+LLSettingsSky::validation_list_t legacyHazeValidationList()
+{
+ static LLSettingsBase::validation_list_t legacyHazeValidation;
+ if (legacyHazeValidation.empty())
+ {
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_BLUE_DENSITY, true, LLSD::TypeArray,
+ boost::bind(&LLSettingsBase::Validator::verifyVectorMinMax, _1,
+ LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
+ LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_BLUE_HORIZON, true, LLSD::TypeArray,
+ boost::bind(&LLSettingsBase::Validator::verifyVectorMinMax, _1,
+ LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
+ LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_HAZE_DENSITY, true, LLSD::TypeReal,
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f)))));
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_HAZE_HORIZON, true, LLSD::TypeReal,
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal,
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f)))));
+ legacyHazeValidation.push_back(LLSettingsBase::Validator(LLSettingsSky::SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal,
+ boost::bind(&LLSettingsBase::Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f)))));
+ }
+ return legacyHazeValidation;
+}
+
LLSettingsSky::validation_list_t rayleighValidationList()
{
static LLSettingsBase::validation_list_t rayleighValidation;
@@ -188,6 +214,24 @@ LLSettingsSky::validation_list_t mieValidationList()
return mieValidation;
}
+bool validateLegacyHaze(LLSD &value)
+{
+ LLSettingsSky::validation_list_t legacyHazeValidations = legacyHazeValidationList();
+ llassert(value.type() == LLSD::TypeMap);
+ LLSD result = LLSettingsBase::settingValidation(value, legacyHazeValidations);
+ if (result["errors"].size() > 0)
+ {
+ LL_WARNS("SETTINGS") << "Legacy Haze Config Validation errors: " << result["errors"] << LL_ENDL;
+ return false;
+ }
+ if (result["warnings"].size() > 0)
+ {
+ LL_WARNS("SETTINGS") << "Legacy Haze Config Validation warnings: " << result["errors"] << LL_ENDL;
+ return false;
+ }
+ return true;
+}
+
bool validateRayleighLayers(LLSD &value)
{
LLSettingsSky::validation_list_t rayleighValidations = rayleighValidationList();
@@ -197,14 +241,14 @@ bool validateRayleighLayers(LLSD &value)
for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf)
{
LLSD& layerConfig = (*itf);
- if (layerConfig.type() == LLSD::Type::TypeMap)
+ if (layerConfig.type() == LLSD::TypeMap)
{
if (!validateRayleighLayers(layerConfig))
{
allGood = false;
}
}
- else if (layerConfig.type() == LLSD::Type::TypeArray)
+ else if (layerConfig.type() == LLSD::TypeArray)
{
return validateRayleighLayers(layerConfig);
}
@@ -215,7 +259,7 @@ bool validateRayleighLayers(LLSD &value)
}
return allGood;
}
- llassert(value.type() == LLSD::Type::TypeMap);
+ llassert(value.type() == LLSD::TypeMap);
LLSD result = LLSettingsBase::settingValidation(value, rayleighValidations);
if (result["errors"].size() > 0)
{
@@ -239,14 +283,14 @@ bool validateAbsorptionLayers(LLSD &value)
for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf)
{
LLSD& layerConfig = (*itf);
- if (layerConfig.type() == LLSD::Type::TypeMap)
+ if (layerConfig.type() == LLSD::TypeMap)
{
if (!validateAbsorptionLayers(layerConfig))
{
allGood = false;
}
}
- else if (layerConfig.type() == LLSD::Type::TypeArray)
+ else if (layerConfig.type() == LLSD::TypeArray)
{
return validateAbsorptionLayers(layerConfig);
}
@@ -257,7 +301,7 @@ bool validateAbsorptionLayers(LLSD &value)
}
return allGood;
}
- llassert(value.type() == LLSD::Type::TypeMap);
+ llassert(value.type() == LLSD::TypeMap);
LLSD result = LLSettingsBase::settingValidation(value, absorptionValidations);
if (result["errors"].size() > 0)
{
@@ -281,14 +325,14 @@ bool validateMieLayers(LLSD &value)
for (LLSD::array_iterator itf = value.beginArray(); itf != value.endArray(); ++itf)
{
LLSD& layerConfig = (*itf);
- if (layerConfig.type() == LLSD::Type::TypeMap)
+ if (layerConfig.type() == LLSD::TypeMap)
{
if (!validateMieLayers(layerConfig))
{
allGood = false;
}
}
- else if (layerConfig.type() == LLSD::Type::TypeArray)
+ else if (layerConfig.type() == LLSD::TypeArray)
{
return validateMieLayers(layerConfig);
}
@@ -307,7 +351,7 @@ bool validateMieLayers(LLSD &value)
}
if (result["warnings"].size() > 0)
{
- LL_WARNS("SETTINGS") << "Mie Config Validation warnings: " << result["errors"] << LL_ENDL;
+ LL_WARNS("SETTINGS") << "Mie Config Validation warnings: " << result["warnings"] << LL_ENDL;
return false;
}
return true;
@@ -334,7 +378,7 @@ LLSettingsSky::LLSettingsSky():
void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
{
- LLSettingsSky::ptr_t other = std::static_pointer_cast<LLSettingsSky>(end);
+ LLSettingsSky::ptr_t other((LLSettingsSky*)end.get());
LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf);
replaceSettings(blenddata);
@@ -344,31 +388,18 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
mNextCloudTextureId = other->getCloudNoiseTextureId();
}
-
-void LLSettingsSky::setMoonRotation(F32 azimuth, F32 altitude)
-{
- setValue(SETTING_MOON_ROTATION, ::body_position_from_angles(azimuth, altitude));
-}
-
-LLSettingsSky::azimalt_t LLSettingsSky::getMoonRotationAzAl() const
-{
- azimalt_t res;
- ::angles_from_rotation(getMoonRotation(), res.first, res.second);
-
- return res;
-}
-
-void LLSettingsSky::setSunRotation(F32 azimuth, F32 altitude)
+LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
{
- setValue(SETTING_SUN_ROTATION, ::body_position_from_angles(azimuth, altitude));
-}
+ static stringset_t skipSet;
-LLSettingsSky::azimalt_t LLSettingsSky::getSunRotationAzAl() const
-{
- azimalt_t res;
- ::angles_from_rotation(getSunRotation(), res.first, res.second);
+ if (skipSet.empty())
+ {
+ skipSet.insert(SETTING_RAYLEIGH_CONFIG);
+ skipSet.insert(SETTING_MIE_CONFIG);
+ skipSet.insert(SETTING_ABSORPTION_CONFIG);
+ }
- return res;
+ return skipSet;
}
LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const
@@ -384,8 +415,6 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const
return slepSet;
}
-
-
LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const
{
return LLSettingsSky::validationList();
@@ -400,28 +429,27 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
// copy constructor for LLSDArray. Directly binding the LLSDArray as
// a parameter without first wrapping it in a pure LLSD object will result
// in deeply nested arrays like this [[[[[[[[[[v1,v2,v3]]]]]]]]]]
-
-// LEGACY_ATMOSPHERICS
- validation.push_back(Validator(SETTING_AMBIENT, true, LLSD::TypeArray,
+ validation.push_back(Validator(SETTING_BLUE_DENSITY, false, LLSD::TypeArray,
boost::bind(&Validator::verifyVectorMinMax, _1,
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
- LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*")))));
- validation.push_back(Validator(SETTING_BLUE_DENSITY, true, LLSD::TypeArray,
+ LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
+ validation.push_back(Validator(SETTING_BLUE_HORIZON, false, LLSD::TypeArray,
boost::bind(&Validator::verifyVectorMinMax, _1,
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
- validation.push_back(Validator(SETTING_BLUE_HORIZON, true, LLSD::TypeArray,
+ validation.push_back(Validator(SETTING_HAZE_DENSITY, false, LLSD::TypeReal,
+ boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f)))));
+ validation.push_back(Validator(SETTING_HAZE_HORIZON, false, LLSD::TypeReal,
+ boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
+ validation.push_back(Validator(SETTING_AMBIENT, false, LLSD::TypeArray,
boost::bind(&Validator::verifyVectorMinMax, _1,
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
- LLSD(LLSDArray(2.0f)(2.0f)(2.0f)("*")))));
- validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, true, LLSD::TypeReal,
+ LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*")))));
+ validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(0.0009f)))));
- validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, true, LLSD::TypeReal,
+ validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(100.0f)))));
- validation.push_back(Validator(SETTING_HAZE_DENSITY, true, LLSD::TypeReal,
- boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4.0f)))));
- validation.push_back(Validator(SETTING_HAZE_HORIZON, true, LLSD::TypeReal,
- boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f)))));
+
validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_CLOUD_COLOR, true, LLSD::TypeArray,
@@ -457,8 +485,6 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
LLSD(LLSDArray(0.2f)("*")(-2.5f)("*")),
LLSD(LLSDArray(20.0f)("*")(0.0f)("*")))));
- validation.push_back(Validator(SETTING_LIGHT_NORMAL, false, LLSD::TypeArray,
- boost::bind(&Validator::verifyVectorNormalized, _1, 3)));
validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f)))));
validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal));
@@ -487,6 +513,7 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers));
validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers));
validation.push_back(Validator(SETTING_MIE_CONFIG, true, LLSD::TypeArray, &validateMieLayers));
+ validation.push_back(Validator(SETTING_LEGACY_HAZE, false, LLSD::TypeMap, &validateLegacyHaze));
}
return validation;
}
@@ -494,11 +521,13 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
LLSD LLSettingsSky::rayleighConfigDefault()
{
LLSD dflt_rayleigh;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
- dflt_rayleigh[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
- dflt_rayleigh[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ LLSD dflt_rayleigh_layer;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
+ dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ dflt_rayleigh.append(dflt_rayleigh_layer);
return dflt_rayleigh;
}
@@ -528,12 +557,14 @@ LLSD LLSettingsSky::absorptionConfigDefault()
LLSD LLSettingsSky::mieConfigDefault()
{
LLSD dflt_mie;
- dflt_mie[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
- dflt_mie[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
- dflt_mie[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
- dflt_mie[SETTING_MIE_ANISOTROPY_FACTOR] = 0.9f;
+ LLSD dflt_mie_layer;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f;
+ dflt_mie_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f;
+ dflt_mie_layer[SETTING_MIE_ANISOTROPY_FACTOR] = 0.8f;
+ dflt_mie.append(dflt_mie_layer);
return dflt_mie;
}
@@ -541,19 +572,12 @@ LLSD LLSettingsSky::defaults()
{
LLSD dfltsetting;
LLQuaternion sunquat;
- sunquat.setEulerAngles(1.39626, 0.0, 0.0); // 80deg Azumith/0deg East
- LLQuaternion moonquat = ~sunquat;
+ LLQuaternion moonquat;
- // Magic constants copied form dfltsetting.xml
-// LEGACY_ATMOSPHERICS
- dfltsetting[SETTING_AMBIENT] = LLColor4::white.getValue();
- dfltsetting[SETTING_BLUE_DENSITY] = LLColor4(0.2447, 0.4487, 0.7599, 0.0).getValue();
- dfltsetting[SETTING_BLUE_HORIZON] = LLColor4(0.4954, 0.4954, 0.6399, 0.0).getValue();
- dfltsetting[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(0.0001);
- dfltsetting[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(0.8000);
- dfltsetting[SETTING_HAZE_DENSITY] = LLSD::Real(0.6999);
- dfltsetting[SETTING_HAZE_HORIZON] = LLSD::Real(0.1899);
+ sunquat = convert_azimuth_and_altitude_to_quat(0.0f, 80.0f * DEG_TO_RAD);
+ moonquat = convert_azimuth_and_altitude_to_quat(F_PI, 80.0f * DEG_TO_RAD);
+ // Magic constants copied form dfltsetting.xml
dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue();
dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue();
dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue();
@@ -566,7 +590,6 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0);
dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue();
- dfltsetting[SETTING_LIGHT_NORMAL] = LLVector3(0.0000, 0.9126, -0.4086).getValue();
dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605);
dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue();
dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000);
@@ -575,8 +598,8 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1;
dfltsetting[SETTING_CLOUD_TEXTUREID] = DEFAULT_CLOUD_ID;
- dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID;
- dfltsetting[SETTING_SUN_TEXTUREID] = LLUUID::null; // DEFAULT_SUN_ID;
+ dfltsetting[SETTING_MOON_TEXTUREID] = DEFAULT_MOON_ID; // gMoonTextureID; // These two are returned by the login... wow!
+ dfltsetting[SETTING_SUN_TEXTUREID] = DEFAULT_SUN_ID; // gSunTextureID;
dfltsetting[SETTING_TYPE] = "sky";
@@ -584,68 +607,67 @@ LLSD LLSettingsSky::defaults()
dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f;
dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f;
dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f;
- dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f;
+ dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f;
- // These are technically capable of handling multiple layers of density config
- // and so are expected to be an array, but we make an array of size 1 w/ each default density config
- dfltsetting[SETTING_RAYLEIGH_CONFIG].append(rayleighConfigDefault());
- dfltsetting[SETTING_MIE_CONFIG].append(mieConfigDefault());
- dfltsetting[SETTING_ABSORPTION_CONFIG].append(absorptionConfigDefault());
+ dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault();
+ dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault();
+ dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault();
return dfltsetting;
}
-LLSD LLSettingsSky::translateLegacySettings(LLSD legacy)
+LLSD LLSettingsSky::translateLegacyHazeSettings(const LLSD& legacy)
{
- LLSD newsettings(defaults());
+ LLSD legacyhazesettings;
// AdvancedAtmospherics TODO
// These need to be translated into density profile info in the new settings format...
-// LEGACY_ATMOSPHERICS
- if (legacy.has(SETTING_AMBIENT))
- {
- newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue();
- }
+// LEGACY_ATMOSPHERICS
if (legacy.has(SETTING_BLUE_DENSITY))
{
- newsettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue();
+ legacyhazesettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue();
}
if (legacy.has(SETTING_BLUE_HORIZON))
{
- newsettings[SETTING_BLUE_HORIZON] = LLColor3(legacy[SETTING_BLUE_HORIZON]).getValue();
+ legacyhazesettings[SETTING_BLUE_HORIZON] = LLColor3(legacy[SETTING_BLUE_HORIZON]).getValue();
}
if (legacy.has(SETTING_DENSITY_MULTIPLIER))
{
- newsettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(legacy[SETTING_DENSITY_MULTIPLIER][0].asReal());
+ legacyhazesettings[SETTING_DENSITY_MULTIPLIER] = LLSD::Real(legacy[SETTING_DENSITY_MULTIPLIER][0].asReal());
}
if (legacy.has(SETTING_DISTANCE_MULTIPLIER))
{
- newsettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(legacy[SETTING_DISTANCE_MULTIPLIER][0].asReal());
+ legacyhazesettings[SETTING_DISTANCE_MULTIPLIER] = LLSD::Real(legacy[SETTING_DISTANCE_MULTIPLIER][0].asReal());
}
if (legacy.has(SETTING_HAZE_DENSITY))
{
- newsettings[SETTING_HAZE_DENSITY] = LLSD::Real(legacy[SETTING_HAZE_DENSITY][0].asReal());
+ legacyhazesettings[SETTING_HAZE_DENSITY] = LLSD::Real(legacy[SETTING_HAZE_DENSITY][0].asReal());
}
if (legacy.has(SETTING_HAZE_HORIZON))
{
- newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal());
+ legacyhazesettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal());
}
- if (!legacy.has(SETTING_RAYLEIGH_CONFIG))
- {
- newsettings[SETTING_RAYLEIGH_CONFIG].append(rayleighConfigDefault());
- }
+ return legacyhazesettings;
+}
+
+LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
+{
+ LLSD newsettings(defaults());
- if (!legacy.has(SETTING_ABSORPTION_CONFIG))
+ // Move legacy haze parameters to an inner map
+ // allowing backward compat and simple conversion to legacy format
+ LLSD legacyhazesettings;
+ legacyhazesettings = translateLegacyHazeSettings(legacy);
+ if (legacyhazesettings.size() > 0)
{
- newsettings[SETTING_ABSORPTION_CONFIG].append(absorptionConfigDefault());
+ newsettings[SETTING_LEGACY_HAZE] = legacyhazesettings;
}
- if (!legacy.has(SETTING_MIE_CONFIG))
+ if (legacy.has(SETTING_AMBIENT))
{
- newsettings[SETTING_MIE_CONFIG].append(mieConfigDefault());
+ newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue();
}
-
if (legacy.has(SETTING_CLOUD_COLOR))
{
newsettings[SETTING_CLOUD_COLOR] = LLColor3(legacy[SETTING_CLOUD_COLOR]).getValue();
@@ -691,11 +713,7 @@ LLSD LLSettingsSky::translateLegacySettings(LLSD legacy)
{
newsettings[SETTING_GLOW] = LLColor3(legacy[SETTING_GLOW]).getValue();
}
-
- if (legacy.has(SETTING_LIGHT_NORMAL))
- {
- newsettings[SETTING_LIGHT_NORMAL] = LLVector3(legacy[SETTING_LIGHT_NORMAL]).getValue();
- }
+
if (legacy.has(SETTING_MAX_Y))
{
newsettings[SETTING_MAX_Y] = LLSD::Real(legacy[SETTING_MAX_Y][0].asReal());
@@ -713,50 +731,34 @@ LLSD LLSettingsSky::translateLegacySettings(LLSD legacy)
{
newsettings[SETTING_PLANET_RADIUS] = LLSD::Real(legacy[SETTING_PLANET_RADIUS].asReal());
}
- else
- {
- newsettings[SETTING_PLANET_RADIUS] = 6360.0f;
- }
if (legacy.has(SETTING_SKY_BOTTOM_RADIUS))
{
newsettings[SETTING_SKY_BOTTOM_RADIUS] = LLSD::Real(legacy[SETTING_SKY_BOTTOM_RADIUS].asReal());
}
- else
- {
- newsettings[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f;
- }
if (legacy.has(SETTING_SKY_TOP_RADIUS))
{
newsettings[SETTING_SKY_TOP_RADIUS] = LLSD::Real(legacy[SETTING_SKY_TOP_RADIUS].asReal());
}
- else
- {
- newsettings[SETTING_SKY_TOP_RADIUS] = 6420.0f;
- }
if (legacy.has(SETTING_SUN_ARC_RADIANS))
{
newsettings[SETTING_SUN_ARC_RADIANS] = LLSD::Real(legacy[SETTING_SUN_ARC_RADIANS].asReal());
}
- else
- {
- newsettings[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f;
- }
if (legacy.has(SETTING_LEGACY_EAST_ANGLE) && legacy.has(SETTING_LEGACY_SUN_ANGLE))
{ // convert the east and sun angles into a quaternion.
- F32 azimuth = legacy[SETTING_LEGACY_EAST_ANGLE].asReal();
+ F32 azimuth = legacy[SETTING_LEGACY_EAST_ANGLE].asReal();
F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal();
- LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude);
- LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude);
+ LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude);
+ LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, altitude);
- F32 az(0), al(0);
- ::angles_from_rotation(sunquat, az, al);
+ //LLVector3 sundir = DUE_EAST * sunquat;
+ //LLVector3 moondir = DUE_EAST * moonquat;
- newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
+ newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
newsettings[SETTING_MOON_ROTATION] = moonquat.getValue();
}
@@ -765,194 +767,285 @@ LLSD LLSettingsSky::translateLegacySettings(LLSD legacy)
void LLSettingsSky::updateSettings()
{
- LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKYVALUES);
- //LL_INFOS("WINDLIGHT", "SKY", "EEP") << "WL Parameters are dirty. Reticulating Splines..." << LL_ENDL;
+ mPositionsDirty = isDirty();
+ mLightingDirty = isDirty();
// base class clears dirty flag so as to not trigger recursive update
LLSettingsBase::updateSettings();
+}
- calculateHeavnlyBodyPositions();
- calculateLightSettings();
+bool LLSettingsSky::getIsSunUp() const
+{
+ LLVector3 sunDir = getSunDirection();
+ return sunDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
+}
+
+bool LLSettingsSky::getIsMoonUp() const
+{
+ LLVector3 moonDir = getMoonDirection();
+ return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
}
-void LLSettingsSky::calculateHeavnlyBodyPositions()
+void LLSettingsSky::calculateHeavenlyBodyPositions() const
{
- mSunDirection = DUE_EAST * getSunRotation();
+ if (!mPositionsDirty)
+ {
+ return;
+ }
+
+ mPositionsDirty = false;
+
+ LLQuaternion sunq = getSunRotation();
+ LLQuaternion moonq = getMoonRotation();
+
+ mSunDirection = DUE_EAST * sunq;
+ mMoonDirection = DUE_EAST * moonq;
+
mSunDirection.normalize();
- mMoonDirection = DUE_EAST * getMoonRotation();
mMoonDirection.normalize();
+}
+
+LLVector3 LLSettingsSky::getLightDirection() const
+{
+ calculateHeavenlyBodyPositions();
// is the normal from the sun or the moon
- if (mSunDirection.mV[1] >= 0.0)
+ if (getIsSunUp())
{
- mLightDirection = mSunDirection;
+ llassert(mSunDirection.length() > 0.01f);
+ return mSunDirection;
}
- else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > NIGHTTIME_ELEVATION_COS)
+ else if (getIsMoonUp())
{
- // clamp v1 to 0 so sun never points up and causes weirdness on some machines
- LLVector3 vec(mSunDirection);
- vec.mV[1] = 0.0;
- vec.normalize();
- mLightDirection = vec;
+ llassert(mMoonDirection.length() > 0.01f);
+ return mMoonDirection;
}
- else
+
+ return LLVector3::z_axis;
+}
+
+LLColor3 LLSettingsSky::getBlueDensity() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_BLUE_DENSITY))
{
- mLightDirection = mMoonDirection;
+ return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY]);
}
+ return LLColor3(0.2447f, 0.4487f, 0.7599f);
+}
- // calculate the clamp lightnorm for sky (to prevent ugly banding in sky
- // when haze goes below the horizon
- mClampedLightDirection = mLightDirection;
+LLColor3 LLSettingsSky::getBlueHorizon() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_BLUE_DENSITY))
+ {
+ return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON]);
+ }
+ return LLColor3(0.4954f, 0.4954f, 0.6399f);
+}
- if (mClampedLightDirection.mV[1] < -0.1f)
+F32 LLSettingsSky::getHazeDensity() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_HAZE_DENSITY))
{
- mClampedLightDirection.mV[1] = -0.1f;
- mClampedLightDirection.normalize();
+ return mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY].asReal();
}
+ return 0.7f;
}
-void LLSettingsSky::calculateLightSettings()
+F32 LLSettingsSky::getHazeHorizon() const
{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_HAZE_HORIZON))
+ {
+ return mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON].asReal();
+ }
+ return 0.19f;
+}
-// LEGACY_ATMOSPHERICS
- LLColor3 vary_HazeColor;
- LLColor3 vary_SunlightColor;
- LLColor3 vary_AmbientColor;
- {
- // Initialize temp variables
- LLColor3 sunlight = getSunlightColor();
- LLColor3 ambient = getAmbientColor();
- F32 gamma = getGamma();
- LLColor3 blue_density = getBlueDensity();
- LLColor3 blue_horizon = getBlueHorizon();
- F32 haze_density = getHazeDensity();
- F32 haze_horizon = getHazeHorizon();
-
- F32 density_multiplier = getDensityMultiplier();
- F32 max_y = getMaxY();
- F32 cloud_shadow = getCloudShadow();
- LLVector3 lightnorm = getLightDirection();
-
- // Sunlight attenuation effect (hue and brightness) due to atmosphere
- // this is used later for sunlight modulation at various altitudes
- LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y);
-
- // Calculate relative weights
- LLColor3 temp2(0.f, 0.f, 0.f);
- LLColor3 temp1 = blue_density + smear(haze_density);
- LLColor3 blue_weight = componentDiv(blue_density, temp1);
- LLColor3 haze_weight = componentDiv(smear(haze_density), temp1);
-
- // Compute sunlight from P & lightnorm (for long rays like sky)
- /// USE only lightnorm.
- // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] );
-
- // and vary_sunlight will work properly with moon light
- F32 lighty = lightnorm[1];
- if (lighty < NIGHTTIME_ELEVATION_COS)
- {
- lighty = -lighty;
- }
+F32 LLSettingsSky::getDensityMultiplier() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_DENSITY_MULTIPLIER))
+ {
+ return mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER].asReal();
+ }
+ return 0.0001f;
+}
- temp2.mV[1] = llmax(0.f, lighty);
- if(temp2.mV[1] > 0.f)
- {
- temp2.mV[1] = 1.f / temp2.mV[1];
- }
- componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1]));
+F32 LLSettingsSky::getDistanceMultiplier() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_DISTANCE_MULTIPLIER))
+ {
+ return mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER].asReal();
+ }
+ return 0.8f;
+}
- // Distance
- temp2.mV[2] = density_multiplier;
+void LLSettingsSky::setBlueDensity(const LLColor3 &val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue();
+ markDirty();
+}
- // Transparency (-> temp1)
- temp1 = componentExp((temp1 * -1.f) * temp2.mV[2]);
+void LLSettingsSky::setBlueHorizon(const LLColor3 &val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue();
+ markDirty();
+}
- // vary_AtmosAttenuation = temp1;
+void LLSettingsSky::setDensityMultiplier(F32 val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val;
+ markDirty();
+}
- //increase ambient when there are more clouds
- LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f;
+void LLSettingsSky::setDistanceMultiplier(F32 val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val;
+ markDirty();
+}
- //haze color
- vary_HazeColor =
- (blue_horizon * blue_weight * (sunlight*(1.f - cloud_shadow) + tmpAmbient)
- + componentMult(haze_horizon * haze_weight, sunlight*(1.f - cloud_shadow) * temp2.mV[0] + tmpAmbient)
- );
+void LLSettingsSky::setHazeDensity(F32 val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val;
+ markDirty();
+}
+void LLSettingsSky::setHazeHorizon(F32 val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val;
+ markDirty();
+}
- //brightness of surface both sunlight and ambient
- vary_SunlightColor = componentMult(sunlight, temp1) * 1.f;
- vary_SunlightColor.clamp();
- vary_SunlightColor = smear(1.0f) - vary_SunlightColor;
- vary_SunlightColor = componentPow(vary_SunlightColor, gamma);
- vary_SunlightColor = smear(1.0f) - vary_SunlightColor;
- vary_AmbientColor = componentMult(tmpAmbient, temp1) * 0.5;
- vary_AmbientColor.clamp();
- vary_AmbientColor = smear(1.0f) - vary_AmbientColor;
- vary_AmbientColor = componentPow(vary_AmbientColor, gamma);
- vary_AmbientColor = smear(1.0f) - vary_AmbientColor;
+// Sunlight attenuation effect (hue and brightness) due to atmosphere
+// this is used later for sunlight modulation at various altitudes
+LLColor3 LLSettingsSky::getLightAttenuation(F32 distance) const
+{
+// LEGACY_ATMOSPHERICS
+ LLColor3 blue_density = getBlueDensity();
+ F32 haze_density = getHazeDensity();
+ F32 density_multiplier = getDensityMultiplier();
+ LLColor3 density = (blue_density * 1.0 + smear(haze_density * 0.25f));
+ LLColor3 light_atten = density * density_multiplier * distance;
+ return light_atten;
+}
- componentMultBy(vary_HazeColor, LLColor3(1.f, 1.f, 1.f) - temp1);
+LLColor3 LLSettingsSky::getLightTransmittance() const
+{
+// LEGACY_ATMOSPHERICS
+ LLColor3 blue_density = getBlueDensity();
+ F32 haze_density = getHazeDensity();
+ F32 density_multiplier = getDensityMultiplier();
+ LLColor3 temp1 = blue_density + smear(haze_density);
+ // Transparency (-> temp1)
+ temp1 = componentExp((temp1 * -1.f) * density_multiplier);
+ return temp1;
+}
- }
+LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const
+{
+ F32 gamma = getGamma();
+ LLColor3 v(in);
+ v.clamp();
+ v= smear(1.0f) - v;
+ v = componentPow(v, gamma);
+ v = smear(1.0f) - v;
+ return v;
+}
- mSunDiffuse = vary_SunlightColor;
- mSunAmbient = vary_AmbientColor;
- mMoonDiffuse = vary_SunlightColor;
- mMoonAmbient = vary_AmbientColor;
+LLVector3 LLSettingsSky::getSunDirection() const
+{
+ calculateHeavenlyBodyPositions();
+ return mSunDirection;
+}
- mTotalAmbient = LLColor4(vary_AmbientColor, 1.0f);
+LLVector3 LLSettingsSky::getMoonDirection() const
+{
+ calculateHeavenlyBodyPositions();
+ return mMoonDirection;
+}
- mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f;
- mFadeColor.setAlpha(0);
+LLColor4U LLSettingsSky::getFadeColor() const
+{
+ calculateLightSettings();
+ return mFadeColor;
}
+LLColor4 LLSettingsSky::getMoonAmbient() const
+{
+ calculateLightSettings();
+ return mMoonAmbient;
+}
-//=========================================================================
-namespace
+LLColor3 LLSettingsSky::getMoonDiffuse() const
{
- LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude)
- {
- // Azimuth is traditionally calculated from North, we are going from East.
- LLQuaternion rot_azi;
- LLQuaternion rot_alt;
+ calculateLightSettings();
+ return mMoonDiffuse;
+}
- rot_azi.setAngleAxis(azimuth, VECT_ZENITH);
- rot_alt.setAngleAxis(-altitude, VECT_NORTHSOUTH);
+LLColor4 LLSettingsSky::getSunAmbient() const
+{
+ calculateLightSettings();
+ return mSunAmbient;
+}
- LLQuaternion body_quat = rot_alt * rot_azi;
- body_quat.normalize();
+LLColor3 LLSettingsSky::getSunDiffuse() const
+{
+ calculateLightSettings();
+ return mSunDiffuse;
+}
- //LLVector3 sun_vector = (DUE_EAST * body_quat);
- //_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL;
- return body_quat;
- }
+LLColor4 LLSettingsSky::getTotalAmbient() const
+{
+ calculateLightSettings();
+ return mTotalAmbient;
+}
- void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude)
+void LLSettingsSky::calculateLightSettings() const
+{
+ if (!mLightingDirty)
{
- LLVector3 body_vector = (DUE_EAST * quat);
+ return;
+ }
- LLVector3 body_az(body_vector[0], 0.f, body_vector[2]);
- LLVector3 body_al(0.f, body_vector[1], body_vector[2]);
-
- if (fabs(body_az.normalize()) > 0.001)
- {
- azimuth = angle_between(DUE_EAST, body_az);
- if (body_az[1] < 0.0f)
- azimuth = F_TWO_PI - azimuth;
- }
- else
- azimuth = 0.0f;
+ calculateHeavenlyBodyPositions();
- if (fabs(body_al.normalize()) > 0.001)
- {
- altitude = angle_between(DUE_EAST, body_al);
- if (body_al[2] < 0.0f)
- {
- altitude = F_TWO_PI - altitude;
- }
- }
- else
- altitude = 0.0f;
+ mLightingDirty = false;
+
+ // Initialize temp variables
+ LLColor3 sunlight = getSunlightColor();
+ LLColor3 ambient = getAmbientColor();
+ F32 cloud_shadow = getCloudShadow();
+ LLVector3 lightnorm = getLightDirection();
+
+ // Sunlight attenuation effect (hue and brightness) due to atmosphere
+ // this is used later for sunlight modulation at various altitudes
+ F32 max_y = getMaxY();
+ LLColor3 light_atten = getLightAttenuation(max_y);
+ LLColor3 light_transmittance = getLightTransmittance();
+
+ // and vary_sunlight will work properly with moon light
+ F32 lighty = lightnorm[1];
+
+ lighty = llmax(0.f, lighty);
+ if(lighty > 0.f)
+ {
+ lighty = 1.f / lighty;
}
-}
+ componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty));
+
+ //increase ambient when there are more clouds
+ LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f;
+ //brightness of surface both sunlight and ambient
+ mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance));
+ mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5);
+ mMoonDiffuse = gammaCorrect(componentMult(LLColor3::white, light_transmittance));
+ mMoonAmbient = gammaCorrect(componentMult(LLColor3::white, light_transmittance) * 0.5f);
+ mTotalAmbient = mSunAmbient;
+
+ mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f;
+ mFadeColor.setAlpha(0);
+}
+
+LLUUID LLSettingsSky::GetDefaultAssetId()
+{
+ return DEFAULT_ASSET_ID;
+} \ No newline at end of file
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index 82c2d6a804..fd613e4299 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -31,6 +31,12 @@
#include "llsettingsbase.h"
#include "v4coloru.h"
+const F32 EARTH_RADIUS = 6.370e6f;
+const F32 SUN_RADIUS = 695.508e6f;
+const F32 SUN_DIST = 149598.260e6f;
+const F32 MOON_RADIUS = 1.737e6f;
+const F32 MOON_DIST = 384.400e6f;
+
class LLSettingsSky: public LLSettingsBase
{
public:
@@ -66,6 +72,7 @@ public:
static const std::string SETTING_SKY_BOTTOM_RADIUS;
static const std::string SETTING_SKY_TOP_RADIUS;
static const std::string SETTING_SUN_ARC_RADIANS;
+ static const std::string SETTING_MIE_ANISOTROPY_FACTOR;
static const std::string SETTING_RAYLEIGH_CONFIG;
static const std::string SETTING_MIE_CONFIG;
@@ -77,16 +84,11 @@ public:
static const std::string SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR;
static const std::string SETTING_DENSITY_PROFILE_LINEAR_TERM;
static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM;
- static const std::string SETTING_MIE_ANISOTROPY_FACTOR;
-
- static const LLUUID DEFAULT_SUN_ID;
- static const LLUUID DEFAULT_MOON_ID;
- static const LLUUID DEFAULT_CLOUD_ID;
+
- static const LLUUID DEFAULT_ASSET_ID;
+ static const std::string SETTING_LEGACY_HAZE;
- typedef std::shared_ptr<LLSettingsSky> ptr_t;
- typedef std::pair<F32, F32> azimalt_t;
+ typedef PTR_NAMESPACE::shared_ptr<LLSettingsSky> ptr_t;
//---------------------------------------------------------------------
LLSettingsSky(const LLSD &data);
@@ -95,89 +97,68 @@ public:
virtual ptr_t buildClone() = 0;
//---------------------------------------------------------------------
- virtual std::string getSettingType() const override { return std::string("sky"); }
- virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_SKY; }
-
+ virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("sky"); }
+ virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_SKY; }
// Settings status
- virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override;
+ virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE;
static LLSD defaults();
- LLUUID getBloomTextureId() const
- {
- return mSettings[SETTING_BLOOM_TEXTUREID].asUUID();
- }
-
- //---------------------------------------------------------------------
- LLColor3 getAmbientColor() const
- {
- return LLColor3(mSettings[SETTING_AMBIENT]);
- }
-
- void setAmbientColor(const LLColor3 &val)
- {
- setValue(SETTING_AMBIENT, val);
- }
-
- LLColor3 getBlueDensity() const
- {
- return LLColor3(mSettings[SETTING_BLUE_DENSITY]);
- }
-
- void setBlueDensity(const LLColor3 &val)
+ F32 getPlanetRadius() const
{
- setValue(SETTING_BLUE_DENSITY, val);
+ return mSettings[SETTING_PLANET_RADIUS].asReal();
}
- LLColor3 getBlueHorizon() const
+ F32 getSkyBottomRadius() const
{
- return LLColor3(mSettings[SETTING_BLUE_HORIZON]);
+ return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal();
}
- void setBlueHorizon(const LLColor3 &val)
+ F32 getSkyTopRadius() const
{
- setValue(SETTING_BLUE_HORIZON, val);
+ return mSettings[SETTING_SKY_TOP_RADIUS].asReal();
}
- F32 getDensityMultiplier() const
+ F32 getSunArcRadians() const
{
- return mSettings[SETTING_DENSITY_MULTIPLIER].asReal();
+ return mSettings[SETTING_SUN_ARC_RADIANS].asReal();
}
- void setDensityMultiplier(F32 val)
+ F32 getMieAnisotropy() const
{
- setValue(SETTING_DENSITY_MULTIPLIER, val);
+ return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal();
}
-
- F32 getDistanceMultiplier() const
+
+ LLSD getRayleighConfigs() const
{
- return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal();
+ return mSettings[SETTING_RAYLEIGH_CONFIG];
}
- void setDistanceMultiplier(F32 val)
+ LLSD getMieConfigs() const
{
- setValue(SETTING_DISTANCE_MULTIPLIER, val);
+ return mSettings[SETTING_MIE_CONFIG];
}
- F32 getHazeDensity() const
+ LLSD getAbsorptionConfigs() const
{
- return mSettings[SETTING_HAZE_DENSITY].asReal();
+ return mSettings[SETTING_ABSORPTION_CONFIG];
}
- void setHazeDensity(F32 val)
+ LLUUID getBloomTextureId() const
{
- setValue(SETTING_HAZE_DENSITY, val);
+ return mSettings[SETTING_BLOOM_TEXTUREID].asUUID();
}
- F32 getHazeHorizon() const
+ //---------------------------------------------------------------------
+ LLColor3 getAmbientColor() const
{
- return mSettings[SETTING_HAZE_HORIZON].asReal();
+ return LLColor3(mSettings[SETTING_AMBIENT]);
}
- void setHazeHorizon(F32 val)
+ void setAmbientColor(const LLColor3 &val)
{
- setValue(SETTING_HAZE_HORIZON, val);
+ setValue(SETTING_AMBIENT, val);
}
LLColor3 getCloudColor() const
@@ -296,16 +277,6 @@ public:
setValue(SETTING_GLOW, val);
}
- LLVector3 getLightNormal() const
- {
- return LLVector3(mSettings[SETTING_LIGHT_NORMAL]);
- }
-
- void setLightNormal(const LLVector3 &val)
- {
- setValue(SETTING_LIGHT_NORMAL, val);
- }
-
F32 getMaxY() const
{
return mSettings[SETTING_MAX_Y].asReal();
@@ -326,15 +297,6 @@ public:
setValue(SETTING_MOON_ROTATION, val);
}
- azimalt_t getMoonRotationAzAl() const;
-
- void setMoonRotation(F32 azimuth, F32 altitude);
-
- void setMoonRotation(const azimalt_t &azialt)
- {
- setMoonRotation(azialt.first, azialt.second);
- }
-
LLUUID getMoonTextureId() const
{
return mSettings[SETTING_MOON_TEXTUREID].asUUID();
@@ -370,20 +332,11 @@ public:
return LLQuaternion(mSettings[SETTING_SUN_ROTATION]);
}
- azimalt_t getSunRotationAzAl() const;
-
void setSunRotation(const LLQuaternion &val)
{
setValue(SETTING_SUN_ROTATION, val);
}
- void setSunRotation(F32 azimuth, F32 altitude);
-
- void setSunRotation(const azimalt_t & azimalt)
- {
- setSunRotation(azimalt.first, azimalt.second);
- }
-
LLUUID getSunTextureId() const
{
return mSettings[SETTING_SUN_TEXTUREID].asUUID();
@@ -394,94 +347,71 @@ public:
setValue(SETTING_SUN_TEXTUREID, id);
}
- // Internal/calculated settings
- LLVector3 getLightDirection() const
- {
- update();
- return mLightDirection;
- };
-
- LLVector3 getClampedLightDirection() const
- {
- update();
- return mClampedLightDirection;
- };
-
- LLVector3 getSunDirection() const
+ //=====================================================================
+ // transient properties used in animations.
+ LLUUID getNextSunTextureId() const
{
- update();
- return mSunDirection;
+ return mNextSunTextureId;
}
- LLVector3 getMoonDirection() const
+ LLUUID getNextMoonTextureId() const
{
- update();
- return mMoonDirection;
+ return mNextMoonTextureId;
}
- LLColor4U getFadeColor() const
+ LLUUID getNextCloudNoiseTextureId() const
{
- update();
- return mFadeColor;
+ return mNextCloudTextureId;
}
- LLColor4 getMoonAmbient() const
- {
- update();
- return mMoonAmbient;
- }
+ //=====================================================================
+ virtual void loadTextures() { };
- LLColor3 getMoonDiffuse() const
- {
- update();
- return mMoonDiffuse;
- }
+ //=====================================================================
+ virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE;
+ static validation_list_t validationList();
- LLColor4 getSunAmbient() const
- {
- update();
- return mSunAmbient;
- }
+ static LLSD translateLegacySettings(const LLSD& legacy);
- LLColor3 getSunDiffuse() const
- {
- update();
- return mSunDiffuse;
- }
+// LEGACY_ATMOSPHERICS
+ static LLSD translateLegacyHazeSettings(const LLSD& legacy);
- LLColor4 getTotalAmbient() const
- {
- update();
- return mTotalAmbient;
- }
+ LLColor3 getLightAttenuation(F32 distance) const;
+ LLColor3 getLightTransmittance() const;
+ LLColor3 gammaCorrect(const LLColor3& in) const;
- //=====================================================================
- virtual void loadTextures() { };
- //=====================================================================
- virtual validation_list_t getValidationList() const override;
- static validation_list_t validationList();
+ LLColor3 getBlueDensity() const;
+ LLColor3 getBlueHorizon() const;
+ F32 getHazeDensity() const;
+ F32 getHazeHorizon() const;
+ F32 getDensityMultiplier() const;
+ F32 getDistanceMultiplier() const;
- static LLSD translateLegacySettings(LLSD legacy);
+ void setBlueDensity(const LLColor3 &val);
+ void setBlueHorizon(const LLColor3 &val);
+ void setDensityMultiplier(F32 val);
+ void setDistanceMultiplier(F32 val);
+ void setHazeDensity(F32 val);
+ void setHazeHorizon(F32 val);
- //=====================================================================
- // transient properties used in animations.
- LLUUID getNextSunTextureId() const
- {
- return mNextSunTextureId;
- }
+// Internal/calculated settings
+ bool getIsSunUp() const;
+ bool getIsMoonUp() const;
- LLUUID getNextMoonTextureId() const
- {
- return mNextMoonTextureId;
- }
+ LLVector3 getLightDirection() const;
+ LLVector3 getSunDirection() const;
+ LLVector3 getMoonDirection() const;
+ LLColor4U getFadeColor() const;
+ LLColor4 getMoonAmbient() const;
+ LLColor3 getMoonDiffuse() const;
+ LLColor4 getSunAmbient() const;
+ LLColor3 getSunDiffuse() const;
+ LLColor4 getTotalAmbient() const;
- LLUUID getNextCloudNoiseTextureId() const
- {
- return mNextCloudTextureId;
- }
+ virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); }
- virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); }
+ static LLUUID GetDefaultAssetId();
protected:
static const std::string SETTING_LEGACY_EAST_ANGLE;
@@ -490,36 +420,34 @@ protected:
LLSettingsSky();
- virtual stringset_t getSlerpKeys() const override;
-
- virtual void updateSettings() override;
+ virtual stringset_t getSlerpKeys() const SETTINGS_OVERRIDE;
+ virtual stringset_t getSkipInterpolateKeys() const SETTINGS_OVERRIDE;
+ virtual void updateSettings() SETTINGS_OVERRIDE;
private:
+ mutable bool mPositionsDirty;
+ mutable bool mLightingDirty;
+
static LLSD rayleighConfigDefault();
static LLSD absorptionConfigDefault();
static LLSD mieConfigDefault();
- static const F32 NIGHTTIME_ELEVATION;
- static const F32 NIGHTTIME_ELEVATION_COS;
+ void calculateHeavenlyBodyPositions() const;
+ void calculateLightSettings() const;
- void calculateHeavnlyBodyPositions();
- void calculateLightSettings();
-
- LLVector3 mSunDirection;
- LLVector3 mMoonDirection;
- LLVector3 mLightDirection;
- LLVector3 mClampedLightDirection;
+ mutable LLVector3 mSunDirection;
+ mutable LLVector3 mMoonDirection;
+ mutable LLVector3 mLightDirection;
static const F32 DOME_RADIUS;
static const F32 DOME_OFFSET;
- LLColor4U mFadeColor;
- LLColor4 mMoonAmbient;
- LLColor3 mMoonDiffuse;
- LLColor4 mSunAmbient;
- LLColor3 mSunDiffuse;
-
- LLColor4 mTotalAmbient;
+ mutable LLColor4U mFadeColor;
+ mutable LLColor4 mMoonAmbient;
+ mutable LLColor3 mMoonDiffuse;
+ mutable LLColor4 mSunAmbient;
+ mutable LLColor3 mSunDiffuse;
+ mutable LLColor4 mTotalAmbient;
LLUUID mNextSunTextureId;
LLUUID mNextMoonTextureId;
diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp
index aa1f0f1935..ba147baed7 100644
--- a/indra/llinventory/llsettingswater.cpp
+++ b/indra/llinventory/llsettingswater.cpp
@@ -67,11 +67,8 @@ const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow");
const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir");
const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir");
-const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL);
-
// *LAPRAS* Change when Agni
-const LLUUID LLSettingsWater::DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661");
-
+static const LLUUID DEFAULT_ASSET_ID("ce4cfe94-700a-292c-7c22-a2d9201bd661");
//=========================================================================
LLSettingsWater::LLSettingsWater(const LLSD &data) :
@@ -98,7 +95,7 @@ LLSD LLSettingsWater::defaults()
dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f);
dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f);
dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999);
- dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL_ID);
+ dfltsetting[SETTING_NORMAL_MAP] = LLSD::UUID(DEFAULT_WATER_NORMAL);
dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f, 2.0f, 2.0f).getValue();
dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f);
dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f);
@@ -168,7 +165,7 @@ LLSD LLSettingsWater::translateLegacySettings(LLSD legacy)
void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
{
- LLSettingsWater::ptr_t other = std::static_pointer_cast<LLSettingsWater>(end);
+ LLSettingsWater::ptr_t other = PTR_NAMESPACE::static_pointer_cast<LLSettingsWater>(end);
LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf);
replaceSettings(blenddata);
@@ -227,3 +224,13 @@ LLSettingsWater::validation_list_t LLSettingsWater::validationList()
return validation;
}
+LLUUID LLSettingsWater::GetDefaultAssetId()
+{
+ return DEFAULT_ASSET_ID;
+}
+
+LLUUID LLSettingsWater::GetDefaultWaterNormalAssetId()
+{
+ return DEFAULT_WATER_NORMAL;
+}
+
diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h
index ca32a46430..92e9869e45 100644
--- a/indra/llinventory/llsettingswater.h
+++ b/indra/llinventory/llsettingswater.h
@@ -46,11 +46,7 @@ public:
static const std::string SETTING_WAVE1_DIR;
static const std::string SETTING_WAVE2_DIR;
- static const LLUUID DEFAULT_WATER_NORMAL_ID;
-
- static const LLUUID DEFAULT_ASSET_ID;
-
- typedef std::shared_ptr<LLSettingsWater> ptr_t;
+ typedef PTR_NAMESPACE::shared_ptr<LLSettingsWater> ptr_t;
//---------------------------------------------------------------------
LLSettingsWater(const LLSD &data);
@@ -59,11 +55,11 @@ public:
virtual ptr_t buildClone() = 0;
//---------------------------------------------------------------------
- virtual std::string getSettingType() const override { return std::string("water"); }
- virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_WATER; }
+ virtual std::string getSettingType() const SETTINGS_OVERRIDE { return std::string("water"); }
+ virtual LLSettingsType::type_e getSettingTypeValue() const SETTINGS_OVERRIDE { return LLSettingsType::ST_WATER; }
// Settings status
- virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override;
+ virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) SETTINGS_OVERRIDE;
static LLSD defaults();
@@ -78,22 +74,22 @@ public:
setValue(SETTING_BLUR_MULTIPILER, val);
}
- LLColor3 getFogColor() const
+ LLColor3 getWaterFogColor() const
{
return LLColor3(mSettings[SETTING_FOG_COLOR]);
}
- void setFogColor(LLColor3 val)
+ void setWaterFogColor(LLColor3 val)
{
setValue(SETTING_FOG_COLOR, val);
}
- F32 getFogDensity() const
+ F32 getWaterFogDensity() const
{
return mSettings[SETTING_FOG_DENSITY].asReal();
}
- void setFogDensity(F32 val)
+ void setWaterFogDensity(F32 val)
{
setValue(SETTING_FOG_DENSITY, val);
}
@@ -208,12 +204,15 @@ public:
}
- virtual validation_list_t getValidationList() const override;
+ virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE;
static validation_list_t validationList();
static LLSD translateLegacySettings(LLSD legacy);
- virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); }
+ virtual LLSettingsBase::ptr_t buildDerivedClone() SETTINGS_OVERRIDE { return buildClone(); }
+
+ static LLUUID GetDefaultAssetId();
+ static LLUUID GetDefaultWaterNormalAssetId();
protected:
static const std::string SETTING_LEGACY_BLUR_MULTIPILER;
@@ -231,11 +230,11 @@ protected:
LLSettingsWater();
- LLVector4 mWaterPlane;
- F32 mWaterFogKS;
+ LLVector4 mWaterPlane;
+ F32 mWaterFogKS;
private:
- LLUUID mNextNormalMapID;
+ LLUUID mNextNormalMapID;
};
#endif