summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2018-08-03 21:01:43 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2018-08-03 21:01:43 +0300
commit51abc168c03f80d63c85d4bb48624f440b585390 (patch)
treeb22814b42377bf217aa03408d64d9bd93baa0372 /indra/llinventory
parent6a54e0948d651963399da82cfc5672125b9442e7 (diff)
MAINT-8902 fix encroaching 'legacy' issues
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp106
-rw-r--r--indra/llinventory/llsettingsdaycycle.h4
2 files changed, 108 insertions, 2 deletions
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<LLSettingsBase::TrackPosition, LLSettingsBase::ptr_t> 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;