aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2012-09-24 20:14:00 +0100
committerMelanie2012-09-24 20:14:00 +0100
commitbbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6 (patch)
tree2ac67907f6333bbbc9e4d821c6607b53d0e22acb /OpenSim/Region/Framework
parentMerge branch 'master' into careminster (diff)
parentHG Rez object: warn the user if the item or asset cannot be found. (diff)
downloadopensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.zip
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.gz
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.bz2
opensim-SC_OLD-bbaf2c5a80441fdbd2f55e02ec9f46c3b66869c6.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs172
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs136
3 files changed, 261 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index e257b57..67d218b 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -188,6 +188,22 @@ namespace OpenSim.Region.Framework.Scenes
188 188
189 public delegate void OnPluginConsoleDelegate(string[] args); 189 public delegate void OnPluginConsoleDelegate(string[] args);
190 190
191 /// <summary>
192 /// Triggered after <see cref="OpenSim.IApplicationPlugin.PostInitialise"/>
193 /// has been called for all <see cref="OpenSim.IApplicationPlugin"/>
194 /// loaded via <see cref="OpenSim.OpenSimBase.LoadPlugins"/>.
195 /// Handlers for this event are typically used to parse the arguments
196 /// from <see cref="OnPluginConsoleDelegate"/> in order to process or
197 /// filter the arguments and pass them onto <see cref="OpenSim.Region.CoreModules.Framework.InterfaceCommander.Commander.ProcessConsoleCommand"/>
198 /// </summary>
199 /// <remarks>
200 /// Triggered by <see cref="TriggerOnPluginConsole"/> in
201 /// <see cref="Scene.SendCommandToPlugins"/> via
202 /// <see cref="SceneManager.SendCommandToPluginModules"/> via
203 /// <see cref="OpenSim.OpenSimBase.HandleCommanderCommand"/> via
204 /// <see cref="OpenSim.OpenSimBase.AddPluginCommands"/> via
205 /// <see cref="OpenSim.OpenSimBase.StartupSpecific"/>
206 /// </remarks>
191 public event OnPluginConsoleDelegate OnPluginConsole; 207 public event OnPluginConsoleDelegate OnPluginConsole;
192 208
193 /// <summary> 209 /// <summary>
@@ -202,6 +218,18 @@ namespace OpenSim.Region.Framework.Scenes
202 218
203 public delegate void OnSetRootAgentSceneDelegate(UUID agentID, Scene scene); 219 public delegate void OnSetRootAgentSceneDelegate(UUID agentID, Scene scene);
204 220
221 /// <summary>
222 /// Triggered before the grunt work for adding a root agent to a
223 /// scene has been performed (resuming attachment scripts, physics,
224 /// animations etc.)
225 /// </summary>
226 /// <remarks>
227 /// Triggered before <see cref="OnMakeRootAgent"/>
228 /// by <see cref="TriggerSetRootAgentScene"/>
229 /// in <see cref="ScenePresence.MakeRootAgent"/>
230 /// via <see cref="Scene.AgentCrossing"/>
231 /// and <see cref="ScenePresence.CompleteMovement"/>
232 /// </remarks>
205 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 233 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
206 234
207 /// <summary> 235 /// <summary>
@@ -226,13 +254,45 @@ namespace OpenSim.Region.Framework.Scenes
226 /// <summary> 254 /// <summary>
227 /// Fired when an object is touched/grabbed. 255 /// Fired when an object is touched/grabbed.
228 /// </summary> 256 /// </summary>
257 /// <remarks>
229 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 258 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
230 /// the root part. 259 /// the root part.
260 /// Triggerd in response to <see cref="OpenSim.Framework.IClientAPI.OnGrabObject"/>
261 /// via <see cref="TriggerObjectGrab"/>
262 /// in <see cref="Scene.ProcessObjectGrab"/>
263 /// </remarks>
231 public event ObjectGrabDelegate OnObjectGrab; 264 public event ObjectGrabDelegate OnObjectGrab;
232 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); 265 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
233 266
267 /// <summary>
268 /// Triggered when an object is being touched/grabbed continuously.
269 /// </summary>
270 /// <remarks>
271 /// Triggered in response to <see cref="OpenSim.Framework.IClientAPI.OnGrabUpdate"/>
272 /// via <see cref="TriggerObjectGrabbing"/>
273 /// in <see cref="Scene.ProcessObjectGrabUpdate"/>
274 /// </remarks>
234 public event ObjectGrabDelegate OnObjectGrabbing; 275 public event ObjectGrabDelegate OnObjectGrabbing;
276
277 /// <summary>
278 /// Triggered when an object stops being touched/grabbed.
279 /// </summary>
280 /// <remarks>
281 /// Triggered in response to <see cref="OpenSim.Framework.IClientAPI.OnDeGrabObject"/>
282 /// via <see cref="TriggerObjectDeGrab"/>
283 /// in <see cref="Scene.ProcessObjectDeGrab"/>
284 /// </remarks>
235 public event ObjectDeGrabDelegate OnObjectDeGrab; 285 public event ObjectDeGrabDelegate OnObjectDeGrab;
286
287 /// <summary>
288 /// Triggered when a script resets.
289 /// </summary>
290 /// <remarks>
291 /// Triggered by <see cref="TriggerScriptReset"/>
292 /// in <see cref="Scene.ProcessScriptReset"/>
293 /// via <see cref="OpenSim.Framework.IClientAPI.OnScriptReset"/>
294 /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.LLClientView.HandleScriptReset"/>
295 /// </remarks>
236 public event ScriptResetDelegate OnScriptReset; 296 public event ScriptResetDelegate OnScriptReset;
237 297
238 public event OnPermissionErrorDelegate OnPermissionError; 298 public event OnPermissionErrorDelegate OnPermissionError;
@@ -242,17 +302,50 @@ namespace OpenSim.Region.Framework.Scenes
242 /// </summary> 302 /// </summary>
243 /// <remarks> 303 /// <remarks>
244 /// Occurs after OnNewScript. 304 /// Occurs after OnNewScript.
305 /// Triggered by <see cref="TriggerRezScript"/>
306 /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>
245 /// </remarks> 307 /// </remarks>
246 public event NewRezScript OnRezScript; 308 public event NewRezScript OnRezScript;
247 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 309 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
248 310
249 public delegate void RemoveScript(uint localID, UUID itemID); 311 public delegate void RemoveScript(uint localID, UUID itemID);
312
313 /// <summary>
314 /// Triggered when a script is removed from an object.
315 /// </summary>
316 /// <remarks>
317 /// Triggered by <see cref="TriggerRemoveScript"/>
318 /// in <see cref="Scene.RemoveTaskInventory"/>,
319 /// <see cref="Scene.CreateAgentInventoryItemFromTask"/>,
320 /// <see cref="SceneObjectPartInventory.RemoveScriptInstance"/>,
321 /// <see cref="SceneObjectPartInventory.RemoveInventoryItem"/>
322 /// </remarks>
250 public event RemoveScript OnRemoveScript; 323 public event RemoveScript OnRemoveScript;
251 324
252 public delegate void StartScript(uint localID, UUID itemID); 325 public delegate void StartScript(uint localID, UUID itemID);
326
327 /// <summary>
328 /// Triggered when a script starts.
329 /// </summary>
330 /// <remarks>
331 /// Triggered by <see cref="TriggerStartScript"/>
332 /// in <see cref="Scene.SetScriptRunning"/>
333 /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>,
334 /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/>
335 /// </remarks>
253 public event StartScript OnStartScript; 336 public event StartScript OnStartScript;
254 337
255 public delegate void StopScript(uint localID, UUID itemID); 338 public delegate void StopScript(uint localID, UUID itemID);
339
340 /// <summary>
341 /// Triggered when a script stops.
342 /// </summary>
343 /// <remarks>
344 /// Triggered by <see cref="TriggerStopScript"/>,
345 /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>,
346 /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>,
347 /// <see cref="Scene.SetScriptRunning"/>
348 /// </remarks>
256 public event StopScript OnStopScript; 349 public event StopScript OnStopScript;
257 350
258 public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta); 351 public delegate bool SceneGroupMoved(UUID groupID, Vector3 delta);
@@ -303,6 +396,9 @@ namespace OpenSim.Region.Framework.Scenes
303 /// </summary> 396 /// </summary>
304 /// <remarks> 397 /// <remarks>
305 /// Occurs before OnRezScript 398 /// Occurs before OnRezScript
399 /// Triggered by <see cref="TriggerNewScript"/>
400 /// in <see cref="Scene.RezScriptFromAgentInventory"/>,
401 /// <see cref="Scene.RezNewScript"/>
306 /// </remarks> 402 /// </remarks>
307 public event NewScript OnNewScript; 403 public event NewScript OnNewScript;
308 404
@@ -337,6 +433,12 @@ namespace OpenSim.Region.Framework.Scenes
337 /// </summary> 433 /// </summary>
338 /// <remarks> 434 /// <remarks>
339 /// Triggered after the scene receives a client's upload of an updated script and has stored it in an asset. 435 /// Triggered after the scene receives a client's upload of an updated script and has stored it in an asset.
436 /// Triggered by <see cref="TriggerUpdateScript"/>
437 /// in <see cref="Scene.CapsUpdateTaskInventoryScriptAsset"/>
438 /// via <see cref="Scene.CapsUpdateTaskInventoryScriptAsset"/>
439 /// via <see cref="OpenSim.Region.ClientStack.Linden.BunchOfCaps.TaskScriptUpdated"/>
440 /// via <see cref="OpenSim.Region.ClientStack.Linden.TaskInventoryScriptUpdater.OnUpLoad"/>
441 /// via <see cref="OpenSim.Region.ClientStack.Linden.TaskInventoryScriptUpdater.uploaderCaps"/>
340 /// </remarks> 442 /// </remarks>
341 public event UpdateScript OnUpdateScript; 443 public event UpdateScript OnUpdateScript;
342 444
@@ -395,15 +497,36 @@ namespace OpenSim.Region.Framework.Scenes
395 public event ScriptColliding OnScriptLandColliderEnd; 497 public event ScriptColliding OnScriptLandColliderEnd;
396 498
397 public delegate void OnMakeChildAgentDelegate(ScenePresence presence); 499 public delegate void OnMakeChildAgentDelegate(ScenePresence presence);
500
501 /// <summary>
502 /// Triggered when an agent has been made a child agent of a scene.
503 /// </summary>
504 /// <remarks>
505 /// Triggered by <see cref="TriggerOnMakeChildAgent"/>
506 /// in <see cref="ScenePresence.MakeChildAgent"/>
507 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.CrossAgentToNewRegionAsync"/>,
508 /// <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>,
509 /// <see cref="OpenSim.Region.CoreModules.InterGrid.KillAUser.ShutdownNoLogout"/>
510 /// </remarks>
398 public event OnMakeChildAgentDelegate OnMakeChildAgent; 511 public event OnMakeChildAgentDelegate OnMakeChildAgent;
399 512
400 public delegate void OnSaveNewWindlightProfileDelegate(); 513 public delegate void OnSaveNewWindlightProfileDelegate();
401 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user); 514 public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionLightShareData wl, UUID user);
402 515
403 /// <summary> 516 /// <summary>
517 /// Triggered after the grunt work for adding a root agent to a
518 /// scene has been performed (resuming attachment scripts, physics,
519 /// animations etc.)
520 /// </summary>
521 /// <remarks>
404 /// This event is on the critical path for transferring an avatar from one region to another. Try and do 522 /// This event is on the critical path for transferring an avatar from one region to another. Try and do
405 /// as little work on this event as possible, or do work asynchronously. 523 /// as little work on this event as possible, or do work asynchronously.
406 /// </summary> 524 /// Triggered after <see cref="OnSetRootAgentScene"/>
525 /// by <see cref="TriggerOnMakeRootAgent"/>
526 /// in <see cref="ScenePresence.MakeRootAgent"/>
527 /// via <see cref="Scene.AgentCrossing"/>
528 /// and <see cref="ScenePresence.CompleteMovement"/>
529 /// </remarks>
407 public event Action<ScenePresence> OnMakeRootAgent; 530 public event Action<ScenePresence> OnMakeRootAgent;
408 531
409 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted; 532 public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
@@ -429,9 +552,10 @@ namespace OpenSim.Region.Framework.Scenes
429 public event AvatarKillData OnAvatarKilled; 552 public event AvatarKillData OnAvatarKilled;
430 public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar); 553 public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar);
431 554
432// public delegate void ScriptTimerEvent(uint localID, double timerinterval); 555 /*
433 556 public delegate void ScriptTimerEvent(uint localID, double timerinterval);
434// public event ScriptTimerEvent OnScriptTimerEvent; 557 public event ScriptTimerEvent OnScriptTimerEvent;
558 */
435 559
436 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 560 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
437 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 561 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
@@ -441,12 +565,27 @@ namespace OpenSim.Region.Framework.Scenes
441 /// <summary> 565 /// <summary>
442 /// Triggered when an object is added to the scene. 566 /// Triggered when an object is added to the scene.
443 /// </summary> 567 /// </summary>
568 /// <remarks>
569 /// Triggered by <see cref="TriggerObjectAddedToScene"/>
570 /// in <see cref="Scene.AddNewSceneObject"/>,
571 /// <see cref="Scene.DuplicateObject"/>,
572 /// <see cref="Scene.doObjectDuplicateOnRay"/>
573 /// </remarks>
444 public event Action<SceneObjectGroup> OnObjectAddedToScene; 574 public event Action<SceneObjectGroup> OnObjectAddedToScene;
445 575
446 /// <summary> 576 /// <summary>
447 /// Triggered when an object is removed from the scene. 577 /// Delegate for <see cref="OnObjectBeingRemovedFromScene"/>
448 /// </summary> 578 /// </summary>
579 /// <param name="obj">The object being removed from the scene</param>
449 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); 580 public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
581
582 /// <summary>
583 /// Triggered when an object is removed from the scene.
584 /// </summary>
585 /// <remarks>
586 /// Triggered by <see cref="TriggerObjectBeingRemovedFromScene"/>
587 /// in <see cref="Scene.DeleteSceneObject"/>
588 /// </remarks>
450 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; 589 public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
451 590
452 public delegate void NoticeNoLandDataFromStorage(); 591 public delegate void NoticeNoLandDataFromStorage();
@@ -632,9 +771,28 @@ namespace OpenSim.Region.Framework.Scenes
632 public event PrimsLoaded OnPrimsLoaded; 771 public event PrimsLoaded OnPrimsLoaded;
633 772
634 public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout); 773 public delegate void TeleportStart(IClientAPI client, GridRegion destination, GridRegion finalDestination, uint teleportFlags, bool gridLogout);
774
775 /// <summary>
776 /// Triggered when a teleport starts
777 /// </summary>
778 /// <remarks>
779 /// Triggered by <see cref="TriggerTeleportStart"/>
780 /// in <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.CreateAgent"/>
781 /// and <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule.CreateAgent"/>
782 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>
783 /// </remarks>
635 public event TeleportStart OnTeleportStart; 784 public event TeleportStart OnTeleportStart;
636 785
637 public delegate void TeleportFail(IClientAPI client, bool gridLogout); 786 public delegate void TeleportFail(IClientAPI client, bool gridLogout);
787
788 /// <summary>
789 /// Trigered when a teleport fails.
790 /// </summary>
791 /// <remarks>
792 /// Triggered by <see cref="TriggerTeleportFail"/>
793 /// in <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.Fail"/>
794 /// via <see cref="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule.DoTeleport"/>
795 /// </remarks>
638 public event TeleportFail OnTeleportFail; 796 public event TeleportFail OnTeleportFail;
639 797
640 public class MoneyTransferArgs : EventArgs 798 public class MoneyTransferArgs : EventArgs
@@ -642,7 +800,9 @@ namespace OpenSim.Region.Framework.Scenes
642 public UUID sender; 800 public UUID sender;
643 public UUID receiver; 801 public UUID receiver;
644 802
645 // Always false. The SL protocol sucks. 803 /// <summary>
804 /// Always false. The SL protocol sucks.
805 /// </summary>
646 public bool authenticated = false; 806 public bool authenticated = false;
647 807
648 public int amount; 808 public int amount;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ee5f6df..129bf09 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
106 /// <summary> 106 /// <summary>
107 /// Minimum value of the size of a non-physical prim in each axis 107 /// Minimum value of the size of a non-physical prim in each axis
108 /// </summary> 108 /// </summary>
109 public float m_minNonphys = 0.01f; 109 public float m_minNonphys = 0.001f;
110 110
111 /// <summary> 111 /// <summary>
112 /// Maximum value of the size of a non-physical prim in each axis 112 /// Maximum value of the size of a non-physical prim in each axis
@@ -769,13 +769,13 @@ namespace OpenSim.Region.Framework.Scenes
769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 769 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 770 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
771 771
772 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys); 772 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
773 if (RegionInfo.NonphysPrimMin > 0) 773 if (RegionInfo.NonphysPrimMin > 0)
774 { 774 {
775 m_minNonphys = RegionInfo.NonphysPrimMin; 775 m_minNonphys = RegionInfo.NonphysPrimMin;
776 } 776 }
777 777
778 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 778 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
779 if (RegionInfo.NonphysPrimMax > 0) 779 if (RegionInfo.NonphysPrimMax > 0)
780 { 780 {
781 m_maxNonphys = RegionInfo.NonphysPrimMax; 781 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -895,6 +895,8 @@ namespace OpenSim.Region.Framework.Scenes
895 } 895 }
896 896
897 // FIXME: Ultimately this should be in a module. 897 // FIXME: Ultimately this should be in a module.
898 SendPeriodicAppearanceUpdates = true;
899
898 IConfig appearanceConfig = m_config.Configs["Appearance"]; 900 IConfig appearanceConfig = m_config.Configs["Appearance"];
899 if (appearanceConfig != null) 901 if (appearanceConfig != null)
900 { 902 {
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 411e421..b5ef7b0 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -52,26 +52,23 @@ namespace OpenSim.Region.Framework.Scenes
52 public class UuidGatherer 52 public class UuidGatherer
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 /// <summary>
57 /// Asset cache used for gathering assets
58 /// </summary>
59 protected IAssetService m_assetCache;
60
61 /// <summary>
62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
63 /// asset was found by the asset service.
64 /// </summary>
65 private AssetBase m_requestedObjectAsset;
66 55
67 /// <summary> 56 protected IAssetService m_assetService;
68 /// Signal whether we are currently waiting for the asset service to deliver an asset. 57
69 /// </summary> 58// /// <summary>
70 private bool m_waitingForObjectAsset; 59// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
60// /// asset was found by the asset service.
61// /// </summary>
62// private AssetBase m_requestedObjectAsset;
63//
64// /// <summary>
65// /// Signal whether we are currently waiting for the asset service to deliver an asset.
66// /// </summary>
67// private bool m_waitingForObjectAsset;
71 68
72 public UuidGatherer(IAssetService assetCache) 69 public UuidGatherer(IAssetService assetCache)
73 { 70 {
74 m_assetCache = assetCache; 71 m_assetService = assetCache;
75 } 72 }
76 73
77 /// <summary> 74 /// <summary>
@@ -191,18 +188,18 @@ namespace OpenSim.Region.Framework.Scenes
191 } 188 }
192 } 189 }
193 190
194 /// <summary> 191// /// <summary>
195 /// The callback made when we request the asset for an object from the asset service. 192// /// The callback made when we request the asset for an object from the asset service.
196 /// </summary> 193// /// </summary>
197 private void AssetReceived(string id, Object sender, AssetBase asset) 194// private void AssetReceived(string id, Object sender, AssetBase asset)
198 { 195// {
199 lock (this) 196// lock (this)
200 { 197// {
201 m_requestedObjectAsset = asset; 198// m_requestedObjectAsset = asset;
202 m_waitingForObjectAsset = false; 199// m_waitingForObjectAsset = false;
203 Monitor.Pulse(this); 200// Monitor.Pulse(this);
204 } 201// }
205 } 202// }
206 203
207 /// <summary> 204 /// <summary>
208 /// Get an asset synchronously, potentially using an asynchronous callback. If the 205 /// Get an asset synchronously, potentially using an asynchronous callback. If the
@@ -212,25 +209,29 @@ namespace OpenSim.Region.Framework.Scenes
212 /// <returns></returns> 209 /// <returns></returns>
213 protected virtual AssetBase GetAsset(UUID uuid) 210 protected virtual AssetBase GetAsset(UUID uuid)
214 { 211 {
215 m_waitingForObjectAsset = true; 212 return m_assetService.Get(uuid.ToString());
216 m_assetCache.Get(uuid.ToString(), this, AssetReceived);
217
218 // The asset cache callback can either
219 //
220 // 1. Complete on the same thread (if the asset is already in the cache) or
221 // 2. Come in via a different thread (if we need to go fetch it).
222 //
223 // The code below handles both these alternatives.
224 lock (this)
225 {
226 if (m_waitingForObjectAsset)
227 {
228 Monitor.Wait(this);
229 m_waitingForObjectAsset = false;
230 }
231 }
232 213
233 return m_requestedObjectAsset; 214 // XXX: Switching to do this synchronously where the call was async before but we always waited for it
215 // to complete anyway!
216// m_waitingForObjectAsset = true;
217// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
218//
219// // The asset cache callback can either
220// //
221// // 1. Complete on the same thread (if the asset is already in the cache) or
222// // 2. Come in via a different thread (if we need to go fetch it).
223// //
224// // The code below handles both these alternatives.
225// lock (this)
226// {
227// if (m_waitingForObjectAsset)
228// {
229// Monitor.Wait(this);
230// m_waitingForObjectAsset = false;
231// }
232// }
233//
234// return m_requestedObjectAsset;
234 } 235 }
235 236
236 /// <summary> 237 /// <summary>
@@ -361,4 +362,47 @@ namespace OpenSim.Region.Framework.Scenes
361 } 362 }
362 } 363 }
363 } 364 }
365
366 public class HGUuidGatherer : UuidGatherer
367 {
368 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
369
370 protected string m_assetServerURL;
371
372 public HGUuidGatherer(IAssetService assetService, string assetServerURL)
373 : base(assetService)
374 {
375 m_assetServerURL = assetServerURL;
376 if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))
377 m_assetServerURL = m_assetServerURL + "/";
378 }
379
380 protected override AssetBase GetAsset(UUID uuid)
381 {
382 if (string.Empty == m_assetServerURL)
383 return base.GetAsset(uuid);
384 else
385 return FetchAsset(uuid);
386 }
387
388 public AssetBase FetchAsset(UUID assetID)
389 {
390
391 // Test if it's already here
392 AssetBase asset = m_assetService.Get(assetID.ToString());
393 if (asset == null)
394 {
395 // It's not, so fetch it from abroad
396 asset = m_assetService.Get(m_assetServerURL + assetID.ToString());
397 if (asset != null)
398 m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server", assetID, m_assetServerURL);
399 else
400 m_log.DebugFormat("[HGUUIDGatherer]: Failed to fetch asset {0} from {1}", assetID, m_assetServerURL);
401 }
402 //else
403 // m_log.DebugFormat("[HGUUIDGatherer]: Asset {0} from {1} was already here", assetID, m_assetServerURL);
404
405 return asset;
406 }
407 }
364} 408}