summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llinventory/llsettingssky.cpp41
-rw-r--r--indra/newview/llsettingsvo.cpp68
2 files changed, 78 insertions, 31 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 0ba40e5e3d..e2fd681039 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -510,9 +510,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*")))));
validation.push_back(Validator(SETTING_DENSITY_MULTIPLIER, false, LLSD::TypeReal,
- boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f)))));
+ boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0001f)(2.0f)))));
validation.push_back(Validator(SETTING_DISTANCE_MULTIPLIER, false, LLSD::TypeReal,
- boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1000.0f)))));
+ boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0001f)(1000.0f)))));
validation.push_back(Validator(SETTING_BLOOM_TEXTUREID, true, LLSD::TypeUUID));
@@ -870,7 +870,7 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy)
// original WL moon dir was diametrically opposed to the sun dir
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();
}
@@ -943,6 +943,19 @@ LLVector3 LLSettingsSky::getLightDirection() const
return LLVector3::z_axis;
}
+LLColor3 LLSettingsSky::getAmbientColor() const
+{
+ if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT))
+ {
+ return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT]);
+ }
+ if (mSettings.has(SETTING_AMBIENT))
+ {
+ return LLColor3(mSettings[SETTING_AMBIENT]);
+ }
+ return LLColor3(0.25f, 0.25f, 0.25f);
+}
+
LLColor3 LLSettingsSky::getBlueDensity() const
{
if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_BLUE_DENSITY))
@@ -1025,17 +1038,23 @@ void LLSettingsSky::setMieAnisotropy(F32 aniso_factor)
void LLSettingsSky::setSkyMoistureLevel(F32 moisture_level)
{
- mSettings[SETTING_SKY_MOISTURE_LEVEL] = moisture_level;
+ setValue(SETTING_SKY_MOISTURE_LEVEL, moisture_level);
}
void LLSettingsSky::setSkyDropletRadius(F32 radius)
{
- mSettings[SETTING_SKY_DROPLET_RADIUS] = radius;
+ setValue(SETTING_SKY_DROPLET_RADIUS,radius);
}
void LLSettingsSky::setSkyIceLevel(F32 ice_level)
{
- mSettings[SETTING_SKY_ICE_LEVEL] = ice_level;
+ setValue(SETTING_SKY_ICE_LEVEL, ice_level);
+}
+
+void LLSettingsSky::setAmbientColor(const LLColor3 &val)
+{
+ mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue();
+ setDirtyFlag(true);
}
void LLSettingsSky::setBlueDensity(const LLColor3 &val)
@@ -1342,16 +1361,6 @@ LLUUID LLSettingsSky::getHaloTextureId() const
}
//---------------------------------------------------------------------
-LLColor3 LLSettingsSky::getAmbientColor() const
-{
- return LLColor3(mSettings[SETTING_AMBIENT]);
-}
-
-void LLSettingsSky::setAmbientColor(const LLColor3 &val)
-{
- setValue(SETTING_AMBIENT, val);
-}
-
LLColor3 LLSettingsSky::getCloudColor() const
{
return LLColor3(mSettings[SETTING_CLOUD_COLOR]);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index b33bdca512..dad7fc9448 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -534,15 +534,32 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildClone() const
void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings)
{
- // These will need to be inferred from new settings' density profiles
+ // These may need to be inferred from new settings' density profiles
+ // if the legacy settings values are not available.
if (settings.has(SETTING_LEGACY_HAZE))
{
LLSD legacyhaze = settings[SETTING_LEGACY_HAZE];
- legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f);
- legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0);
- legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0);
- legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f);
- legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal())(0.0f)(0.0f)(1.0f);
+
+ // work-around for setter formerly putting ambient values in wrong loc...
+ if (legacyhaze.has(SETTING_AMBIENT))
+ {
+ legacy[SETTING_AMBIENT] = ensure_array_4(legacyhaze[SETTING_AMBIENT], 1.0f);
+ }
+ else if (settings.has(SETTING_AMBIENT))
+ {
+ legacy[SETTING_AMBIENT] = ensure_array_4(settings[SETTING_AMBIENT], 1.0f);
+ }
+
+ legacy[SETTING_BLUE_DENSITY] = ensure_array_4(legacyhaze[SETTING_BLUE_DENSITY], 1.0);
+ legacy[SETTING_BLUE_HORIZON] = ensure_array_4(legacyhaze[SETTING_BLUE_HORIZON], 1.0);
+
+ F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal();
+ density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier;
+ legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f);
+
+ F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal();
+ legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f);
+
legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f);
legacy[SETTING_HAZE_HORIZON] = LLSDArray(legacyhaze[SETTING_HAZE_HORIZON])(0.0f)(0.0f)(1.0f);
}
@@ -570,19 +587,40 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA
legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS];
legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f);
- LLQuaternion sunquat = psky->getSunRotation();
+ LLVector3 dir = psky->getLightDirection();
+
+ F32 phi = asin(dir.mV[2]);
+ F32 cos_phi = cosf(phi);
+ F32 theta = (cos_phi != 0) ? asin(dir.mV[1] / cos_phi) : 0.0f;
- F32 roll;
- F32 pitch;
- F32 yaw;
+ theta = -theta;
- // get euler angles in right-handed X right, Y up, Z at
- sunquat.getEulerAngles(&roll, &pitch, &yaw);
+ // get angles back into valid ranges for legacy viewer...
+ //
+ while (theta < 0)
+ {
+ theta += F_PI * 2;
+ }
+
+ if (theta > 4 * F_PI)
+ {
+ theta = fmod(theta, 2 * F_PI);
+ }
- legacy[SETTING_LEGACY_EAST_ANGLE] = yaw;
- legacy[SETTING_LEGACY_SUN_ANGLE] = -pitch;
+ while (phi < -F_PI)
+ {
+ phi += 2 * F_PI;
+ }
+
+ if (phi > 3 * F_PI)
+ {
+ phi = F_PI + fmod(phi - F_PI, 2 * F_PI);
+ }
- return legacy;
+ legacy[SETTING_LEGACY_EAST_ANGLE] = theta;
+ legacy[SETTING_LEGACY_SUN_ANGLE] = phi;
+
+ return legacy;
}
//-------------------------------------------------------------------------