diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 27f93880f2..f34bf71c3c 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2442,6 +2442,7 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mWater(), mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH), mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET), + mDayOffsetOverride(LLSettingsDay::MINIMUM_DAYOFFSET), // KC mBlenderSky(), mBlenderWater(), mInitialized(false), @@ -2551,6 +2552,7 @@ void LLEnvironment::DayInstance::clear() mWater.reset(); mDayLength = LLSettingsDay::DEFAULT_DAYLENGTH; mDayOffset = LLSettingsDay::DEFAULT_DAYOFFSET; + mDayOffsetOverride = LLSettingsDay::MINIMUM_DAYOFFSET; // KC mBlenderSky.reset(); mBlenderWater.reset(); mSkyTrack = 1; @@ -2574,7 +2576,8 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky LLSettingsBase::TrackPosition LLEnvironment::DayInstance::getProgress() const { LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - now += mDayOffset; + // now += mDayOffset; + now += mDayOffset + mDayOffsetOverride; // KC if ((mDayLength <= 0) || !mDayCycle) return -1.0f; // no actual day cycle. @@ -2591,7 +2594,8 @@ void LLEnvironment::DayInstance::animate() { LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch()); - now += mDayOffset; + // now += mDayOffset; + now += mDayOffset + mDayOffsetOverride; // KC if (!mDayCycle) return; @@ -2607,7 +2611,8 @@ void LLEnvironment::DayInstance::animate() { mWater = LLSettingsVOWater::buildDefaultWater(); mBlenderWater = std::make_shared(mWater, mDayCycle, 0, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + // mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + mDayLength, mDayOffset + mDayOffsetOverride, DEFAULT_UPDATE_THRESHOLD); // KC } // sky, initialize to track 1 @@ -2622,7 +2627,8 @@ void LLEnvironment::DayInstance::animate() { mSky = LLSettingsVOSky::buildDefaultSky(); mBlenderSky = std::make_shared(mSky, mDayCycle, 1, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + // mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + mDayLength, mDayOffset + mDayOffsetOverride, DEFAULT_UPDATE_THRESHOLD); // KC mBlenderSky->switchTrack(mSkyTrack, 0.0); } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index c287e0d3e6..3038c36286 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -260,9 +260,11 @@ public: LLSettingsWater::ptr_t getWater() const { return mWater; } LLSettingsDay::Seconds getDayLength() const { return mDayLength; } LLSettingsDay::Seconds getDayOffset() const { return mDayOffset; } + LLSettingsDay::Seconds getDayOffsetOverride() const { return mDayOffsetOverride; } //KC S32 getSkyTrack() const { return mSkyTrack; } void setDayOffset(LLSettingsBase::Seconds offset) { mDayOffset = offset; animate(); } + void setDayOffsetOverride(LLSettingsBase::Seconds offset) { mDayOffsetOverride = offset; animate(); } //KC virtual void animate(); @@ -284,6 +286,7 @@ public: LLSettingsDay::Seconds mDayLength; LLSettingsDay::Seconds mDayOffset; + LLSettingsDay::Seconds mDayOffsetOverride; S32 mLastTrackAltitude; LLSettingsBlender::ptr_t mBlenderSky; @@ -315,8 +318,9 @@ public: // public: + LLSettingsDay::Seconds getDayLength() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getDayLength() : LLSettingsDay::MINIMUM_DAYOFFSET; } LLSettingsDay::Seconds getDayOffset() const { return (mCurrentEnvironment) ? mCurrentEnvironment->getDayOffset() : LLSettingsDay::INVALID_DAYOFFSET; } - void setDayOffset(LLSettingsBase::Seconds offset) { if (mCurrentEnvironment) mCurrentEnvironment->setDayOffset(offset); } + void setDayOffsetOverride(LLSettingsBase::Seconds offset) { if (mCurrentEnvironment) mCurrentEnvironment->setDayOffsetOverride(offset); } // protected: diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index cea41ae90f..3c5cf5e50d 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -35,6 +35,7 @@ #include "fscommon.h" #include "llagent.h" #include "llappviewer.h" +#include "llcallbacklist.h" #include "llcheckboxctrl.h" #include "llcolorswatch.h" #include "llcombobox.h" @@ -210,7 +211,9 @@ void FloaterQuickPrefs::initCallbacks() getChild("DCPrevPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickDayCyclePrev, this)); getChild("DCNextPreset")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickDayCycleNext, this)); getChild("ResetToRegionDefault")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onClickResetToRegionDefault, this)); - getChild("WLSunPos")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onSunMoved, this)); + getChild("WLSunPos")->setSliderMouseUpCallback(boost::bind(&FloaterQuickPrefs::onDayOffset, this)); + getChild("SunAltitude")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onSunMoved, this)); + getChild("SunAzimuth")->setCommitCallback(boost::bind(&FloaterQuickPrefs::onSunMoved, this)); // Phototools additions if (getIsPhototools()) @@ -571,9 +574,13 @@ BOOL FloaterQuickPrefs::postBuild() mWaterPresetsCombo = getChild("WaterPresetsCombo"); mWLPresetsCombo = getChild("WLPresetsCombo"); mDayCyclePresetsCombo = getChild("DCPresetsCombo"); - mWLSunPos = getChild("WLSunPos"); - mWLSunPos->addSlider(0); - mWLSunPos->setMaxValue(LLSettingsDay::MAXIMUM_DAYOFFSET); + mWLDayOffset = getChild("WLSunPos"); + mWLDayOffset->addSlider(0); + // mWLDayOffset->setMaxValue(LLSettingsDay::MAXIMUM_DAYOFFSET); + + mWLSunAltitude = getChild("SunAltitude"); + mWLSunAzimuth = getChild("SunAzimuth"); + initCallbacks(); loadPresets(); @@ -877,33 +884,58 @@ void FloaterQuickPrefs::draw() //mWLSunPos->setCurSliderValue(val); // [/EEPMERGE] - - // Quick hack to see if this is viable - KC - LLSettingsDay::Seconds day_offset = LLEnvironment::instance().getDayOffset(); - if (day_offset > LLSettingsDay::INVALID_DAYOFFSET) + + // KC: Limit day cycle offset max to day length if less than a full real day + LLSettingsDay::Seconds day_length = LLEnvironment::instance().getDayLength(); + if (day_length > LLSettingsDay::MINIMUM_DAYOFFSET) { - mWLSunPos->setCurSliderValue(day_offset); + if (day_length < LLSettingsDay::MAXIMUM_DAYOFFSET) + { + mWLDayOffset->setMaxValue(day_length); + } + else + { + mWLDayOffset->setMaxValue(LLSettingsDay::MAXIMUM_DAYOFFSET); + } } - - // The fallowing kind of works for sun position, conflicts with above - // - Slider tick does not work properly - - // LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - // LLQuaternion sunq = psky->getSunRotation(); - // LLVector3 draw_point = VectorZero * sunq; - - // LL_INFOS() << "draw_point VX: " << draw_point.mV[VX] << LL_ENDL; - // LL_INFOS() << "draw_point VY: " << draw_point.mV[VY] << LL_ENDL; - - // draw_point.mV[VX] = draw_point.mV[VX] * 24.f; - // // draw_point.mV[VY] = draw_point.mV[VY] * 24.f; - // mWLSunPos->setCurSliderValue(draw_point.mV[VX]); + updateSun(); - LLTransientDockableFloater::draw(); + LLTransientDockableFloater::draw(); } -void FloaterQuickPrefs::onSunMoved() +void FloaterQuickPrefs::onIdle(void* user_data) +{ + FloaterQuickPrefs* floater_quickprefs = (FloaterQuickPrefs*)user_data; + floater_quickprefs->updateSun(); +} + +void FloaterQuickPrefs::updateSun() +{ + // The fallowing kind of works for sun position, conflicts with above + // - Slider tick does not work properly + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLQuaternion sunq = psky->getSunRotation(); + + F32 azimuth, altitude; + sunq.getAzimuthAndAltitude(azimuth, altitude); + + // LLVector3 draw_point = VectorZero * sunq; + + // LL_INFOS() << "draw_point VX: " << draw_point.mV[VX] << LL_ENDL; + // LL_INFOS() << "draw_point VY: " << draw_point.mV[VY] << LL_ENDL; + // LL_WARNS() << "==== altitude: " << altitude << " azimuth: " << azimuth << LL_ENDL; + + // draw_point.mV[VX] = draw_point.mV[VX] * 24.f; + // draw_point.mV[VY] = draw_point.mV[VY] * 24.f; + + // mWLSunAltitude->setValue(draw_point.mV[VX]); + // mWLSunAzimuth->setValue(draw_point.mV[VX]); + mWLSunAltitude->setValue(altitude); + mWLSunAzimuth->setValue(azimuth); +} + +void FloaterQuickPrefs::onDayOffset() { // [EEPMERGE] //if (LLEnvManagerNew::instance().getUseRegionSettings() || @@ -927,36 +959,43 @@ void FloaterQuickPrefs::onSunMoved() // Quick hack to see if this is viable - KC if (LLEnvironment::instance().getDayOffset() > LLSettingsDay::INVALID_DAYOFFSET) { - LLSettingsDay::Seconds day_offset(mWLSunPos->getCurSliderValue()); - LLEnvironment::instance().setDayOffset(day_offset); + LLSettingsDay::Seconds day_offset(mWLDayOffset->getCurSliderValue()); + LLEnvironment::instance().setDayOffsetOverride(day_offset); } - + updateSun(); +} + +void FloaterQuickPrefs::onSunMoved() +{ // The fallowing kind of works for sun position, conflicts with above // - Sometimes it seems that only the light source moves and not the visual sun - - // LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - // LLQuaternion sunq = psky->getSunRotation(); - - // F32 altitude = mWLSunPos->getCurSliderValue() / 24.0f; - // // F32 azimuth = mWLSunPos->getCurSliderValue() / 24.0f; - - // LLVector3 draw_point = VectorZero * sunq; - // if (draw_point.mV[VZ] >= 0.f) - // { - // if (is_approx_zero(altitude)) // don't change the hemisphere - // { - // altitude = F_APPROXIMATELY_ZERO; - // } - // altitude *= -1; - // } + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLQuaternion sunq = psky->getSunRotation(); + + F32 altitude = mWLSunAltitude->getValueF32(); + F32 azimuth = mWLSunAzimuth->getValueF32(); + + LLVector3 draw_point = VectorZero * sunq; + if (draw_point.mV[VZ] >= 0.f) + { + if (is_approx_zero(altitude)) // don't change the hemisphere + { + altitude = F_APPROXIMATELY_ZERO; + } + altitude *= -1; + } // sunq.setAngleAxis(altitude, 0, 1, 0); - // // LLQuaternion az_quat; - // // az_quat.setAngleAxis(azimuth, 0, 0, 1); - // // sunq *= az_quat; + // LLQuaternion az_quat; + // az_quat.setAngleAxis(azimuth, 0, 0, 1); + // sunq *= az_quat; + sunq.setFromAzimuthAndAltitude(azimuth, altitude); - // psky->setSunRotation(sunq); + psky->setSunRotation(sunq); + + updateSun(); } void FloaterQuickPrefs::onClickResetToRegionDefault() @@ -964,6 +1003,7 @@ void FloaterQuickPrefs::onClickResetToRegionDefault() mWLPresetsCombo->setValue(LLSD(PRESET_NAME_REGION_DEFAULT)); mWaterPresetsCombo->setValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + LLEnvironment::instance().setDayOffsetOverride(LLSettingsDay::MINIMUM_DAYOFFSET); LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_LOCAL); LLEnvironment::instance().setSelectedEnvironment(LLEnvironment::ENV_LOCAL); LLEnvironment::instance().updateEnvironment(); @@ -2215,6 +2255,19 @@ void FloaterQuickPrefs::dockToToolbarButton() } } +void FloaterQuickPrefs::onVisibilityChange(BOOL new_visibility) +{ + if (new_visibility) + { + gIdleCallbacks.addFunction(onIdle, this); + } + else + { + gIdleCallbacks.deleteFunction(onIdle, this); + } + +} + void FloaterQuickPrefs::onAvatarZOffsetSliderMoved() { F32 value = mAvatarZOffsetSlider->getValueF32(); diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index df52b3f6d2..da01ea285a 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -65,6 +65,8 @@ class FloaterQuickPrefs : public LLTransientDockableFloater private: FloaterQuickPrefs(const LLSD& key); ~FloaterQuickPrefs(); + + void onDayOffset(); void onSunMoved(); void selectSkyPreset(const LLSD& preset); @@ -111,9 +113,15 @@ public: void dockToToolbarButton(); + static void onIdle(void* user_data); + void updateSun(); + virtual void onVisibilityChange(BOOL new_visibility) override; + private: - LLMultiSliderCtrl* mWLSunPos; + LLMultiSliderCtrl* mWLDayOffset; + LLSlider* mWLSunAltitude; + LLSlider* mWLSunAzimuth; LLComboBox* mWLPresetsCombo; LLComboBox* mWaterPresetsCombo; LLComboBox* mDayCyclePresetsCombo; diff --git a/indra/newview/skins/default/xui/en/floater_quickprefs.xml b/indra/newview/skins/default/xui/en/floater_quickprefs.xml index 2a33f4f3eb..83d8251ec0 100644 --- a/indra/newview/skins/default/xui/en/floater_quickprefs.xml +++ b/indra/newview/skins/default/xui/en/floater_quickprefs.xml @@ -5,7 +5,7 @@ can_resize="false" can_dock="true" can_close="true" - height="183" + height="218" width="260" layout="topleft" name="quickprefs" @@ -20,7 +20,7 @@ left="0" top="16" width="260" - height="185" + height="203" follows="all" layout="topleft"> + + Sun Altitude: + + + + Sun Azimuth: + +