diff options
author | Graham Linden <graham@lindenlab.com> | 2018-06-22 00:41:19 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-06-22 00:41:19 +0100 |
commit | a02b3500b9979c10336eb13674279b3c07367445 (patch) | |
tree | ff8b1d336efd7d64c4ab235dbbf3a8e5d2bf8606 | |
parent | 52b946fd09196989e34afd7226a82060c4f8d831 (diff) |
Make LLSettingsFoo::defaults() funcs only calculate the invariant values once (use static trick ala the validations).
Fix conversion of legacy settings w/ non-zero east angles to account for those values being CW radian angles.
-rw-r--r-- | indra/llinventory/llsettingsdaycycle.cpp | 67 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 108 | ||||
-rw-r--r-- | indra/llinventory/llsettingswater.cpp | 39 | ||||
-rw-r--r-- | indra/newview/llsettingsvo.cpp | 9 |
4 files changed, 118 insertions, 105 deletions
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 7dc415e480..2c8bddee93 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -285,52 +285,51 @@ bool LLSettingsDay::initialize() //========================================================================= LLSD LLSettingsDay::defaults() { - LLSD dfltsetting; + static LLSD dfltsetting; - dfltsetting[SETTING_NAME] = "_default_"; - - LLSD frames(LLSD::emptyMap()); - LLSD waterTrack; - LLSD skyTrack; - - - const U32 FRAME_COUNT = 8; - const F32 FRAME_STEP = 1.0f / F32(FRAME_COUNT); - F32 time = 0.0f; - for (U32 i = 0; i < FRAME_COUNT; i++) + if (dfltsetting.size() == 0) { - std::string name("_default_"); - name += ('a' + i); - - std::string water_frame_name("water:"); - std::string sky_frame_name("sky:"); + dfltsetting[SETTING_NAME] = "_default_"; + dfltsetting[SETTING_TYPE] = "daycycle"; - water_frame_name += name; - sky_frame_name += name; + LLSD frames(LLSD::emptyMap()); + LLSD waterTrack; + LLSD skyTrack; - waterTrack[SETTING_KEYKFRAME] = time; - waterTrack[SETTING_KEYNAME] = water_frame_name; + + const U32 FRAME_COUNT = 8; + const F32 FRAME_STEP = 1.0f / F32(FRAME_COUNT); + F32 time = 0.0f; + for (U32 i = 0; i < FRAME_COUNT; i++) + { + std::string name("_default_"); + name += ('a' + i); - skyTrack[SETTING_KEYKFRAME] = time; - skyTrack[SETTING_KEYNAME] = sky_frame_name; + std::string water_frame_name("water:"); + std::string sky_frame_name("sky:"); - frames[water_frame_name] = LLSettingsWater::defaults(time); - frames[sky_frame_name] = LLSettingsSky::defaults(time); + water_frame_name += name; + sky_frame_name += name; - time += FRAME_STEP; - } + waterTrack[SETTING_KEYKFRAME] = time; + waterTrack[SETTING_KEYNAME] = water_frame_name; - LLSD tracks; - tracks.append(LLSDArray(waterTrack)); - tracks.append(LLSDArray(skyTrack)); + skyTrack[SETTING_KEYKFRAME] = time; + skyTrack[SETTING_KEYNAME] = sky_frame_name; - dfltsetting[SETTING_TRACKS] = tracks; + frames[water_frame_name] = LLSettingsWater::defaults(time); + frames[sky_frame_name] = LLSettingsSky::defaults(time); - + time += FRAME_STEP; + } - dfltsetting[SETTING_FRAMES] = frames; + LLSD tracks; + tracks.append(LLSDArray(waterTrack)); + tracks.append(LLSDArray(skyTrack)); - dfltsetting[SETTING_TYPE] = "daycycle"; + dfltsetting[SETTING_TRACKS] = tracks; + dfltsetting[SETTING_FRAMES] = frames; + } return dfltsetting; } diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 6f1520bdfa..bf0115b80b 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -40,7 +40,7 @@ static const LLVector3 DUE_EAST = LLVector3::x_axis; static LLQuaternion convert_azimuth_and_altitude_to_quat(F32 azimuth, F32 altitude) { LLQuaternion quat; - quat.setEulerAngles(0.0f, -altitude, azimuth); + quat.setEulerAngles(0.0f, altitude, azimuth); return quat; } @@ -585,53 +585,57 @@ LLSD LLSettingsSky::mieConfigDefault() LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) { - LLSD dfltsetting; - LLQuaternion sunquat; - LLQuaternion moonquat; - - F32 azimuth = (F_PI * position) + (80.0f * DEG_TO_RAD); - F32 altitude = (F_PI * position); - - // give the sun and moon slightly different tracks through the sky - // instead of positioning them at opposite poles from each other... - 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)); - - // Magic constants copied form dfltsetting.xml - dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); - dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); - dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); - dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699); + static LLSD dfltsetting; + + if (dfltsetting.size() == 0) + { + LLQuaternion sunquat; + LLQuaternion moonquat; + + F32 azimuth = (F_PI * position) + (80.0f * DEG_TO_RAD); + F32 altitude = (F_PI * position); + + // give the sun and moon slightly different tracks through the sky + // instead of positioning them at opposite poles from each other... + 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)); + + // Magic constants copied form dfltsetting.xml + dfltsetting[SETTING_CLOUD_COLOR] = LLColor4(0.4099, 0.4099, 0.4099, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY1] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_POS_DENSITY2] = LLColor4(1.0000, 0.5260, 1.0000, 0.0).getValue(); + dfltsetting[SETTING_CLOUD_SCALE] = LLSD::Real(0.4199); + dfltsetting[SETTING_CLOUD_SCROLL_RATE] = LLSDArray(10.1999)(10.0109); + dfltsetting[SETTING_CLOUD_SHADOW] = LLSD::Real(0.2699); - dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); - dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); - dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); - dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); + dfltsetting[SETTING_DOME_OFFSET] = LLSD::Real(0.96f); + dfltsetting[SETTING_DOME_RADIUS] = LLSD::Real(15000.f); + dfltsetting[SETTING_GAMMA] = LLSD::Real(1.0); + dfltsetting[SETTING_GLOW] = LLColor4(5.000, 0.0010, -0.4799, 1.0).getValue(); - dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); - dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); - dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); - dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); - dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); - - dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1; - dfltsetting[SETTING_CLOUD_TEXTUREID] = GetDefaultCloudNoiseTextureId(); - dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId(); - dfltsetting[SETTING_SUN_TEXTUREID] = GetDefaultSunTextureId(); - - dfltsetting[SETTING_TYPE] = "sky"; - - // defaults are for earth... - dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f; - dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f; - dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f; - dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f; - - dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault(); - dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault(); - dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault(); + dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); + dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); + dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(0.0000); + dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); + dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); + + dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1; + dfltsetting[SETTING_CLOUD_TEXTUREID] = GetDefaultCloudNoiseTextureId(); + dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId(); + dfltsetting[SETTING_SUN_TEXTUREID] = GetDefaultSunTextureId(); + + dfltsetting[SETTING_TYPE] = "sky"; + + // defaults are for earth... + dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f; + dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f; + dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f; + dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f; + + dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault(); + dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault(); + dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault(); + } return dfltsetting; } @@ -769,11 +773,17 @@ 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 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + F32 two_pi = F_PI * 2.0f; + + // get counter-clockwise radian angle from clockwise legacy WL east angle... + F32 azimuth = two_pi - legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude); - LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, altitude); + + // original WL moon dir was diametrically opposed to the sun dir + LLQuaternion moonquat = convert_azimuth_and_altitude_to_quat(azimuth + F_PI, -altitude); //LLVector3 sundir = DUE_EAST * sunquat; //LLVector3 moondir = DUE_EAST * moonquat; diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp index 8eb65331ad..3e0c6dcb82 100644 --- a/indra/llinventory/llsettingswater.cpp +++ b/indra/llinventory/llsettingswater.cpp @@ -89,27 +89,30 @@ LLSettingsWater::LLSettingsWater() : //========================================================================= LLSD LLSettingsWater::defaults(const LLSettingsBase::TrackPosition& position) { - LLSD dfltsetting; + static LLSD dfltsetting; - // give the normal scale offset some variability over track time... - F32 normal_scale_offset = (position * 0.5f) - 0.25f; + if (dfltsetting.size() == 0) + { + // give the normal scale offset some variability over track time... + F32 normal_scale_offset = (position * 0.5f) - 0.25f; - // Magic constants copied form defaults.xml - dfltsetting[SETTING_BLUR_MULTIPILER] = LLSD::Real(0.04000f); - dfltsetting[SETTING_FOG_COLOR] = LLColor3(0.0156f, 0.1490f, 0.2509f).getValue(); - dfltsetting[SETTING_FOG_DENSITY] = LLSD::Real(2.0f); - dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); - dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); - dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); - dfltsetting[SETTING_TRANSPARENT_TEXTURE] = GetDefaultTransparentTextureAssetId(); - dfltsetting[SETTING_NORMAL_MAP] = GetDefaultWaterNormalAssetId(); - dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f + normal_scale_offset, 2.0f + normal_scale_offset, 2.0f + normal_scale_offset).getValue(); - dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); - dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); - dfltsetting[SETTING_WAVE1_DIR] = LLVector2(1.04999f, -0.42000f).getValue(); - dfltsetting[SETTING_WAVE2_DIR] = LLVector2(1.10999f, -1.16000f).getValue(); + // Magic constants copied form defaults.xml + dfltsetting[SETTING_BLUR_MULTIPILER] = LLSD::Real(0.04000f); + dfltsetting[SETTING_FOG_COLOR] = LLColor3(0.0156f, 0.1490f, 0.2509f).getValue(); + dfltsetting[SETTING_FOG_DENSITY] = LLSD::Real(2.0f); + dfltsetting[SETTING_FOG_MOD] = LLSD::Real(0.25f); + dfltsetting[SETTING_FRESNEL_OFFSET] = LLSD::Real(0.5f); + dfltsetting[SETTING_FRESNEL_SCALE] = LLSD::Real(0.3999); + dfltsetting[SETTING_TRANSPARENT_TEXTURE] = GetDefaultTransparentTextureAssetId(); + dfltsetting[SETTING_NORMAL_MAP] = GetDefaultWaterNormalAssetId(); + dfltsetting[SETTING_NORMAL_SCALE] = LLVector3(2.0f + normal_scale_offset, 2.0f + normal_scale_offset, 2.0f + normal_scale_offset).getValue(); + dfltsetting[SETTING_SCALE_ABOVE] = LLSD::Real(0.0299f); + dfltsetting[SETTING_SCALE_BELOW] = LLSD::Real(0.2000f); + dfltsetting[SETTING_WAVE1_DIR] = LLVector2(1.04999f, -0.42000f).getValue(); + dfltsetting[SETTING_WAVE2_DIR] = LLVector2(1.10999f, -1.16000f).getValue(); - dfltsetting[SETTING_TYPE] = "water"; + dfltsetting[SETTING_TYPE] = "water"; + } return dfltsetting; } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index deaaffb1f5..44bb9fc6f5 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -525,10 +525,11 @@ void LLSettingsVOSky::updateSettings() F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f); mSceneLightStrength = 2.0f * (1.0f + sun_dynamic_range * dp); - // Axis swaps convert from +x right, +z up, +y at - // to CFR +x at, +z up, +y right coord sys - LLVector3 sun_direction_cfr(sun_direction.mV[0], -sun_direction.mV[1], sun_direction.mV[2]); - LLVector3 moon_direction_cfr(moon_direction.mV[0], -moon_direction.mV[1], moon_direction.mV[2]); + // Axis swaps convert from "normal" (+x right, +z up, +y at) + // to CFR (+x at, +z up, +y right) coord sys + LLVector3 sun_direction_cfr(sun_direction.mV[1], sun_direction.mV[0], sun_direction.mV[2]); + LLVector3 moon_direction_cfr(moon_direction.mV[1], moon_direction.mV[0], moon_direction.mV[2]); + gSky.setSunAndMoonDirectionsCFR(sun_direction_cfr, moon_direction_cfr); gSky.setSunTextures(getSunTextureId(), getNextSunTextureId()); gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId()); |