summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-06-29 10:44:08 -0700
committerRider Linden <rider@lindenlab.com>2018-06-29 10:44:08 -0700
commit79570e276108c59f3384d49318835fdce35ce213 (patch)
treed10524caa2b0afcddec6094f9428c92cbe669f48 /indra/llinventory
parent19069ce25c30f6744310e015dbf767954efbd8ae (diff)
Fix moon rotation.
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingssky.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index b797c1b715..91d2e9b23d 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -36,28 +36,32 @@
static const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees
static const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD);
-static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude)
-{
- F32 sinTheta = sin(azimuth);
- F32 cosTheta = cos(azimuth);
- F32 sinPhi = sin(altitude);
- F32 cosPhi = cos(altitude);
+namespace {
+ LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude)
+ {
+ F32 sinTheta = sin(azimuth);
+ F32 cosTheta = cos(azimuth);
+ F32 sinPhi = sin(altitude);
+ F32 cosPhi = cos(altitude);
- LLVector3 dir;
- // +x right, +z up, +y at...
- dir.mV[0] = cosTheta * cosPhi;
- dir.mV[1] = sinTheta * cosPhi;
- dir.mV[2] = sinPhi;
+ LLVector3 dir;
+ // +x right, +z up, +y at...
+ dir.mV[0] = cosTheta * cosPhi;
+ dir.mV[1] = sinTheta * cosPhi;
+ dir.mV[2] = sinPhi;
- LLVector3 axis = LLVector3::x_axis % dir;
- axis.normalize();
+ LLVector3 axis = LLVector3::x_axis % dir;
+ axis.normalize();
+ if (mirror_axis)
+ axis *= -1;
- F32 angle = acos(LLVector3::x_axis * dir);
+ F32 angle = acos(LLVector3::x_axis * dir);
- LLQuaternion quat;
- quat.setAngleAxis(angle, axis);
+ LLQuaternion quat;
+ quat.setAngleAxis(angle, axis);
- return quat;
+ return quat;
+ }
}
static LLTrace::BlockTimerStatHandle FTM_BLEND_SKYVALUES("Blending Sky Environment");
@@ -613,8 +617,9 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position)
// give the sun and moon slightly different tracks through the sky
// instead of positioning them at opposite poles from each other...
+ // but keep them on opposite sides of the sky.
sunquat = convert_azimuth_and_altitude_to_quat(altitude, azimuth);
- moonquat = convert_azimuth_and_altitude_to_quat(altitude + (F_PI * 0.125f), azimuth + (F_PI * 0.125f));
+ moonquat = convert_azimuth_and_altitude_to_quat(-(altitude + (F_PI * 0.125f)), azimuth + (F_PI * 1.125f));
// Magic constants copied form dfltsetting.xml
dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue();
@@ -794,11 +799,10 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal();
LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude);
-
// original WL moon dir was diametrically opposed to the sun dir
- LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, altitude + F_PI);
+ LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, -altitude);
- newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
+ newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();
newsettings[SETTING_MOON_ROTATION] = moonquat.getValue();
}