aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-06-27 23:42:35 +0100
committerJustin Clark-Casey (justincc)2013-06-27 23:42:35 +0100
commit149487ea0f74a46a70c98b3a31259b667f4d29b2 (patch)
tree19524863c98a1d5b229cfda790913da1588d372b /OpenSim/Region/Framework/Scenes
parentMake the concept of namespaces explicit in dynamic attributes (diff)
downloadopensim-SC_OLD-149487ea0f74a46a70c98b3a31259b667f4d29b2.zip
opensim-SC_OLD-149487ea0f74a46a70c98b3a31259b667f4d29b2.tar.gz
opensim-SC_OLD-149487ea0f74a46a70c98b3a31259b667f4d29b2.tar.bz2
opensim-SC_OLD-149487ea0f74a46a70c98b3a31259b667f4d29b2.tar.xz
refactor: Move code for gathering textures referenced by materials into MaterialsDemoModule from UuidGatherer
This code is now triggered via EventManager.OnGatherUuids which modules can subscribe to.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs31
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs69
2 files changed, 33 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index a246319..720bfa9 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -1021,6 +1021,16 @@ 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);
1025
1026 /// <summary>
1027 /// Triggered when UUIDs referenced by a scene object are being gathered for archiving, hg transfer, etc.
1028 /// </summary>
1029 /// <remarks>
1030 /// The listener should add references to the IDictionary<UUID, AssetType> as appropriate.
1031 /// </remarks>
1032 public event GatherUuids OnGatherUuids;
1033
1024 public class MoneyTransferArgs : EventArgs 1034 public class MoneyTransferArgs : EventArgs
1025 { 1035 {
1026 public UUID sender; 1036 public UUID sender;
@@ -3237,5 +3247,26 @@ namespace OpenSim.Region.Framework.Scenes
3237 } 3247 }
3238 } 3248 }
3239 } 3249 }
3250
3251 public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids)
3252 {
3253 GatherUuids handler = OnGatherUuids;
3254
3255 if (handler != null)
3256 {
3257 foreach (GatherUuids d in handler.GetInvocationList())
3258 {
3259 try
3260 {
3261 d(sop, assetUuids);
3262 }
3263 catch (Exception e)
3264 {
3265 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TriggerUuidGather failed - continuing {0} - {1}",
3266 e.Message, e.StackTrace);
3267 }
3268 }
3269 }
3270 }
3240 } 3271 }
3241} 3272}
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 586b59d..3492813 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -186,8 +186,7 @@ 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 // get any texture UUIDs used for materials such as normal and specular maps 189 part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
190 GatherMaterialsUuids(part, assetUuids);
191 } 190 }
192 catch (Exception e) 191 catch (Exception e)
193 { 192 {
@@ -211,71 +210,7 @@ namespace OpenSim.Region.Framework.Scenes
211// Monitor.Pulse(this); 210// Monitor.Pulse(this);
212// } 211// }
213// } 212// }
214 213
215 /// <summary>
216 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
217 /// </summary>
218 /// <param name="part"></param>
219 /// <param name="assetUuids"></param>
220 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
221 {
222 // scan thru the dynAttrs map of this part for any textures used as materials
223 OSD osdMaterials = null;
224
225 lock (part.DynAttrs)
226 {
227 if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
228 {
229 OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
230 materialsStore.TryGetValue("Materials", out osdMaterials);
231 }
232
233 if (osdMaterials != null)
234 {
235 //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
236
237 if (osdMaterials is OSDArray)
238 {
239 OSDArray matsArr = osdMaterials as OSDArray;
240 foreach (OSDMap matMap in matsArr)
241 {
242 try
243 {
244 if (matMap.ContainsKey("Material"))
245 {
246 OSDMap mat = matMap["Material"] as OSDMap;
247 if (mat.ContainsKey("NormMap"))
248 {
249 UUID normalMapId = mat["NormMap"].AsUUID();
250 if (normalMapId != UUID.Zero)
251 {
252 assetUuids[normalMapId] = AssetType.Texture;
253 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
254 }
255 }
256 if (mat.ContainsKey("SpecMap"))
257 {
258 UUID specularMapId = mat["SpecMap"].AsUUID();
259 if (specularMapId != UUID.Zero)
260 {
261 assetUuids[specularMapId] = AssetType.Texture;
262 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
263 }
264 }
265 }
266
267 }
268 catch (Exception e)
269 {
270 m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message);
271 }
272 }
273 }
274 }
275 }
276 }
277
278
279 /// <summary> 214 /// <summary>
280 /// Get an asset synchronously, potentially using an asynchronous callback. If the 215 /// Get an asset synchronously, potentially using an asynchronous callback. If the
281 /// asynchronous callback is used, we will wait for it to complete. 216 /// asynchronous callback is used, we will wait for it to complete.