From 76ca42509870ef5c6f1cb7a7204dfbc519fa63da Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 3 Apr 2012 06:46:53 +1000 Subject: The next bit of WindLight refactoring, some prep work. Also fixes http://redmine.kokuaviewer.org/issues/415 in a better way. --- linden/indra/newview/llwaterparamset.h | 3 +- linden/indra/newview/llwlparammanager.cpp | 110 ++++++++++++++++++++++-------- linden/indra/newview/llwlparammanager.h | 7 ++ linden/indra/newview/llwlparamset.h | 4 +- 4 files changed, 91 insertions(+), 33 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llwaterparamset.h b/linden/indra/newview/llwaterparamset.h index efbad31..f2667ab 100644 --- a/linden/indra/newview/llwaterparamset.h +++ b/linden/indra/newview/llwaterparamset.h @@ -47,12 +47,13 @@ class LLWaterParamSet; class LLWaterParamSet { friend class LLWaterParamManager; + friend class LLWLParamManager; public: std::string mName; LLUUID mInventoryID; -private: +protected: LLSD mParamValues; diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index 8f1aa23..75592da 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp @@ -860,59 +860,109 @@ bool LLWLParamManager::isSettingsNotecard(std::string name) return (isSkySettingsNotecard(name) || isWaterSettingsNotecard(name)); } + +struct WLCombined userSet, regionSet, parcelSet, RLVSet; + //static void LLWLParamManager::apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky) +// TODO - Pass in scope and day cycle stuff. { LLWaterParamManager* waterMgr = LLWaterParamManager::instance(); LLWLParamManager* skyMgr = LLWLParamManager::instance(); + struct WLCombined* thisSet = &userSet; + +// if (region == scope) + thisSet = ®ionSet; +// if (parcel== scope) +// thisSet = &parcelSet; +// if (RLV == scope) +// thisSet = &RLVSet; + + thisSet->water.setAll(newWater->getAll()); + thisSet->water.mParamValues["normalMap"] = *newWaterNormal; + thisSet->sky.setAll(newSky->getAll()); + +// TODO - if scope is region or parcel, and not using server settings +// return + + thisSet->enabled = true; F32 fade = 0; //Instant bool error; fade = newSky->getFloat("fade", error); newWater->mName = sWaterPresetName; - if(fade != 0 && waterMgr->mCurParams.mName == sWaterPresetName)//Load the settings forcefully the first time + newSky->mName = sSkyPresetName; + LLWaterParamSet oldWaterSet = waterMgr->mCurParams; + LLWLParamSet oldWLSet = skyMgr->mCurParams; + + if (fade) { - LLWaterParamSet oldWset = waterMgr->mCurParams; - //This still needs done so that we update right, but load it to the old + // TODO - should copy the original, then set that here. + // The fade should delete this copy once it's done fading. waterMgr->removeParamSet( sWaterPresetName, false ); - waterMgr->addParamSet( sWaterPresetName, oldWset ); - waterMgr->savePreset( sWaterPresetName ); + waterMgr->addParamSet( sWaterPresetName, oldWaterSet ); waterMgr->loadPreset( sWaterPresetName, true ); waterMgr->setNormalMapID( *newWaterNormal ); - //Then mix with the new - waterMgr->SetMixTime(newWater, fade); + + skyMgr->removeParamSet( sSkyPresetName, true ); + skyMgr->addParamSet( sSkyPresetName, oldWLSet ); + skyMgr->loadPreset( sSkyPresetName, true ); + } + + for(LLSD::map_const_iterator i = thisSet->water.mParamValues.beginMap(); + i != thisSet->water.mParamValues.endMap(); + ++i) + { + const std::string& param = i->first; + + if(i->second.isArray()) + { + for (int j = 0; j < i->second.size(); j++) + { + oldWaterSet.mParamValues[param][j] = i->second[j].asReal(); + } + } + else if(i->second.isReal()) + oldWaterSet.mParamValues[param] = i->second.asReal(); } - else + + skyMgr->mAnimator.mIsRunning = false; + skyMgr->mAnimator.mUseLindenTime = false; + for(LLSD::map_const_iterator i = thisSet->sky.mParamValues.beginMap(); + i != thisSet->sky.mParamValues.endMap(); + ++i) { - //Instant if fade is 0 - waterMgr->removeParamSet( sWaterPresetName, false ); - waterMgr->addParamSet( sWaterPresetName, *newWater ); - waterMgr->savePreset( sWaterPresetName ); - waterMgr->loadPreset( sWaterPresetName, true ); - waterMgr->setNormalMapID( *newWaterNormal ); + const std::string& param = i->first; + + if(i->second.isArray()) + { + for (int j = 0; j < i->second.size(); j++) + { + oldWLSet.mParamValues[param][j] = i->second[j].asReal(); + } + } + else if(i->second.isReal()) + oldWLSet.mParamValues[param] = i->second.asReal(); } - newSky->mName = sSkyPresetName; - if(fade != 0 && skyMgr->mCurParams.mName == sSkyPresetName)//Load the settings forcefully the first time +// TODO - If RLV enabled +// Loop through RLVSet, setting the values into the old one, but keeping old values that are not in RLVSet + + if (fade) { - LLWLParamSet oldset = skyMgr->mCurParams; - //This still needs done so that we update right, but load it to the old - skyMgr->removeParamSet( sSkyPresetName, true ); - skyMgr->addParamSet( sSkyPresetName, oldset ); - skyMgr->savePreset( sSkyPresetName ); - skyMgr->loadPreset( sSkyPresetName, true ); - //Then mix with the new - skyMgr->SetMixTime(newSky, fade); + waterMgr->SetMixTime(&oldWaterSet, fade); + skyMgr->SetMixTime(&oldWLSet, fade); } else { - //Instant if fade is 0 - skyMgr->mAnimator.mIsRunning = false; - skyMgr->mAnimator.mUseLindenTime = false; - skyMgr->removeParamSet( sSkyPresetName, false ); - skyMgr->addParamSet( sSkyPresetName, *newSky ); - skyMgr->savePreset( sSkyPresetName ); + waterMgr->removeParamSet( sWaterPresetName, false ); + waterMgr->addParamSet( sWaterPresetName, oldWaterSet ); + waterMgr->loadPreset( sWaterPresetName, true ); + waterMgr->setNormalMapID( *newWaterNormal ); + + skyMgr->removeParamSet( sSkyPresetName, true ); + skyMgr->addParamSet( sSkyPresetName, oldWLSet ); skyMgr->loadPreset( sSkyPresetName, true ); } diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h index 66975fa..4c7fdc1 100644 --- a/linden/indra/newview/llwlparammanager.h +++ b/linden/indra/newview/llwlparammanager.h @@ -333,4 +333,11 @@ inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const return mRotatedLightDir; } +struct WLCombined +{ + LLWaterParamSet water; + LLWLParamSet sky; + BOOL enabled; +}; + #endif diff --git a/linden/indra/newview/llwlparamset.h b/linden/indra/newview/llwlparamset.h index 3a59f6b..4b6f336 100644 --- a/linden/indra/newview/llwlparamset.h +++ b/linden/indra/newview/llwlparamset.h @@ -51,8 +51,8 @@ class LLWLParamSet { public: std::string mName; LLUUID mInventoryID; - -private: + +protected: LLSD mParamValues; -- cgit v1.1