aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwaterparammanager.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llwaterparammanager.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llwaterparammanager.cpp')
-rw-r--r--linden/indra/newview/llwaterparammanager.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp
index fb09fd8..f4f1163 100644
--- a/linden/indra/newview/llwaterparammanager.cpp
+++ b/linden/indra/newview/llwaterparammanager.cpp
@@ -33,6 +33,8 @@
33 33
34#include "llwaterparammanager.h" 34#include "llwaterparammanager.h"
35 35
36#include "llrender.h"
37
36#include "pipeline.h" 38#include "pipeline.h"
37#include "llsky.h" 39#include "llsky.h"
38 40
@@ -84,9 +86,9 @@ LLWaterParamManager::~LLWaterParamManager()
84{ 86{
85} 87}
86 88
87void LLWaterParamManager::loadAllPresets(const LLString& file_name) 89void LLWaterParamManager::loadAllPresets(const std::string& file_name)
88{ 90{
89 LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); 91 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
90 LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL; 92 LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL;
91 93
92 //mParamList.clear(); 94 //mParamList.clear();
@@ -111,10 +113,10 @@ void LLWaterParamManager::loadAllPresets(const LLString& file_name)
111 // not much error checking here since we're getting rid of this 113 // not much error checking here since we're getting rid of this
112 std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4); 114 std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4);
113 115
114 LLString cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); 116 std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name));
115 LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL; 117 LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL;
116 118
117 std::ifstream water_xml(cur_path.c_str()); 119 llifstream water_xml(cur_path);
118 if (water_xml) 120 if (water_xml)
119 { 121 {
120 LLSD water_data(LLSD::emptyMap()); 122 LLSD water_data(LLSD::emptyMap());
@@ -122,12 +124,13 @@ void LLWaterParamManager::loadAllPresets(const LLString& file_name)
122 parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED); 124 parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED);
123 125
124 addParamSet(water_name, water_data); 126 addParamSet(water_name, water_data);
127 water_xml.close();
125 } 128 }
126 } 129 }
127 } 130 }
128} 131}
129 132
130void LLWaterParamManager::loadPreset(const LLString & name) 133void LLWaterParamManager::loadPreset(const std::string & name)
131{ 134{
132 // bugfix for SL-46920: preventing filenames that break stuff. 135 // bugfix for SL-46920: preventing filenames that break stuff.
133 char * curl_str = curl_escape(name.c_str(), name.size()); 136 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -140,7 +143,7 @@ void LLWaterParamManager::loadPreset(const LLString & name)
140 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); 143 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename));
141 llinfos << "Loading water settings from " << pathName << llendl; 144 llinfos << "Loading water settings from " << pathName << llendl;
142 145
143 std::ifstream presetsXML(pathName.c_str()); 146 llifstream presetsXML(pathName);
144 147
145 if (presetsXML) 148 if (presetsXML)
146 { 149 {
@@ -159,6 +162,7 @@ void LLWaterParamManager::loadPreset(const LLString & name)
159 { 162 {
160 setParamSet(name, paramsData); 163 setParamSet(name, paramsData);
161 } 164 }
165 presetsXML.close();
162 } 166 }
163 else 167 else
164 { 168 {
@@ -171,7 +175,7 @@ void LLWaterParamManager::loadPreset(const LLString & name)
171 propagateParameters(); 175 propagateParameters();
172} 176}
173 177
174void LLWaterParamManager::savePreset(const LLString & name) 178void LLWaterParamManager::savePreset(const std::string & name)
175{ 179{
176 // bugfix for SL-46920: preventing filenames that break stuff. 180 // bugfix for SL-46920: preventing filenames that break stuff.
177 char * curl_str = curl_escape(name.c_str(), name.size()); 181 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -189,7 +193,7 @@ void LLWaterParamManager::savePreset(const LLString & name)
189 paramsData = mParamList[name].getAll(); 193 paramsData = mParamList[name].getAll();
190 194
191 // write to file 195 // write to file
192 std::ofstream presetsXML(pathName.c_str()); 196 llofstream presetsXML(pathName);
193 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); 197 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
194 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); 198 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
195 presetsXML.close(); 199 presetsXML.close();
@@ -203,9 +207,9 @@ void LLWaterParamManager::propagateParameters(void)
203 // bind the variables only if we're using shaders 207 // bind the variables only if we're using shaders
204 if(gPipeline.canUseVertexShaders()) 208 if(gPipeline.canUseVertexShaders())
205 { 209 {
206 LLShaderMgr::shader_iter shaders_iter, end_shaders; 210 LLViewerShaderMgr::shader_iter shaders_iter, end_shaders;
207 end_shaders = LLShaderMgr::endShaders(); 211 end_shaders = LLViewerShaderMgr::instance()->endShaders();
208 for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) 212 for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
209 { 213 {
210 if (shaders_iter->mProgramObject != 0 214 if (shaders_iter->mProgramObject != 0
211 && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) 215 && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)
@@ -227,7 +231,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)
227{ 231{
228 if (shader->mShaderGroup == LLGLSLShader::SG_WATER) 232 if (shader->mShaderGroup == LLGLSLShader::SG_WATER)
229 { 233 {
230 shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, LLWLParamManager::instance()->getRotatedLightDir().mV); 234 shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::instance()->getRotatedLightDir().mV);
231 shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); 235 shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV);
232 shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV); 236 shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV);
233 shader->uniform4fv("waterPlane", 1, mWaterPlane.mV); 237 shader->uniform4fv("waterPlane", 1, mWaterPlane.mV);
@@ -287,9 +291,9 @@ void LLWaterParamManager::update(LLViewerCamera * cam)
287 sunMoonDir.normVec(); 291 sunMoonDir.normVec();
288 mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); 292 mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP);
289 293
290 LLShaderMgr::shader_iter shaders_iter, end_shaders; 294 LLViewerShaderMgr::shader_iter shaders_iter, end_shaders;
291 end_shaders = LLShaderMgr::endShaders(); 295 end_shaders = LLViewerShaderMgr::instance()->endShaders();
292 for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) 296 for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
293 { 297 {
294 if (shaders_iter->mProgramObject != 0 298 if (shaders_iter->mProgramObject != 0
295 && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER) 299 && shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)
@@ -386,7 +390,7 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr
386 390
387 if(delete_from_disk) 391 if(delete_from_disk)
388 { 392 {
389 LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); 393 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
390 394
391 // use full curl escaped name 395 // use full curl escaped name
392 char * curl_str = curl_escape(name.c_str(), name.size()); 396 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -425,7 +429,7 @@ LLWaterParamManager * LLWaterParamManager::instance()
425 { 429 {
426 sInstance = new LLWaterParamManager(); 430 sInstance = new LLWaterParamManager();
427 431
428 sInstance->loadAllPresets(""); 432 sInstance->loadAllPresets(LLStringUtil::null);
429 433
430 sInstance->getParamSet("Default", sInstance->mCurParams); 434 sInstance->getParamSet("Default", sInstance->mCurParams);
431 } 435 }