diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-13 01:50:04 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-02-15 22:02:21 +0200 |
commit | 58827cb2752b9a184d638ed6a4f0efa0e9740d64 (patch) | |
tree | f72d8fe77e9fdaa4a636aeb06a1defb91c594323 /indra | |
parent | 5971c647e4abd11c4c4f055f124ac2251b720c25 (diff) |
SL-14725 Rotation sliders for sun and moon panels
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/llvirtualtrackball.cpp | 46 | ||||
-rw-r--r-- | indra/llui/llvirtualtrackball.h | 3 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.cpp | 119 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_fixedenvironment.xml | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_favorites.xml | 12 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml | 162 |
7 files changed, 294 insertions, 52 deletions
diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp index 723643dd25..15847a7282 100644 --- a/indra/llui/llvirtualtrackball.cpp +++ b/indra/llui/llvirtualtrackball.cpp @@ -348,6 +348,52 @@ LLQuaternion LLVirtualTrackball::getRotation() const return mValue; } +// static +void LLVirtualTrackball::getAzimuthAndElevation(const LLQuaternion &quat, F32 &azimuth, F32 &elevation) +{ + // LLQuaternion has own function to get azimuth, but it doesn't appear to return correct values (meant for 2d?) + const LLVector3 VectorZero(10000.0f, 0.0f, 0.0f); + LLVector3 point = VectorZero * quat; + + if (!is_approx_zero(point.mV[VX]) || !is_approx_zero(point.mV[VY])) + { + azimuth = atan2f(point.mV[VX], point.mV[VY]); + } + else + { + azimuth = 0; + } + + azimuth -= F_PI_BY_TWO; + + if (azimuth < 0) + { + azimuth += F_PI * 2; + } + + if (abs(point.mV[VY]) > abs(point.mV[VX]) && !is_approx_zero(point.mV[VY])) // to avoid precision drop + { + elevation = atanl((F64)point.mV[VZ] / (F64)abs(point.mV[VY])); + } + else if (!is_approx_zero(point.mV[VX])) + { + elevation = atanl((F64)point.mV[VZ] / (F64)abs(point.mV[VX])); + } + else + { + // both VX and VY are near zero, VZ should be high + elevation = point.mV[VZ] > 0 ? F_PI_BY_TWO : -F_PI_BY_TWO; + } +} + +// static +void LLVirtualTrackball::getAzimuthAndElevationDeg(const LLQuaternion &quat, F32 &azimuth, F32 &elevation) +{ + getAzimuthAndElevation(quat, azimuth, elevation); + azimuth *= RAD_TO_DEG; + elevation *= RAD_TO_DEG; +} + BOOL LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask) { if (hasMouseCapture()) diff --git a/indra/llui/llvirtualtrackball.h b/indra/llui/llvirtualtrackball.h index 2d4b1ece17..c7a893877b 100644 --- a/indra/llui/llvirtualtrackball.h +++ b/indra/llui/llvirtualtrackball.h @@ -96,6 +96,9 @@ public: void setRotation(const LLQuaternion &value); LLQuaternion getRotation() const; + static void getAzimuthAndElevation(const LLQuaternion &quat, F32 &azimuth, F32 &elevation); + static void getAzimuthAndElevationDeg(const LLQuaternion &quat, F32 &azimuth, F32 &elevation); + protected: friend class LLUICtrlFactory; LLVirtualTrackball(const Params&); diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 2e26b69144..06e406e2ab 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -69,11 +69,15 @@ namespace const std::string FIELD_SKY_GLOW_SIZE("glow_size"); const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness"); const std::string FIELD_SKY_SUN_ROTATION("sun_rotation"); + const std::string FIELD_SKY_SUN_AZIMUTH("sun_azimuth"); + const std::string FIELD_SKY_SUN_ELEVATION("sun_elevation"); const std::string FIELD_SKY_SUN_IMAGE("sun_image"); const std::string FIELD_SKY_SUN_SCALE("sun_scale"); const std::string FIELD_SKY_SUN_BEACON("sunbeacon"); const std::string FIELD_SKY_MOON_BEACON("moonbeacon"); const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); + const std::string FIELD_SKY_MOON_AZIMUTH("moon_azimuth"); + const std::string FIELD_SKY_MOON_ELEVATION("moon_elevation"); const std::string FIELD_SKY_MOON_IMAGE("moon_image"); const std::string FIELD_SKY_MOON_SCALE("moon_scale"); const std::string FIELD_SKY_MOON_BRIGHTNESS("moon_brightness"); @@ -473,12 +477,16 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild() getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); }); getChild<LLUICtrl>(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunAzimElevChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunAzimElevChanged(); }); getChild<LLUICtrl>(FIELD_SKY_SUN_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); }); getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); }); getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId()); getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetBlankSunTextureId()); getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setAllowNoTexture(TRUE); getChild<LLUICtrl>(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonAzimElevChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonAzimElevChanged(); }); getChild<LLUICtrl>(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); }); getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); @@ -537,13 +545,29 @@ void LLPanelSettingsSkySunMoonTab::refresh() getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B); getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness()); - getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation()); getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId()); getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setValue(mSkySettings->getSunScale()); - getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation()); getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId()); getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale()); getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setValue(mSkySettings->getMoonBrightness()); + + // Sun rotation values + F32 azimuth, elevation; + LLQuaternion quat = mSkySettings->getSunRotation(); + LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation); + + getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(quat); + getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth); + getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation); + + // Moon rotation values + quat = mSkySettings->getMoonRotation(); + LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation); + + getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(quat); + getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth); + getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation); + } //------------------------------------------------------------------------- @@ -583,10 +607,47 @@ void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() { - if (!mSkySettings) return; - mSkySettings->setSunRotation(getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation()); - mSkySettings->update(); - setIsDirty(); + LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation(); + + F32 azimuth, elevation; + LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation); + getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth); + getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation); + if (mSkySettings) + { + mSkySettings->setSunRotation(quat); + mSkySettings->update(); + setIsDirty(); + } +} + +void LLPanelSettingsSkySunMoonTab::onSunAzimElevChanged() +{ + F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal(); + F32 elevation = getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal(); + LLQuaternion quat = mSkySettings->getSunRotation(); + + azimuth *= DEG_TO_RAD; + elevation *= DEG_TO_RAD; + + if (is_approx_zero(elevation)) + { + elevation = F_APPROXIMATELY_ZERO; + } + + quat.setAngleAxis(-elevation, 0, 1, 0); + LLQuaternion az_quat; + az_quat.setAngleAxis(F_TWO_PI - azimuth, 0, 0, 1); + quat *= az_quat; + + getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(quat); + + if (mSkySettings) + { + mSkySettings->setSunRotation(quat); + mSkySettings->update(); + setIsDirty(); + } } void LLPanelSettingsSkySunMoonTab::onSunScaleChanged() @@ -607,10 +668,48 @@ void LLPanelSettingsSkySunMoonTab::onSunImageChanged() void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() { - if (!mSkySettings) return; - mSkySettings->setMoonRotation(getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation()); - mSkySettings->update(); - setIsDirty(); + LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation(); + + F32 azimuth, elevation; + LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation); + getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth); + getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation); + + if (mSkySettings) + { + mSkySettings->setMoonRotation(quat); + mSkySettings->update(); + setIsDirty(); + } +} + +void LLPanelSettingsSkySunMoonTab::onMoonAzimElevChanged() +{ + F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal(); + F32 elevation = getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal(); + LLQuaternion quat = mSkySettings->getMoonRotation(); + + azimuth *= DEG_TO_RAD; + elevation *= DEG_TO_RAD; + + if (is_approx_zero(elevation)) + { + elevation = F_APPROXIMATELY_ZERO; + } + + quat.setAngleAxis(-elevation, 0, 1, 0); + LLQuaternion az_quat; + az_quat.setAngleAxis(F_TWO_PI- azimuth, 0, 0, 1); + quat *= az_quat; + + getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(quat); + + if (mSkySettings) + { + mSkySettings->setMoonRotation(quat); + mSkySettings->update(); + setIsDirty(); + } } void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index c02c9c95a0..d1c558c902 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -124,9 +124,11 @@ private: void onGlowChanged(); void onStarBrightnessChanged(); void onSunRotationChanged(); + void onSunAzimElevChanged(); void onSunScaleChanged(); void onSunImageChanged(); void onMoonRotationChanged(); + void onMoonAzimElevChanged(); void onMoonScaleChanged(); void onMoonBrightnessChanged(); void onMoonImageChanged(); diff --git a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml index dbf91b0834..2cc73361f5 100644 --- a/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml +++ b/indra/newview/skins/default/xui/en/floater_fixedenvironment.xml @@ -89,7 +89,7 @@ follows="left|top|right|bottom" auto_resize="false" user_resize="false" - height="40" + height="35" visible="true"> <layout_stack follows="bottom|left|right" diff --git a/indra/newview/skins/default/xui/en/menu_favorites.xml b/indra/newview/skins/default/xui/en/menu_favorites.xml index be380e11e5..082f2f9670 100644 --- a/indra/newview/skins/default/xui/en/menu_favorites.xml +++ b/indra/newview/skins/default/xui/en/menu_favorites.xml @@ -21,20 +21,20 @@ parameter="about" /> </menu_item_call> <menu_item_call - label="Copy SLurl" + label="Show on Map" layout="topleft" - name="Copy slurl"> + name="Show On Map"> <menu_item_call.on_click function="Favorites.DoToSelected" - parameter="copy_slurl" /> + parameter="show_on_map" /> </menu_item_call> <menu_item_call - label="Show on Map" + label="Copy SLurl" layout="topleft" - name="Show On Map"> + name="Copy slurl"> <menu_item_call.on_click function="Favorites.DoToSelected" - parameter="show_on_map" /> + parameter="copy_slurl" /> </menu_item_call> <menu_item_separator diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml index 0e3de821d1..6be5aba545 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml @@ -38,7 +38,7 @@ height="10" layout="topleft" left_delta="10" - top_delta="30" + top_delta="25" width="100"> Position: </text> @@ -93,7 +93,7 @@ follows="left|top" height="10" layout="topleft" - left_delta="-5" + left_delta="65" top_delta="20" width="80"> Color: @@ -108,12 +108,58 @@ name="sun_moon_color" top_pad="5" width="60" /> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-235" + top_delta="-3" + width="200"> + Azimuth: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="359.99" + name="sun_azimuth" + top_delta="13" + width="215" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Elevation: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="-90" + max_val="90" + name="sun_elevation" + top_delta="13" + width="215" + can_edit_text="true"/> <text follows="left|top" height="10" layout="topleft" - left_delta="-160" - top_delta="27" + left_delta="-5" + top_delta="22" width="200"> Glow Focus: </text> @@ -128,8 +174,8 @@ min_val="-2" max_val="2" name="glow_focus" - top_delta="15" - width="250" + top_delta="13" + width="215" can_edit_text="true"/> <text follows="left|top" @@ -151,8 +197,8 @@ min_val="0" max_val="1.99" name="glow_size" - top_delta="15" - width="250" + top_delta="13" + width="215" can_edit_text="true"/> <text follows="left|top" @@ -174,8 +220,8 @@ min_val="0" max_val="500" name="star_brightness" - top_delta="15" - width="250" + top_delta="13" + width="215" can_edit_text="true"/> <check_box @@ -227,7 +273,7 @@ height="10" layout="topleft" left_delta="10" - top_delta="30" + top_delta="25" width="100"> Position: </text> @@ -278,30 +324,76 @@ top_delta="15" width="130" can_edit_text="true"/> - <text - follows="left|top" - height="10" - layout="topleft" - left_delta="-5" - top_delta="22" - width="200"> - Brightness: - </text> - <slider - decimal_digits="2" - follows="left|top" - height="16" - increment="0.01" - initial_value="0" - layout="topleft" - left_delta="5" - min_val="0.0" - max_val="1.0" - name="moon_brightness" - top_delta="15" - width="130" - can_edit_text="true"/> - <check_box + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-170" + top_delta="32" + width="200"> + Azimuth: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0" + max_val="359.99" + name="moon_azimuth" + top_delta="13" + width="215" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Elevation: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="-90" + max_val="90" + name="moon_elevation" + top_delta="13" + width="215" + can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Brightness: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.0" + max_val="1.0" + name="moon_brightness" + top_delta="13" + width="215" + can_edit_text="true"/> + <check_box control_name="moonbeacon" width="60" height="16" |