diff options
author | dahlia | 2013-06-28 14:03:46 -0700 |
---|---|---|
committer | dahlia | 2013-06-28 14:03:46 -0700 |
commit | 4cb4c9fb25f15d05c269e1796571795e46b7074e (patch) | |
tree | 820d89c1afdbd987b66f4b37013e72e493ba8b6e /OpenSim/Region | |
parent | add some locking to materials storage dictionary (diff) | |
parent | Remove "Asset deletion not supported by database" message from "delete asset"... (diff) | |
download | opensim-SC_OLD-4cb4c9fb25f15d05c269e1796571795e46b7074e.zip opensim-SC_OLD-4cb4c9fb25f15d05c269e1796571795e46b7074e.tar.gz opensim-SC_OLD-4cb4c9fb25f15d05c269e1796571795e46b7074e.tar.bz2 opensim-SC_OLD-4cb4c9fb25f15d05c269e1796571795e46b7074e.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 58 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 71 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | 136 |
3 files changed, 168 insertions, 97 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 720bfa9..61b0ebd 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -1021,15 +1021,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1021 | /// </remarks> | 1021 | /// </remarks> |
1022 | public event TeleportFail OnTeleportFail; | 1022 | public event TeleportFail OnTeleportFail; |
1023 | 1023 | ||
1024 | public delegate void GatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids); | 1024 | // public delegate void GatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids); |
1025 | 1025 | // | |
1026 | /// <summary> | 1026 | // /// <summary> |
1027 | /// Triggered when UUIDs referenced by a scene object are being gathered for archiving, hg transfer, etc. | 1027 | // /// Triggered when UUIDs referenced by a scene object are being gathered for archiving, hg transfer, etc. |
1028 | /// </summary> | 1028 | // /// </summary> |
1029 | /// <remarks> | 1029 | // /// <remarks> |
1030 | /// The listener should add references to the IDictionary<UUID, AssetType> as appropriate. | 1030 | // /// The listener should add references to the IDictionary<UUID, AssetType> as appropriate. |
1031 | /// </remarks> | 1031 | // /// </remarks> |
1032 | public event GatherUuids OnGatherUuids; | 1032 | // public event GatherUuids OnGatherUuids; |
1033 | 1033 | ||
1034 | public class MoneyTransferArgs : EventArgs | 1034 | public class MoneyTransferArgs : EventArgs |
1035 | { | 1035 | { |
@@ -3248,25 +3248,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3248 | } | 3248 | } |
3249 | } | 3249 | } |
3250 | 3250 | ||
3251 | public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) | 3251 | // public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) |
3252 | { | 3252 | // { |
3253 | GatherUuids handler = OnGatherUuids; | 3253 | // GatherUuids handler = OnGatherUuids; |
3254 | 3254 | // | |
3255 | if (handler != null) | 3255 | // if (handler != null) |
3256 | { | 3256 | // { |
3257 | foreach (GatherUuids d in handler.GetInvocationList()) | 3257 | // foreach (GatherUuids d in handler.GetInvocationList()) |
3258 | { | 3258 | // { |
3259 | try | 3259 | // try |
3260 | { | 3260 | // { |
3261 | d(sop, assetUuids); | 3261 | // d(sop, assetUuids); |
3262 | } | 3262 | // } |
3263 | catch (Exception e) | 3263 | // catch (Exception e) |
3264 | { | 3264 | // { |
3265 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TriggerUuidGather failed - continuing {0} - {1}", | 3265 | // m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TriggerUuidGather failed - continuing {0} - {1}", |
3266 | e.Message, e.StackTrace); | 3266 | // e.Message, e.StackTrace); |
3267 | } | 3267 | // } |
3268 | } | 3268 | // } |
3269 | } | 3269 | // } |
3270 | } | 3270 | // } |
3271 | } | 3271 | } |
3272 | } | 3272 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3492813..4e5fb8e 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -186,7 +186,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
186 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); | 186 | GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); |
187 | } | 187 | } |
188 | 188 | ||
189 | part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); | 189 | // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed |
190 | // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and | ||
191 | // inventory transfer. There needs to be a way for a module to register a method without assuming a | ||
192 | // Scene.EventManager is present. | ||
193 | // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); | ||
194 | |||
195 | GatherMaterialsUuids(part, assetUuids); | ||
190 | } | 196 | } |
191 | catch (Exception e) | 197 | catch (Exception e) |
192 | { | 198 | { |
@@ -210,6 +216,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
210 | // Monitor.Pulse(this); | 216 | // Monitor.Pulse(this); |
211 | // } | 217 | // } |
212 | // } | 218 | // } |
219 | |||
220 | /// <summary> | ||
221 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | ||
222 | /// </summary> | ||
223 | /// <param name="part"></param> | ||
224 | /// <param name="assetUuids"></param> | ||
225 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | ||
226 | { | ||
227 | // scan thru the dynAttrs map of this part for any textures used as materials | ||
228 | OSD osdMaterials = null; | ||
229 | |||
230 | lock (part.DynAttrs) | ||
231 | { | ||
232 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | ||
233 | { | ||
234 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | ||
235 | materialsStore.TryGetValue("Materials", out osdMaterials); | ||
236 | } | ||
237 | |||
238 | if (osdMaterials != null) | ||
239 | { | ||
240 | //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); | ||
241 | |||
242 | if (osdMaterials is OSDArray) | ||
243 | { | ||
244 | OSDArray matsArr = osdMaterials as OSDArray; | ||
245 | foreach (OSDMap matMap in matsArr) | ||
246 | { | ||
247 | try | ||
248 | { | ||
249 | if (matMap.ContainsKey("Material")) | ||
250 | { | ||
251 | OSDMap mat = matMap["Material"] as OSDMap; | ||
252 | if (mat.ContainsKey("NormMap")) | ||
253 | { | ||
254 | UUID normalMapId = mat["NormMap"].AsUUID(); | ||
255 | if (normalMapId != UUID.Zero) | ||
256 | { | ||
257 | assetUuids[normalMapId] = AssetType.Texture; | ||
258 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | ||
259 | } | ||
260 | } | ||
261 | if (mat.ContainsKey("SpecMap")) | ||
262 | { | ||
263 | UUID specularMapId = mat["SpecMap"].AsUUID(); | ||
264 | if (specularMapId != UUID.Zero) | ||
265 | { | ||
266 | assetUuids[specularMapId] = AssetType.Texture; | ||
267 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | |||
272 | } | ||
273 | catch (Exception e) | ||
274 | { | ||
275 | m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message); | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | } | ||
213 | 282 | ||
214 | /// <summary> | 283 | /// <summary> |
215 | /// Get an asset synchronously, potentially using an asynchronous callback. If the | 284 | /// Get an asset synchronously, potentially using an asynchronous callback. If the |
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 19d8141..3a39971 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | |||
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
125 | m_scene = scene; | 125 | m_scene = scene; |
126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | 126 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; |
127 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; | 127 | m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; |
128 | m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; | 128 | // m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids; |
129 | } | 129 | } |
130 | 130 | ||
131 | void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) | 131 | void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) |
@@ -161,7 +161,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
161 | 161 | ||
162 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | 162 | m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; |
163 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; | 163 | m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; |
164 | m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; | 164 | // m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids; |
165 | 165 | ||
166 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | 166 | m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); |
167 | } | 167 | } |
@@ -591,70 +591,72 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
591 | output.Flush(); | 591 | output.Flush(); |
592 | } | 592 | } |
593 | 593 | ||
594 | /// <summary> | 594 | // FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some |
595 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | 595 | // calls to the gatherer are done for objects with no scene. |
596 | /// </summary> | 596 | // /// <summary> |
597 | /// <param name="part"></param> | 597 | // /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps |
598 | /// <param name="assetUuids"></param> | 598 | // /// </summary> |
599 | private void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | 599 | // /// <param name="part"></param> |
600 | { | 600 | // /// <param name="assetUuids"></param> |
601 | // scan thru the dynAttrs map of this part for any textures used as materials | 601 | // private void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) |
602 | OSD osdMaterials = null; | 602 | // { |
603 | 603 | // // scan thru the dynAttrs map of this part for any textures used as materials | |
604 | lock (part.DynAttrs) | 604 | // OSD osdMaterials = null; |
605 | { | 605 | // |
606 | if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) | 606 | // lock (part.DynAttrs) |
607 | { | 607 | // { |
608 | OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); | 608 | // if (part.DynAttrs.ContainsStore("OpenSim", "Materials")) |
609 | if (materialsStore == null) | 609 | // { |
610 | return; | 610 | // OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials"); |
611 | 611 | // if (materialsStore == null) | |
612 | materialsStore.TryGetValue("Materials", out osdMaterials); | 612 | // return; |
613 | } | 613 | // |
614 | 614 | // materialsStore.TryGetValue("Materials", out osdMaterials); | |
615 | if (osdMaterials != null) | 615 | // } |
616 | { | 616 | // |
617 | //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); | 617 | // if (osdMaterials != null) |
618 | 618 | // { | |
619 | if (osdMaterials is OSDArray) | 619 | // //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); |
620 | { | 620 | // |
621 | OSDArray matsArr = osdMaterials as OSDArray; | 621 | // if (osdMaterials is OSDArray) |
622 | foreach (OSDMap matMap in matsArr) | 622 | // { |
623 | { | 623 | // OSDArray matsArr = osdMaterials as OSDArray; |
624 | try | 624 | // foreach (OSDMap matMap in matsArr) |
625 | { | 625 | // { |
626 | if (matMap.ContainsKey("Material")) | 626 | // try |
627 | { | 627 | // { |
628 | OSDMap mat = matMap["Material"] as OSDMap; | 628 | // if (matMap.ContainsKey("Material")) |
629 | if (mat.ContainsKey("NormMap")) | 629 | // { |
630 | { | 630 | // OSDMap mat = matMap["Material"] as OSDMap; |
631 | UUID normalMapId = mat["NormMap"].AsUUID(); | 631 | // if (mat.ContainsKey("NormMap")) |
632 | if (normalMapId != UUID.Zero) | 632 | // { |
633 | { | 633 | // UUID normalMapId = mat["NormMap"].AsUUID(); |
634 | assetUuids[normalMapId] = AssetType.Texture; | 634 | // if (normalMapId != UUID.Zero) |
635 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | 635 | // { |
636 | } | 636 | // assetUuids[normalMapId] = AssetType.Texture; |
637 | } | 637 | // //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); |
638 | if (mat.ContainsKey("SpecMap")) | 638 | // } |
639 | { | 639 | // } |
640 | UUID specularMapId = mat["SpecMap"].AsUUID(); | 640 | // if (mat.ContainsKey("SpecMap")) |
641 | if (specularMapId != UUID.Zero) | 641 | // { |
642 | { | 642 | // UUID specularMapId = mat["SpecMap"].AsUUID(); |
643 | assetUuids[specularMapId] = AssetType.Texture; | 643 | // if (specularMapId != UUID.Zero) |
644 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | 644 | // { |
645 | } | 645 | // assetUuids[specularMapId] = AssetType.Texture; |
646 | } | 646 | // //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); |
647 | } | 647 | // } |
648 | 648 | // } | |
649 | } | 649 | // } |
650 | catch (Exception e) | 650 | // |
651 | { | 651 | // } |
652 | m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); | 652 | // catch (Exception e) |
653 | } | 653 | // { |
654 | } | 654 | // m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message); |
655 | } | 655 | // } |
656 | } | 656 | // } |
657 | } | 657 | // } |
658 | } | 658 | // } |
659 | // } | ||
660 | // } | ||
659 | } | 661 | } |
660 | } \ No newline at end of file | 662 | } \ No newline at end of file |