aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs1
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs43
-rw-r--r--OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs57
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityManager.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs36
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs448
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs62
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs115
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs166
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs101
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs83
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
30 files changed, 783 insertions, 495 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
index da39e95..0bb4567 100644
--- a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs
@@ -37,6 +37,7 @@ namespace OpenSim.Region.Framework.Interfaces
37 { 37 {
38 bool CreateStore(string value, ref UUID result); 38 bool CreateStore(string value, ref UUID result);
39 bool DestroyStore(UUID storeID); 39 bool DestroyStore(UUID storeID);
40 bool TestStore(UUID storeID);
40 bool TestPath(UUID storeID, string path, bool useJson); 41 bool TestPath(UUID storeID, string path, bool useJson);
41 bool SetValue(UUID storeID, string path, string value, bool useJson); 42 bool SetValue(UUID storeID, string path, string value, bool useJson);
42 bool RemoveValue(UUID storeID, string path); 43 bool RemoveValue(UUID storeID, string path);
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs
new file mode 100644
index 0000000..c5e678b
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs
@@ -0,0 +1,43 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33
34namespace OpenSim.Region.Framework.Interfaces
35{
36 public interface ISceneCommandsModule
37 {
38 /// <summary>
39 /// Sets the scene debug options.
40 /// </summary>
41 void SetSceneDebugOptions(Dictionary<string, string> options);
42 }
43} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
index 6db6674..093d3f0 100644
--- a/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
+++ b/OpenSim/Region/Framework/Interfaces/IXmlRpcRouter.cs
@@ -34,5 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces
34 void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url); 34 void RegisterNewReceiver(IScriptModule scriptEngine, UUID channelID, UUID objectID, UUID itemID, string url);
35 void ScriptRemoved(UUID itemID); 35 void ScriptRemoved(UUID itemID);
36 void ObjectRemoved(UUID objectID); 36 void ObjectRemoved(UUID objectID);
37 void UnRegisterReceiver(string channelID, UUID itemID);
37 } 38 }
38} 39}
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
index 65ae445..66edfed 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
@@ -87,13 +87,24 @@ namespace OpenSim.Region.Framework.Scenes.Animation
87 return false; 87 return false;
88 } 88 }
89 89
90 public bool Remove(UUID animID) 90 /// <summary>
91 /// Remove the specified animation
92 /// </summary>
93 /// <param name='animID'></param>
94 /// <param name='allowNoDefault'>
95 /// If true, then the default animation can be entirely removed.
96 /// If false, then removing the default animation will reset it to the simulator default (currently STAND).
97 /// </param>
98 public bool Remove(UUID animID, bool allowNoDefault)
91 { 99 {
92 lock (m_animations) 100 lock (m_animations)
93 { 101 {
94 if (m_defaultAnimation.AnimID == animID) 102 if (m_defaultAnimation.AnimID == animID)
95 { 103 {
96 m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero); 104 if (allowNoDefault)
105 m_defaultAnimation = new OpenSim.Framework.Animation(UUID.Zero, 1, UUID.Zero);
106 else
107 ResetDefaultAnimation();
97 } 108 }
98 else if (HasAnimation(animID)) 109 else if (HasAnimation(animID))
99 { 110 {
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 9458079..65c279e 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -26,9 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Threading;
30using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
32using log4net; 33using log4net;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -86,6 +87,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
86 return; 87 return;
87 88
88 // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); 89 // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name);
90 if (m_scenePresence.Scene.DebugAnimations)
91 m_log.DebugFormat(
92 "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}",
93 GetAnimName(animID), animID, m_scenePresence.Name);
89 94
90 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) 95 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
91 SendAnimPack(); 96 SendAnimPack();
@@ -108,12 +113,25 @@ namespace OpenSim.Region.Framework.Scenes.Animation
108 AddAnimation(animID, objectID); 113 AddAnimation(animID, objectID);
109 } 114 }
110 115
111 public void RemoveAnimation(UUID animID) 116 /// <summary>
117 /// Remove the specified animation
118 /// </summary>
119 /// <param name='animID'></param>
120 /// <param name='allowNoDefault'>
121 /// If true, then the default animation can be entirely removed.
122 /// If false, then removing the default animation will reset it to the simulator default (currently STAND).
123 /// </param>
124 public void RemoveAnimation(UUID animID, bool allowNoDefault)
112 { 125 {
113 if (m_scenePresence.IsChildAgent) 126 if (m_scenePresence.IsChildAgent)
114 return; 127 return;
115 128
116 if (m_animations.Remove(animID)) 129 if (m_scenePresence.Scene.DebugAnimations)
130 m_log.DebugFormat(
131 "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}",
132 GetAnimName(animID), animID, m_scenePresence.Name);
133
134 if (m_animations.Remove(animID, allowNoDefault))
117 SendAnimPack(); 135 SendAnimPack();
118 } 136 }
119 137
@@ -127,7 +145,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
127 if (addRemove) 145 if (addRemove)
128 m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); 146 m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero);
129 else 147 else
130 m_animations.Remove(animID); 148 m_animations.Remove(animID, true);
131 } 149 }
132 if(sendPack) 150 if(sendPack)
133 SendAnimPack(); 151 SendAnimPack();
@@ -145,14 +163,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
145 if (animID == UUID.Zero) 163 if (animID == UUID.Zero)
146 return; 164 return;
147 165
148 RemoveAnimation(animID); 166 RemoveAnimation(animID, true);
149 } 167 }
150 168
151 public void ResetAnimations() 169 public void ResetAnimations()
152 { 170 {
153// m_log.DebugFormat( 171 if (m_scenePresence.Scene.DebugAnimations)
154// "[SCENE PRESENCE ANIMATOR]: Resetting animations for {0} in {1}", 172 m_log.DebugFormat(
155// m_scenePresence.Name, m_scenePresence.Scene.RegionInfo.RegionName); 173 "[SCENE PRESENCE ANIMATOR]: Resetting animations for {0} in {1}",
174 m_scenePresence.Name, m_scenePresence.Scene.RegionInfo.RegionName);
156 175
157 m_animations.Clear(); 176 m_animations.Clear();
158 } 177 }
@@ -519,6 +538,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
519 if (m_scenePresence.IsChildAgent) 538 if (m_scenePresence.IsChildAgent)
520 return; 539 return;
521 540
541// m_log.DebugFormat(
542// "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'",
543// string.Join(",", Array.ConvertAll<UUID, string>(animations, a => a.ToString())),
544// string.Join(",", Array.ConvertAll<int, string>(seqs, s => s.ToString())),
545// string.Join(",", Array.ConvertAll<UUID, string>(objectIDs, o => o.ToString())));
546
522 m_scenePresence.Scene.ForEachClient( 547 m_scenePresence.Scene.ForEachClient(
523 delegate(IClientAPI client) 548 delegate(IClientAPI client)
524 { 549 {
@@ -557,5 +582,21 @@ namespace OpenSim.Region.Framework.Scenes.Animation
557 582
558 SendAnimPack(animIDs, sequenceNums, objectIDs); 583 SendAnimPack(animIDs, sequenceNums, objectIDs);
559 } 584 }
585
586 public string GetAnimName(UUID animId)
587 {
588 string animName;
589
590 if (!DefaultAvatarAnimations.AnimsNames.TryGetValue(animId, out animName))
591 {
592 AssetMetadata amd = m_scenePresence.Scene.AssetService.GetMetadata(animId.ToString());
593 if (amd != null)
594 animName = amd.Name;
595 else
596 animName = "Unknown";
597 }
598
599 return animName;
600 }
560 } 601 }
561} 602}
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs
index b788a3c..7181313 100644
--- a/OpenSim/Region/Framework/Scenes/EntityManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework;
34 35
35namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
36{ 37{
@@ -38,7 +39,8 @@ namespace OpenSim.Region.Framework.Scenes
38 { 39 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 40// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 41
41 private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>(); 42 private readonly DoubleDictionaryThreadAbortSafe<UUID, uint, EntityBase> m_entities
43 = new DoubleDictionaryThreadAbortSafe<UUID, uint, EntityBase>();
42 44
43 public int Count 45 public int Count
44 { 46 {
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 5b1c9f4..052a05e 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -550,6 +550,20 @@ namespace OpenSim.Region.Framework.Scenes
550 /// </remarks> 550 /// </remarks>
551 public event ScriptControlEvent OnScriptControlEvent; 551 public event ScriptControlEvent OnScriptControlEvent;
552 552
553 public delegate void ScriptMovingStartEvent(uint localID);
554
555 /// <summary>
556 /// TODO: Should be triggered when a physics object starts moving.
557 /// </summary>
558 public event ScriptMovingStartEvent OnScriptMovingStartEvent;
559
560 public delegate void ScriptMovingEndEvent(uint localID);
561
562 /// <summary>
563 /// TODO: Should be triggered when a physics object stops moving.
564 /// </summary>
565 public event ScriptMovingEndEvent OnScriptMovingEndEvent;
566
553 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 567 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
554 568
555 /// <summary> 569 /// <summary>
@@ -755,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes
755 public event ScriptTimerEvent OnScriptTimerEvent; 769 public event ScriptTimerEvent OnScriptTimerEvent;
756 */ 770 */
757 771
758 public delegate void EstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour); 772 public delegate void EstateToolsSunUpdate(ulong regionHandle);
759 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); 773 public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
760 774
761 public event EstateToolsSunUpdate OnEstateToolsSunUpdate; 775 public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
@@ -2238,6 +2252,48 @@ namespace OpenSim.Region.Framework.Scenes
2238 } 2252 }
2239 } 2253 }
2240 2254
2255 public void TriggerMovingStartEvent(uint localID)
2256 {
2257 ScriptMovingStartEvent handlerScriptMovingStartEvent = OnScriptMovingStartEvent;
2258 if (handlerScriptMovingStartEvent != null)
2259 {
2260 foreach (ScriptMovingStartEvent d in handlerScriptMovingStartEvent.GetInvocationList())
2261 {
2262 try
2263 {
2264 d(localID);
2265 }
2266 catch (Exception e)
2267 {
2268 m_log.ErrorFormat(
2269 "[EVENT MANAGER]: Delegate for TriggerMovingStartEvent failed - continuing. {0} {1}",
2270 e.Message, e.StackTrace);
2271 }
2272 }
2273 }
2274 }
2275
2276 public void TriggerMovingEndEvent(uint localID)
2277 {
2278 ScriptMovingEndEvent handlerScriptMovingEndEvent = OnScriptMovingEndEvent;
2279 if (handlerScriptMovingEndEvent != null)
2280 {
2281 foreach (ScriptMovingEndEvent d in handlerScriptMovingEndEvent.GetInvocationList())
2282 {
2283 try
2284 {
2285 d(localID);
2286 }
2287 catch (Exception e)
2288 {
2289 m_log.ErrorFormat(
2290 "[EVENT MANAGER]: Delegate for TriggerMovingEndEvent failed - continuing. {0} {1}",
2291 e.Message, e.StackTrace);
2292 }
2293 }
2294 }
2295 }
2296
2241 public void TriggerRequestChangeWaterHeight(float height) 2297 public void TriggerRequestChangeWaterHeight(float height)
2242 { 2298 {
2243 if (height < 0) 2299 if (height < 0)
@@ -2536,13 +2592,10 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2592 }
2537 2593
2538 /// <summary> 2594 /// <summary>
2539 /// Updates the system as to how the position of the sun should be handled. 2595 /// Called when the sun's position parameters have changed in the Region and/or Estate
2540 /// </summary> 2596 /// </summary>
2541 /// <param name="regionHandle"></param> 2597 /// <param name="regionHandle">The region that changed</param>
2542 /// <param name="FixedTime">True if the Sun Position is fixed</param> 2598 public void TriggerEstateToolsSunUpdate(ulong regionHandle)
2543 /// <param name="useEstateTime">True if the Estate Settings should be used instead of region</param>
2544 /// <param name="FixedSunHour">The hour 0.0 <= FixedSunHour <= 24.0 at which the sun is fixed at. Sun Hour 0 is sun-rise, when Day/Night ratio is 1:1</param>
2545 public void TriggerEstateToolsSunUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float FixedSunHour)
2546 { 2599 {
2547 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate; 2600 EstateToolsSunUpdate handlerEstateToolsSunUpdate = OnEstateToolsSunUpdate;
2548 if (handlerEstateToolsSunUpdate != null) 2601 if (handlerEstateToolsSunUpdate != null)
@@ -2551,7 +2604,7 @@ namespace OpenSim.Region.Framework.Scenes
2551 { 2604 {
2552 try 2605 try
2553 { 2606 {
2554 d(regionHandle, FixedTime, useEstateTime, FixedSunHour); 2607 d(regionHandle);
2555 } 2608 }
2556 catch (Exception e) 2609 catch (Exception e)
2557 { 2610 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4130029..a9e1fc2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -684,12 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
684 itemCopy.SalePrice = item.SalePrice; 684 itemCopy.SalePrice = item.SalePrice;
685 itemCopy.SaleType = item.SaleType; 685 itemCopy.SaleType = item.SaleType;
686 686
687 if (AddInventoryItem(itemCopy)) 687 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
688 { 688 if (invAccess != null)
689 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 689 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
690 if (invAccess != null) 690 AddInventoryItem(itemCopy);
691 Util.FireAndForget(delegate { invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); });
692 }
693 691
694 if (!Permissions.BypassPermissions()) 692 if (!Permissions.BypassPermissions())
695 { 693 {
@@ -1786,6 +1784,21 @@ namespace OpenSim.Region.Framework.Scenes
1786 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns> 1784 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1787 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase) 1785 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase)
1788 { 1786 {
1787 return RezNewScript(
1788 agentID,
1789 itemBase,
1790 "default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}");
1791 }
1792
1793 /// <summary>
1794 /// Rez a new script from nothing with given script text.
1795 /// </summary>
1796 /// <param name="remoteClient"></param>
1797 /// <param name="itemBase">Template item.</param>
1798 /// <param name="scriptText"></param>
1799 /// <returns>The part where the script was rezzed if successful. False otherwise.</returns>
1800 public SceneObjectPart RezNewScript(UUID agentID, InventoryItemBase itemBase, string scriptText)
1801 {
1789 // The part ID is the folder ID! 1802 // The part ID is the folder ID!
1790 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder); 1803 SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
1791 if (part == null) 1804 if (part == null)
@@ -1805,9 +1818,14 @@ namespace OpenSim.Region.Framework.Scenes
1805 return null; 1818 return null;
1806 } 1819 }
1807 1820
1808 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, 1821 AssetBase asset
1809 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), 1822 = CreateAsset(
1810 agentID); 1823 itemBase.Name,
1824 itemBase.Description,
1825 (sbyte)itemBase.AssetType,
1826 Encoding.ASCII.GetBytes(scriptText),
1827 agentID);
1828
1811 AssetService.Store(asset); 1829 AssetService.Store(asset);
1812 1830
1813 TaskInventoryItem taskItem = new TaskInventoryItem(); 1831 TaskInventoryItem taskItem = new TaskInventoryItem();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c7a38f7..40a57a4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -68,14 +68,84 @@ namespace OpenSim.Region.Framework.Scenes
68 public bool EmergencyMonitoring = false; 68 public bool EmergencyMonitoring = false;
69 69
70 /// <summary> 70 /// <summary>
71 /// Show debug information about animations.
72 /// </summary>
73 public bool DebugAnimations { get; set; }
74
75 /// <summary>
71 /// Show debug information about teleports. 76 /// Show debug information about teleports.
72 /// </summary> 77 /// </summary>
73 public bool DebugTeleporting { get; private set; } 78 public bool DebugTeleporting { get; set; }
74 79
75 /// <summary> 80 /// <summary>
76 /// Show debug information about the scene loop. 81 /// Show debug information about the scene loop.
77 /// </summary> 82 /// </summary>
78 public bool DebugUpdates { get; private set; } 83 public bool DebugUpdates { get; set; }
84
85 /// <summary>
86 /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and
87 /// if objects meet required conditions (m_dontPersistBefore and m_dontPersistAfter).
88 /// </summary>
89 /// <remarks>
90 /// Even if false, the scene will still be saved on clean shutdown.
91 /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels.
92 /// This needs to be fixed.
93 /// </remarks>
94 public bool PeriodicBackup { get; set; }
95
96 /// <summary>
97 /// If false then the scene is never saved to persistence storage even if PeriodicBackup == true and even
98 /// if the scene is being shut down for the final time.
99 /// </summary>
100 public bool UseBackup { get; set; }
101
102 /// <summary>
103 /// If false then physical objects are disabled, though collisions will continue as normal.
104 /// </summary>
105 public bool PhysicsEnabled { get; set; }
106
107 /// <summary>
108 /// If false then scripts are not enabled on the smiulator
109 /// </summary>
110 public bool ScriptsEnabled
111 {
112 get { return m_scripts_enabled; }
113 set
114 {
115 if (m_scripts_enabled != value)
116 {
117 if (!value)
118 {
119 m_log.Info("Stopping all Scripts in Scene");
120
121 EntityBase[] entities = Entities.GetEntities();
122 foreach (EntityBase ent in entities)
123 {
124 if (ent is SceneObjectGroup)
125 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
126 }
127 }
128 else
129 {
130 m_log.Info("Starting all Scripts in Scene");
131
132 EntityBase[] entities = Entities.GetEntities();
133 foreach (EntityBase ent in entities)
134 {
135 if (ent is SceneObjectGroup)
136 {
137 SceneObjectGroup sog = (SceneObjectGroup)ent;
138 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
139 sog.ResumeScripts();
140 }
141 }
142 }
143
144 m_scripts_enabled = value;
145 }
146 }
147 }
148 private bool m_scripts_enabled;
79 149
80 public SynchronizeSceneHandler SynchronizeScene; 150 public SynchronizeSceneHandler SynchronizeScene;
81 151
@@ -284,8 +354,6 @@ namespace OpenSim.Region.Framework.Scenes
284 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 354 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
285 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); 355 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>();
286 356
287 private bool m_physics_enabled = true;
288 private bool m_scripts_enabled = true;
289 private string m_defaultScriptEngine; 357 private string m_defaultScriptEngine;
290 358
291 /// <summary> 359 /// <summary>
@@ -348,7 +416,6 @@ namespace OpenSim.Region.Framework.Scenes
348 416
349 private Timer m_mapGenerationTimer = new Timer(); 417 private Timer m_mapGenerationTimer = new Timer();
350 private bool m_generateMaptiles; 418 private bool m_generateMaptiles;
351 private bool m_useBackup = true;
352 419
353 #endregion Fields 420 #endregion Fields
354 421
@@ -614,11 +681,6 @@ namespace OpenSim.Region.Framework.Scenes
614 get { return m_authenticateHandler; } 681 get { return m_authenticateHandler; }
615 } 682 }
616 683
617 public bool UseBackup
618 {
619 get { return m_useBackup; }
620 }
621
622 // an instance to the physics plugin's Scene object. 684 // an instance to the physics plugin's Scene object.
623 public PhysicsScene PhysicsScene 685 public PhysicsScene PhysicsScene
624 { 686 {
@@ -762,15 +824,22 @@ namespace OpenSim.Region.Framework.Scenes
762 // 824 //
763 // Out of memory 825 // Out of memory
764 // Operating system has killed the plugin 826 // Operating system has killed the plugin
765 m_sceneGraph.UnRecoverableError += RestartNow; 827 m_sceneGraph.UnRecoverableError
828 += () =>
829 {
830 m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
831 RestartNow();
832 };
766 833
767 RegisterDefaultSceneEvents(); 834 RegisterDefaultSceneEvents();
768 835
769 DumpAssetsToFile = dumpAssetsToFile; 836 DumpAssetsToFile = dumpAssetsToFile;
770 837
838 // XXX: Don't set the public property since we don't want to activate here. This needs to be handled
839 // better in the future.
771 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; 840 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
772 841
773 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; 842 PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
774 843
775 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; 844 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
776 845
@@ -778,141 +847,139 @@ namespace OpenSim.Region.Framework.Scenes
778 847
779 // Region config overrides global config 848 // Region config overrides global config
780 // 849 //
781 try 850 if (m_config.Configs["Startup"] != null)
782 { 851 {
783 if (m_config.Configs["Startup"] != null) 852 IConfig startupConfig = m_config.Configs["Startup"];
784 {
785 IConfig startupConfig = m_config.Configs["Startup"];
786 853
787 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 854 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
788 855
789 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); 856 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
790 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); 857 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
791 if (!m_useBackup) 858 if (!UseBackup)
792 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 859 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
793 860
794 //Animation states 861 //Animation states
795 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 862 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
796 863
797 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 864 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
798 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 865 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
799 866
800 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 867 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
801 if (RegionInfo.NonphysPrimMin > 0) 868 if (RegionInfo.NonphysPrimMin > 0)
802 { 869 {
803 m_minNonphys = RegionInfo.NonphysPrimMin; 870 m_minNonphys = RegionInfo.NonphysPrimMin;
804 } 871 }
805 872
806 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 873 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
807 if (RegionInfo.NonphysPrimMax > 0) 874 if (RegionInfo.NonphysPrimMax > 0)
808 { 875 {
809 m_maxNonphys = RegionInfo.NonphysPrimMax; 876 m_maxNonphys = RegionInfo.NonphysPrimMax;
810 } 877 }
811 878
812 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 879 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
813 if (RegionInfo.PhysPrimMin > 0) 880 if (RegionInfo.PhysPrimMin > 0)
814 { 881 {
815 m_minPhys = RegionInfo.PhysPrimMin; 882 m_minPhys = RegionInfo.PhysPrimMin;
816 } 883 }
817 884
818 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 885 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
819 886
820 if (RegionInfo.PhysPrimMax > 0) 887 if (RegionInfo.PhysPrimMax > 0)
821 { 888 {
822 m_maxPhys = RegionInfo.PhysPrimMax; 889 m_maxPhys = RegionInfo.PhysPrimMax;
823 } 890 }
824 891
825 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 892 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
826 if (RegionInfo.LinksetCapacity > 0) 893 if (RegionInfo.LinksetCapacity > 0)
827 { 894 {
828 m_linksetCapacity = RegionInfo.LinksetCapacity; 895 m_linksetCapacity = RegionInfo.LinksetCapacity;
829 } 896 }
830 897
831 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 898 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
832 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 899 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
833 900
834 // Here, if clamping is requested in either global or 901 // Here, if clamping is requested in either global or
835 // local config, it will be used 902 // local config, it will be used
836 // 903 //
837 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); 904 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
838 if (RegionInfo.ClampPrimSize) 905 if (RegionInfo.ClampPrimSize)
906 {
907 m_clampPrimSize = true;
908 }
909
910 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
911 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
912 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
913 m_dontPersistBefore =
914 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
915 m_dontPersistBefore *= 10000000;
916 m_persistAfter =
917 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
918 m_persistAfter *= 10000000;
919
920 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
921 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
922
923 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
924 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
925 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
926
927 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
928 if (m_generateMaptiles)
929 {
930 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
931 if (maptileRefresh != 0)
839 { 932 {
840 m_clampPrimSize = true; 933 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
934 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
935 m_mapGenerationTimer.AutoReset = true;
936 m_mapGenerationTimer.Start();
841 } 937 }
938 }
939 else
940 {
941 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
942 UUID tileID;
842 943
843 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); 944 if ((tile!=UUID.Zero.ToString()) && UUID.TryParse(tile, out tileID))
844 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
845 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
846 m_dontPersistBefore =
847 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
848 m_dontPersistBefore *= 10000000;
849 m_persistAfter =
850 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
851 m_persistAfter *= 10000000;
852
853 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
854 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
855
856 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
857 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
858 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
859
860 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
861 if (m_generateMaptiles)
862 { 945 {
863 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 946 RegionInfo.RegionSettings.TerrainImageID = tileID;
864 if (maptileRefresh != 0)
865 {
866 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
867 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
868 m_mapGenerationTimer.AutoReset = true;
869 m_mapGenerationTimer.Start();
870 }
871 } 947 }
872 else 948 else
873 { 949 {
874 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); 950 RegionInfo.RegionSettings.TerrainImageID = RegionInfo.MaptileStaticUUID;
875 UUID tileID; 951 m_log.InfoFormat("[SCENE]: Region {0}, maptile set to {1}", RegionInfo.RegionName, RegionInfo.MaptileStaticUUID.ToString());
876
877 if (UUID.TryParse(tile, out tileID))
878 {
879 RegionInfo.RegionSettings.TerrainImageID = tileID;
880 }
881 } 952 }
953 }
882 954
883 string grant = startupConfig.GetString("AllowedClients", String.Empty); 955 string grant = startupConfig.GetString("AllowedClients", String.Empty);
884 if (grant.Length > 0) 956 if (grant.Length > 0)
957 {
958 foreach (string viewer in grant.Split(','))
885 { 959 {
886 foreach (string viewer in grant.Split(',')) 960 m_AllowedViewers.Add(viewer.Trim().ToLower());
887 {
888 m_AllowedViewers.Add(viewer.Trim().ToLower());
889 }
890 } 961 }
962 }
891 963
892 grant = startupConfig.GetString("BannedClients", String.Empty); 964 grant = startupConfig.GetString("BannedClients", String.Empty);
893 if (grant.Length > 0) 965 if (grant.Length > 0)
966 {
967 foreach (string viewer in grant.Split(','))
894 { 968 {
895 foreach (string viewer in grant.Split(',')) 969 m_BannedViewers.Add(viewer.Trim().ToLower());
896 {
897 m_BannedViewers.Add(viewer.Trim().ToLower());
898 }
899 } 970 }
900
901 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
902 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
903 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
904 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
905 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
906 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
907 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
908 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
909 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
910 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
911 } 971 }
912 } 972
913 catch (Exception e) 973 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
914 { 974 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
915 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); 975 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
976 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
977 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
978 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
979 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
980 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
981 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
982 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
916 } 983 }
917 984
918 // FIXME: Ultimately this should be in a module. 985 // FIXME: Ultimately this should be in a module.
@@ -965,6 +1032,10 @@ namespace OpenSim.Region.Framework.Scenes
965 { 1032 {
966 PhysicalPrims = true; 1033 PhysicalPrims = true;
967 CollidablePrims = true; 1034 CollidablePrims = true;
1035 PhysicsEnabled = true;
1036
1037 PeriodicBackup = true;
1038 UseBackup = true;
968 1039
969 BordersLocked = true; 1040 BordersLocked = true;
970 Border northBorder = new Border(); 1041 Border northBorder = new Border();
@@ -1207,83 +1278,6 @@ namespace OpenSim.Region.Framework.Scenes
1207 } 1278 }
1208 } 1279 }
1209 1280
1210 public void SetSceneCoreDebug(Dictionary<string, string> options)
1211 {
1212 if (options.ContainsKey("active"))
1213 {
1214 bool active;
1215
1216 if (bool.TryParse(options["active"], out active))
1217 Active = active;
1218 }
1219
1220 if (options.ContainsKey("scripting"))
1221 {
1222 bool enableScripts = true;
1223 if (bool.TryParse(options["scripting"], out enableScripts) && m_scripts_enabled != enableScripts)
1224 {
1225 if (!enableScripts)
1226 {
1227 m_log.Info("Stopping all Scripts in Scene");
1228
1229 EntityBase[] entities = Entities.GetEntities();
1230 foreach (EntityBase ent in entities)
1231 {
1232 if (ent is SceneObjectGroup)
1233 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
1234 }
1235 }
1236 else
1237 {
1238 m_log.Info("Starting all Scripts in Scene");
1239
1240 EntityBase[] entities = Entities.GetEntities();
1241 foreach (EntityBase ent in entities)
1242 {
1243 if (ent is SceneObjectGroup)
1244 {
1245 SceneObjectGroup sog = (SceneObjectGroup)ent;
1246 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
1247 sog.ResumeScripts();
1248 }
1249 }
1250 }
1251
1252 m_scripts_enabled = enableScripts;
1253 }
1254 }
1255
1256 if (options.ContainsKey("physics"))
1257 {
1258 bool enablePhysics;
1259 if (bool.TryParse(options["physics"], out enablePhysics))
1260 m_physics_enabled = enablePhysics;
1261 }
1262
1263// if (options.ContainsKey("collisions"))
1264// {
1265// // TODO: Implement. If false, should stop objects colliding, though possibly should still allow
1266// // the avatar themselves to collide with the ground.
1267// }
1268
1269 if (options.ContainsKey("teleport"))
1270 {
1271 bool enableTeleportDebugging;
1272 if (bool.TryParse(options["teleport"], out enableTeleportDebugging))
1273 DebugTeleporting = enableTeleportDebugging;
1274 }
1275
1276 if (options.ContainsKey("updates"))
1277 {
1278 bool enableUpdateDebugging;
1279 if (bool.TryParse(options["updates"], out enableUpdateDebugging))
1280 {
1281 DebugUpdates = enableUpdateDebugging;
1282 GcNotify.Enabled = DebugUpdates;
1283 }
1284 }
1285 }
1286
1287 public int GetInaccurateNeighborCount() 1281 public int GetInaccurateNeighborCount()
1288 { 1282 {
1289 return m_neighbours.Count; 1283 return m_neighbours.Count;
@@ -1332,16 +1326,7 @@ namespace OpenSim.Region.Framework.Scenes
1332 1326
1333 m_log.Debug("[SCENE]: Persisting changed objects"); 1327 m_log.Debug("[SCENE]: Persisting changed objects");
1334 1328
1335 EntityBase[] entities = GetEntities(); 1329 Backup(false);
1336 foreach (EntityBase entity in entities)
1337 {
1338 if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged)
1339 {
1340 ((SceneObjectGroup)entity).ProcessBackup(SimulationDataService, false);
1341 }
1342 }
1343
1344 m_log.Debug("[SCENE]: Graph close");
1345 m_sceneGraph.Close(); 1330 m_sceneGraph.Close();
1346 1331
1347 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1332 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
@@ -1568,7 +1553,7 @@ namespace OpenSim.Region.Framework.Scenes
1568 } 1553 }
1569 1554
1570 tmpMS = Util.EnvironmentTickCount(); 1555 tmpMS = Util.EnvironmentTickCount();
1571 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1556 if (PhysicsEnabled && Frame % m_update_physics == 0)
1572 m_sceneGraph.UpdatePreparePhysics(); 1557 m_sceneGraph.UpdatePreparePhysics();
1573 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1558 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1574 1559
@@ -1583,7 +1568,7 @@ namespace OpenSim.Region.Framework.Scenes
1583 tmpMS = Util.EnvironmentTickCount(); 1568 tmpMS = Util.EnvironmentTickCount();
1584 if (Frame % m_update_physics == 0) 1569 if (Frame % m_update_physics == 0)
1585 { 1570 {
1586 if (m_physics_enabled) 1571 if (PhysicsEnabled)
1587 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); 1572 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime);
1588 1573
1589 if (SynchronizeScene != null) 1574 if (SynchronizeScene != null)
@@ -1625,7 +1610,7 @@ namespace OpenSim.Region.Framework.Scenes
1625 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1610 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1626 } 1611 }
1627 1612
1628 if (Frame % m_update_backup == 0) 1613 if (PeriodicBackup && Frame % m_update_backup == 0)
1629 { 1614 {
1630 tmpMS = Util.EnvironmentTickCount(); 1615 tmpMS = Util.EnvironmentTickCount();
1631 UpdateStorageBackup(); 1616 UpdateStorageBackup();
@@ -5621,33 +5606,7 @@ Environment.Exit(1);
5621 5606
5622 public void TriggerEstateSunUpdate() 5607 public void TriggerEstateSunUpdate()
5623 { 5608 {
5624 float sun; 5609 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5625 if (RegionInfo.RegionSettings.UseEstateSun)
5626 {
5627 sun = (float)RegionInfo.EstateSettings.SunPosition;
5628 if (RegionInfo.EstateSettings.UseGlobalTime)
5629 {
5630 sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
5631 }
5632
5633 //
5634 EventManager.TriggerEstateToolsSunUpdate(
5635 RegionInfo.RegionHandle,
5636 RegionInfo.EstateSettings.FixedSun,
5637 RegionInfo.RegionSettings.UseEstateSun,
5638 sun);
5639 }
5640 else
5641 {
5642 // Use the Sun Position from the Region Settings
5643 sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
5644
5645 EventManager.TriggerEstateToolsSunUpdate(
5646 RegionInfo.RegionHandle,
5647 RegionInfo.RegionSettings.FixedSun,
5648 RegionInfo.RegionSettings.UseEstateSun,
5649 sun);
5650 }
5651 } 5610 }
5652 5611
5653 private void HandleReloadEstate(string module, string[] cmd) 5612 private void HandleReloadEstate(string module, string[] cmd)
@@ -6043,10 +6002,17 @@ Environment.Exit(1);
6043 GC.Collect(); 6002 GC.Collect();
6044 } 6003 }
6045 6004
6046 // Wrappers to get physics modules retrieve assets. Has to be done this way 6005 /// <summary>
6047 // because we can't assign the asset service to physics directly - at the 6006 /// Wrappers to get physics modules retrieve assets.
6048 // time physics are instantiated it's not registered but it will be by 6007 /// </summary>
6049 // the time the first prim exists. 6008 /// <remarks>
6009 /// Has to be done this way
6010 /// because we can't assign the asset service to physics directly - at the
6011 /// time physics are instantiated it's not registered but it will be by
6012 /// the time the first prim exists.
6013 /// </remarks>
6014 /// <param name="assetID"></param>
6015 /// <param name="callback"></param>
6050 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback) 6016 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
6051 { 6017 {
6052 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived); 6018 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ed1bbd8..0f5d116 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -101,6 +101,15 @@ namespace OpenSim.Region.Framework.Scenes
101 /// </summary> 101 /// </summary>
102 public partial class SceneObjectGroup : EntityBase, ISceneObject 102 public partial class SceneObjectGroup : EntityBase, ISceneObject
103 { 103 {
104 // Axis selection bitmask used by SetAxisRotation()
105 // Just happen to be the same bits used by llSetStatus() and defined in ScriptBaseClass.
106 public enum axisSelect : int
107 {
108 STATUS_ROTATE_X = 0x002,
109 STATUS_ROTATE_Y = 0x004,
110 STATUS_ROTATE_Z = 0x008,
111 }
112
104 // private PrimCountTaintedDelegate handlerPrimCountTainted = null; 113 // private PrimCountTaintedDelegate handlerPrimCountTainted = null;
105 114
106 /// <summary> 115 /// <summary>
@@ -512,11 +521,19 @@ namespace OpenSim.Region.Framework.Scenes
512 521
513 if (Scene != null) 522 if (Scene != null)
514 { 523 {
515 // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 524 if (
516 // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 525 // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E)
517 // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 526 // || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
518 if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) 527 // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N)
519 || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) 528 // || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
529 // Experimental change for better border crossings.
530 // The commented out original lines above would, it seems, trigger
531 // a border crossing a little early or late depending on which
532 // direction the object was moving.
533 (Scene.TestBorderCross(val, Cardinals.E)
534 || Scene.TestBorderCross(val, Cardinals.W)
535 || Scene.TestBorderCross(val, Cardinals.N)
536 || Scene.TestBorderCross(val, Cardinals.S))
520 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) 537 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
521 { 538 {
522 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 539 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
@@ -935,6 +952,18 @@ namespace OpenSim.Region.Framework.Scenes
935 /// </remarks> 952 /// </remarks>
936 public UUID FromFolderID { get; set; } 953 public UUID FromFolderID { get; set; }
937 954
955 /// <summary>
956 /// IDs of all avatars sat on this scene object.
957 /// </summary>
958 /// <remarks>
959 /// We need this so that we can maintain a linkset wide ordering of avatars sat on different parts.
960 /// This must be locked before it is read or written.
961 /// SceneObjectPart sitting avatar add/remove code also locks on this object to avoid race conditions.
962 /// No avatar should appear more than once in this list.
963 /// Do not manipulate this list directly - use the Add/Remove sitting avatar methods on SceneObjectPart.
964 /// </remarks>
965 protected internal List<UUID> m_sittingAvatars = new List<UUID>();
966
938 #endregion 967 #endregion
939 968
940// ~SceneObjectGroup() 969// ~SceneObjectGroup()
@@ -4509,17 +4538,28 @@ namespace OpenSim.Region.Framework.Scenes
4509 } 4538 }
4510 4539
4511 /// <summary> 4540 /// <summary>
4541 /// Get a copy of the list of sitting avatars on all prims of this object.
4542 /// </summary>
4543 /// <remarks>
4544 /// This is sorted by the order in which avatars sat down. If an avatar stands up then all avatars that sat
4545 /// down after it move one place down the list.
4546 /// </remarks>
4547 /// <returns>A list of the sitting avatars. Returns an empty list if there are no sitting avatars.</returns>
4548 public List<UUID> GetSittingAvatars()
4549 {
4550 lock (m_sittingAvatars)
4551 return new List<UUID>(m_sittingAvatars);
4552 }
4553
4554 /// <summary>
4512 /// Gets the number of sitting avatars. 4555 /// Gets the number of sitting avatars.
4513 /// </summary> 4556 /// </summary>
4514 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> 4557 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
4515 /// <returns></returns> 4558 /// <returns></returns>
4516 public int GetSittingAvatarsCount() 4559 public int GetSittingAvatarsCount()
4517 { 4560 {
4518 int count = 0; 4561 lock (m_sittingAvatars)
4519 4562 return m_sittingAvatars.Count;
4520 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
4521
4522 return count;
4523 } 4563 }
4524 4564
4525 public override string ToString() 4565 public override string ToString()
@@ -4528,7 +4568,7 @@ namespace OpenSim.Region.Framework.Scenes
4528 } 4568 }
4529 4569
4530 #region ISceneObject 4570 #region ISceneObject
4531 4571
4532 public virtual ISceneObject CloneForNewScene() 4572 public virtual ISceneObject CloneForNewScene()
4533 { 4573 {
4534 SceneObjectGroup sog = Copy(false); 4574 SceneObjectGroup sog = Copy(false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 8528edc..f037348 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1342,7 +1342,7 @@ namespace OpenSim.Region.Framework.Scenes
1342 public UUID SitTargetAvatar { get; set; } 1342 public UUID SitTargetAvatar { get; set; }
1343 1343
1344 /// <summary> 1344 /// <summary>
1345 /// IDs of all avatars start on this object part. 1345 /// IDs of all avatars sat on this part.
1346 /// </summary> 1346 /// </summary>
1347 /// <remarks> 1347 /// <remarks>
1348 /// We need to track this so that we can stop sat upon prims from being attached. 1348 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -2431,11 +2431,11 @@ namespace OpenSim.Region.Framework.Scenes
2431 public int GetAxisRotation(int axis) 2431 public int GetAxisRotation(int axis)
2432 { 2432 {
2433 //Cannot use ScriptBaseClass constants as no referance to it currently. 2433 //Cannot use ScriptBaseClass constants as no referance to it currently.
2434 if (axis == 2)//STATUS_ROTATE_X 2434 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X)
2435 return STATUS_ROTATE_X; 2435 return STATUS_ROTATE_X;
2436 if (axis == 4)//STATUS_ROTATE_Y 2436 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y)
2437 return STATUS_ROTATE_Y; 2437 return STATUS_ROTATE_Y;
2438 if (axis == 8)//STATUS_ROTATE_Z 2438 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z)
2439 return STATUS_ROTATE_Z; 2439 return STATUS_ROTATE_Z;
2440 2440
2441 return 0; 2441 return 0;
@@ -2470,18 +2470,6 @@ namespace OpenSim.Region.Framework.Scenes
2470 return new Vector3(0, 0, 0); 2470 return new Vector3(0, 0, 0);
2471 2471
2472 return ParentGroup.GetGeometricCenter(); 2472 return ParentGroup.GetGeometricCenter();
2473
2474 /*
2475 PhysicsActor pa = PhysActor;
2476
2477 if (pa != null)
2478 {
2479 Vector3 vtmp = pa.CenterOfMass;
2480 return vtmp;
2481 }
2482 else
2483 return new Vector3(0, 0, 0);
2484 */
2485 } 2473 }
2486 2474
2487 public float GetMass() 2475 public float GetMass()
@@ -2895,11 +2883,14 @@ namespace OpenSim.Region.Framework.Scenes
2895 2883
2896 public void PhysicsOutOfBounds(Vector3 pos) 2884 public void PhysicsOutOfBounds(Vector3 pos)
2897 { 2885 {
2898 m_log.Error("[PHYSICS]: Physical Object went out of bounds."); 2886 // Note: This is only being called on the root prim at this time.
2887
2888 m_log.ErrorFormat(
2889 "[SCENE OBJECT PART]: Physical object {0}, localID {1} went out of bounds at {2} in {3}. Stopping at {4} and making non-physical.",
2890 Name, LocalId, pos, ParentGroup.Scene.Name, AbsolutePosition);
2899 2891
2900 RemFlag(PrimFlags.Physics); 2892 RemFlag(PrimFlags.Physics);
2901 DoPhysicsPropertyUpdate(false, true); 2893 DoPhysicsPropertyUpdate(false, true);
2902 //ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2903 } 2894 }
2904 2895
2905 public void PhysicsRequestingTerseUpdate() 2896 public void PhysicsRequestingTerseUpdate()
@@ -3322,13 +3313,13 @@ namespace OpenSim.Region.Framework.Scenes
3322 ParentGroup.SetAxisRotation(axis, rotate); 3313 ParentGroup.SetAxisRotation(axis, rotate);
3323 3314
3324 //Cannot use ScriptBaseClass constants as no referance to it currently. 3315 //Cannot use ScriptBaseClass constants as no referance to it currently.
3325 if (axis == 2)//STATUS_ROTATE_X 3316 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0)
3326 STATUS_ROTATE_X = rotate; 3317 STATUS_ROTATE_X = rotate;
3327 3318
3328 if (axis == 4)//STATUS_ROTATE_Y 3319 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0)
3329 STATUS_ROTATE_Y = rotate; 3320 STATUS_ROTATE_Y = rotate;
3330 3321
3331 if (axis == 8)//STATUS_ROTATE_Z 3322 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0)
3332 STATUS_ROTATE_Z = rotate; 3323 STATUS_ROTATE_Z = rotate;
3333 } 3324 }
3334 3325
@@ -4235,6 +4226,7 @@ namespace OpenSim.Region.Framework.Scenes
4235 result.distance = distance2; 4226 result.distance = distance2;
4236 result.HitTF = true; 4227 result.HitTF = true;
4237 result.ipoint = q; 4228 result.ipoint = q;
4229 result.face = i;
4238 //m_log.Info("[FACE]:" + i.ToString()); 4230 //m_log.Info("[FACE]:" + i.ToString());
4239 //m_log.Info("[POINT]: " + q.ToString()); 4231 //m_log.Info("[POINT]: " + q.ToString());
4240 //m_log.Info("[DIST]: " + distance2.ToString()); 4232 //m_log.Info("[DIST]: " + distance2.ToString());
@@ -4558,7 +4550,7 @@ namespace OpenSim.Region.Framework.Scenes
4558 if (ParentGroup.RootPart == this) 4550 if (ParentGroup.RootPart == this)
4559 AngularVelocity = new Vector3(0, 0, 0); 4551 AngularVelocity = new Vector3(0, 0, 0);
4560 } 4552 }
4561 else 4553 else if (SetVD != wasVD)
4562 { 4554 {
4563 if (ParentGroup.Scene.CollidablePrims) 4555 if (ParentGroup.Scene.CollidablePrims)
4564 { 4556 {
@@ -4646,9 +4638,9 @@ namespace OpenSim.Region.Framework.Scenes
4646 PhysicsShapeType, 4638 PhysicsShapeType,
4647 m_localId); 4639 m_localId);
4648 } 4640 }
4649 catch (Exception ex) 4641 catch (Exception e)
4650 { 4642 {
4651 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); 4643 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e);
4652 pa = null; 4644 pa = null;
4653 } 4645 }
4654 4646
@@ -5202,18 +5194,22 @@ namespace OpenSim.Region.Framework.Scenes
5202 /// <param name='avatarId'></param> 5194 /// <param name='avatarId'></param>
5203 protected internal bool AddSittingAvatar(UUID avatarId) 5195 protected internal bool AddSittingAvatar(UUID avatarId)
5204 { 5196 {
5205 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5197 lock (ParentGroup.m_sittingAvatars)
5206 SitTargetAvatar = avatarId; 5198 {
5199 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5200 SitTargetAvatar = avatarId;
5207 5201
5208 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5202 if (m_sittingAvatars == null)
5203 m_sittingAvatars = new HashSet<UUID>();
5209 5204
5210 if (sittingAvatars == null) 5205 if (m_sittingAvatars.Add(avatarId))
5211 sittingAvatars = new HashSet<UUID>(); 5206 {
5207 ParentGroup.m_sittingAvatars.Add(avatarId);
5212 5208
5213 lock (sittingAvatars) 5209 return true;
5214 { 5210 }
5215 m_sittingAvatars = sittingAvatars; 5211
5216 return m_sittingAvatars.Add(avatarId); 5212 return false;
5217 } 5213 }
5218 } 5214 }
5219 5215
@@ -5227,27 +5223,26 @@ namespace OpenSim.Region.Framework.Scenes
5227 /// <param name='avatarId'></param> 5223 /// <param name='avatarId'></param>
5228 protected internal bool RemoveSittingAvatar(UUID avatarId) 5224 protected internal bool RemoveSittingAvatar(UUID avatarId)
5229 { 5225 {
5230 if (SitTargetAvatar == avatarId) 5226 lock (ParentGroup.m_sittingAvatars)
5231 SitTargetAvatar = UUID.Zero; 5227 {
5232 5228 if (SitTargetAvatar == avatarId)
5233 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5229 SitTargetAvatar = UUID.Zero;
5234 5230
5235 // This can occur under a race condition where another thread 5231 if (m_sittingAvatars == null)
5236 if (sittingAvatars == null) 5232 return false;
5237 return false;
5238 5233
5239 lock (sittingAvatars) 5234 if (m_sittingAvatars.Remove(avatarId))
5240 {
5241 if (sittingAvatars.Remove(avatarId))
5242 { 5235 {
5243 if (sittingAvatars.Count == 0) 5236 if (m_sittingAvatars.Count == 0)
5244 m_sittingAvatars = null; 5237 m_sittingAvatars = null;
5245 5238
5239 ParentGroup.m_sittingAvatars.Remove(avatarId);
5240
5246 return true; 5241 return true;
5247 } 5242 }
5248 }
5249 5243
5250 return false; 5244 return false;
5245 }
5251 } 5246 }
5252 5247
5253 /// <summary> 5248 /// <summary>
@@ -5257,16 +5252,12 @@ namespace OpenSim.Region.Framework.Scenes
5257 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 5252 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5258 public HashSet<UUID> GetSittingAvatars() 5253 public HashSet<UUID> GetSittingAvatars()
5259 { 5254 {
5260 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5255 lock (ParentGroup.m_sittingAvatars)
5261
5262 if (sittingAvatars == null)
5263 { 5256 {
5264 return null; 5257 if (m_sittingAvatars == null)
5265 } 5258 return null;
5266 else 5259 else
5267 { 5260 return new HashSet<UUID>(m_sittingAvatars);
5268 lock (sittingAvatars)
5269 return new HashSet<UUID>(sittingAvatars);
5270 } 5261 }
5271 } 5262 }
5272 5263
@@ -5277,13 +5268,13 @@ namespace OpenSim.Region.Framework.Scenes
5277 /// <returns></returns> 5268 /// <returns></returns>
5278 public int GetSittingAvatarsCount() 5269 public int GetSittingAvatarsCount()
5279 { 5270 {
5280 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5271 lock (ParentGroup.m_sittingAvatars)
5281 5272 {
5282 if (sittingAvatars == null) 5273 if (m_sittingAvatars == null)
5283 return 0; 5274 return 0;
5284 5275 else
5285 lock (sittingAvatars) 5276 return m_sittingAvatars.Count;
5286 return sittingAvatars.Count; 5277 }
5287 } 5278 }
5288 } 5279 }
5289} 5280}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a9195f7..6005f07 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes
204 204
205 private const int LAND_VELOCITYMAG_MAX = 12; 205 private const int LAND_VELOCITYMAG_MAX = 12;
206 206
207 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
208
209 private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f;
210 private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f;
211
207 private float m_health = 100f; 212 private float m_health = 100f;
208 213
209 protected ulong crossingFromRegion; 214 protected ulong crossingFromRegion;
@@ -216,8 +221,6 @@ namespace OpenSim.Region.Framework.Scenes
216 221
217 private Quaternion m_headrotation = Quaternion.Identity; 222 private Quaternion m_headrotation = Quaternion.Identity;
218 223
219 private string m_nextSitAnimation = String.Empty;
220
221 //PauPaw:Proper PID Controler for autopilot************ 224 //PauPaw:Proper PID Controler for autopilot************
222 public bool MovingToTarget { get; private set; } 225 public bool MovingToTarget { get; private set; }
223 public Vector3 MoveToPositionTarget { get; private set; } 226 public Vector3 MoveToPositionTarget { get; private set; }
@@ -591,21 +594,29 @@ namespace OpenSim.Region.Framework.Scenes
591 set 594 set
592 { 595 {
593 m_bodyRot = value; 596 m_bodyRot = value;
594 // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
595 if (PhysicsActor != null) 597 if (PhysicsActor != null)
596 { 598 {
597 try 599 try
598 { 600 {
599 PhysicsActor.Orientation = value; 601 PhysicsActor.Orientation = m_bodyRot;
600 } 602 }
601 catch (Exception e) 603 catch (Exception e)
602 { 604 {
603 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); 605 m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message);
604 } 606 }
605 } 607 }
608// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
606 } 609 }
607 } 610 }
608 611
612 // Used for limited viewer 'fake' user rotations.
613 private Vector3 m_AngularVelocity = Vector3.Zero;
614
615 public Vector3 AngularVelocity
616 {
617 get { return m_AngularVelocity; }
618 }
619
609 public bool IsChildAgent { get; set; } 620 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; } 621 public bool IsLoggingIn { get; set; }
611 622
@@ -736,6 +747,8 @@ namespace OpenSim.Region.Framework.Scenes
736 747
737 #endregion 748 #endregion
738 749
750
751
739 #region Constructor(s) 752 #region Constructor(s)
740 753
741 public ScenePresence( 754 public ScenePresence(
@@ -1225,6 +1238,85 @@ namespace OpenSim.Region.Framework.Scenes
1225 ControllingClient.StopFlying(this); 1238 ControllingClient.StopFlying(this);
1226 } 1239 }
1227 1240
1241 /// <summary>
1242 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1243 /// </summary>
1244 /// <param name="amount">Postive or negative roll amount in radians</param>
1245 private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown)
1246 {
1247
1248 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS);
1249 m_AngularVelocity.Z = rollAmount;
1250
1251 // APPLY EXTRA consideration for flying up and flying down during this time.
1252 // if we're turning left
1253 if (amount > 0)
1254 {
1255
1256 // If we're at the max roll and pressing up, we want to swing BACK a bit
1257 // Automatically adds noise
1258 if (PressingUp)
1259 {
1260 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f)
1261 m_AngularVelocity.Z -= 0.9f;
1262 }
1263 // If we're at the max roll and pressing down, we want to swing MORE a bit
1264 if (PressingDown)
1265 {
1266 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f)
1267 m_AngularVelocity.Z += 0.6f;
1268 }
1269 }
1270 else // we're turning right.
1271 {
1272 // If we're at the max roll and pressing up, we want to swing BACK a bit
1273 // Automatically adds noise
1274 if (PressingUp)
1275 {
1276 if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS))
1277 m_AngularVelocity.Z += 0.6f;
1278 }
1279 // If we're at the max roll and pressing down, we want to swing MORE a bit
1280 if (PressingDown)
1281 {
1282 if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f)
1283 m_AngularVelocity.Z -= 0.6f;
1284 }
1285 }
1286 }
1287
1288 /// <summary>
1289 /// incrementally sets roll amount to zero
1290 /// </summary>
1291 /// <param name="amount">Positive roll amount in radians</param>
1292 /// <returns></returns>
1293 private float CalculateFlyingRollResetToZero(float amount)
1294 {
1295 const float rollMinRadians = 0f;
1296
1297 if (m_AngularVelocity.Z > 0)
1298 {
1299
1300 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1301 if (amount > leftOverToMin)
1302 return -leftOverToMin;
1303 else
1304 return -amount;
1305
1306 }
1307 else
1308 {
1309
1310 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1311 if (amount > leftOverToMin)
1312 return leftOverToMin;
1313 else
1314 return amount;
1315 }
1316 }
1317
1318
1319
1228 // neighbouring regions we have enabled a child agent in 1320 // neighbouring regions we have enabled a child agent in
1229 // holds the seed cap for the child agent in that region 1321 // holds the seed cap for the child agent in that region
1230 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1322 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1741,6 +1833,33 @@ namespace OpenSim.Region.Framework.Scenes
1741 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1833 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1742 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1834 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1743 1835
1836
1837 //m_log.Debug("[CONTROL]: " +flags);
1838 // Applies a satisfying roll effect to the avatar when flying.
1839 if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0))
1840 {
1841
1842 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1843
1844
1845 }
1846 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) &&
1847 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0))
1848 {
1849 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1850
1851
1852 }
1853 else
1854 {
1855 if (m_AngularVelocity.Z != 0)
1856 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1857
1858 }
1859
1860
1861
1862
1744 if (Flying && IsColliding && controlland) 1863 if (Flying && IsColliding && controlland)
1745 { 1864 {
1746 // nesting this check because LengthSquared() is expensive and we don't 1865 // nesting this check because LengthSquared() is expensive and we don't
@@ -2199,28 +2318,16 @@ namespace OpenSim.Region.Framework.Scenes
2199 2318
2200 if (ParentID != 0) 2319 if (ParentID != 0)
2201 { 2320 {
2321 if (ParentPart.UUID == targetID)
2322 return; // already sitting here, ignore
2323
2202 StandUp(); 2324 StandUp();
2203 } 2325 }
2204 2326
2205// if (!String.IsNullOrEmpty(sitAnimation))
2206// {
2207// m_nextSitAnimation = sitAnimation;
2208// }
2209// else
2210// {
2211 m_nextSitAnimation = "SIT";
2212// }
2213
2214 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
2215 SceneObjectPart part = FindNextAvailableSitTarget(targetID); 2327 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
2216 2328
2217 if (part != null) 2329 if (part != null)
2218 { 2330 {
2219 if (!String.IsNullOrEmpty(part.SitAnimation))
2220 {
2221 m_nextSitAnimation = part.SitAnimation;
2222 }
2223
2224 m_requestedSitTargetID = part.LocalId; 2331 m_requestedSitTargetID = part.LocalId;
2225 m_requestedSitTargetUUID = targetID; 2332 m_requestedSitTargetUUID = targetID;
2226 2333
@@ -2341,18 +2448,6 @@ namespace OpenSim.Region.Framework.Scenes
2341 2448
2342 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 2449 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
2343 { 2450 {
2344 if (!String.IsNullOrEmpty(m_nextSitAnimation))
2345 {
2346 HandleAgentSit(remoteClient, agentID, m_nextSitAnimation);
2347 }
2348 else
2349 {
2350 HandleAgentSit(remoteClient, agentID, "SIT");
2351 }
2352 }
2353
2354 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation)
2355 {
2356 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 2451 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
2357 2452
2358 if (part != null) 2453 if (part != null)
@@ -2425,7 +2520,12 @@ namespace OpenSim.Region.Framework.Scenes
2425 2520
2426 Velocity = Vector3.Zero; 2521 Velocity = Vector3.Zero;
2427 RemoveFromPhysicalScene(); 2522 RemoveFromPhysicalScene();
2428 2523
2524 String sitAnimation = "SIT";
2525 if (!String.IsNullOrEmpty(part.SitAnimation))
2526 {
2527 sitAnimation = part.SitAnimation;
2528 }
2429 Animator.TrySetMovementAnimation(sitAnimation); 2529 Animator.TrySetMovementAnimation(sitAnimation);
2430 SendAvatarDataToAllAgents(); 2530 SendAvatarDataToAllAgents();
2431 } 2531 }
@@ -2455,7 +2555,7 @@ namespace OpenSim.Region.Framework.Scenes
2455 2555
2456 public void HandleStopAnim(IClientAPI remoteClient, UUID animID) 2556 public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
2457 { 2557 {
2458 Animator.RemoveAnimation(animID); 2558 Animator.RemoveAnimation(animID, false);
2459 } 2559 }
2460 2560
2461 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) 2561 public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack)
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
index 4a21dc9..e209221 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common;
37namespace OpenSim.Region.Framework.Scenes.Tests 37namespace OpenSim.Region.Framework.Scenes.Tests
38{ 38{
39 [TestFixture] 39 [TestFixture]
40 public class BorderTests 40 public class BorderTests : OpenSimTestCase
41 { 41 {
42 [Test] 42 [Test]
43 public void TestCross() 43 public void TestCross()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index ea9fc93..766ce83 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common;
41namespace OpenSim.Region.Framework.Scenes.Tests 41namespace OpenSim.Region.Framework.Scenes.Tests
42{ 42{
43 [TestFixture, LongRunning] 43 [TestFixture, LongRunning]
44 public class EntityManagerTests 44 public class EntityManagerTests : OpenSimTestCase
45 { 45 {
46 static public Random random; 46 static public Random random;
47 SceneObjectGroup found; 47 SceneObjectGroup found;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index d23c965..575a081 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneGraphTests 43 public class SceneGraphTests : OpenSimTestCase
44 { 44 {
45 [Test] 45 [Test]
46 public void TestDuplicateObject() 46 public void TestDuplicateObject()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
index ab56f4e..2d831fa 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common.Mock;
41namespace OpenSim.Region.Framework.Scenes.Tests 41namespace OpenSim.Region.Framework.Scenes.Tests
42{ 42{
43 [TestFixture] 43 [TestFixture]
44 public class SceneManagerTests 44 public class SceneManagerTests : OpenSimTestCase
45 { 45 {
46 [Test] 46 [Test]
47 public void TestClose() 47 public void TestClose()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 5b334c6..a07d64c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using Nini.Config;
32using NUnit.Framework; 33using NUnit.Framework;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
@@ -182,6 +183,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
182 /// <summary> 183 /// <summary>
183 /// Test deleting an object from a scene. 184 /// Test deleting an object from a scene.
184 /// </summary> 185 /// </summary>
186 /// <remarks>
187 /// This is the most basic form of delete. For all more sophisticated forms of derez (done asynchrnously
188 /// and where object can be taken to user inventory, etc.), see SceneObjectDeRezTests.
189 /// </remarks>
185 [Test] 190 [Test]
186 public void TestDeleteSceneObject() 191 public void TestDeleteSceneObject()
187 { 192 {
@@ -201,100 +206,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
201 } 206 }
202 207
203 /// <summary> 208 /// <summary>
204 /// Test deleting an object asynchronously
205 /// </summary>
206 [Test]
207 public void TestDeleteSceneObjectAsync()
208 {
209 TestHelpers.InMethod();
210 //log4net.Config.XmlConfigurator.Configure();
211
212 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
213
214 TestScene scene = new SceneHelpers().SetupScene();
215
216 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
217 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
218 sogd.Enabled = false;
219
220 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
221
222 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
223 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero);
224
225 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
226
227 Assert.That(retrievedPart, Is.Not.Null);
228
229 Assert.That(so.IsDeleted, Is.False);
230
231 sogd.InventoryDeQueueAndDelete();
232
233 Assert.That(so.IsDeleted, Is.True);
234
235 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
236 Assert.That(retrievedPart2, Is.Null);
237 }
238
239 /// <summary>
240 /// Test deleting an object asynchronously to user inventory.
241 /// </summary>
242// [Test]
243 public void TestDeleteSceneObjectAsyncToUserInventory()
244 {
245 TestHelpers.InMethod();
246 TestHelpers.EnableLogging();
247
248 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
249 string myObjectName = "Fred";
250
251 TestScene scene = new SceneHelpers().SetupScene();
252
253 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
254 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
255 sogd.Enabled = false;
256
257 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
258
259// Assert.That(
260// scene.CommsManager.UserAdminService.AddUser(
261// "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId),
262// Is.EqualTo(agentId));
263
264 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
265 InventoryFolderBase folder1
266 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1");
267
268 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
269 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
270
271 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
272
273 Assert.That(retrievedPart, Is.Not.Null);
274 Assert.That(so.IsDeleted, Is.False);
275
276 sogd.InventoryDeQueueAndDelete();
277
278 Assert.That(so.IsDeleted, Is.True);
279
280 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
281 Assert.That(retrievedPart2, Is.Null);
282
283// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
284
285 InventoryItemBase retrievedItem
286 = UserInventoryHelpers.GetInventoryItem(
287 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
288
289 // Check that we now have the taken part in our inventory
290 Assert.That(retrievedItem, Is.Not.Null);
291
292 // Check that the taken part has actually disappeared
293// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
294// Assert.That(retrievedPart, Is.Null);
295 }
296
297 /// <summary>
298 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not 209 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
299 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by 210 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by
300 /// OpenSim. 211 /// OpenSim.
@@ -329,4 +240,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests
329 Assert.That(sog.Parts.Length, Is.EqualTo(2)); 240 Assert.That(sog.Parts.Length, Is.EqualTo(2));
330 } 241 }
331 } 242 }
332} 243} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 0076f41..c1522e7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -33,22 +33,24 @@ using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.CoreModules.Framework.InventoryAccess;
36using OpenSim.Region.CoreModules.World.Permissions; 37using OpenSim.Region.CoreModules.World.Permissions;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
38using OpenSim.Tests.Common; 40using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 41using OpenSim.Tests.Common.Mock;
40 42
41namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
42{ 44{
43 /// <summary> 45 /// <summary>
44 /// Tests derez of scene objects by users. 46 /// Tests derez of scene objects.
45 /// </summary> 47 /// </summary>
46 /// <remarks> 48 /// <remarks>
47 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. 49 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly.
48 /// TODO: These tests are very incomplete - they only test for a few conditions. 50 /// TODO: These tests are incomplete - need to test more kinds of derez (e.g. return object).
49 /// </remarks> 51 /// </remarks>
50 [TestFixture] 52 [TestFixture]
51 public class SceneObjectDeRezTests 53 public class SceneObjectDeRezTests : OpenSimTestCase
52 { 54 {
53 /// <summary> 55 /// <summary>
54 /// Test deleting an object from a scene. 56 /// Test deleting an object from a scene.
@@ -76,14 +78,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
76 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); 78 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
77 part.Name = "obj1"; 79 part.Name = "obj1";
78 scene.AddNewSceneObject(new SceneObjectGroup(part), false); 80 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
81
79 List<uint> localIds = new List<uint>(); 82 List<uint> localIds = new List<uint>();
80 localIds.Add(part.LocalId); 83 localIds.Add(part.LocalId);
81
82 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); 84 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
85
86 // Check that object isn't deleted until we crank the sogd handle.
87 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
88 Assert.That(retrievedPart, Is.Not.Null);
89 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
90
83 sogd.InventoryDeQueueAndDelete(); 91 sogd.InventoryDeQueueAndDelete();
84 92
85 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 93 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
86 Assert.That(retrievedPart, Is.Null); 94 Assert.That(retrievedPart2, Is.Null);
87 } 95 }
88 96
89 /// <summary> 97 /// <summary>
@@ -124,6 +132,67 @@ namespace OpenSim.Region.Framework.Scenes.Tests
124 // Object should still be in the scene. 132 // Object should still be in the scene.
125 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 133 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
126 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); 134 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
127 } 135 }
136
137 /// <summary>
138 /// Test deleting an object asynchronously to user inventory.
139 /// </summary>
140 [Test]
141 public void TestDeleteSceneObjectAsyncToUserInventory()
142 {
143 TestHelpers.InMethod();
144// TestHelpers.EnableLogging();
145
146 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
147 string myObjectName = "Fred";
148
149 TestScene scene = new SceneHelpers().SetupScene();
150
151 IConfigSource configSource = new IniConfigSource();
152 IConfig config = configSource.AddConfig("Modules");
153 config.Set("InventoryAccessModule", "BasicInventoryAccessModule");
154 SceneHelpers.SetupSceneModules(
155 scene, configSource, new object[] { new BasicInventoryAccessModule() });
156
157 SceneHelpers.SetupSceneModules(scene, new object[] { });
158
159 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
160 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
161 sogd.Enabled = false;
162
163 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
164
165 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
166 InventoryFolderBase folder1
167 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1");
168
169 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
170 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
171
172 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
173
174 Assert.That(retrievedPart, Is.Not.Null);
175 Assert.That(so.IsDeleted, Is.False);
176
177 sogd.InventoryDeQueueAndDelete();
178
179 Assert.That(so.IsDeleted, Is.True);
180
181 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
182 Assert.That(retrievedPart2, Is.Null);
183
184// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
185
186 InventoryItemBase retrievedItem
187 = UserInventoryHelpers.GetInventoryItem(
188 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
189
190 // Check that we now have the taken part in our inventory
191 Assert.That(retrievedItem, Is.Not.Null);
192
193 // Check that the taken part has actually disappeared
194// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
195// Assert.That(retrievedPart, Is.Null);
196 }
128 } 197 }
129} \ No newline at end of file 198} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 0e525c9..9378e20 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -40,7 +40,7 @@ using log4net;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneObjectLinkingTests 43 public class SceneObjectLinkingTests : OpenSimTestCase
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index e931859..1182c96 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
41 /// Basic scene object resize tests 41 /// Basic scene object resize tests
42 /// </summary> 42 /// </summary>
43 [TestFixture] 43 [TestFixture]
44 public class SceneObjectResizeTests 44 public class SceneObjectResizeTests : OpenSimTestCase
45 { 45 {
46 /// <summary> 46 /// <summary>
47 /// Test resizing an object 47 /// Test resizing an object
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
index d2361f8..a58e735 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock;
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 [TestFixture] 42 [TestFixture]
43 public class SceneObjectScriptTests 43 public class SceneObjectScriptTests : OpenSimTestCase
44 { 44 {
45 [Test] 45 [Test]
46 public void TestAddScript() 46 public void TestAddScript()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
index 6d255aa..abaa1d1 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
@@ -42,14 +42,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
42 /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) 42 /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.)
43 /// </summary> 43 /// </summary>
44 [TestFixture] 44 [TestFixture]
45 public class SceneObjectSpatialTests 45 public class SceneObjectSpatialTests : OpenSimTestCase
46 { 46 {
47 TestScene m_scene; 47 TestScene m_scene;
48 UUID m_ownerId = TestHelpers.ParseTail(0x1); 48 UUID m_ownerId = TestHelpers.ParseTail(0x1);
49 49
50 [SetUp] 50 [SetUp]
51 public void SetUp() 51 public override void SetUp()
52 { 52 {
53 base.SetUp();
54
53 m_scene = new SceneHelpers().SetupScene(); 55 m_scene = new SceneHelpers().SetupScene();
54 } 56 }
55 57
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 742c769..8eb3191 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
42 /// Basic scene object status tests 42 /// Basic scene object status tests
43 /// </summary> 43 /// </summary>
44 [TestFixture] 44 [TestFixture]
45 public class SceneObjectStatusTests 45 public class SceneObjectStatusTests : OpenSimTestCase
46 { 46 {
47 private TestScene m_scene; 47 private TestScene m_scene;
48 private UUID m_ownerId = TestHelpers.ParseTail(0x1); 48 private UUID m_ownerId = TestHelpers.ParseTail(0x1);
@@ -78,6 +78,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
78 } 78 }
79 79
80 [Test] 80 [Test]
81 public void TestSetNonPhysicsVolumeDetectSinglePrim()
82 {
83 TestHelpers.InMethod();
84
85 m_scene.AddSceneObject(m_so1);
86
87 SceneObjectPart rootPart = m_so1.RootPart;
88 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
89
90 m_so1.ScriptSetVolumeDetect(true);
91
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
94
95 m_so1.ScriptSetVolumeDetect(false);
96
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 }
99
100 [Test]
81 public void TestSetPhysicsSinglePrim() 101 public void TestSetPhysicsSinglePrim()
82 { 102 {
83 TestHelpers.InMethod(); 103 TestHelpers.InMethod();
@@ -89,13 +109,32 @@ namespace OpenSim.Region.Framework.Scenes.Tests
89 109
90 m_so1.ScriptSetPhysicsStatus(true); 110 m_so1.ScriptSetPhysicsStatus(true);
91 111
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); 112 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
94 113
95 m_so1.ScriptSetPhysicsStatus(false); 114 m_so1.ScriptSetPhysicsStatus(false);
96 115
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 116 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 } 117 }
118
119 [Test]
120 public void TestSetPhysicsVolumeDetectSinglePrim()
121 {
122 TestHelpers.InMethod();
123
124 m_scene.AddSceneObject(m_so1);
125
126 SceneObjectPart rootPart = m_so1.RootPart;
127 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
128
129 m_so1.ScriptSetPhysicsStatus(true);
130 m_so1.ScriptSetVolumeDetect(true);
131
132 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics));
133
134 m_so1.ScriptSetVolumeDetect(false);
135
136 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
137 }
99 138
100 [Test] 139 [Test]
101 public void TestSetPhysicsLinkset() 140 public void TestSetPhysicsLinkset()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 646e5fa..1cd8ae9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
51 /// Scene presence animation tests 51 /// Scene presence animation tests
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class ScenePresenceAnimationTests 54 public class ScenePresenceAnimationTests : OpenSimTestCase
55 { 55 {
56 [Test] 56 [Test]
57 public void TestFlyingAnimation() 57 public void TestFlyingAnimation()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index 1d1ff88..d80afd3 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock;
42namespace OpenSim.Region.Framework.Scenes.Tests 42namespace OpenSim.Region.Framework.Scenes.Tests
43{ 43{
44 [TestFixture] 44 [TestFixture]
45 public class ScenePresenceAutopilotTests 45 public class ScenePresenceAutopilotTests : OpenSimTestCase
46 { 46 {
47 private TestScene m_scene; 47 private TestScene m_scene;
48 48
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index 493ab70..acaeb90 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -43,7 +43,7 @@ using System.Threading;
43namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
44{ 44{
45 [TestFixture] 45 [TestFixture]
46 public class ScenePresenceSitTests 46 public class ScenePresenceSitTests : OpenSimTestCase
47 { 47 {
48 private TestScene m_scene; 48 private TestScene m_scene;
49 private ScenePresence m_sp; 49 private ScenePresence m_sp;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index 37b5184..8dd1f3d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
49 /// Teleport tests in a standalone OpenSim 49 /// Teleport tests in a standalone OpenSim
50 /// </summary> 50 /// </summary>
51 [TestFixture] 51 [TestFixture]
52 public class ScenePresenceTeleportTests 52 public class ScenePresenceTeleportTests : OpenSimTestCase
53 { 53 {
54 [TestFixtureSetUp] 54 [TestFixtureSetUp]
55 public void FixtureInit() 55 public void FixtureInit()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index ac3da1e..9d8eb0b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
50 /// Scene presence tests 50 /// Scene presence tests
51 /// </summary> 51 /// </summary>
52 [TestFixture] 52 [TestFixture]
53 public class SceneTests 53 public class SceneTests : OpenSimTestCase
54 { 54 {
55 /// <summary> 55 /// <summary>
56 /// Very basic scene update test. Should become more elaborate with time. 56 /// Very basic scene update test. Should become more elaborate with time.
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index a51e4e3..0b461f5 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -50,7 +50,7 @@ using OpenSim.Tests.Common.Mock;
50namespace OpenSim.Region.Framework.Tests 50namespace OpenSim.Region.Framework.Tests
51{ 51{
52 [TestFixture] 52 [TestFixture]
53 public class TaskInventoryTests 53 public class TaskInventoryTests : OpenSimTestCase
54 { 54 {
55 [Test] 55 [Test]
56 public void TestAddTaskInventoryItem() 56 public void TestAddTaskInventoryItem()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index 198e487..dd27294 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -38,7 +38,7 @@ using OpenSim.Tests.Common.Mock;
38namespace OpenSim.Region.Framework.Scenes.Tests 38namespace OpenSim.Region.Framework.Scenes.Tests
39{ 39{
40 [TestFixture] 40 [TestFixture]
41 public class UuidGathererTests 41 public class UuidGathererTests : OpenSimTestCase
42 { 42 {
43 protected IAssetService m_assetService; 43 protected IAssetService m_assetService;
44 protected UuidGatherer m_uuidGatherer; 44 protected UuidGatherer m_uuidGatherer;