diff options
author | Oren Hurvitz | 2013-11-26 10:37:32 +0200 |
---|---|---|
committer | dahlia | 2014-01-20 00:37:26 -0800 |
commit | e8273fa8ad85323f18fb67ecf6d5f07eced87178 (patch) | |
tree | 2c156f7939364e3e57356814a12b46e7b8bad464 /OpenSim/Region | |
parent | Fix casting error for float type INI file parameter parsing. (diff) | |
download | opensim-SC_OLD-e8273fa8ad85323f18fb67ecf6d5f07eced87178.zip opensim-SC_OLD-e8273fa8ad85323f18fb67ecf6d5f07eced87178.tar.gz opensim-SC_OLD-e8273fa8ad85323f18fb67ecf6d5f07eced87178.tar.bz2 opensim-SC_OLD-e8273fa8ad85323f18fb67ecf6d5f07eced87178.tar.xz |
- Materials: support the viewer removing the material (in which case matsMap["Material"] is missing) - Reduced logging
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index d8f5563..44b1a4a 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | |||
@@ -104,7 +104,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
104 | if (!m_enabled) | 104 | if (!m_enabled) |
105 | return; | 105 | return; |
106 | 106 | ||
107 | m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE"); | 107 | m_log.DebugFormat("[MaterialsDemoModule]: Initialized"); |
108 | } | 108 | } |
109 | 109 | ||
110 | public void Close() | 110 | public void Close() |
@@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
112 | if (!m_enabled) | 112 | if (!m_enabled) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); | 115 | //m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE"); |
116 | } | 116 | } |
117 | 117 | ||
118 | public void AddRegion(Scene scene) | 118 | public void AddRegion(Scene scene) |
@@ -120,7 +120,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
120 | if (!m_enabled) | 120 | if (!m_enabled) |
121 | return; | 121 | return; |
122 | 122 | ||
123 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); | 123 | //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); |
124 | 124 | ||
125 | m_scene = scene; | 125 | m_scene = scene; |
126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | 126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; |
@@ -166,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
166 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | 166 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; |
167 | // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; | 167 | // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; |
168 | 168 | ||
169 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | 169 | //m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); |
170 | } | 170 | } |
171 | 171 | ||
172 | public void RegionLoaded(Scene scene) | 172 | public void RegionLoaded(Scene scene) |
@@ -195,7 +195,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
195 | 195 | ||
196 | if (part.DynAttrs == null) | 196 | if (part.DynAttrs == null) |
197 | { | 197 | { |
198 | m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); | 198 | //m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( "); |
199 | return; | ||
199 | } | 200 | } |
200 | 201 | ||
201 | lock (part.DynAttrs) | 202 | lock (part.DynAttrs) |
@@ -216,11 +217,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
216 | return; | 217 | return; |
217 | } | 218 | } |
218 | 219 | ||
219 | m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); | 220 | //m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); |
220 | 221 | ||
221 | if (matsArr == null) | 222 | if (matsArr == null) |
222 | { | 223 | { |
223 | m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); | 224 | //m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); |
224 | return; | 225 | return; |
225 | } | 226 | } |
226 | 227 | ||
@@ -238,7 +239,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
238 | } | 239 | } |
239 | catch (Exception e) | 240 | catch (Exception e) |
240 | { | 241 | { |
241 | m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString()); | 242 | m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material ", e); |
242 | } | 243 | } |
243 | } | 244 | } |
244 | } | 245 | } |
@@ -299,7 +300,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
299 | } | 300 | } |
300 | catch (Exception e) | 301 | catch (Exception e) |
301 | { | 302 | { |
302 | m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString()); | 303 | m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart() ", e); |
303 | } | 304 | } |
304 | } | 305 | } |
305 | 306 | ||
@@ -307,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
307 | string param, IOSHttpRequest httpRequest, | 308 | string param, IOSHttpRequest httpRequest, |
308 | IOSHttpResponse httpResponse) | 309 | IOSHttpResponse httpResponse) |
309 | { | 310 | { |
310 | m_log.Debug("[MaterialsDemoModule]: POST cap handler"); | 311 | //m_log.Debug("[MaterialsDemoModule]: POST cap handler"); |
311 | 312 | ||
312 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | 313 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); |
313 | OSDMap resp = new OSDMap(); | 314 | OSDMap resp = new OSDMap(); |
@@ -341,7 +342,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
341 | { | 342 | { |
342 | if (m_knownMaterials.ContainsKey(id)) | 343 | if (m_knownMaterials.ContainsKey(id)) |
343 | { | 344 | { |
344 | m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); | 345 | //m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); |
345 | OSDMap matMap = new OSDMap(); | 346 | OSDMap matMap = new OSDMap(); |
346 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); | 347 | matMap["ID"] = OSD.FromBinary(id.GetBytes()); |
347 | 348 | ||
@@ -374,34 +375,40 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
374 | { | 375 | { |
375 | foreach (OSDMap matsMap in matsArr) | 376 | foreach (OSDMap matsMap in matsArr) |
376 | { | 377 | { |
377 | m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); | 378 | //m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap)); |
378 | 379 | ||
379 | uint matLocalID = 0; | 380 | uint primLocalID = 0; |
380 | try { matLocalID = matsMap["ID"].AsUInteger(); } | 381 | try { primLocalID = matsMap["ID"].AsUInteger(); } |
381 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } | 382 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); } |
382 | m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString()); | 383 | //m_log.Debug("[MaterialsDemoModule]: primLocalID: " + primLocalID.ToString()); |
383 | |||
384 | 384 | ||
385 | OSDMap mat = null; | 385 | OSDMap mat = null; |
386 | try { mat = matsMap["Material"] as OSDMap; } | 386 | try { mat = matsMap["Material"] as OSDMap; } |
387 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } | 387 | catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); } |
388 | m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); | 388 | //m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); |
389 | 389 | ||
390 | UUID id = HashOsd(mat); | 390 | UUID id; |
391 | lock (m_knownMaterials) | 391 | if (mat == null) |
392 | m_knownMaterials[id] = mat; | 392 | { |
393 | 393 | id = UUID.Zero; | |
394 | 394 | } | |
395 | var sop = m_scene.GetSceneObjectPart(matLocalID); | 395 | else |
396 | { | ||
397 | id = HashOsd(mat); | ||
398 | lock (m_knownMaterials) | ||
399 | m_knownMaterials[id] = mat; | ||
400 | } | ||
401 | |||
402 | var sop = m_scene.GetSceneObjectPart(primLocalID); | ||
396 | if (sop == null) | 403 | if (sop == null) |
397 | m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); | 404 | m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + primLocalID.ToString()); |
398 | else | 405 | else |
399 | { | 406 | { |
400 | var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); | 407 | var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); |
401 | 408 | ||
402 | if (te == null) | 409 | if (te == null) |
403 | { | 410 | { |
404 | m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString()); | 411 | m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + primLocalID.ToString()); |
405 | } | 412 | } |
406 | else | 413 | else |
407 | { | 414 | { |
@@ -434,7 +441,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
434 | te.DefaultTexture.MaterialID = id; | 441 | te.DefaultTexture.MaterialID = id; |
435 | } | 442 | } |
436 | 443 | ||
437 | m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString()); | 444 | //m_log.DebugFormat("[MaterialsDemoModule]: in \"{0}\", setting material ID for face {1} to {2}", sop.Name, face, id); |
438 | 445 | ||
439 | //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually | 446 | //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually |
440 | 447 | ||
@@ -455,7 +462,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
455 | } | 462 | } |
456 | catch (Exception e) | 463 | catch (Exception e) |
457 | { | 464 | { |
458 | m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message); | 465 | m_log.Warn("[MaterialsDemoModule]: exception processing received material ", e); |
459 | } | 466 | } |
460 | } | 467 | } |
461 | } | 468 | } |
@@ -465,10 +472,10 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
465 | } | 472 | } |
466 | catch (Exception e) | 473 | catch (Exception e) |
467 | { | 474 | { |
468 | m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message); | 475 | m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload ", e); |
469 | //return ""; | 476 | //return ""; |
470 | } | 477 | } |
471 | m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); | 478 | //m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString()); |
472 | } | 479 | } |
473 | 480 | ||
474 | 481 | ||
@@ -476,8 +483,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
476 | string response = OSDParser.SerializeLLSDXmlString(resp); | 483 | string response = OSDParser.SerializeLLSDXmlString(resp); |
477 | 484 | ||
478 | //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); | 485 | //m_log.Debug("[MaterialsDemoModule]: cap request: " + request); |
479 | m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); | 486 | //m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary())); |
480 | m_log.Debug("[MaterialsDemoModule]: cap response: " + response); | 487 | //m_log.Debug("[MaterialsDemoModule]: cap response: " + response); |
481 | return response; | 488 | return response; |
482 | } | 489 | } |
483 | 490 | ||
@@ -486,7 +493,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
486 | string param, IOSHttpRequest httpRequest, | 493 | string param, IOSHttpRequest httpRequest, |
487 | IOSHttpResponse httpResponse) | 494 | IOSHttpResponse httpResponse) |
488 | { | 495 | { |
489 | m_log.Debug("[MaterialsDemoModule]: GET cap handler"); | 496 | //m_log.Debug("[MaterialsDemoModule]: GET cap handler"); |
490 | 497 | ||
491 | OSDMap resp = new OSDMap(); | 498 | OSDMap resp = new OSDMap(); |
492 | int matsCount = 0; | 499 | int matsCount = 0; |
@@ -506,7 +513,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
506 | } | 513 | } |
507 | 514 | ||
508 | resp["Zipped"] = ZCompressOSD(allOsd, false); | 515 | resp["Zipped"] = ZCompressOSD(allOsd, false); |
509 | m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); | 516 | //m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); |
510 | 517 | ||
511 | return OSDParser.SerializeLLSDXmlString(resp); | 518 | return OSDParser.SerializeLLSDXmlString(resp); |
512 | } | 519 | } |
@@ -654,4 +661,4 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
654 | // } | 661 | // } |
655 | // } | 662 | // } |
656 | } | 663 | } |
657 | } \ No newline at end of file | 664 | } |