diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llwlparammanager.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llwlparammanager.cpp')
-rw-r--r-- | linden/indra/newview/llwlparammanager.cpp | 572 |
1 files changed, 572 insertions, 0 deletions
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp new file mode 100644 index 0000000..11ed43c --- /dev/null +++ b/linden/indra/newview/llwlparammanager.cpp | |||
@@ -0,0 +1,572 @@ | |||
1 | /** | ||
2 | * @file llwlparammanager.cpp | ||
3 | * @brief Implementation for the LLWLParamManager class. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
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 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
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 | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
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 | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llwlparammanager.h" | ||
35 | |||
36 | #include "pipeline.h" | ||
37 | #include "llsky.h" | ||
38 | |||
39 | #include "llsliderctrl.h" | ||
40 | #include "llspinctrl.h" | ||
41 | #include "llcheckboxctrl.h" | ||
42 | #include "llvieweruictrlfactory.h" | ||
43 | #include "llviewercamera.h" | ||
44 | #include "llcombobox.h" | ||
45 | #include "lllineeditor.h" | ||
46 | #include "llsdserialize.h" | ||
47 | |||
48 | #include "v4math.h" | ||
49 | #include "llviewerdisplay.h" | ||
50 | #include "llviewercontrol.h" | ||
51 | #include "llviewerwindow.h" | ||
52 | #include "lldrawpoolwater.h" | ||
53 | #include "llagent.h" | ||
54 | #include "llviewerregion.h" | ||
55 | |||
56 | #include "llwlparamset.h" | ||
57 | #include "llpostprocess.h" | ||
58 | #include "llfloaterwindlight.h" | ||
59 | #include "llfloaterdaycycle.h" | ||
60 | #include "llfloaterenvsettings.h" | ||
61 | |||
62 | #include "curl/curl.h" | ||
63 | |||
64 | LLWLParamManager * LLWLParamManager::sInstance = NULL; | ||
65 | |||
66 | LLWLParamManager::LLWLParamManager() : | ||
67 | |||
68 | //set the defaults for the controls | ||
69 | // index is from sWLUniforms in pipeline.cpp line 979 | ||
70 | |||
71 | /// Sun Delta Terrain tweak variables. | ||
72 | mSunDeltaYaw(180.0f), | ||
73 | mSceneLightStrength(2.0f), | ||
74 | mWLGamma(1.0f, "gamma"), | ||
75 | |||
76 | mBlueHorizon(0.25f, 0.25f, 1.0f, 1.0f, "blue_horizon", "WLBlueHorizon"), | ||
77 | mHazeDensity(1.0f, 1.0f, 1.0f, 0.5f, "haze_density"), | ||
78 | mBlueDensity(0.25f, 0.25f, 0.25f, 1.0f, "blue_density", "WLBlueDensity"), | ||
79 | mDensityMult(1.0f, "density_multiplier", 1000), | ||
80 | mHazeHorizon(1.0f, 1.0f, 1.0f, 0.5f, "haze_horizon"), | ||
81 | mMaxAlt(4000.0f, "max_y"), | ||
82 | |||
83 | // Lighting | ||
84 | mLightnorm(0.f, 0.707f, -0.707f, 1.f, "lightnorm"), | ||
85 | mSunlight(0.5f, 0.5f, 0.5f, 1.0f, "sunlight_color", "WLSunlight"), | ||
86 | mAmbient(0.5f, 0.75f, 1.0f, 1.19f, "ambient", "WLAmbient"), | ||
87 | mGlow(18.0f, 0.0f, -0.01f, 1.0f, "glow"), | ||
88 | |||
89 | // Clouds | ||
90 | mCloudColor(0.5f, 0.5f, 0.5f, 1.0f, "cloud_color", "WLCloudColor"), | ||
91 | mCloudMain(0.5f, 0.5f, 0.125f, 1.0f, "cloud_pos_density1"), | ||
92 | mCloudCoverage(0.0f, "cloud_shadow"), | ||
93 | mCloudDetail(0.0f, 0.0f, 0.0f, 1.0f, "cloud_pos_density2"), | ||
94 | mDistanceMult(1.0f, "distance_multiplier"), | ||
95 | mCloudScale(0.42f, "cloud_scale"), | ||
96 | |||
97 | // sky dome | ||
98 | mDomeOffset(0.96f), | ||
99 | mDomeRadius(15000.f) | ||
100 | { | ||
101 | } | ||
102 | |||
103 | LLWLParamManager::~LLWLParamManager() | ||
104 | { | ||
105 | } | ||
106 | |||
107 | void LLWLParamManager::loadPresets(const LLString& file_name) | ||
108 | { | ||
109 | // if fileName exists, use legacy loading form the big file, otherwise, search the sky | ||
110 | // directory, and add the list | ||
111 | if(file_name != "") | ||
112 | { | ||
113 | LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); | ||
114 | llinfos << "Loading WindLight settings from " << path_name << llendl; | ||
115 | |||
116 | llifstream presetsXML(path_name.c_str()); | ||
117 | |||
118 | if (presetsXML) | ||
119 | { | ||
120 | LLSD paramsData(LLSD::emptyMap()); | ||
121 | |||
122 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
123 | |||
124 | parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); | ||
125 | |||
126 | LLSD::map_const_iterator endParams = paramsData.endMap(); | ||
127 | for(LLSD::map_const_iterator curParams = paramsData.beginMap(); | ||
128 | curParams != endParams; | ||
129 | ++curParams) | ||
130 | { | ||
131 | addParamSet(curParams->first, curParams->second); | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | |||
136 | // otherwise, search the sky directory and find things there | ||
137 | else | ||
138 | { | ||
139 | LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); | ||
140 | llinfos << "Loading WindLight settings from " << path_name << llendl; | ||
141 | |||
142 | //mParamList.clear(); | ||
143 | |||
144 | bool found = true; | ||
145 | while(found) | ||
146 | { | ||
147 | std::string name; | ||
148 | found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); | ||
149 | |||
150 | llinfos << "name: " << name << llendl; | ||
151 | |||
152 | // if we have one | ||
153 | if(found) | ||
154 | { | ||
155 | // bugfix for SL-46920: preventing filenames that break stuff. | ||
156 | char * curl_str = curl_unescape(name.c_str(), name.size()); | ||
157 | std::string unescaped_name(curl_str); | ||
158 | curl_free(curl_str); | ||
159 | curl_str = NULL; | ||
160 | |||
161 | // not much error checking here since we're getting rid of this | ||
162 | std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4); | ||
163 | |||
164 | LLString cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); | ||
165 | llinfos << "Loading sky from " << cur_path << llendl; | ||
166 | |||
167 | std::ifstream sky_xml(cur_path.c_str()); | ||
168 | if (sky_xml) | ||
169 | { | ||
170 | LLSD sky_data(LLSD::emptyMap()); | ||
171 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
172 | parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED); | ||
173 | |||
174 | addParamSet(sky_name, sky_data); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | |||
181 | void LLWLParamManager::savePresets(const LLString & fileName) | ||
182 | { | ||
183 | LLSD paramsData(LLSD::emptyMap()); | ||
184 | |||
185 | LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); | ||
186 | |||
187 | for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin(); | ||
188 | mIt != mParamList.end(); | ||
189 | ++mIt) | ||
190 | { | ||
191 | paramsData[mIt->first] = mIt->second.getAll(); | ||
192 | } | ||
193 | |||
194 | std::ofstream presetsXML(pathName.c_str()); | ||
195 | |||
196 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); | ||
197 | |||
198 | formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); | ||
199 | |||
200 | presetsXML.close(); | ||
201 | } | ||
202 | |||
203 | void LLWLParamManager::loadPreset(const LLString & name) | ||
204 | { | ||
205 | // bugfix for SL-46920: preventing filenames that break stuff. | ||
206 | char * curl_str = curl_escape(name.c_str(), name.size()); | ||
207 | std::string escaped_filename(curl_str); | ||
208 | curl_free(curl_str); | ||
209 | curl_str = NULL; | ||
210 | |||
211 | escaped_filename += ".xml"; | ||
212 | |||
213 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); | ||
214 | llinfos << "Loading WindLight sky setting from " << pathName << llendl; | ||
215 | |||
216 | std::ifstream presetsXML(pathName.c_str()); | ||
217 | |||
218 | if (presetsXML) | ||
219 | { | ||
220 | LLSD paramsData(LLSD::emptyMap()); | ||
221 | |||
222 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | ||
223 | |||
224 | parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED); | ||
225 | |||
226 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
227 | if(mIt == mParamList.end()) | ||
228 | { | ||
229 | addParamSet(name, paramsData); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | setParamSet(name, paramsData); | ||
234 | } | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | llwarns << "Can't find " << name << llendl; | ||
239 | return; | ||
240 | } | ||
241 | |||
242 | getParamSet(name, mCurParams); | ||
243 | |||
244 | propagateParameters(); | ||
245 | } | ||
246 | |||
247 | void LLWLParamManager::savePreset(const LLString & name) | ||
248 | { | ||
249 | // bugfix for SL-46920: preventing filenames that break stuff. | ||
250 | char * curl_str = curl_escape(name.c_str(), name.size()); | ||
251 | std::string escaped_filename(curl_str); | ||
252 | curl_free(curl_str); | ||
253 | curl_str = NULL; | ||
254 | |||
255 | escaped_filename += ".xml"; | ||
256 | |||
257 | // make an empty llsd | ||
258 | LLSD paramsData(LLSD::emptyMap()); | ||
259 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); | ||
260 | |||
261 | // fill it with LLSD windlight params | ||
262 | paramsData = mParamList[name].getAll(); | ||
263 | |||
264 | // write to file | ||
265 | std::ofstream presetsXML(pathName.c_str()); | ||
266 | LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); | ||
267 | formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); | ||
268 | presetsXML.close(); | ||
269 | |||
270 | propagateParameters(); | ||
271 | } | ||
272 | |||
273 | void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader) | ||
274 | { | ||
275 | if (gPipeline.canUseWindLightShaders()) | ||
276 | { | ||
277 | mCurParams.update(shader); | ||
278 | } | ||
279 | |||
280 | if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) | ||
281 | { | ||
282 | shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); | ||
283 | shader->uniform3fv("camPosLocal", 1, gCamera->getOrigin().mV); | ||
284 | } | ||
285 | |||
286 | else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) | ||
287 | { | ||
288 | shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); | ||
289 | } | ||
290 | |||
291 | shader->uniform1f("scene_light_strength", mSceneLightStrength); | ||
292 | |||
293 | } | ||
294 | |||
295 | void LLWLParamManager::propagateParameters(void) | ||
296 | { | ||
297 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); | ||
298 | |||
299 | LLVector4 sunDir; | ||
300 | LLVector4 moonDir; | ||
301 | |||
302 | // set the sun direction from mSunAngle and mEastAngle | ||
303 | F32 sinTheta = sin(mCurParams.getEastAngle()); | ||
304 | F32 cosTheta = cos(mCurParams.getEastAngle()); | ||
305 | |||
306 | F32 sinPhi = sin(mCurParams.getSunAngle()); | ||
307 | F32 cosPhi = cos(mCurParams.getSunAngle()); | ||
308 | |||
309 | sunDir.mV[0] = -sinTheta * cosPhi; | ||
310 | sunDir.mV[1] = sinPhi; | ||
311 | sunDir.mV[2] = cosTheta * cosPhi; | ||
312 | sunDir.mV[3] = 0; | ||
313 | |||
314 | moonDir = -sunDir; | ||
315 | |||
316 | // is the normal from the sun or the moon | ||
317 | if(sunDir.mV[1] >= 0) | ||
318 | { | ||
319 | mLightDir = sunDir; | ||
320 | } | ||
321 | else if(sunDir.mV[1] < 0 && sunDir.mV[1] > NIGHTTIME_ELEVATION_COS) | ||
322 | { | ||
323 | // clamp v1 to 0 so sun never points up and causes weirdness on some machines | ||
324 | LLVector3 vec(sunDir.mV[0], sunDir.mV[1], sunDir.mV[2]); | ||
325 | vec.mV[1] = 0; | ||
326 | vec.normVec(); | ||
327 | mLightDir = LLVector4(vec, 0.f); | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | mLightDir = moonDir; | ||
332 | } | ||
333 | |||
334 | // calculate the clamp lightnorm for sky (to prevent ugly banding in sky | ||
335 | // when haze goes below the horizon | ||
336 | mClampedLightDir = sunDir; | ||
337 | |||
338 | if (mClampedLightDir.mV[1] < -0.1f) | ||
339 | { | ||
340 | mClampedLightDir.mV[1] = -0.1f; | ||
341 | } | ||
342 | |||
343 | mCurParams.set("lightnorm", mLightDir); | ||
344 | |||
345 | // bind the variables for all shaders only if we're using WindLight | ||
346 | LLShaderMgr::shader_iter shaders_iter, end_shaders; | ||
347 | end_shaders = LLShaderMgr::endShaders(); | ||
348 | for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) | ||
349 | { | ||
350 | if (shaders_iter->mProgramObject != 0 | ||
351 | && (gPipeline.canUseWindLightShaders() | ||
352 | || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) | ||
353 | { | ||
354 | shaders_iter->mUniformsDirty = TRUE; | ||
355 | } | ||
356 | } | ||
357 | |||
358 | // get the cfr version of the sun's direction | ||
359 | LLVector3 cfrSunDir(sunDir.mV[2], sunDir.mV[0], sunDir.mV[1]); | ||
360 | |||
361 | // set direction and don't allow overriding | ||
362 | gSky.setSunDirection(cfrSunDir, LLVector3(0,0,0)); | ||
363 | gSky.setOverrideSun(TRUE); | ||
364 | } | ||
365 | |||
366 | void LLWLParamManager::update(LLViewerCamera * cam) | ||
367 | { | ||
368 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_WLPARAM); | ||
369 | |||
370 | // update clouds, sun, and general | ||
371 | mCurParams.updateCloudScrolling(); | ||
372 | |||
373 | // update only if running | ||
374 | if(mAnimator.mIsRunning) | ||
375 | { | ||
376 | mAnimator.update(mCurParams); | ||
377 | } | ||
378 | |||
379 | // update the shaders and the menu | ||
380 | propagateParameters(); | ||
381 | |||
382 | // sync menus if they exist | ||
383 | if(LLFloaterWindLight::isOpen()) | ||
384 | { | ||
385 | LLFloaterWindLight::instance()->syncMenu(); | ||
386 | } | ||
387 | if(LLFloaterDayCycle::isOpen()) | ||
388 | { | ||
389 | LLFloaterDayCycle::instance()->syncMenu(); | ||
390 | } | ||
391 | if(LLFloaterEnvSettings::isOpen()) | ||
392 | { | ||
393 | LLFloaterEnvSettings::instance()->syncMenu(); | ||
394 | } | ||
395 | |||
396 | F32 camYaw = cam->getYaw(); | ||
397 | |||
398 | stop_glerror(); | ||
399 | |||
400 | // *TODO: potential optimization - this block may only need to be | ||
401 | // executed some of the time. For example for water shaders only. | ||
402 | { | ||
403 | F32 camYawDelta = mSunDeltaYaw * DEG_TO_RAD; | ||
404 | |||
405 | LLVector3 lightNorm3(mLightDir); | ||
406 | lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); | ||
407 | mRotatedLightDir = LLVector4(lightNorm3, 0.f); | ||
408 | |||
409 | LLShaderMgr::shader_iter shaders_iter, end_shaders; | ||
410 | end_shaders = LLShaderMgr::endShaders(); | ||
411 | for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) | ||
412 | { | ||
413 | if (shaders_iter->mProgramObject != 0 | ||
414 | && (gPipeline.canUseWindLightShaders() | ||
415 | || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER)) | ||
416 | { | ||
417 | shaders_iter->mUniformsDirty = TRUE; | ||
418 | } | ||
419 | } | ||
420 | } | ||
421 | } | ||
422 | |||
423 | // static | ||
424 | void LLWLParamManager::initClass(void) | ||
425 | { | ||
426 | instance(); | ||
427 | } | ||
428 | |||
429 | // static | ||
430 | void LLWLParamManager::cleanupClass() | ||
431 | { | ||
432 | delete sInstance; | ||
433 | sInstance = NULL; | ||
434 | } | ||
435 | |||
436 | void LLWLParamManager::resetAnimator(F32 curTime, bool run) | ||
437 | { | ||
438 | mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate, | ||
439 | curTime, run); | ||
440 | |||
441 | return; | ||
442 | } | ||
443 | bool LLWLParamManager::addParamSet(const std::string& name, LLWLParamSet& param) | ||
444 | { | ||
445 | // add a new one if not one there already | ||
446 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
447 | if(mIt == mParamList.end()) | ||
448 | { | ||
449 | mParamList[name] = param; | ||
450 | return true; | ||
451 | } | ||
452 | |||
453 | return false; | ||
454 | } | ||
455 | |||
456 | BOOL LLWLParamManager::addParamSet(const std::string& name, LLSD const & param) | ||
457 | { | ||
458 | // add a new one if not one there already | ||
459 | std::map<std::string, LLWLParamSet>::const_iterator finder = mParamList.find(name); | ||
460 | if(finder == mParamList.end()) | ||
461 | { | ||
462 | mParamList[name].setAll(param); | ||
463 | return TRUE; | ||
464 | } | ||
465 | else | ||
466 | { | ||
467 | return FALSE; | ||
468 | } | ||
469 | } | ||
470 | |||
471 | bool LLWLParamManager::getParamSet(const std::string& name, LLWLParamSet& param) | ||
472 | { | ||
473 | // find it and set it | ||
474 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
475 | if(mIt != mParamList.end()) | ||
476 | { | ||
477 | param = mParamList[name]; | ||
478 | param.mName = name; | ||
479 | return true; | ||
480 | } | ||
481 | |||
482 | return false; | ||
483 | } | ||
484 | |||
485 | bool LLWLParamManager::setParamSet(const std::string& name, LLWLParamSet& param) | ||
486 | { | ||
487 | mParamList[name] = param; | ||
488 | |||
489 | return true; | ||
490 | } | ||
491 | |||
492 | bool LLWLParamManager::setParamSet(const std::string& name, const LLSD & param) | ||
493 | { | ||
494 | // quick, non robust (we won't be working with files, but assets) check | ||
495 | if(!param.isMap()) | ||
496 | { | ||
497 | return false; | ||
498 | } | ||
499 | |||
500 | mParamList[name].setAll(param); | ||
501 | |||
502 | return true; | ||
503 | } | ||
504 | |||
505 | bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_disk) | ||
506 | { | ||
507 | // remove from param list | ||
508 | std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name); | ||
509 | if(mIt != mParamList.end()) | ||
510 | { | ||
511 | mParamList.erase(mIt); | ||
512 | } | ||
513 | |||
514 | F32 key; | ||
515 | |||
516 | // remove all references | ||
517 | bool stat = true; | ||
518 | do | ||
519 | { | ||
520 | // get it | ||
521 | stat = mDay.getKey(name, key); | ||
522 | if(stat == false) | ||
523 | { | ||
524 | break; | ||
525 | } | ||
526 | |||
527 | // and remove | ||
528 | stat = mDay.removeKey(key); | ||
529 | |||
530 | } while(stat == true); | ||
531 | |||
532 | if(delete_from_disk) | ||
533 | { | ||
534 | LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); | ||
535 | |||
536 | // use full curl escaped name | ||
537 | char * curl_str = curl_escape(name.c_str(), name.size()); | ||
538 | std::string escaped_name(curl_str); | ||
539 | curl_free(curl_str); | ||
540 | curl_str = NULL; | ||
541 | |||
542 | gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml"); | ||
543 | } | ||
544 | |||
545 | return true; | ||
546 | } | ||
547 | |||
548 | |||
549 | // static | ||
550 | LLWLParamManager * LLWLParamManager::instance() | ||
551 | { | ||
552 | if(NULL == sInstance) | ||
553 | { | ||
554 | sInstance = new LLWLParamManager(); | ||
555 | |||
556 | sInstance->loadPresets(""); | ||
557 | |||
558 | // load the day | ||
559 | sInstance->mDay.loadDayCycle("Default.xml"); | ||
560 | |||
561 | // *HACK - sets cloud scrolling to what we want... fix this better in the future | ||
562 | sInstance->getParamSet("Default", sInstance->mCurParams); | ||
563 | |||
564 | // set it to noon | ||
565 | sInstance->resetAnimator(0.5, true); | ||
566 | |||
567 | // but use linden time sets it to what the estate is | ||
568 | sInstance->mAnimator.mUseLindenTime = true; | ||
569 | } | ||
570 | |||
571 | return sInstance; | ||
572 | } | ||