diff options
author | Rider Linden <rider@lindenlab.com> | 2018-06-12 12:39:59 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-06-12 12:39:59 -0700 |
commit | 2add1e7abdf536b32bfbfa4b353189782df8cb19 (patch) | |
tree | 35866e89acb21c13a6c14e078e6f45fc8d384126 /indra/llinventory | |
parent | 0f608cb764856ae8586a9d9631842a782cb70a23 (diff) |
Time threshold on timer based updates. Editor can replace frame with one from inventory. Extra check on adding a frame type.
Diffstat (limited to 'indra/llinventory')
-rw-r--r-- | indra/llinventory/llsettingsbase.cpp | 16 | ||||
-rw-r--r-- | indra/llinventory/llsettingsbase.h | 46 | ||||
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 15 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 81 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 7 |
5 files changed, 128 insertions, 37 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 1b3b5d2576..f28d90cb62 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -53,6 +53,7 @@ const std::string LLSettingsBase::SETTING_ID("id"); const std::string LLSettingsBase::SETTING_NAME("name"); const std::string LLSettingsBase::SETTING_HASH("hash"); const std::string LLSettingsBase::SETTING_TYPE("type"); +const std::string LLSettingsBase::SETTING_ASSETID("asset_id"); //========================================================================= LLSettingsBase::LLSettingsBase(): @@ -307,6 +308,7 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida static Validator validateId(SETTING_ID, false, LLSD::TypeUUID); static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger); static Validator validateType(SETTING_TYPE, false, LLSD::TypeString); + static Validator validateAssetId(SETTING_ASSETID, false, LLSD::TypeUUID); stringset_t validated; stringset_t strip; bool isValid(true); @@ -335,6 +337,13 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida } validated.insert(validateHash.getName()); + if (!validateAssetId.verify(settings)) + { + errors.append(LLSD::String("Invalid asset Id")); + isValid = false; + } + validated.insert(validateAssetId.getName()); + if (!validateType.verify(settings)) { errors.append( LLSD::String("Unable to validate 'type'.") ); @@ -595,12 +604,19 @@ LLSettingsBase::BlendFactor LLSettingsBlenderTimeDelta::calculateBlend(const LLS void LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& timedelta) { mTimeSpent += timedelta; + mTimeDeltaPassed += timedelta; if (mTimeSpent > mBlendSpan) { triggerComplete(); return; } + if (mTimeDeltaPassed < mTimeDeltaThreshold) + { + return; + } + + mTimeDeltaPassed = LLSettingsBase::Seconds(0.0); LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 5e40d185a1..f0d104ff53 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -67,6 +67,7 @@ public: static const std::string SETTING_NAME; static const std::string SETTING_HASH; static const std::string SETTING_TYPE; + static const std::string SETTING_ASSETID; typedef std::map<std::string, S32> parammapping_t; @@ -83,6 +84,7 @@ public: // Settings status inline bool hasSetting(const std::string ¶m) const { return mSettings.has(param); } inline bool isDirty() const { return mDirty; } + inline bool isVeryDirty() const { return mReplaced; } inline void setDirtyFlag(bool dirty) { mDirty = dirty; } size_t getHash() const; // Hash will not include Name, ID or a previously stored Hash @@ -102,11 +104,20 @@ public: setValue(SETTING_NAME, val); } + inline LLUUID getAssetId() const + { + if (mSettings.has(SETTING_ASSETID)) + return mSettings[SETTING_ASSETID].asUUID(); + return LLUUID(); + } + + inline void replaceSettings(LLSD settings) { mSettings = settings; mBlendedFactor = 0.0; setDirtyFlag(true); + mReplaced = true; } virtual LLSD getSettings() const; @@ -117,6 +128,8 @@ public: { mSettings[name] = value; mDirty = true; + if (mSettings.has(SETTING_ASSETID)) + mSettings.erase(SETTING_ASSETID); } inline void setValue(const std::string &name, const LLSD &value) @@ -176,7 +189,7 @@ public: // special consideration from getters. inline void update() const { - if (!mDirty) + if ((!mDirty) && (!mReplaced)) return; (const_cast<LLSettingsBase *>(this))->updateSettings(); } @@ -226,6 +239,12 @@ public: typedef std::vector<Validator> validation_list_t; static LLSD settingValidation(LLSD &settings, validation_list_t &validations); + + inline void setAssetId(LLUUID value) + { // note that this skips setLLSD + mSettings[SETTING_ASSETID] = value; + } + protected: LLSettingsBase(); @@ -249,7 +268,7 @@ protected: virtual stringset_t getSlerpKeys() const { return stringset_t(); } // Calculate any custom settings that may need to be cached. - virtual void updateSettings() { mDirty = false; }; + virtual void updateSettings() { mDirty = false; mReplaced = false; }; virtual validation_list_t getValidationList() const = 0; @@ -269,10 +288,9 @@ protected: mBlendedFactor = blendfactor; } - void markDirty() { mDirty = true; } - private: bool mDirty; + bool mReplaced; // super dirty! LLSD combineSDMaps(const LLSD &first, const LLSD &other) const; @@ -367,7 +385,9 @@ public: LLSettingsBlender(target, initsetting, endsetting), mBlendSpan(blend_span), mLastUpdate(0.0f), - mTimeSpent(0.0f) + mTimeSpent(0.0f), + mTimeDeltaThreshold(0.0f), + mTimeDeltaPassed(0.0f) { mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; @@ -384,11 +404,23 @@ public: mBlendSpan = blend_span; mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch()); mLastUpdate = mTimeStart; - mTimeSpent = LLSettingsBase::Seconds(0.0); + mTimeSpent = LLSettingsBase::Seconds(0.0f); + mTimeDeltaPassed = LLSettingsBase::Seconds(0.0f); } virtual void applyTimeDelta(const LLSettingsBase::Seconds& timedelta) SETTINGS_OVERRIDE; + inline void setTimeDeltaThreshold(const LLSettingsBase::Seconds time) + { + mTimeDeltaThreshold = time; + mTimeDeltaPassed = time + LLSettingsBase::Seconds(1.0); // take the next update call. + } + + inline LLSettingsBase::Seconds getTimeDeltaThreshold() const + { + return mTimeDeltaThreshold; + } + protected: LLSettingsBase::BlendFactor calculateBlend(const LLSettingsBase::TrackPosition& spanpos, const LLSettingsBase::TrackPosition& spanlen) const; @@ -396,6 +428,8 @@ protected: LLSettingsBase::Seconds mLastUpdate; LLSettingsBase::Seconds mTimeSpent; LLSettingsBase::Seconds mTimeStart; + LLSettingsBase::Seconds mTimeDeltaThreshold; + LLSettingsBase::Seconds mTimeDeltaPassed; }; diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 54cf5302fa..87233e18c3 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -26,6 +26,7 @@ */ #include "llsettingsdaycycle.h" +#include "llerror.h" #include <algorithm> #include <boost/make_shared.hpp> #include "lltrace.h" @@ -610,6 +611,20 @@ void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, return; } + std::string type = settings->getSettingsType(); + if ((track == TRACK_WATER) && (type != "water")) + { + LL_WARNS("DAYCYCLE") << "Attempt to add frame of type '" << type << "' to water track!" << LL_ENDL; + llassert(type == "water"); + return; + } + else if ((track != TRACK_WATER) && (type != "sky")) + { + LL_WARNS("DAYCYCLE") << "Attempt to add frame of type '" << type << "' to sky track!" << LL_ENDL; + llassert(type == "sky"); + return; + } + mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings; setDirtyFlag(true); } diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 38574c4ef8..87581e813b 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -32,25 +32,24 @@ #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 { LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment"); LLTrace::BlockTimerStatHandle FTM_UPDATE_SKYVALUES("Update Sky Environment"); -} -static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude) -{ - LLQuaternion quat; - quat.setEulerAngles(0.0f, -altitude, azimuth); - return quat; -} + const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees + const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD); + const LLVector3 DUE_EAST = LLVector3::x_axis; -const F32 LLSettingsSky::DOME_OFFSET(0.96f); -const F32 LLSettingsSky::DOME_RADIUS(15000.f); + LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude) + { + LLQuaternion quat; + quat.setEulerAngles(0.0f, -altitude, azimuth); + return quat; + } + +} //========================================================================= const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); @@ -114,6 +113,9 @@ static const LLUUID DEFAULT_ASSET_ID("cec9af47-90d4-9093-5245-397e5c9e7749"); const std::string LLSettingsSky::SETTING_LEGACY_HAZE("legacy_haze"); +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f); + namespace { @@ -771,11 +773,14 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) void LLSettingsSky::updateSettings() { - mPositionsDirty = isDirty(); - mLightingDirty = isDirty(); + mPositionsDirty |= isVeryDirty(); + mLightingDirty |= isVeryDirty(); // base class clears dirty flag so as to not trigger recursive update LLSettingsBase::updateSettings(); + + calculateHeavenlyBodyPositions(); + calculateLightSettings(); } bool LLSettingsSky::getIsSunUp() const @@ -798,6 +803,7 @@ void LLSettingsSky::calculateHeavenlyBodyPositions() const } mPositionsDirty = false; + mLightingDirty = true; // changes light direction LLQuaternion sunq = getSunRotation(); LLQuaternion moonq = getMoonRotation(); @@ -807,21 +813,27 @@ void LLSettingsSky::calculateHeavenlyBodyPositions() const mSunDirection.normalize(); mMoonDirection.normalize(); + + LL_WARNS("LAPRAS") << "Sun info: Rotation=" << sunq << " Vector=" << mSunDirection << LL_ENDL; + LL_WARNS("LAPRAS") << "Moon info: Rotation=" << moonq << " Vector=" << mMoonDirection << LL_ENDL; + + llassert(mSunDirection.lengthSquared() > 0.0); + llassert(mMoonDirection.lengthSquared() > 0.0); } LLVector3 LLSettingsSky::getLightDirection() const { - calculateHeavenlyBodyPositions(); + update(); // is the normal from the sun or the moon if (getIsSunUp()) { - llassert(mSunDirection.length() > 0.01f); + llassert(mSunDirection.lengthSquared() > 0.01f); return mSunDirection; } else if (getIsMoonUp()) { - llassert(mMoonDirection.length() > 0.01f); + llassert(mMoonDirection.lengthSquared() > 0.01f); return mMoonDirection; } @@ -885,36 +897,43 @@ F32 LLSettingsSky::getDistanceMultiplier() const void LLSettingsSky::setBlueDensity(const LLColor3 &val) { mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY] = val.getValue(); - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } void LLSettingsSky::setBlueHorizon(const LLColor3 &val) { mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON] = val.getValue(); - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } void LLSettingsSky::setDensityMultiplier(F32 val) { mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER] = val; - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } void LLSettingsSky::setDistanceMultiplier(F32 val) { mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER] = val; - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } void LLSettingsSky::setHazeDensity(F32 val) { mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY] = val; - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } + void LLSettingsSky::setHazeHorizon(F32 val) { mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON] = val; - markDirty(); + setDirtyFlag(true); + mLightingDirty = true; } // Sunlight attenuation effect (hue and brightness) due to atmosphere @@ -955,49 +974,49 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const LLVector3 LLSettingsSky::getSunDirection() const { - calculateHeavenlyBodyPositions(); + update(); return mSunDirection; } LLVector3 LLSettingsSky::getMoonDirection() const { - calculateHeavenlyBodyPositions(); + update(); return mMoonDirection; } LLColor4U LLSettingsSky::getFadeColor() const { - calculateLightSettings(); + update(); return mFadeColor; } LLColor4 LLSettingsSky::getMoonAmbient() const { - calculateLightSettings(); + update(); return mMoonAmbient; } LLColor3 LLSettingsSky::getMoonDiffuse() const { - calculateLightSettings(); + update(); return mMoonDiffuse; } LLColor4 LLSettingsSky::getSunAmbient() const { - calculateLightSettings(); + update(); return mSunAmbient; } LLColor3 LLSettingsSky::getSunDiffuse() const { - calculateLightSettings(); + update(); return mSunDiffuse; } LLColor4 LLSettingsSky::getTotalAmbient() const { - calculateLightSettings(); + update(); return mTotalAmbient; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index c30efe0781..a206106945 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -159,6 +159,7 @@ public: void setAmbientColor(const LLColor3 &val) { setValue(SETTING_AMBIENT, val); + mLightingDirty = true; } LLColor3 getCloudColor() const @@ -241,6 +242,7 @@ public: void setCloudShadow(F32 val) { setValue(SETTING_CLOUD_SHADOW, val); + mLightingDirty = true; } @@ -265,6 +267,7 @@ public: { mSettings[SETTING_GAMMA] = LLSD::Real(val); setDirtyFlag(true); + mLightingDirty = true; } LLColor3 getGlow() const @@ -285,6 +288,7 @@ public: void setMaxY(F32 val) { setValue(SETTING_MAX_Y, val); + mLightingDirty = true; } LLQuaternion getMoonRotation() const @@ -295,6 +299,7 @@ public: void setMoonRotation(const LLQuaternion &val) { setValue(SETTING_MOON_ROTATION, val); + mPositionsDirty = true; } LLUUID getMoonTextureId() const @@ -325,6 +330,7 @@ public: void setSunlightColor(const LLColor3 &val) { setValue(SETTING_SUNLIGHT_COLOR, val); + mLightingDirty = true; } LLQuaternion getSunRotation() const @@ -335,6 +341,7 @@ public: void setSunRotation(const LLQuaternion &val) { setValue(SETTING_SUN_ROTATION, val); + mPositionsDirty = true; } LLUUID getSunTextureId() const |