summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-23 01:16:12 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-23 01:16:12 +0100
commit439273c9c11ec5f3c186fd7d97a28d11419153cd (patch)
treef6e4f1566425921d71e40b9628011eb0f5f539f3 /indra/llinventory
parent13536bb273b7413aa4461c8eeaf5a6a865f4234d (diff)
parent689beff6698fcb8582c44f58bb9896606850b149 (diff)
Merge
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingsbase.cpp12
-rw-r--r--indra/llinventory/llsettingsbase.h7
-rw-r--r--indra/llinventory/llsettingsdaycycle.cpp46
-rw-r--r--indra/llinventory/llsettingsdaycycle.h10
-rw-r--r--indra/llinventory/llsettingssky.cpp132
-rw-r--r--indra/llinventory/llsettingssky.h24
6 files changed, 66 insertions, 165 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index e297fbd94e..f870ec8904 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -207,11 +207,6 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
LLQuaternion q = slerp(mix, LLQuaternion(value), LLQuaternion(other_value));
newvalue = q.getValue();
}
- else if (value[0].type() == LLSD::TypeMap)
- {
- // TODO
- // determine if lerping between maps is both feasible and reasonable
- }
else
{ // TODO: We could expand this to inspect the type and do a deep lerp based on type.
// for now assume a heterogeneous array of reals.
@@ -219,6 +214,7 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
for (size_t i = 0; i < len; ++i)
{
+
newvalue[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix);
}
}
@@ -539,7 +535,7 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range)
//=========================================================================
void LLSettingsBlender::update(F64 blendf)
{
-
+ setPosition(blendf);
}
F64 LLSettingsBlender::setPosition(F64 blendf)
@@ -561,8 +557,8 @@ F64 LLSettingsBlender::setPosition(F64 blendf)
void LLSettingsBlender::triggerComplete()
{
mTarget->replaceSettings(mFinal->getSettings());
- LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon
- mOnFinished(shared_from_this());
+ LLSettingsBlender::ptr_t hold = shared_from_this(); // prevents this from deleting too soon
+ mOnFinished(shared_from_this());
}
//-------------------------------------------------------------------------
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index aebb3ddc5a..5b44dc4666 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -267,7 +267,7 @@ public:
typedef boost::signals2::connection connection_t;
LLSettingsBlender(const LLSettingsBase::ptr_t &target,
- const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64 span = 1.0) :
+ const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting) :
mOnFinished(),
mTarget(target),
mInitial(initsetting),
@@ -279,8 +279,9 @@ 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, F64 /*span*/ = 1.0)
{
+ // note: the 'span' reset parameter is unused by the base class.
mInitial = initsetting;
mFinal = endsetting;
mTarget->replaceSettings(mInitial->getSettings());
@@ -324,7 +325,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
public:
LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target,
const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, F64Seconds seconds) :
- LLSettingsBlender(target, initsetting, endsetting, seconds.value()),
+ LLSettingsBlender(target, initsetting, endsetting),
mBlendSpan(seconds),
mLastUpdate(0.0f),
mTimeSpent(0.0f)
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 5a6280884d..aa3fd4e0e6 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -551,23 +551,15 @@ bool LLSettingsDay::removeTrackKeyframe(S32 trackno, F32 frame)
void LLSettingsDay::setWaterAtKeyframe(const LLSettingsWaterPtr_t &water, F32 keyframe)
{
- mDayTracks[TRACK_WATER][llclamp(keyframe, 0.0f, 1.0f)] = water;
- setDirtyFlag(true);
+ setSettingsAtKeyframe(water, keyframe, TRACK_WATER);
}
-const LLSettingsWaterPtr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe)
+LLSettingsWater::ptr_t LLSettingsDay::getWaterAtKeyframe(F32 keyframe) const
{
- // todo: better way to identify keyframes?
- CycleTrack_t::iterator iter = mDayTracks[TRACK_WATER].find(keyframe);
- if (iter != mDayTracks[TRACK_WATER].end())
- {
- return std::dynamic_pointer_cast<LLSettingsWater>(iter->second);
- }
-
- return LLSettingsWaterPtr_t(NULL);
+ return std::dynamic_pointer_cast<LLSettingsWater>(getSettingsAtKeyframe(keyframe, TRACK_WATER));
}
-void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track)
+void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSky::ptr_t &sky, F32 keyframe, S32 track)
{
if ((track < 1) || (track >= TRACK_MAX))
{
@@ -575,44 +567,48 @@ void LLSettingsDay::setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe
return;
}
- mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = sky;
- setDirtyFlag(true);
+ setSettingsAtKeyframe(sky, keyframe, track);
}
-const LLSettingsSkyPtr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track)
+LLSettingsSky::ptr_t LLSettingsDay::getSkyAtKeyframe(F32 keyframe, S32 track) const
{
if ((track < 1) || (track >= TRACK_MAX))
{
LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL;
- return LLSettingsSkyPtr_t(NULL);
+ return LLSettingsSky::ptr_t();
}
- // todo: better way to identify keyframes?
- CycleTrack_t::iterator iter = mDayTracks[track].find(keyframe);
- if (iter != mDayTracks[track].end())
+ return std::dynamic_pointer_cast<LLSettingsSky>(getSettingsAtKeyframe(keyframe, track));
+}
+
+void LLSettingsDay::setSettingsAtKeyframe(const LLSettingsBase::ptr_t &settings, F32 keyframe, S32 track)
+{
+ if ((track < 0) || (track >= TRACK_MAX))
{
- return std::dynamic_pointer_cast<LLSettingsSky>(iter->second);
+ LL_WARNS("DAYCYCLE") << "Attempt to set track (#" << track << ") out of range!" << LL_ENDL;
+ return;
}
- return LLSettingsSkyPtr_t(NULL);
+ mDayTracks[track][llclamp(keyframe, 0.0f, 1.0f)] = settings;
+ setDirtyFlag(true);
}
-const LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track)
+LLSettingsBase::ptr_t LLSettingsDay::getSettingsAtKeyframe(F32 keyframe, S32 track) const
{
if ((track < 0) || (track >= TRACK_MAX))
{
LL_WARNS("DAYCYCLE") << "Attempt to set sky track (#" << track << ") out of range!" << LL_ENDL;
- return LLSettingsBase::ptr_t(NULL);
+ return LLSettingsBase::ptr_t();
}
// todo: better way to identify keyframes?
- CycleTrack_t::iterator iter = mDayTracks[track].find(keyframe);
+ CycleTrack_t::const_iterator iter = mDayTracks[track].find(keyframe);
if (iter != mDayTracks[track].end())
{
return iter->second;
}
- return LLSettingsSkyPtr_t(NULL);
+ return LLSettingsBase::ptr_t();
}
LLSettingsDay::TrackBound_t LLSettingsDay::getBoundingEntries(LLSettingsDay::CycleTrack_t &track, F32 keyframe)
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index 15a5b29f9f..9a89031aed 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -33,6 +33,8 @@
class LLSettingsWater;
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;
@@ -84,16 +86,16 @@ public:
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);
- const LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe);
+ LLSettingsWaterPtr_t getWaterAtKeyframe(F32 keyframe) const;
void setSkyAtKeyframe(const LLSettingsSkyPtr_t &sky, F32 keyframe, S32 track);
- const LLSettingsSkyPtr_t getSkyAtKeyframe(F32 keyframe, S32 track);
- const LLSettingsBase::ptr_t getSettingsAtKeyframe(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;
//---------------------------------------------------------------------
void startDayCycle();
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 6b8acac3da..e06cd7ca72 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -32,19 +32,23 @@
#include "llfasttimer.h"
#include "v3colorutil.h"
+#pragma optimize("", off)
+
+static const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees
+static const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD);
+
//=========================================================================
namespace
{
- // vectors in +x at, +y up, +z right coord sys
- 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");
+}
- LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude);
- void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude);
+static LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude)
+{
+ LLQuaternion body_quat;
+ body_quat.setEulerAngles(0.0f, -altitude, azimuth);
+ return body_quat;
}
const F32 LLSettingsSky::DOME_OFFSET(0.96f);
@@ -384,33 +388,6 @@ 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)
-{
- setValue(SETTING_SUN_ROTATION, ::body_position_from_angles(azimuth, altitude));
-}
-
-LLSettingsSky::azimalt_t LLSettingsSky::getSunRotationAzAl() const
-{
- azimalt_t res;
- ::angles_from_rotation(getSunRotation(), res.first, res.second);
-
- return res;
-}
-
LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
{
static stringset_t skipSet;
@@ -600,13 +577,10 @@ LLSD LLSettingsSky::defaults()
{
LLSD dfltsetting;
LLQuaternion sunquat;
+ LLQuaternion moonquat;
- // we're using the roll value of 80 degrees from horizon
- // with an euler angle conversion meant for a +x right, +y up, +z at coord sys here
- sunquat.setEulerAngles(1.39626, 0.0, 0.0); // 80deg Azumith/0deg East
-
- // then we're using the conjugate which does not give the opposite direction
- LLQuaternion moonquat = ~sunquat;
+ sunquat.setEulerAngles(0.0f, -1.39626, 0.0f); // 80 deg pitch / 0 deg azimuth from East
+ moonquat.setEulerAngles(0.0f, -1.39626, F_PI); // 80 deg pitch / 180 deg azimuth from East
// Magic constants copied form dfltsetting.xml
dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue();
@@ -683,7 +657,7 @@ LLSD LLSettingsSky::translateLegacyHazeSettings(const LLSD& legacy)
return legacyhazesettings;
}
-LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
+LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy, const std::string* name)
{
LLSD newsettings(defaults());
@@ -785,16 +759,21 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
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);
+ F32 pi_over_2 = F_PI * 0.5f;
+ LLQuaternion sunquat = body_position_from_angles(azimuth - pi_over_2, altitude);
+ LLQuaternion moonquat = body_position_from_angles(azimuth + pi_over_2, altitude);
- F32 az(0), al(0);
- ::angles_from_rotation(sunquat, az, al);
+ if (name)
+ {
+ LLVector3 sundir = LLVector3::x_axis * sunquat;
+ LLVector3 moondir = LLVector3::x_axis * moonquat;
+ LL_INFOS() << *name << " sun: " << sundir << " moon: " << moondir << LL_ENDL;
+ }
- newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
+ newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
newsettings[SETTING_MOON_ROTATION] = moonquat.getValue();
}
@@ -816,13 +795,13 @@ void LLSettingsSky::updateSettings()
bool LLSettingsSky::getIsSunUp() const
{
LLVector3 sunDir = getSunDirection();
- return sunDir.mV[1] > NIGHTTIME_ELEVATION_SIN;
+ return sunDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
}
bool LLSettingsSky::getIsMoonUp() const
{
LLVector3 moonDir = getMoonDirection();
- return moonDir.mV[1] > NIGHTTIME_ELEVATION_SIN;
+ return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
}
void LLSettingsSky::calculateHeavnlyBodyPositions()
@@ -830,10 +809,10 @@ void LLSettingsSky::calculateHeavnlyBodyPositions()
LLQuaternion sunq = getSunRotation();
LLQuaternion moonq = getMoonRotation();
- mSunDirection = DUE_EAST * sunq;
+ mSunDirection = LLVector3::x_axis * sunq;
mSunDirection.normalize();
- mMoonDirection = DUE_EAST * moonq;
+ mMoonDirection = LLVector3::x_axis * moonq;
mMoonDirection.normalize();
// is the normal from the sun or the moon
@@ -1037,54 +1016,3 @@ void LLSettingsSky::calculateLightSettings()
mFadeColor.setAlpha(0);
}
-
-//=========================================================================
-namespace
-{
- 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;
-
- rot_azi.setAngleAxis(azimuth, VECT_ZENITH);
- rot_alt.setAngleAxis(-altitude, VECT_NORTHSOUTH);
-
- LLQuaternion body_quat = rot_alt * rot_azi;
- body_quat.normalize();
-
- //LLVector3 sun_vector = (DUE_EAST * body_quat);
- //_WARNS("RIDER") << "Azimuth=" << azimuth << " Altitude=" << altitude << " Body Vector=" << sun_vector.getValue() << LL_ENDL;
- return body_quat;
- }
-
- void angles_from_rotation(LLQuaternion quat, F32 &azimuth, F32 &altitude)
- {
- LLVector3 body_vector = (DUE_EAST * quat);
-
- 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;
-
- 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;
- }
-}
-
-
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index bb8633d338..4c8a5e4016 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -37,9 +37,6 @@ const F32 SUN_DIST = 149598.260e6f;
const F32 MOON_RADIUS = 1.737e6f;
const F32 MOON_DIST = 384.400e6f;
-const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees
-const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD);
-
class LLSettingsSky: public LLSettingsBase
{
public:
@@ -96,7 +93,6 @@ public:
static const std::string SETTING_LEGACY_HAZE;
typedef std::shared_ptr<LLSettingsSky> ptr_t;
- typedef std::pair<F32, F32> azimalt_t;
//---------------------------------------------------------------------
LLSettingsSky(const LLSD &data);
@@ -315,15 +311,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();
@@ -359,20 +346,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();
@@ -468,7 +446,7 @@ public:
virtual validation_list_t getValidationList() const override;
static validation_list_t validationList();
- static LLSD translateLegacySettings(const LLSD& legacy);
+ static LLSD translateLegacySettings(const LLSD& legacy, const std::string* name = nullptr);
static LLSD translateLegacyHazeSettings(const LLSD& legacy);
LLColor3 getLightAttenuation(F32 distance) const;