diff options
Diffstat (limited to 'linden/indra/newview/llwaterparammanager.cpp')
-rw-r--r-- | linden/indra/newview/llwaterparammanager.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index 0156622..9d0fd86 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp | |||
@@ -3,9 +3,9 @@ | |||
3 | * @brief Implementation for the LLWaterParamManager class. | 3 | * @brief Implementation for the LLWaterParamManager class. |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2009, Linden Research, Inc. | 7 | * Copyright (c) 2007-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
11 | * to you under the terms of the GNU General Public License, version 2.0 | 11 | * to you under the terms of the GNU General Public License, version 2.0 |
@@ -13,17 +13,17 @@ | |||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 13 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | 15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
16 | * | 16 | * |
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | 21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception |
22 | * | 22 | * |
23 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
24 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
25 | * and agree to abide by those obligations. | 25 | * and agree to abide by those obligations. |
26 | * | 26 | * |
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
29 | * COMPLETENESS OR PERFORMANCE. | 29 | * COMPLETENESS OR PERFORMANCE. |
@@ -102,9 +102,9 @@ void LLWaterParamManager::loadAllPresets(const std::string& file_name) | |||
102 | { | 102 | { |
103 | std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); | 103 | std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); |
104 | LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading Default water settings from " << path_name << LL_ENDL; | 104 | LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading Default water settings from " << path_name << LL_ENDL; |
105 | 105 | ||
106 | bool found = true; | 106 | bool found = true; |
107 | while(found) | 107 | while(found) |
108 | { | 108 | { |
109 | std::string name; | 109 | std::string name; |
110 | found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); | 110 | found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); |
@@ -128,9 +128,9 @@ void LLWaterParamManager::loadAllPresets(const std::string& file_name) | |||
128 | 128 | ||
129 | std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); | 129 | std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); |
130 | LL_DEBUGS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; | 130 | LL_DEBUGS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; |
131 | 131 | ||
132 | found = true; | 132 | found = true; |
133 | while(found) | 133 | while(found) |
134 | { | 134 | { |
135 | std::string name; | 135 | std::string name; |
136 | found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); | 136 | found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); |
@@ -174,10 +174,10 @@ void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) | |||
174 | 174 | ||
175 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); | 175 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); |
176 | LL_DEBUGS2("AppInit", "Shaders") << "Loading water settings from " << pathName << LL_ENDL; | 176 | LL_DEBUGS2("AppInit", "Shaders") << "Loading water settings from " << pathName << LL_ENDL; |
177 | 177 | ||
178 | std::ifstream presetsXML; | 178 | std::ifstream presetsXML; |
179 | presetsXML.open(pathName.c_str()); | 179 | presetsXML.open(pathName.c_str()); |
180 | 180 | ||
181 | // That failed, try loading from the users area instead. | 181 | // That failed, try loading from the users area instead. |
182 | if(!presetsXML) | 182 | if(!presetsXML) |
183 | { | 183 | { |
@@ -190,8 +190,8 @@ void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) | |||
190 | { | 190 | { |
191 | loadPresetXML(name, presetsXML); | 191 | loadPresetXML(name, presetsXML); |
192 | presetsXML.close(); | 192 | presetsXML.close(); |
193 | } | 193 | } |
194 | else | 194 | else |
195 | { | 195 | { |
196 | llwarns << "Can't find " << name << llendl; | 196 | llwarns << "Can't find " << name << llendl; |
197 | return; | 197 | return; |
@@ -240,17 +240,17 @@ bool LLWaterParamManager::loadPresetXML(const std::string& name, std::istream& p | |||
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | 244 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); |
245 | if(mIt == mParamList.end()) | 245 | if(mIt == mParamList.end()) |
246 | { | 246 | { |
247 | addParamSet(name, paramsData); | 247 | addParamSet(name, paramsData); |
248 | } | 248 | } |
249 | else | 249 | else |
250 | { | 250 | { |
251 | setParamSet(name, paramsData); | 251 | setParamSet(name, paramsData); |
252 | } | 252 | } |
253 | 253 | ||
254 | if(propagate) | 254 | if(propagate) |
255 | { | 255 | { |
256 | getParamSet(name, mCurParams); | 256 | getParamSet(name, mCurParams); |
@@ -306,19 +306,19 @@ bool LLWaterParamManager::savePresetToNotecard(const std::string & name) | |||
306 | { | 306 | { |
307 | // make an empty llsd | 307 | // make an empty llsd |
308 | LLSD paramsData(LLSD::emptyMap()); | 308 | LLSD paramsData(LLSD::emptyMap()); |
309 | 309 | ||
310 | // fill it with LLSD windlight params | 310 | // fill it with LLSD windlight params |
311 | paramsData = mParamList[name].getAll(); | 311 | paramsData = mParamList[name].getAll(); |
312 | 312 | ||
313 | // get some XML | 313 | // get some XML |
314 | std::ostringstream presetsXML; | 314 | std::ostringstream presetsXML; |
315 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); | 315 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); |
316 | formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); | 316 | formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); |
317 | 317 | ||
318 | // Write it to a notecard | 318 | // Write it to a notecard |
319 | LLNotecard notecard; | 319 | LLNotecard notecard; |
320 | notecard.setText(presetsXML.str()); | 320 | notecard.setText(presetsXML.str()); |
321 | 321 | ||
322 | LLInventoryItem *item = gInventory.getItem(mParamList[name].mInventoryID); | 322 | LLInventoryItem *item = gInventory.getItem(mParamList[name].mInventoryID); |
323 | if(!item) | 323 | if(!item) |
324 | { | 324 | { |
@@ -332,13 +332,13 @@ bool LLWaterParamManager::savePresetToNotecard(const std::string & name) | |||
332 | LLAssetID asset_id; | 332 | LLAssetID asset_id; |
333 | tid.generate(); | 333 | tid.generate(); |
334 | asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); | 334 | asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); |
335 | 335 | ||
336 | LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); | 336 | LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND); |
337 | 337 | ||
338 | std::ostringstream stream; | 338 | std::ostringstream stream; |
339 | notecard.exportStream(stream); | 339 | notecard.exportStream(stream); |
340 | std::string buffer = stream.str(); | 340 | std::string buffer = stream.str(); |
341 | 341 | ||
342 | S32 size = buffer.length() + 1; | 342 | S32 size = buffer.length() + 1; |
343 | file.setMaxSize(size); | 343 | file.setMaxSize(size); |
344 | file.write((U8*)buffer.c_str(), size); | 344 | file.write((U8*)buffer.c_str(), size); |
@@ -351,7 +351,7 @@ bool LLWaterParamManager::savePresetToNotecard(const std::string & name) | |||
351 | LL_WARNS("WindLight") << "Stuff the legacy system." << LL_ENDL; | 351 | LL_WARNS("WindLight") << "Stuff the legacy system." << LL_ENDL; |
352 | return false; | 352 | return false; |
353 | } | 353 | } |
354 | 354 | ||
355 | propagateParameters(); | 355 | propagateParameters(); |
356 | return true; | 356 | return true; |
357 | } | 357 | } |
@@ -374,8 +374,8 @@ void LLWaterParamManager::propagateParameters(void) | |||
374 | } | 374 | } |
375 | 375 | ||
376 | bool err; | 376 | bool err; |
377 | F32 fog_density_slider = | 377 | F32 fog_density_slider = |
378 | log(mCurParams.getFloat(mFogDensity.mName, err)) / | 378 | log(mCurParams.getFloat(mFogDensity.mName, err)) / |
379 | log(mFogDensity.mBase); | 379 | log(mFogDensity.mBase); |
380 | 380 | ||
381 | setDensitySliderValue(fog_density_slider); | 381 | setDensitySliderValue(fog_density_slider); |
@@ -398,12 +398,12 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader) | |||
398 | void LLWaterParamManager::update(LLViewerCamera * cam) | 398 | void LLWaterParamManager::update(LLViewerCamera * cam) |
399 | { | 399 | { |
400 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); | 400 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); |
401 | 401 | ||
402 | // update the shaders and the menu | 402 | // update the shaders and the menu |
403 | propagateParameters(); | 403 | propagateParameters(); |
404 | 404 | ||
405 | // sync menus if they exist | 405 | // sync menus if they exist |
406 | if(LLFloaterWater::isOpen()) | 406 | if(LLFloaterWater::isOpen()) |
407 | { | 407 | { |
408 | LLFloaterWater::instance()->syncMenu(); | 408 | LLFloaterWater::instance()->syncMenu(); |
409 | } | 409 | } |
@@ -411,12 +411,12 @@ void LLWaterParamManager::update(LLViewerCamera * cam) | |||
411 | stop_glerror(); | 411 | stop_glerror(); |
412 | 412 | ||
413 | // only do this if we're dealing with shaders | 413 | // only do this if we're dealing with shaders |
414 | if(gPipeline.canUseVertexShaders()) | 414 | if(gPipeline.canUseVertexShaders()) |
415 | { | 415 | { |
416 | //transform water plane to eye space | 416 | //transform water plane to eye space |
417 | glh::vec3f norm(0.f, 0.f, 1.f); | 417 | glh::vec3f norm(0.f, 0.f, 1.f); |
418 | glh::vec3f p(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f); | 418 | glh::vec3f p(0.f, 0.f, gAgent.getRegion()->getWaterHeight()+0.1f); |
419 | 419 | ||
420 | F32 modelView[16]; | 420 | F32 modelView[16]; |
421 | for (U32 i = 0; i < 16; i++) | 421 | for (U32 i = 0; i < 16; i++) |
422 | { | 422 | { |
@@ -434,13 +434,13 @@ void LLWaterParamManager::update(LLViewerCamera * cam) | |||
434 | mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); | 434 | mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm)); |
435 | 435 | ||
436 | LLVector3 sunMoonDir; | 436 | LLVector3 sunMoonDir; |
437 | if (gSky.getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS) | 437 | if (gSky.getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS) |
438 | { | 438 | { |
439 | sunMoonDir = gSky.getSunDirection(); | 439 | sunMoonDir = gSky.getSunDirection(); |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | sunMoonDir = gSky.getMoonDirection(); | 443 | sunMoonDir = gSky.getMoonDirection(); |
444 | } | 444 | } |
445 | sunMoonDir.normVec(); | 445 | sunMoonDir.normVec(); |
446 | mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); | 446 | mWaterFogKS = 1.f/llmax(sunMoonDir.mV[2], WATER_FOG_LIGHT_CLAMP); |
@@ -510,8 +510,8 @@ bool LLWaterParamManager::addParamSet(const std::string& name, LLWaterParamSet& | |||
510 | { | 510 | { |
511 | // add a new one if not one there already | 511 | // add a new one if not one there already |
512 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | 512 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); |
513 | if(mIt == mParamList.end()) | 513 | if(mIt == mParamList.end()) |
514 | { | 514 | { |
515 | mParamList[name] = param; | 515 | mParamList[name] = param; |
516 | return true; | 516 | return true; |
517 | } | 517 | } |
@@ -538,7 +538,7 @@ bool LLWaterParamManager::getParamSet(const std::string& name, LLWaterParamSet& | |||
538 | { | 538 | { |
539 | // find it and set it | 539 | // find it and set it |
540 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | 540 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); |
541 | if(mIt != mParamList.end()) | 541 | if(mIt != mParamList.end()) |
542 | { | 542 | { |
543 | param = mParamList[name]; | 543 | param = mParamList[name]; |
544 | param.mName = name; | 544 | param.mName = name; |
@@ -558,11 +558,11 @@ bool LLWaterParamManager::setParamSet(const std::string& name, LLWaterParamSet& | |||
558 | bool LLWaterParamManager::setParamSet(const std::string& name, const LLSD & param) | 558 | bool LLWaterParamManager::setParamSet(const std::string& name, const LLSD & param) |
559 | { | 559 | { |
560 | // quick, non robust (we won't be working with files, but assets) check | 560 | // quick, non robust (we won't be working with files, but assets) check |
561 | if(!param.isMap()) | 561 | if(!param.isMap()) |
562 | { | 562 | { |
563 | return false; | 563 | return false; |
564 | } | 564 | } |
565 | 565 | ||
566 | mParamList[name].setAll(param); | 566 | mParamList[name].setAll(param); |
567 | 567 | ||
568 | return true; | 568 | return true; |
@@ -572,7 +572,7 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr | |||
572 | { | 572 | { |
573 | // remove from param list | 573 | // remove from param list |
574 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); | 574 | std::map<std::string, LLWaterParamSet>::iterator mIt = mParamList.find(name); |
575 | if(mIt != mParamList.end()) | 575 | if(mIt != mParamList.end()) |
576 | { | 576 | { |
577 | mParamList.erase(mIt); | 577 | mParamList.erase(mIt); |
578 | } | 578 | } |
@@ -581,13 +581,13 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr | |||
581 | { | 581 | { |
582 | 582 | ||
583 | std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); | 583 | std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); |
584 | 584 | ||
585 | // use full curl escaped name | 585 | // use full curl escaped name |
586 | char * curl_str = curl_escape(name.c_str(), name.size()); | 586 | char * curl_str = curl_escape(name.c_str(), name.size()); |
587 | std::string escaped_name(curl_str); | 587 | std::string escaped_name(curl_str); |
588 | curl_free(curl_str); | 588 | curl_free(curl_str); |
589 | curl_str = NULL; | 589 | curl_str = NULL; |
590 | 590 | ||
591 | gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); | 591 | gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); |
592 | } | 592 | } |
593 | 593 | ||
@@ -599,7 +599,7 @@ F32 LLWaterParamManager::getFogDensity(void) | |||
599 | bool err; | 599 | bool err; |
600 | 600 | ||
601 | F32 fogDensity = mCurParams.getFloat("waterFogDensity", err); | 601 | F32 fogDensity = mCurParams.getFloat("waterFogDensity", err); |
602 | 602 | ||
603 | // modify if we're underwater | 603 | // modify if we're underwater |
604 | const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; | 604 | const F32 water_height = gAgent.getRegion() ? gAgent.getRegion()->getWaterHeight() : 0.f; |
605 | F32 camera_height = gAgent.getCameraPositionAgent().mV[2]; | 605 | F32 camera_height = gAgent.getCameraPositionAgent().mV[2]; |
@@ -659,7 +659,7 @@ void LLWaterParamManager::loadWaterNotecard(LLVFS *vfs, const LLUUID& asset_id, | |||
659 | } | 659 | } |
660 | else | 660 | else |
661 | { | 661 | { |
662 | // We can do this because we know mCurParams | 662 | // We can do this because we know mCurParams |
663 | sInstance->mParamList[name].mInventoryID = inventory_id; | 663 | sInstance->mParamList[name].mInventoryID = inventory_id; |
664 | } | 664 | } |
665 | } | 665 | } |