STORM-1269 FIXED Teleport to a region that has no env. settings now resets environment to defaults.

meow-7.2.2
Vadim ProductEngine 2011-05-19 21:10:34 +03:00
parent f02d6e7095
commit 0c358f78ab
5 changed files with 57 additions and 17 deletions

View File

@ -821,7 +821,7 @@ void LLEnvManagerNew::onRegionChange(bool interpolate)
void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content)
{
// 1. Refresh cached region settings.
LL_DEBUGS("Windlight") << "Caching region environment settings" << LL_ENDL;
LL_DEBUGS("Windlight") << "Caching region environment settings: " << content << LL_ENDL;
F32 sun_hour = 0; // *TODO
LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour);
mCachedRegionPrefs = new_settings;

View File

@ -264,11 +264,27 @@ void LLWaterParamManager::applyUserPrefs(bool interpolate)
LLSD target_water_params;
// Determine new water settings based on user prefs.
{
// Fall back to default water.
LLWaterParamSet default_water;
getParamSet("Default", default_water);
target_water_params = default_water.getAll();
}
if (LLEnvManagerNew::instance().getUseRegionSettings())
{
// *TODO: make sure whether region settings belong to the current region?
LL_DEBUGS("Windlight") << "Applying region water" << LL_ENDL;
target_water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams();
const LLSD& region_water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams();
if (region_water_params.size() != 0) // region has no water settings
{
LL_DEBUGS("Windlight") << "Applying region water" << LL_ENDL;
target_water_params = region_water_params;
}
else
{
LL_DEBUGS("Windlight") << "Applying default water" << LL_ENDL;
}
}
else
{
@ -280,7 +296,7 @@ void LLWaterParamManager::applyUserPrefs(bool interpolate)
}
// Apply them with or without interpolation.
if (target_water_params.isUndefined())
if (target_water_params.size() == 0)
{
llwarns << "Undefined target water params" << llendl;
return;

View File

@ -214,6 +214,7 @@ struct WaterExpFloatControl
/// WindLight parameter manager class - what controls all the wind light shaders
class LLWaterParamManager : public LLSingleton<LLWaterParamManager>
{
LOG_CLASS(LLWaterParamManager);
public:
/// load a preset file

View File

@ -585,30 +585,35 @@ void LLWLParamManager::update(LLViewerCamera * cam)
void LLWLParamManager::applyUserPrefs(bool interpolate)
{
LL_DEBUGS("Windlight") << "Applying sky prefs" << LL_ENDL;
// Remove all region sky presets because they may belong to a previously visited region.
clearParamSetsOfScope(LLEnvKey::SCOPE_REGION);
if (LLEnvManagerNew::instance().getUseRegionSettings()) // apply region-wide settings
{
// *TODO: Support fixed sky from region.
LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL;
const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings();
addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap());
mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION);
LL_DEBUGS("Windlight") << "Applying region time: " << region_settings.getDayTime()
<< " = " << region_settings.getDayTime() * 24.0f << " h" << LL_ENDL;
resetAnimator(region_settings.getDayTime(), true);
if (region_settings.getSkyMap().size() == 0)
{
applyDefaults();
}
else
{
// *TODO: Support fixed sky from region.
LL_DEBUGS("Windlight") << "Applying region sky" << LL_ENDL;
// Add all sky presets belonging to the current region.
addAllSkies(LLEnvKey::SCOPE_REGION, region_settings.getSkyMap());
// Apply region day cycle.
mDay.loadDayCycle(region_settings.getWLDayCycle(), LLEnvKey::SCOPE_REGION);
resetAnimator(region_settings.getDayTime(), true);
}
}
else // apply user-specified settings
{
if (LLEnvManagerNew::instance().getUseDayCycle())
{
std::string day_cycle = LLEnvManagerNew::instance().getDayCycleName();
LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL;
mDay.loadDayCycleFromFile(day_cycle + ".xml");
resetAnimator(0.5, true); // set to noon and start animator
applyDayCycle(LLEnvManagerNew::instance().getDayCycleName());
}
else
{
@ -620,6 +625,18 @@ void LLWLParamManager::applyUserPrefs(bool interpolate)
}
}
void LLWLParamManager::applyDefaults()
{
applyDayCycle("Default");
}
void LLWLParamManager::applyDayCycle(const std::string& day_cycle)
{
LL_DEBUGS("Windlight") << "Applying day cycle [" << day_cycle << "]" << LL_ENDL;
mDay.loadDayCycleFromFile(day_cycle + ".xml");
resetAnimator(0.5, true); // set to noon and start animator
}
void LLWLParamManager::resetAnimator(F32 curTime, bool run)
{
mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate,

View File

@ -238,6 +238,12 @@ public:
/// apply specified params
void applyUserPrefs(bool interpolate);
/// apply default sky params
void applyDefaults();
/// apply default sky params
void applyDayCycle(const std::string& day);
// get where the light is pointing
inline LLVector4 getLightDir(void) const;