diff options
| author | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-07-05 22:52:31 +0300 | 
|---|---|---|
| committer | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-07-05 22:52:31 +0300 | 
| commit | 02c9c49788c6677a4332246a8d748d3e002c712f (patch) | |
| tree | 3242752e3bca0c03000b039350a692ac2f3452b1 | |
| parent | 7aa7ee68387bf9393db023f6961340e8fa247bfb (diff) | |
STORM-1330 WIP Override region sun position when switching the region to fixed sky.
| -rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 50 | ||||
| -rw-r--r-- | indra/newview/llfloaterregioninfo.h | 8 | ||||
| -rw-r--r-- | indra/newview/llregioninfomodel.cpp | 15 | ||||
| -rw-r--r-- | indra/newview/llregioninfomodel.h | 4 | ||||
| -rw-r--r-- | indra/newview/llviewermessage.cpp | 4 | 
5 files changed, 74 insertions, 7 deletions
| diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index b6339387a9..59a996b2ed 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -2994,6 +2994,8 @@ bool LLDispatchEstateUpdateInfo::operator()(  		const LLUUID& invoice,  		const sparam_t& strings)  { +	lldebugs << "Received estate update" << llendl; +  	LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();  	if (!panel) return true; @@ -3020,10 +3022,13 @@ bool LLDispatchEstateUpdateInfo::operator()(  	F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f;  	if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE))  	{ +		// no need to overwrite region sun phase? +		lldebugs << "Estate uses global time" << llendl;  		panel->setGlobalTime(TRUE);  	}   	else  	{ +		lldebugs << "Estate sun hour: " << sun_hour << llendl;  		panel->setGlobalTime(FALSE);  		panel->setSunHour(sun_hour);  	} @@ -3355,6 +3360,33 @@ void LLPanelEnvironmentInfo::setDirty(bool dirty)  	getChildView("cancel_btn")->setEnabled(dirty);  } +void LLPanelEnvironmentInfo::sendRegionSunUpdate(F32 sun_angle) +{ +	LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); +	bool region_use_fixed_sky = sun_angle >= 0.f; + +	// Set sun hour. +	if (region_use_fixed_sky) +	{ +		LLWLParamSet param_set; +		LLSD params; +		std::string unused; +		if (!getSelectedSkyParams(params, unused)) +		{ +			return; +		} +		param_set.setAll(params); + +		// 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; + +	region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); +} +  void LLPanelEnvironmentInfo::populateWaterPresetsList()  {  	mWaterPresetCombo->removeall(); @@ -3634,6 +3666,7 @@ 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)  	{ @@ -3666,6 +3699,9 @@ 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  		{ @@ -3686,6 +3722,16 @@ 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. @@ -3705,6 +3751,10 @@ void LLPanelEnvironmentInfo::onBtnApply()  		return;  	} +	// Set the region sun phase/flags according to the chosen new preferences. +	sendRegionSunUpdate(sun_angle); + +	// Start spinning the progress indicator.  	setApplyProgress(true);  } diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 6075842e76..810a71f463 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -328,10 +328,10 @@ public:  	BOOL getGlobalTime();  	void setGlobalTime(bool b); -	BOOL getFixedSun(); +	BOOL getFixedSun();				// *TODO: deprecated -	F32 getSunHour(); -	void setSunHour(F32 sun_hour); +	F32 getSunHour();				// *TODO: deprecated +	void setSunHour(F32 sun_hour);	// *TODO: deprecated  	const std::string getEstateName() const;  	void setEstateName(const std::string& name); @@ -450,6 +450,8 @@ private:  	void setApplyProgress(bool started);  	void setDirty(bool dirty); +	void sendRegionSunUpdate(F32 sun_angle); +  	void populateWaterPresetsList();  	void populateSkyPresetsList();  	void populateDayCyclesList(); diff --git a/indra/newview/llregioninfomodel.cpp b/indra/newview/llregioninfomodel.cpp index e1ef57f8e9..6238f183c1 100644 --- a/indra/newview/llregioninfomodel.cpp +++ b/indra/newview/llregioninfomodel.cpp @@ -122,6 +122,18 @@ bool LLRegionInfoModel::getUseFixedSun() const  	return mRegionFlags & REGION_FLAGS_SUN_FIXED;  } +void LLRegionInfoModel::setUseFixedSun(bool fixed) +{ +	if (fixed) +	{ +		mRegionFlags |= REGION_FLAGS_SUN_FIXED; +	} +	else +	{ +		mRegionFlags &= ~REGION_FLAGS_SUN_FIXED; +	} +} +  void LLRegionInfoModel::update(LLMessageSystem* msg)  {  	reset(); @@ -192,8 +204,9 @@ void LLRegionInfoModel::sendEstateOwnerMessage(  	{  		std::vector<std::string>::const_iterator it = strings.begin();  		std::vector<std::string>::const_iterator end = strings.end(); -		for (; it != end; ++it) +		for (unsigned i = 0; it != end; ++it, ++i)  		{ +			lldebugs << "- [" << i << "] " << (*it) << llendl;  			msg->nextBlock("ParamList");  			msg->addString("Parameter", *it);  		} diff --git a/indra/newview/llregioninfomodel.h b/indra/newview/llregioninfomodel.h index cbb5e5210a..89efd82767 100644 --- a/indra/newview/llregioninfomodel.h +++ b/indra/newview/llregioninfomodel.h @@ -46,6 +46,8 @@ public:  	bool getUseFixedSun() const; +	void setUseFixedSun(bool fixed); +  	// *TODO: Add getters and make the data private.  	U8			mSimAccess;  	U8			mAgentLimit; @@ -63,7 +65,7 @@ public:  	F32			mWaterHeight;  	F32			mTerrainRaiseLimit;  	F32			mTerrainLowerLimit; -	F32			mSunHour; +	F32			mSunHour; // 6..30  	BOOL		mUseEstateSun; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index f6b01e92cb..9f7559ad15 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4265,8 +4265,8 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data)  	LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); -	//LL_DEBUGS("Messaging") << "time_synch() - " << sun_direction << ", " << sun_ang_velocity -	//		 << ", " << phase << LL_ENDL; +	LL_DEBUGS("Windlight Sync") << "time_synch() - " << sun_direction << ", " << sun_ang_velocity +		<< ", " << phase << LL_ENDL;  	gSky.setSunPhase(phase);  	gSky.setSunTargetDirection(sun_direction, sun_ang_velocity); | 
