diff options
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 56 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.h | 7 | ||||
-rw-r--r-- | indra/newview/llregioninfomodel.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llviewermessage.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewerregion.cpp | 1 |
5 files changed, 34 insertions, 34 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 07c0878877..bedc7ef704 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -317,11 +317,8 @@ void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) // static void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { - LL_DEBUGS("Windlight") << "Processing region info" << LL_ENDL; - LLPanel* panel; LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); - llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; if(!floater) { return; @@ -330,6 +327,7 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) // We need to re-request environment setting here, // otherwise after we apply (send) updated region settings we won't get them back, // so our environment won't be updated. + // This is also the way to know about externally changed region environment. LLEnvManagerNew::instance().requestRegionSettings(); LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); @@ -3249,29 +3247,30 @@ void LLPanelEnvironmentInfo::setDirty(bool dirty) getChildView("cancel_btn")->setEnabled(dirty); } -void LLPanelEnvironmentInfo::sendRegionSunUpdate(F32 sun_angle) +void LLPanelEnvironmentInfo::sendRegionSunUpdate() { LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); - bool region_use_fixed_sky = sun_angle >= 0.f; - // Set sun hour. + // If the region is being switched to fixed sky, + // change the region's sun hour according to the (fixed) sun position. + // This is needed for llGetSunDirection() LSL function to work properly (STORM-1330). + const LLSD& sky_map = mNewRegionSettings.getSkyMap(); + bool region_use_fixed_sky = sky_map.size() == 1; if (region_use_fixed_sky) { LLWLParamSet param_set; - LLSD params; - std::string unused; - if (!getSelectedSkyParams(params, unused)) - { - return; - } - param_set.setAll(params); + llassert(sky_map.isMap()); + param_set.setAll(sky_map.beginMap()->second); + F32 sun_angle = param_set.getSunAngle(); + LL_DEBUGS("Windlight Sync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL; // convert value range from 0..2pi to 6..30 region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; } region_info.setUseFixedSun(region_use_fixed_sky); region_info.mUseEstateSun = !region_use_fixed_sky; + LL_DEBUGS("Windlight Sync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); } @@ -3555,7 +3554,6 @@ void LLPanelEnvironmentInfo::onBtnApply() LLSD day_cycle; LLSD sky_map; LLSD water_params; - F32 sun_angle = -1.f; // invalid value meaning no fixed sky if (use_defaults) { @@ -3588,9 +3586,6 @@ void LLPanelEnvironmentInfo::onBtnApply() param_set.setAll(params); refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here sky_map = LLWLParamManager::createSkyMap(refs); - - // Remember the sun angle to set fixed region sun hour below. - sun_angle = param_set.getSunAngle(); } else // use day cycle { @@ -3611,16 +3606,6 @@ void LLPanelEnvironmentInfo::onBtnApply() LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; day_cycle[0][0] = 0.0f; } - - // If the day cycle contains exactly one preset (i.e it's effectively a fixed sky), - // remember the preset's sun angle to set fixed region sun hour below. - if (sky_map.size() == 1) - { - LLWLParamSet param_set; - llassert(sky_map.isMap()); - param_set.setAll(sky_map.beginMap()->second); - sun_angle = param_set.getSunAngle(); - } } // Get water params. @@ -3640,8 +3625,9 @@ void LLPanelEnvironmentInfo::onBtnApply() return; } - // Set the region sun phase/flags according to the chosen new preferences. - sendRegionSunUpdate(sun_angle); + // When the settings get applied, we'll also send the region sun position update. + // To determine the sun angle we're going to need the new settings. + mNewRegionSettings = new_region_settings; // Start spinning the progress indicator. setApplyProgress(true); @@ -3672,10 +3658,18 @@ void LLPanelEnvironmentInfo::onRegionSettingschange() void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) { - LL_DEBUGS("Windlight") << "Applying region settings finished, stopping indicator" << LL_ENDL; // If applying new settings has failed, stop the indicator right away. // Otherwise it will be stopped when we receive the updated settings from server. - if (!ok) + if (ok) + { + // Set the region sun phase/flags according to the chosen new preferences. + // + // If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481). + // That is caused by the simulator re-sending the region info, which in turn makes us + // re-request and display old region environment settings while the new ones haven't been applied yet. + sendRegionSunUpdate(); + } + else { setApplyProgress(false); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 4809937324..e7917c382c 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -34,6 +34,8 @@ #include "llhost.h" #include "llpanel.h" +#include "llenvmanager.h" // for LLEnvironmentSettings + class LLAvatarName; class LLDispatcher; class LLLineEditor; @@ -431,7 +433,7 @@ private: void setApplyProgress(bool started); void setDirty(bool dirty); - void sendRegionSunUpdate(F32 sun_angle); + void sendRegionSunUpdate(); void populateWaterPresetsList(); void populateSkyPresetsList(); @@ -454,6 +456,9 @@ private: void onRegionSettingschange(); void onRegionSettingsApplied(bool ok); + /// New environment settings that are being applied to the region. + LLEnvironmentSettings mNewRegionSettings; + bool mEnableEditing; LLRadioGroup* mRegionSettingsRadioGroup; diff --git a/indra/newview/llregioninfomodel.cpp b/indra/newview/llregioninfomodel.cpp index 6238f183c1..698c4f9bb9 100644 --- a/indra/newview/llregioninfomodel.cpp +++ b/indra/newview/llregioninfomodel.cpp @@ -157,6 +157,7 @@ void LLRegionInfoModel::update(LLMessageSystem* msg) // actually the "last set" sun hour, not the current sun hour. JC msg->getF32(_PREHASH_RegionInfo, _PREHASH_SunHour, mSunHour); + LL_DEBUGS("Windlight Sync") << "Got region sun hour: " << mSunHour << LL_ENDL; // the only reasonable way to decide if we actually have any data is to // check to see if any of these fields have nonzero sizes diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 44b3a85f25..e934c38c22 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4346,8 +4346,7 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); - LL_DEBUGS("Windlight Sync") << "time_synch() - " << sun_direction << ", " << sun_ang_velocity - << ", " << phase << LL_ENDL; + LL_DEBUGS("Windlight Sync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; gSky.setSunPhase(phase); gSky.setSunTargetDirection(sun_direction, sun_ang_velocity); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 8ba231b28c..bb7170e0f7 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -645,6 +645,7 @@ void LLViewerRegion::processRegionInfo(LLMessageSystem* msg, void**) { // send it to 'observers' // *TODO: switch the floaters to using LLRegionInfoModel + llinfos << "Processing region info" << llendl; LLRegionInfoModel::instance().update(msg); LLFloaterGodTools::processRegionInfo(msg); LLFloaterRegionInfo::processRegionInfo(msg); |