From 51abc168c03f80d63c85d4bb48624f440b585390 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 3 Aug 2018 21:01:43 +0300 Subject: MAINT-8902 fix encroaching 'legacy' issues --- indra/llinventory/llsettingsdaycycle.cpp | 106 ++++++++++++++++++++++++++++++- indra/llinventory/llsettingsdaycycle.h | 4 +- 2 files changed, 108 insertions(+), 2 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index ff9614fb10..320e090bfd 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -118,8 +118,12 @@ 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); +const F32 LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR(0.02501f); + const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("283a26a3-b147-47b7-8057-cfff0302ec0e"); +// Minimum value to prevent multislider in edit floaters from eating up frames that 'encroach' on one another's space +static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f); //========================================================================= LLSettingsDay::LLSettingsDay(const LLSD &data) : LLSettingsBase(data), @@ -185,7 +189,7 @@ LLSD LLSettingsDay::getSettings() const return settings; } -bool LLSettingsDay::initialize() +bool LLSettingsDay::initialize(bool validate_frames) { LLSD tracks = mSettings[SETTING_TRACKS]; LLSD frames = mSettings[SETTING_FRAMES]; @@ -263,6 +267,106 @@ bool LLSettingsDay::initialize() else hassky |= true; + if (validate_frames && mDayTracks[i].size() > 0) + { + // check if we hit close to anything in the list + LLSettingsDay::CycleTrack_t::value_type frame = getSettingsNearKeyframe(keyframe, i, DEFAULT_FRAME_SLOP_FACTOR); + if (frame.second) + { + // figure out direction of search + LLSettingsBase::TrackPosition found = frame.first; + LLSettingsBase::TrackPosition new_frame = keyframe; + F32 total_frame_shift = 0; + // We consider frame DEFAULT_FRAME_SLOP_FACTOR away as still encroaching, so add minimum increment + F32 move_factor = DEFAULT_FRAME_SLOP_FACTOR + DEFAULT_MULTISLIDER_INCREMENT; + bool move_forward = true; + if ((new_frame < found && (found - new_frame) <= DEFAULT_FRAME_SLOP_FACTOR) + || (new_frame > found && (new_frame - found) > DEFAULT_FRAME_SLOP_FACTOR)) + { + move_forward = false; + } + + if (move_forward) + { + CycleTrack_t::iterator iter = mDayTracks[i].find(found); + new_frame = found; // for total_frame_shift + while (total_frame_shift < 1) + { + // calculate shifted position from previous found point + total_frame_shift += move_factor + (found >= new_frame ? found : found + 1) - new_frame; + new_frame = found + move_factor; + if (new_frame > 1) new_frame--; + + // we know that current point is too close, go for next one + iter++; + if (iter == mDayTracks[i].end()) + { + iter = mDayTracks[i].begin(); + } + + if ((iter->first >= (new_frame - DEFAULT_MULTISLIDER_INCREMENT) && (new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= iter->first) + || iter->first < new_frame && (new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= (iter->first + 1)) + { + // we are encroaching at new point as well + found = iter->first; + } + else // (new_frame + DEFAULT_FRAME_SLOP_FACTOR < iter->first) + { + //we found clear spot + break; + } + } + } + else + { + CycleTrack_t::reverse_iterator iter = mDayTracks[i].rbegin(); + while (iter->first != found) + { + iter++; + } + new_frame = found; // for total_frame_shift + while (total_frame_shift < 1) + { + // calculate shifted position from current found point + total_frame_shift += move_factor + new_frame - (found <= new_frame ? found : found - 1); + new_frame = found - move_factor; + if (new_frame < 0) new_frame++; + + // we know that current point is too close, go for next one + iter++; + if (iter == mDayTracks[i].rend()) + { + iter = mDayTracks[i].rbegin(); + } + + if ((iter->first <= (new_frame + DEFAULT_MULTISLIDER_INCREMENT) && (new_frame - DEFAULT_FRAME_SLOP_FACTOR) <= iter->first) + || iter->first > new_frame && (new_frame - DEFAULT_FRAME_SLOP_FACTOR) <= (iter->first - 1)) + { + // we are encroaching at new point as well + found = iter->first; + } + else // (new_frame - DEFAULT_FRAME_SLOP_FACTOR > iter->first) + { + //we found clear spot + break; + } + } + + + } + + if (total_frame_shift >= 1) + { + LL_WARNS() << "Could not fix frame position, adding as is to position: " << keyframe << LL_ENDL; + } + else + { + // Mark as new position + keyframe = new_frame; + } + } + } + // Build clone since: // - can use settings from "used" multiple times // - settings can reuse LLSDs they were initialized from diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h index 484c59e57f..974ca8660d 100644 --- a/indra/llinventory/llsettingsdaycycle.h +++ b/indra/llinventory/llsettingsdaycycle.h @@ -63,6 +63,8 @@ public: static const S32 TRACK_MAX; static const S32 FRAME_MAX; + static const F32 DEFAULT_FRAME_SLOP_FACTOR; + static const LLUUID DEFAULT_ASSET_ID; typedef std::map CycleTrack_t; @@ -76,7 +78,7 @@ public: LLSettingsDay(const LLSD &data); virtual ~LLSettingsDay() { }; - bool initialize(); + bool initialize(bool validate_frames = false); virtual ptr_t buildClone() = 0; virtual LLSD getSettings() const SETTINGS_OVERRIDE; -- cgit v1.3 From 881ee670d92f13ac518a74e1bff81bf69e07ccfa Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Aug 2018 15:41:28 -0700 Subject: Fix for mac build MAINT-8870, MAINT-8871: When legacy windlight fails load the default day cycle asset and use that. --- indra/llinventory/llsettingsdaycycle.cpp | 4 ++-- indra/newview/llenvironment.cpp | 23 ++++++++++++++++------- indra/newview/llenvironment.h | 3 ++- indra/newview/llwlhandlers.cpp | 7 +++++-- 4 files changed, 25 insertions(+), 12 deletions(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 320e090bfd..84ef145913 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -304,8 +304,8 @@ bool LLSettingsDay::initialize(bool validate_frames) iter = mDayTracks[i].begin(); } - if ((iter->first >= (new_frame - DEFAULT_MULTISLIDER_INCREMENT) && (new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= iter->first) - || iter->first < new_frame && (new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= (iter->first + 1)) + if (((iter->first >= (new_frame - DEFAULT_MULTISLIDER_INCREMENT)) && ((new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= iter->first)) + || ((iter->first < new_frame) && ((new_frame + DEFAULT_FRAME_SLOP_FACTOR) >= (iter->first + 1)))) { // we are encroaching at new point as well found = iter->first; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8f6a94962f..b2bd20d809 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -423,13 +423,17 @@ void LLEnvironment::onLegacyRegionSettings(LLSD data) LLUUID regionId = data[0]["regionID"].asUUID(); LLSettingsDay::ptr_t regionday; - if (data[1].isUndefined()) - regionday = LLSettingsVODay::buildDefaultDayCycle(); - else + if (!data[1].isUndefined()) regionday = LLSettingsVODay::buildFromLegacyMessage(regionId, data[1], data[2], data[3]); clearEnvironment(ENV_PARCEL); - setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + if (!regionday) + { + LL_WARNS("ENVIRONMENT") << "Unable to create day from legacy. Using default day cycle." << LL_ENDL; + setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId(), LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); + } + else + setEnvironment(ENV_REGION, regionday, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); updateEnvironment(); } @@ -570,12 +574,17 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId) { - LLSettingsVOBase::getSettingsAsset(assetId, - [this, env](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, status); }); + setEnvironment(env, assetId, LLSettingsDay::DEFAULT_DAYLENGTH, LLSettingsDay::DEFAULT_DAYOFFSET); +} + +void LLEnvironment::setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset) +{ + LLSettingsVOBase::getSettingsAsset(assetId, + [this, env, daylength, dayoffset](LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, LLExtStat) { onSetEnvAssetLoaded(env, asset_id, settings, daylength, dayoffset, status); }); } -void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status) +void LLEnvironment::onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 status) { if (!settings || status) { diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 80d186c9e6..eba1b737c8 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -172,6 +172,7 @@ public: void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); } void setEnvironment(EnvSelection_t env, const LLSettingsWater::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(LLSettingsSky::ptr_t(), fixed)); } void setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); } + void setEnvironment(EnvSelection_t env, const LLUUID &assetId, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset); void setEnvironment(EnvSelection_t env, const LLUUID &assetId); void clearEnvironment(EnvSelection_t env); @@ -368,7 +369,7 @@ private: void onAgentPositionHasChanged(const LLVector3 &localpos); - void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status); + void onSetEnvAssetLoaded(EnvSelection_t env, LLUUID asset_id, LLSettingsBase::ptr_t settings, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset, S32 status); void onUpdateParcelAssetLoaded(LLUUID asset_id, LLSettingsBase::ptr_t settings, S32 status, S32 parcel_id, S32 day_length, S32 day_offset); }; diff --git a/indra/newview/llwlhandlers.cpp b/indra/newview/llwlhandlers.cpp index 6aa379e0de..f0453b4d6d 100644 --- a/indra/newview/llwlhandlers.cpp +++ b/indra/newview/llwlhandlers.cpp @@ -80,6 +80,9 @@ bool LLEnvironmentRequest::doRequest() { LL_INFOS("WindlightCaps") << "Skipping windlight setting request - we don't have this capability" << LL_ENDL; // region is apparently not capable of this; don't respond at all + // (there shouldn't be any regions where this is the case... but + LL_INFOS("ENVIRONMENT") << "No legacy windlight caps... just set the region to be the default day." << LL_ENDL; + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId()); return false; } @@ -117,8 +120,8 @@ void LLEnvironmentRequest::environmentRequestCoro(std::string url) if (!status) { LL_WARNS("WindlightCaps") << "Got an error, not using region windlight... " << LL_ENDL; - LLEnvironment::instance().onLegacyRegionSettings(LLSD()); - + LLEnvironment::instance().setEnvironment(LLEnvironment::ENV_REGION, LLSettingsDay::GetDefaultAssetId()); + return; } result = result["content"]; -- cgit v1.3 From 133900d31a4f75621bad070043f5ef0125708a88 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Aug 2018 16:22:04 -0700 Subject: Miss an || && in an if --- indra/llinventory/llsettingsdaycycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llinventory') diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 84ef145913..ea57c8987f 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -340,7 +340,7 @@ bool LLSettingsDay::initialize(bool validate_frames) } if ((iter->first <= (new_frame + DEFAULT_MULTISLIDER_INCREMENT) && (new_frame - DEFAULT_FRAME_SLOP_FACTOR) <= iter->first) - || iter->first > new_frame && (new_frame - DEFAULT_FRAME_SLOP_FACTOR) <= (iter->first - 1)) + || ((iter->first > new_frame) && ((new_frame - DEFAULT_FRAME_SLOP_FACTOR) <= (iter->first - 1)))) { // we are encroaching at new point as well found = iter->first; -- cgit v1.3