aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs18
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataService.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IPermissionsModule.cs54
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityBase.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs172
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs54
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs46
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs66
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs201
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs58
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs135
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs11
19 files changed, 656 insertions, 289 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 73d15a5..5ffbec8 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -88,6 +88,15 @@ namespace OpenSim.Region.Framework.Interfaces
88 ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); 88 ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
89 89
90 /// <summary> 90 /// <summary>
91 /// Rez an attachment from user inventory and change inventory status to match.
92 /// </summary>
93 /// <param name="sp"></param>
94 /// <param name="itemID"></param>
95 /// <param name="AttachmentPt"></param>
96 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
97 ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt);
98
99 /// <summary>
91 /// Rez multiple attachments from a user's inventory 100 /// Rez multiple attachments from a user's inventory
92 /// </summary> 101 /// </summary>
93 /// <param name="remoteClient"></param> 102 /// <param name="remoteClient"></param>
@@ -129,14 +138,5 @@ namespace OpenSim.Region.Framework.Interfaces
129 /// <param name="sog"></param> 138 /// <param name="sog"></param>
130 /// <param name="pos"></param> 139 /// <param name="pos"></param>
131 void UpdateAttachmentPosition(SceneObjectGroup sog, Vector3 pos); 140 void UpdateAttachmentPosition(SceneObjectGroup sog, Vector3 pos);
132
133 /// <summary>
134 /// Update the user inventory with a changed attachment
135 /// </summary>
136 /// <param name="remoteClient"></param>
137 /// <param name="grp"></param>
138 /// <param name="itemID"></param>
139 /// <param name="agentID"></param>
140 void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID);
141 } 141 }
142} 142}
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
index 7066cf2..35cc220 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -48,6 +48,14 @@ namespace OpenSim.Region.Framework.Interfaces
48 /// <param name="estateID"></param> 48 /// <param name="estateID"></param>
49 /// <returns></returns> 49 /// <returns></returns>
50 EstateSettings LoadEstateSettings(int estateID); 50 EstateSettings LoadEstateSettings(int estateID);
51
52 /// <summary>
53 /// Create a new estate.
54 /// </summary>
55 /// <returns>
56 /// A <see cref="EstateSettings"/>
57 /// </returns>
58 EstateSettings CreateNewEstate();
51 59
52 /// <summary> 60 /// <summary>
53 /// Load/Get all estate settings. 61 /// Load/Get all estate settings.
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
index d790a30..8febb13 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs
@@ -55,6 +55,14 @@ namespace OpenSim.Region.Framework.Interfaces
55 EstateSettings LoadEstateSettings(int estateID); 55 EstateSettings LoadEstateSettings(int estateID);
56 56
57 /// <summary> 57 /// <summary>
58 /// Create a new estate.
59 /// </summary>
60 /// <returns>
61 /// A <see cref="EstateSettings"/>
62 /// </returns>
63 EstateSettings CreateNewEstate();
64
65 /// <summary>
58 /// Load/Get all estate settings. 66 /// Load/Get all estate settings.
59 /// </summary> 67 /// </summary>
60 /// <returns>An empty list if no estates were found.</returns> 68 /// <returns>An empty list if no estates were found.</returns>
diff --git a/OpenSim/Region/Framework/Interfaces/IPermissionsModule.cs b/OpenSim/Region/Framework/Interfaces/IPermissionsModule.cs
new file mode 100644
index 0000000..1ed978b
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IPermissionsModule.cs
@@ -0,0 +1,54 @@
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 OpenSimulator 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 OpenMetaverse;
29using OpenSim.Region.Framework.Scenes;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 /// <value>
34 /// Which set of permissions a user has.
35 /// </value>
36 public enum PermissionClass
37 {
38 Owner,
39 Group,
40 Everyone
41 };
42
43 public interface IPermissionsModule
44 {
45
46 /// <summary>
47 /// Returns the type of permissions that the user has over an object.
48 /// </summary>
49 /// <param name="user">The user</param>
50 /// <param name="obj">The object</param>
51 /// <returns>The type of permissions the user has over the object</returns>
52 PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj);
53 }
54}
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 8913133..ff39283 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -61,6 +61,14 @@ namespace OpenSim.Region.Framework.Interfaces
61 AvatarAppearance Appearance { get; set; } 61 AvatarAppearance Appearance { get; set; }
62 62
63 /// <summary> 63 /// <summary>
64 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
65 /// </summary>
66 /// <remarks>
67 /// All add and remove attachment operations must synchronize on this for the lifetime of their operations.
68 /// </remarks>
69 Object AttachmentsSyncLock { get; }
70
71 /// <summary>
64 /// The scene objects attached to this avatar. 72 /// The scene objects attached to this avatar.
65 /// </summary> 73 /// </summary>
66 /// <returns> 74 /// <returns>
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index d9752e6..b27b7da 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -52,5 +52,10 @@ namespace OpenSim.Region.Framework.Interfaces
52 ArrayList GetScriptErrors(UUID itemID); 52 ArrayList GetScriptErrors(UUID itemID);
53 53
54 void SaveAllState(); 54 void SaveAllState();
55
56 /// <summary>
57 /// Starts the processing threads.
58 /// </summary>
59 void StartProcessing();
55 } 60 }
56} 61}
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs
index 213431a..320b904 100644
--- a/OpenSim/Region/Framework/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs
@@ -26,8 +26,10 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
29using System.Runtime.Serialization; 30using System.Runtime.Serialization;
30using System.Security.Permissions; 31using System.Security.Permissions;
32using log4net;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenMetaverse; 34using OpenMetaverse;
33 35
@@ -35,6 +37,8 @@ namespace OpenSim.Region.Framework.Scenes
35{ 37{
36 public abstract class EntityBase : ISceneEntity 38 public abstract class EntityBase : ISceneEntity
37 { 39 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41
38 /// <summary> 42 /// <summary>
39 /// The scene to which this entity belongs 43 /// The scene to which this entity belongs
40 /// </summary> 44 /// </summary>
@@ -71,12 +75,15 @@ namespace OpenSim.Region.Framework.Scenes
71 protected Vector3 m_pos; 75 protected Vector3 m_pos;
72 76
73 /// <summary> 77 /// <summary>
74 /// 78 /// Absolute position of this entity in a scene.
75 /// </summary> 79 /// </summary>
76 public virtual Vector3 AbsolutePosition 80 public virtual Vector3 AbsolutePosition
77 { 81 {
78 get { return m_pos; } 82 get { return m_pos; }
79 set { m_pos = value; } 83 set
84 {
85 m_pos = value;
86 }
80 } 87 }
81 88
82 protected Vector3 m_velocity; 89 protected Vector3 m_velocity;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4700c3b..663aa22 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -57,11 +57,11 @@ namespace OpenSim.Region.Framework.Scenes
57 protected AsyncInventorySender m_asyncInventorySender; 57 protected AsyncInventorySender m_asyncInventorySender;
58 58
59 /// <summary> 59 /// <summary>
60 /// Start all the scripts in the scene which should be started. 60 /// Creates all the scripts in the scene which should be started.
61 /// </summary> 61 /// </summary>
62 public void CreateScriptInstances() 62 public void CreateScriptInstances()
63 { 63 {
64 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); 64 m_log.Info("[PRIM INVENTORY]: Creating scripts in scene");
65 65
66 EntityBase[] entities = Entities.GetEntities(); 66 EntityBase[] entities = Entities.GetEntities();
67 foreach (EntityBase group in entities) 67 foreach (EntityBase group in entities)
@@ -74,6 +74,26 @@ namespace OpenSim.Region.Framework.Scenes
74 } 74 }
75 } 75 }
76 76
77 /// <summary>
78 /// Lets the script engines start processing scripts.
79 /// </summary>
80 public void StartScripts()
81 {
82 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene");
83
84 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
85 if (engines != null)
86 {
87 foreach (IScriptModule engine in engines)
88 {
89 if (engine != null)
90 {
91 engine.StartProcessing();
92 }
93 }
94 }
95 }
96
77 public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) 97 public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
78 { 98 {
79 IMoneyModule money = RequestModuleInterface<IMoneyModule>(); 99 IMoneyModule money = RequestModuleInterface<IMoneyModule>();
@@ -254,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes
254 if (group.UpdateInventoryItem(item)) 274 if (group.UpdateInventoryItem(item))
255 remoteClient.SendAgentAlertMessage("Script saved", false); 275 remoteClient.SendAgentAlertMessage("Script saved", false);
256 276
257 part.GetProperties(remoteClient); 277 part.SendPropertiesToClient(remoteClient);
258 278
259 // Trigger rerunning of script (use TriggerRezScript event, see RezScript) 279 // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
260 ArrayList errors = new ArrayList(); 280 ArrayList errors = new ArrayList();
@@ -314,6 +334,10 @@ namespace OpenSim.Region.Framework.Scenes
314 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 334 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
315 UUID itemID, InventoryItemBase itemUpd) 335 UUID itemID, InventoryItemBase itemUpd)
316 { 336 {
337// m_log.DebugFormat(
338// "[USER INVENTORY]: Updating asset for item {0} {1}, transaction ID {2} for {3}",
339// itemID, itemUpd.Name, transactionID, remoteClient.Name);
340
317 // This one will let people set next perms on items in agent 341 // This one will let people set next perms on items in agent
318 // inventory. Rut-Roh. Whatever. Make this secure. Yeah. 342 // inventory. Rut-Roh. Whatever. Make this secure. Yeah.
319 // 343 //
@@ -365,8 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
365 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 389 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
366 if (agentTransactions != null) 390 if (agentTransactions != null)
367 { 391 {
368 agentTransactions.HandleItemUpdateFromTransaction( 392 agentTransactions.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
369 remoteClient, transactionID, item);
370 } 393 }
371 } 394 }
372 } 395 }
@@ -979,7 +1002,7 @@ namespace OpenSim.Region.Framework.Scenes
979 } 1002 }
980 1003
981 group.RemoveInventoryItem(localID, itemID); 1004 group.RemoveInventoryItem(localID, itemID);
982 part.GetProperties(remoteClient); 1005 part.SendPropertiesToClient(remoteClient);
983 } 1006 }
984 1007
985 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) 1008 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId)
@@ -1252,7 +1275,7 @@ namespace OpenSim.Region.Framework.Scenes
1252 1275
1253 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) 1276 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1254 { 1277 {
1255 destPart.GetProperties(avatar.ControllingClient); 1278 destPart.SendPropertiesToClient(avatar.ControllingClient);
1256 } 1279 }
1257 } 1280 }
1258 1281
@@ -1407,7 +1430,7 @@ namespace OpenSim.Region.Framework.Scenes
1407 m_log.InfoFormat( 1430 m_log.InfoFormat(
1408 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1431 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1409 item.Name, primLocalID, remoteClient.Name); 1432 item.Name, primLocalID, remoteClient.Name);
1410 part.GetProperties(remoteClient); 1433 part.SendPropertiesToClient(remoteClient);
1411 if (!Permissions.BypassPermissions()) 1434 if (!Permissions.BypassPermissions())
1412 { 1435 {
1413 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1436 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
@@ -1502,7 +1525,7 @@ namespace OpenSim.Region.Framework.Scenes
1502 1525
1503 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1526 if (part.Inventory.UpdateInventoryItem(itemInfo))
1504 { 1527 {
1505 part.GetProperties(remoteClient); 1528 part.SendPropertiesToClient(remoteClient);
1506 } 1529 }
1507 } 1530 }
1508 } 1531 }
@@ -1554,7 +1577,7 @@ namespace OpenSim.Region.Framework.Scenes
1554 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1577 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1555 // "Rezzed script {0} into prim local ID {1} for user {2}", 1578 // "Rezzed script {0} into prim local ID {1} for user {2}",
1556 // item.inventoryName, localID, remoteClient.Name); 1579 // item.inventoryName, localID, remoteClient.Name);
1557 part.GetProperties(remoteClient); 1580 part.SendPropertiesToClient(remoteClient);
1558 part.ParentGroup.ResumeScripts(); 1581 part.ParentGroup.ResumeScripts();
1559 } 1582 }
1560 else 1583 else
@@ -1612,7 +1635,7 @@ namespace OpenSim.Region.Framework.Scenes
1612 taskItem.AssetID = asset.FullID; 1635 taskItem.AssetID = asset.FullID;
1613 1636
1614 part.Inventory.AddInventoryItem(taskItem, false); 1637 part.Inventory.AddInventoryItem(taskItem, false);
1615 part.GetProperties(remoteClient); 1638 part.SendPropertiesToClient(remoteClient);
1616 1639
1617 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1640 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1618 part.ParentGroup.ResumeScripts(); 1641 part.ParentGroup.ResumeScripts();
@@ -1726,7 +1749,7 @@ namespace OpenSim.Region.Framework.Scenes
1726 1749
1727 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) 1750 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1728 { 1751 {
1729 destPart.GetProperties(avatar.ControllingClient); 1752 destPart.SendPropertiesToClient(avatar.ControllingClient);
1730 } 1753 }
1731 } 1754 }
1732 1755
@@ -2064,7 +2087,7 @@ namespace OpenSim.Region.Framework.Scenes
2064 SceneObjectPart part = GetSceneObjectPart(localID); 2087 SceneObjectPart part = GetSceneObjectPart(localID);
2065 if (part == null) 2088 if (part == null)
2066 continue; 2089 continue;
2067 part.GetProperties(remoteClient); 2090 part.SendPropertiesToClient(remoteClient);
2068 } 2091 }
2069 } 2092 }
2070 2093
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 29d01d6..270e582 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -144,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes
144 { 144 {
145 if (((SceneObjectGroup) ent).LocalId == primLocalID) 145 if (((SceneObjectGroup) ent).LocalId == primLocalID)
146 { 146 {
147 ((SceneObjectGroup) ent).GetProperties(remoteClient); 147 ((SceneObjectGroup) ent).SendPropertiesToClient(remoteClient);
148 ((SceneObjectGroup) ent).IsSelected = true; 148 ((SceneObjectGroup) ent).IsSelected = true;
149 // A prim is only tainted if it's allowed to be edited by the person clicking it. 149 // A prim is only tainted if it's allowed to be edited by the person clicking it.
150 if (Permissions.CanEditObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId) 150 if (Permissions.CanEditObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId)
@@ -167,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
167 { 167 {
168 if (part.LocalId == primLocalID) 168 if (part.LocalId == primLocalID)
169 { 169 {
170 part.GetProperties(remoteClient); 170 part.SendPropertiesToClient(remoteClient);
171 foundPrim = true; 171 foundPrim = true;
172 break; 172 break;
173 } 173 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f86b3b6..eadec09 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -656,7 +656,7 @@ namespace OpenSim.Region.Framework.Scenes
656 EventManager.OnLandObjectRemoved += 656 EventManager.OnLandObjectRemoved +=
657 new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); 657 new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);
658 658
659 m_sceneGraph = new SceneGraph(this, m_regInfo); 659 m_sceneGraph = new SceneGraph(this);
660 660
661 // If the scene graph has an Unrecoverable error, restart this sim. 661 // If the scene graph has an Unrecoverable error, restart this sim.
662 // Currently the only thing that causes it to happen is two kinds of specific 662 // Currently the only thing that causes it to happen is two kinds of specific
@@ -870,6 +870,8 @@ namespace OpenSim.Region.Framework.Scenes
870 870
871 if (dm != null) 871 if (dm != null)
872 m_eventManager.OnPermissionError += dm.SendAlertToUser; 872 m_eventManager.OnPermissionError += dm.SendAlertToUser;
873
874 m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement;
873 } 875 }
874 876
875 public override string GetSimulatorVersion() 877 public override string GetSimulatorVersion()
@@ -1170,87 +1172,6 @@ namespace OpenSim.Region.Framework.Scenes
1170 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1172 m_dialogModule = RequestModuleInterface<IDialogModule>();
1171 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1173 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1172 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1174 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1173
1174 // Shoving this in here for now, because we have the needed
1175 // interfaces at this point
1176 //
1177 // TODO: Find a better place for this
1178 //
1179 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1180 {
1181 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName);
1182 List<char> excluded = new List<char>(new char[1]{' '});
1183 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
1184 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
1185
1186 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1187
1188 if (account == null)
1189 {
1190 // Create a new account
1191 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1192 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1193 {
1194 account.ServiceURLs = new Dictionary<string, object>();
1195 account.ServiceURLs["HomeURI"] = string.Empty;
1196 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1197 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1198 account.ServiceURLs["AssetServerURI"] = string.Empty;
1199 }
1200
1201 if (UserAccountService.StoreUserAccount(account))
1202 {
1203 string password = MainConsole.Instance.PasswdPrompt("Password");
1204 string email = MainConsole.Instance.CmdPrompt("Email", "");
1205
1206 account.Email = email;
1207 UserAccountService.StoreUserAccount(account);
1208
1209 bool success = false;
1210 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1211 if (!success)
1212 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1213 first, last);
1214
1215 GridRegion home = null;
1216 if (GridService != null)
1217 {
1218 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1219 if (defaultRegions != null && defaultRegions.Count >= 1)
1220 home = defaultRegions[0];
1221
1222 if (GridUserService != null && home != null)
1223 GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1224 else
1225 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1226 first, last);
1227
1228 }
1229 else
1230 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1231 first, last);
1232
1233 if (InventoryService != null)
1234 success = InventoryService.CreateUserInventory(account.PrincipalID);
1235 if (!success)
1236 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1237 first, last);
1238
1239
1240 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1241
1242 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1243 m_regInfo.EstateSettings.Save();
1244 }
1245 else
1246 m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
1247 }
1248 else
1249 {
1250 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1251 m_regInfo.EstateSettings.Save();
1252 }
1253 }
1254 } 1175 }
1255 1176
1256 #endregion 1177 #endregion
@@ -1579,7 +1500,9 @@ namespace OpenSim.Region.Framework.Scenes
1579 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1500 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1580 msg.Position = Vector3.Zero; 1501 msg.Position = Vector3.Zero;
1581 msg.RegionID = RegionInfo.RegionID.Guid; 1502 msg.RegionID = RegionInfo.RegionID.Guid;
1582 msg.binaryBucket = new byte[0]; 1503
1504 // We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3.
1505 msg.binaryBucket = Util.StringToBytes256("\0");
1583 if (ret.Value.count > 1) 1506 if (ret.Value.count > 1)
1584 msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); 1507 msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
1585 else 1508 else
@@ -2459,14 +2382,16 @@ namespace OpenSim.Region.Framework.Scenes
2459 /// <returns>False</returns> 2382 /// <returns>False</returns>
2460 public virtual bool IncomingCreateObject(UUID userID, UUID itemID) 2383 public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
2461 { 2384 {
2462 //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); 2385 m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
2463 2386
2464 ScenePresence sp = GetScenePresence(userID); 2387 // Commented out since this is as yet unused and is arguably not the appropriate place to do this, as
2465 if (sp != null && AttachmentsModule != null) 2388 // attachments are being rezzed elsewhere in AddNewClient()
2466 { 2389// ScenePresence sp = GetScenePresence(userID);
2467 uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); 2390// if (sp != null && AttachmentsModule != null)
2468 AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt); 2391// {
2469 } 2392// uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
2393// AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
2394// }
2470 2395
2471 return false; 2396 return false;
2472 } 2397 }
@@ -5215,5 +5140,70 @@ namespace OpenSim.Region.Framework.Scenes
5215 reason = String.Empty; 5140 reason = String.Empty;
5216 return true; 5141 return true;
5217 } 5142 }
5143
5144 /// <summary>
5145 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5146 /// autopilot that moves an avatar to a sit target!.
5147 /// </summary>
5148 /// <remarks>
5149 /// This is not intended as a permament location for this method.
5150 /// </remarks>
5151 /// <param name="presence"></param>
5152 private void HandleOnSignificantClientMovement(ScenePresence presence)
5153 {
5154 if (presence.MovingToTarget)
5155 {
5156 double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
5157// m_log.DebugFormat(
5158// "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
5159// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
5160
5161 // Check the error term of the current position in relation to the target position
5162 if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
5163 {
5164 // We are close enough to the target
5165// m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name);
5166
5167 presence.Velocity = Vector3.Zero;
5168 presence.AbsolutePosition = presence.MoveToPositionTarget;
5169 presence.ResetMoveToTarget();
5170
5171 if (presence.PhysicsActor.Flying)
5172 {
5173 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
5174 // the target if flying.
5175 // We really need to be more subtle (slow the avatar as it approaches the target) or at
5176 // least be able to set collision status once, rather than 5 times to give it enough
5177 // weighting so that that PhysicsActor thinks it really is colliding.
5178 for (int i = 0; i < 5; i++)
5179 presence.PhysicsActor.IsColliding = true;
5180
5181 if (presence.LandAtTarget)
5182 presence.PhysicsActor.Flying = false;
5183
5184// Vector3 targetPos = presence.MoveToPositionTarget;
5185// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
5186// if (targetPos.Z - terrainHeight < 0.2)
5187// {
5188// presence.PhysicsActor.Flying = false;
5189// }
5190 }
5191
5192// m_log.DebugFormat(
5193// "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
5194// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
5195 }
5196 else
5197 {
5198// m_log.DebugFormat(
5199// "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
5200// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
5201
5202 Vector3 agent_control_v3 = new Vector3();
5203 presence.HandleMoveToTargetUpdate(ref agent_control_v3);
5204 presence.AddNewMovement(agent_control_v3);
5205 }
5206 }
5207 }
5218 } 5208 }
5219} 5209}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 6f963ac..36c5c52 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -74,7 +74,6 @@ namespace OpenSim.Region.Framework.Scenes
74 74
75 protected internal EntityManager Entities = new EntityManager(); 75 protected internal EntityManager Entities = new EntityManager();
76 76
77 protected RegionInfo m_regInfo;
78 protected Scene m_parentScene; 77 protected Scene m_parentScene;
79 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); 78 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
80 protected int m_numRootAgents = 0; 79 protected int m_numRootAgents = 0;
@@ -108,10 +107,9 @@ namespace OpenSim.Region.Framework.Scenes
108 107
109 #endregion 108 #endregion
110 109
111 protected internal SceneGraph(Scene parent, RegionInfo regInfo) 110 protected internal SceneGraph(Scene parent)
112 { 111 {
113 m_parentScene = parent; 112 m_parentScene = parent;
114 m_regInfo = regInfo;
115 } 113 }
116 114
117 public PhysicsScene PhysicsScene 115 public PhysicsScene PhysicsScene
@@ -122,7 +120,6 @@ namespace OpenSim.Region.Framework.Scenes
122 // If we're not doing the initial set 120 // If we're not doing the initial set
123 // Then we've got to remove the previous 121 // Then we've got to remove the previous
124 // event handler 122 // event handler
125
126 if (_PhyScene != null) 123 if (_PhyScene != null)
127 _PhyScene.OnPhysicsCrash -= physicsBasedCrash; 124 _PhyScene.OnPhysicsCrash -= physicsBasedCrash;
128 125
@@ -372,12 +369,12 @@ namespace OpenSim.Region.Framework.Scenes
372// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}", 369// "[SCENEGRAPH]: Adding scene object {0} {1}, with {2} parts on {3}",
373// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName); 370// sceneObject.Name, sceneObject.UUID, sceneObject.Parts.Length, m_parentScene.RegionInfo.RegionName);
374 371
375 SceneObjectPart[] children = sceneObject.Parts; 372 SceneObjectPart[] parts = sceneObject.Parts;
376 373
377 // Clamp child prim sizes and add child prims to the m_numPrim count 374 // Clamp child prim sizes and add child prims to the m_numPrim count
378 if (m_parentScene.m_clampPrimSize) 375 if (m_parentScene.m_clampPrimSize)
379 { 376 {
380 foreach (SceneObjectPart part in children) 377 foreach (SceneObjectPart part in parts)
381 { 378 {
382 Vector3 scale = part.Shape.Scale; 379 Vector3 scale = part.Shape.Scale;
383 380
@@ -391,7 +388,7 @@ namespace OpenSim.Region.Framework.Scenes
391 part.Shape.Scale = scale; 388 part.Shape.Scale = scale;
392 } 389 }
393 } 390 }
394 m_numPrim += children.Length; 391 m_numPrim += parts.Length;
395 392
396 sceneObject.AttachToScene(m_parentScene); 393 sceneObject.AttachToScene(m_parentScene);
397 394
@@ -411,15 +408,17 @@ namespace OpenSim.Region.Framework.Scenes
411 408
412 lock (SceneObjectGroupsByFullPartID) 409 lock (SceneObjectGroupsByFullPartID)
413 { 410 {
414 SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject; 411 foreach (SceneObjectPart part in parts)
415 foreach (SceneObjectPart part in children)
416 SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; 412 SceneObjectGroupsByFullPartID[part.UUID] = sceneObject;
417 } 413 }
418 414
419 lock (SceneObjectGroupsByLocalPartID) 415 lock (SceneObjectGroupsByLocalPartID)
420 { 416 {
421 SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject; 417// m_log.DebugFormat(
422 foreach (SceneObjectPart part in children) 418// "[SCENE GRAPH]: Adding scene object {0} {1} {2} to SceneObjectGroupsByLocalPartID in {3}",
419// sceneObject.Name, sceneObject.UUID, sceneObject.LocalId, m_parentScene.RegionInfo.RegionName);
420
421 foreach (SceneObjectPart part in parts)
423 SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; 422 SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject;
424 } 423 }
425 424
@@ -432,6 +431,10 @@ namespace OpenSim.Region.Framework.Scenes
432 /// <returns>true if the object was deleted, false if there was no object to delete</returns> 431 /// <returns>true if the object was deleted, false if there was no object to delete</returns>
433 public bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked) 432 public bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked)
434 { 433 {
434// m_log.DebugFormat(
435// "[SCENE GRAPH]: Deleting scene object with uuid {0}, resultOfObjectLinked = {1}",
436// uuid, resultOfObjectLinked);
437
435 EntityBase entity; 438 EntityBase entity;
436 if (!Entities.TryGetValue(uuid, out entity) || (!(entity is SceneObjectGroup))) 439 if (!Entities.TryGetValue(uuid, out entity) || (!(entity is SceneObjectGroup)))
437 return false; 440 return false;
@@ -460,7 +463,6 @@ namespace OpenSim.Region.Framework.Scenes
460 SceneObjectPart[] parts = grp.Parts; 463 SceneObjectPart[] parts = grp.Parts;
461 for (int i = 0; i < parts.Length; i++) 464 for (int i = 0; i < parts.Length; i++)
462 SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); 465 SceneObjectGroupsByFullPartID.Remove(parts[i].UUID);
463 SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID);
464 } 466 }
465 467
466 lock (SceneObjectGroupsByLocalPartID) 468 lock (SceneObjectGroupsByLocalPartID)
@@ -468,7 +470,6 @@ namespace OpenSim.Region.Framework.Scenes
468 SceneObjectPart[] parts = grp.Parts; 470 SceneObjectPart[] parts = grp.Parts;
469 for (int i = 0; i < parts.Length; i++) 471 for (int i = 0; i < parts.Length; i++)
470 SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); 472 SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId);
471 SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId);
472 } 473 }
473 474
474 return Entities.Remove(uuid); 475 return Entities.Remove(uuid);
@@ -589,7 +590,7 @@ namespace OpenSim.Region.Framework.Scenes
589 ScenePresence newAvatar = null; 590 ScenePresence newAvatar = null;
590 591
591 // ScenePresence always defaults to child agent 592 // ScenePresence always defaults to child agent
592 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance, type); 593 newAvatar = new ScenePresence(client, m_parentScene, appearance, type);
593 594
594 AddScenePresence(newAvatar); 595 AddScenePresence(newAvatar);
595 596
@@ -651,7 +652,7 @@ namespace OpenSim.Region.Framework.Scenes
651 if (!Entities.Remove(agentID)) 652 if (!Entities.Remove(agentID))
652 { 653 {
653 m_log.WarnFormat( 654 m_log.WarnFormat(
654 "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", 655 "[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
655 agentID); 656 agentID);
656 } 657 }
657 658
@@ -674,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
674 } 675 }
675 else 676 else
676 { 677 {
677 m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 678 m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
678 } 679 }
679 } 680 }
680 } 681 }
@@ -881,7 +882,8 @@ namespace OpenSim.Region.Framework.Scenes
881 if (Entities.TryGetValue(localID, out entity)) 882 if (Entities.TryGetValue(localID, out entity))
882 return entity as SceneObjectGroup; 883 return entity as SceneObjectGroup;
883 884
884 //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); 885// m_log.DebugFormat("[SCENE GRAPH]: Entered GetGroupByPrim with localID {0}", localID);
886
885 SceneObjectGroup sog; 887 SceneObjectGroup sog;
886 lock (SceneObjectGroupsByLocalPartID) 888 lock (SceneObjectGroupsByLocalPartID)
887 SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog); 889 SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog);
@@ -889,8 +891,24 @@ namespace OpenSim.Region.Framework.Scenes
889 if (sog != null) 891 if (sog != null)
890 { 892 {
891 if (sog.HasChildPrim(localID)) 893 if (sog.HasChildPrim(localID))
894 {
895// m_log.DebugFormat(
896// "[SCENE GRAPH]: Found scene object {0} {1} {2} containing part with local id {3} in {4}. Returning.",
897// sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName);
898
892 return sog; 899 return sog;
893 SceneObjectGroupsByLocalPartID.Remove(localID); 900 }
901 else
902 {
903 lock (SceneObjectGroupsByLocalPartID)
904 {
905 m_log.WarnFormat(
906 "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.",
907 sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName);
908
909 SceneObjectGroupsByLocalPartID.Remove(localID);
910 }
911 }
894 } 912 }
895 913
896 EntityBase[] entityList = GetEntities(); 914 EntityBase[] entityList = GetEntities();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 4bca3d0..905ecc9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -389,5 +389,18 @@ namespace OpenSim.Region.Framework.Scenes
389 for (int i = 0; i < parts.Length; i++) 389 for (int i = 0; i < parts.Length; i++)
390 parts[i].Inventory.ResumeScripts(); 390 parts[i].Inventory.ResumeScripts();
391 } 391 }
392
393 /// <summary>
394 /// Returns true if any part in the scene object contains scripts, false otherwise.
395 /// </summary>
396 /// <returns></returns>
397 public bool ContainsScripts()
398 {
399 foreach (SceneObjectPart part in Parts)
400 if (part.Inventory.ContainsScripts())
401 return true;
402
403 return false;
404 }
392 } 405 }
393} 406}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 2819545..980b01f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1599,7 +1599,7 @@ namespace OpenSim.Region.Framework.Scenes
1599 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); 1599 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1600 if (avatar != null) 1600 if (avatar != null)
1601 { 1601 {
1602 avatar.MoveToTarget(target, false); 1602 avatar.MoveToTarget(target, false, false);
1603 } 1603 }
1604 } 1604 }
1605 else 1605 else
@@ -1728,8 +1728,6 @@ namespace OpenSim.Region.Framework.Scenes
1728 1728
1729 #endregion 1729 #endregion
1730 1730
1731 #region Scheduling
1732
1733 public override void Update() 1731 public override void Update()
1734 { 1732 {
1735 // Check that the group was not deleted before the scheduled update 1733 // Check that the group was not deleted before the scheduled update
@@ -1880,7 +1878,14 @@ namespace OpenSim.Region.Framework.Scenes
1880 parts[i].SendTerseUpdateToAllClients(); 1878 parts[i].SendTerseUpdateToAllClients();
1881 } 1879 }
1882 1880
1883 #endregion 1881 /// <summary>
1882 /// Send metadata about the root prim (name, description, sale price, etc.) to a client.
1883 /// </summary>
1884 /// <param name="client"></param>
1885 public void SendPropertiesToClient(IClientAPI client)
1886 {
1887 m_rootPart.SendPropertiesToClient(client);
1888 }
1884 1889
1885 #region SceneGroupPart Methods 1890 #region SceneGroupPart Methods
1886 1891
@@ -2370,15 +2375,6 @@ namespace OpenSim.Region.Framework.Scenes
2370 } 2375 }
2371 2376
2372 /// <summary> 2377 /// <summary>
2373 /// Return metadata about a prim (name, description, sale price, etc.)
2374 /// </summary>
2375 /// <param name="client"></param>
2376 public void GetProperties(IClientAPI client)
2377 {
2378 m_rootPart.GetProperties(client);
2379 }
2380
2381 /// <summary>
2382 /// Set the name of a prim 2378 /// Set the name of a prim
2383 /// </summary> 2379 /// </summary>
2384 /// <param name="name"></param> 2380 /// <param name="name"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 04fef83..632ac8f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1305,8 +1305,6 @@ namespace OpenSim.Region.Framework.Scenes
1305 1305
1306 #endregion Public Properties with only Get 1306 #endregion Public Properties with only Get
1307 1307
1308 #region Private Methods
1309
1310 private uint ApplyMask(uint val, bool set, uint mask) 1308 private uint ApplyMask(uint val, bool set, uint mask)
1311 { 1309 {
1312 if (set) 1310 if (set)
@@ -1327,14 +1325,27 @@ namespace OpenSim.Region.Framework.Scenes
1327 m_updateFlag = 0; 1325 m_updateFlag = 0;
1328 } 1326 }
1329 1327
1330 private void SendObjectPropertiesToClient(UUID AgentID) 1328 /// <summary>
1329 /// Send this part's properties (name, description, inventory serial, base mask, etc.) to a client
1330 /// </summary>
1331 /// <param name="client"></param>
1332 public void SendPropertiesToClient(IClientAPI client)
1333 {
1334 client.SendObjectPropertiesReply(this);
1335 }
1336
1337 /// <summary>
1338 /// For the scene object group to which this part belongs, send that scene object's root part properties to a client.
1339 /// </summary>
1340 /// <param name="AgentID"></param>
1341 private void SendRootPartPropertiesToClient(UUID AgentID)
1331 { 1342 {
1332 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) 1343 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1333 { 1344 {
1334 // Ugly reference :( 1345 // Ugly reference :(
1335 if (avatar.UUID == AgentID) 1346 if (avatar.UUID == AgentID)
1336 { 1347 {
1337 m_parentGroup.GetProperties(avatar.ControllingClient); 1348 m_parentGroup.SendPropertiesToClient(avatar.ControllingClient);
1338 } 1349 }
1339 }); 1350 });
1340 } 1351 }
@@ -1363,8 +1374,6 @@ namespace OpenSim.Region.Framework.Scenes
1363 // } 1374 // }
1364 // } 1375 // }
1365 1376
1366 #endregion Private Methods
1367
1368 #region Public Methods 1377 #region Public Methods
1369 1378
1370 public void ResetExpire() 1379 public void ResetExpire()
@@ -1705,20 +1714,6 @@ namespace OpenSim.Region.Framework.Scenes
1705 Name, LocalId, id); 1714 Name, LocalId, id);
1706 } 1715 }
1707 1716
1708 public static SceneObjectPart Create()
1709 {
1710 SceneObjectPart part = new SceneObjectPart();
1711 part.UUID = UUID.Random();
1712
1713 PrimitiveBaseShape shape = PrimitiveBaseShape.Create();
1714 part.Shape = shape;
1715
1716 part.Name = "Primitive";
1717 part._ownerID = UUID.Random();
1718
1719 return part;
1720 }
1721
1722 /// <summary> 1717 /// <summary>
1723 /// Do a physics property update for a NINJA joint. 1718 /// Do a physics property update for a NINJA joint.
1724 /// </summary> 1719 /// </summary>
@@ -2030,11 +2025,6 @@ namespace OpenSim.Region.Framework.Scenes
2030 return Vector3.Zero; 2025 return Vector3.Zero;
2031 } 2026 }
2032 2027
2033 public void GetProperties(IClientAPI client)
2034 {
2035 client.SendObjectPropertiesReply(this);
2036 }
2037
2038 /// <summary> 2028 /// <summary>
2039 /// Method for a prim to get it's world position from the group. 2029 /// Method for a prim to get it's world position from the group.
2040 /// </summary> 2030 /// </summary>
@@ -3453,7 +3443,7 @@ namespace OpenSim.Region.Framework.Scenes
3453 { 3443 {
3454 _groupID = groupID; 3444 _groupID = groupID;
3455 if (client != null) 3445 if (client != null)
3456 GetProperties(client); 3446 SendPropertiesToClient(client);
3457 m_updateFlag = 2; 3447 m_updateFlag = 2;
3458 } 3448 }
3459 3449
@@ -4273,10 +4263,10 @@ namespace OpenSim.Region.Framework.Scenes
4273 4263
4274 break; 4264 break;
4275 } 4265 }
4276 SendFullUpdateToAllClients();
4277 4266
4278 SendObjectPropertiesToClient(AgentID); 4267 SendFullUpdateToAllClients();
4279 4268
4269 SendRootPartPropertiesToClient(AgentID);
4280 } 4270 }
4281 } 4271 }
4282 4272
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index e40e57d..9446741 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -784,6 +784,10 @@ namespace OpenSim.Region.Framework.Scenes
784 784
785 private bool CreateInventoryFile() 785 private bool CreateInventoryFile()
786 { 786 {
787// m_log.DebugFormat(
788// "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}",
789// m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial);
790
787 if (m_inventoryFileName == String.Empty || 791 if (m_inventoryFileName == String.Empty ||
788 m_inventoryFileNameSerial < m_inventorySerial) 792 m_inventoryFileNameSerial < m_inventorySerial)
789 { 793 {
@@ -797,6 +801,10 @@ namespace OpenSim.Region.Framework.Scenes
797 { 801 {
798 foreach (TaskInventoryItem item in m_items.Values) 802 foreach (TaskInventoryItem item in m_items.Values)
799 { 803 {
804// m_log.DebugFormat(
805// "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}",
806// item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId);
807
800 UUID ownerID = item.OwnerID; 808 UUID ownerID = item.OwnerID;
801 uint everyoneMask = 0; 809 uint everyoneMask = 0;
802 uint baseMask = item.BasePermissions; 810 uint baseMask = item.BasePermissions;
@@ -856,28 +864,43 @@ namespace OpenSim.Region.Framework.Scenes
856 /// <param name="xferManager"></param> 864 /// <param name="xferManager"></param>
857 public void RequestInventoryFile(IClientAPI client, IXfer xferManager) 865 public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
858 { 866 {
859 CreateInventoryFile(); 867 lock (m_items)
860
861 if (m_inventorySerial == 0) // No inventory
862 { 868 {
863 client.SendTaskInventory(m_part.UUID, 0, new byte[0]); 869 // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing
864 return; 870 // a new script if any previous deletion has left the prim inventory empty.
865 } 871 if (m_items.Count == 0) // No inventory
866 872 {
867 // In principle, we should only do the rest if the inventory changed; 873// m_log.DebugFormat(
868 // by sending m_inventorySerial to the client, it ought to know 874// "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items",
869 // that nothing changed and that it doesn't need to request the file. 875// m_part.Name, m_part.LocalId, m_part.UUID, client.Name);
870 // Unfortunately, it doesn't look like the client optimizes this;
871 // the client seems to always come back and request the Xfer,
872 // no matter what value m_inventorySerial has.
873 876
874 if (m_inventoryFileData.Length > 2) 877 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
875 // Add the file for Xfer 878 return;
876 xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); 879 }
877 880
878 // Tell the client we're ready to Xfer the file 881 CreateInventoryFile();
879 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, 882
880 Util.StringToBytes256(m_inventoryFileName)); 883 // In principle, we should only do the rest if the inventory changed;
884 // by sending m_inventorySerial to the client, it ought to know
885 // that nothing changed and that it doesn't need to request the file.
886 // Unfortunately, it doesn't look like the client optimizes this;
887 // the client seems to always come back and request the Xfer,
888 // no matter what value m_inventorySerial has.
889 // FIXME: Could probably be > 0 here rather than > 2
890 if (m_inventoryFileData.Length > 2)
891 {
892 // Add the file for Xfer
893 // m_log.DebugFormat(
894 // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}",
895 // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId);
896
897 xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
898 }
899
900 // Tell the client we're ready to Xfer the file
901 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
902 Util.StringToBytes256(m_inventoryFileName));
903 }
881 } 904 }
882 905
883 /// <summary> 906 /// <summary>
@@ -1035,10 +1058,15 @@ namespace OpenSim.Region.Framework.Scenes
1035 item.BasePermissions = perms; 1058 item.BasePermissions = perms;
1036 } 1059 }
1037 } 1060 }
1061
1038 m_inventorySerial++; 1062 m_inventorySerial++;
1039 HasInventoryChanged = true; 1063 HasInventoryChanged = true;
1040 } 1064 }
1041 1065
1066 /// <summary>
1067 /// Returns true if this part inventory contains any scripts. False otherwise.
1068 /// </summary>
1069 /// <returns></returns>
1042 public bool ContainsScripts() 1070 public bool ContainsScripts()
1043 { 1071 {
1044 lock (m_items) 1072 lock (m_items)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f231a39..5b02c3b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes
70 { 70 {
71// ~ScenePresence() 71// ~ScenePresence()
72// { 72// {
73// m_log.Debug("[ScenePresence] Destructor called"); 73// m_log.Debug("[SCENE PRESENCE] Destructor called");
74// } 74// }
75 75
76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -120,6 +120,8 @@ namespace OpenSim.Region.Framework.Scenes
120 /// </remarks> 120 /// </remarks>
121 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); 121 protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
122 122
123 public Object AttachmentsSyncLock { get; private set; }
124
123 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); 125 private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
124 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 126 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
125 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; 127 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
@@ -176,8 +178,6 @@ namespace OpenSim.Region.Framework.Scenes
176 178
177 private Quaternion m_bodyRot = Quaternion.Identity; 179 private Quaternion m_bodyRot = Quaternion.Identity;
178 180
179 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
180
181 private const int LAND_VELOCITYMAG_MAX = 12; 181 private const int LAND_VELOCITYMAG_MAX = 12;
182 182
183 public bool IsRestrictedToRegion; 183 public bool IsRestrictedToRegion;
@@ -186,7 +186,6 @@ namespace OpenSim.Region.Framework.Scenes
186 186
187 private float m_health = 100f; 187 private float m_health = 100f;
188 188
189 protected RegionInfo m_regionInfo;
190 protected ulong crossingFromRegion; 189 protected ulong crossingFromRegion;
191 190
192 private readonly Vector3[] Dir_Vectors = new Vector3[9]; 191 private readonly Vector3[] Dir_Vectors = new Vector3[9];
@@ -221,6 +220,11 @@ namespace OpenSim.Region.Framework.Scenes
221 public bool MovingToTarget { get; private set; } 220 public bool MovingToTarget { get; private set; }
222 public Vector3 MoveToPositionTarget { get; private set; } 221 public Vector3 MoveToPositionTarget { get; private set; }
223 222
223 /// <summary>
224 /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying).
225 /// </summary>
226 public bool LandAtTarget { get; private set; }
227
224 private bool m_followCamAuto; 228 private bool m_followCamAuto;
225 229
226 private int m_movementUpdateCount; 230 private int m_movementUpdateCount;
@@ -466,7 +470,13 @@ namespace OpenSim.Region.Framework.Scenes
466 { 470 {
467 PhysicsActor actor = m_physicsActor; 471 PhysicsActor actor = m_physicsActor;
468 if (actor != null) 472 if (actor != null)
473 {
469 m_pos = actor.Position; 474 m_pos = actor.Position;
475
476// m_log.DebugFormat(
477// "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!",
478// m_pos, Name, Scene.RegionInfo.RegionName);
479 }
470 else 480 else
471 { 481 {
472 // Obtain the correct position of a seated avatar. 482 // Obtain the correct position of a seated avatar.
@@ -510,19 +520,26 @@ namespace OpenSim.Region.Framework.Scenes
510 } 520 }
511 catch (Exception e) 521 catch (Exception e)
512 { 522 {
513 m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); 523 m_log.Error("[SCENE PRESENCE]: ABSOLUTE POSITION " + e.Message);
514 } 524 }
515 } 525 }
516 526
517 m_pos = value; 527 m_pos = value;
518 m_parentPosition = Vector3.Zero; 528 m_parentPosition = Vector3.Zero;
529
530// m_log.DebugFormat(
531// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
532// Scene.RegionInfo.RegionName, Name, m_pos);
519 } 533 }
520 } 534 }
521 535
536 /// <summary>
537 /// If sitting, returns the offset position from the prim the avatar is sitting on.
538 /// Otherwise, returns absolute position in the scene.
539 /// </summary>
522 public Vector3 OffsetPosition 540 public Vector3 OffsetPosition
523 { 541 {
524 get { return m_pos; } 542 get { return m_pos; }
525 set { m_pos = value; }
526 } 543 }
527 544
528 /// <summary> 545 /// <summary>
@@ -534,8 +551,14 @@ namespace OpenSim.Region.Framework.Scenes
534 { 551 {
535 PhysicsActor actor = m_physicsActor; 552 PhysicsActor actor = m_physicsActor;
536 if (actor != null) 553 if (actor != null)
554 {
537 m_velocity = actor.Velocity; 555 m_velocity = actor.Velocity;
538 556
557// m_log.DebugFormat(
558// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
559// m_velocity, Name, Scene.RegionInfo.RegionName);
560 }
561
539 return m_velocity; 562 return m_velocity;
540 } 563 }
541 set 564 set
@@ -550,24 +573,26 @@ namespace OpenSim.Region.Framework.Scenes
550 } 573 }
551 catch (Exception e) 574 catch (Exception e)
552 { 575 {
553 m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); 576 m_log.Error("[SCENE PRESENCE]: VELOCITY " + e.Message);
554 } 577 }
555 } 578 }
556 579
557 m_velocity = value; 580 m_velocity = value;
581
582// m_log.DebugFormat(
583// "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}",
584// Scene.RegionInfo.RegionName, Name, m_velocity);
558 } 585 }
559 } 586 }
560 587
561 public Quaternion Rotation 588 public Quaternion Rotation
562 { 589 {
563 get { return m_bodyRot; } 590 get { return m_bodyRot; }
564 set { m_bodyRot = value; } 591 set
565 } 592 {
566 593 m_bodyRot = value;
567 public Quaternion PreviousRotation 594// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
568 { 595 }
569 get { return m_bodyRotPrevious; }
570 set { m_bodyRotPrevious = value; }
571 } 596 }
572 597
573 /// <summary> 598 /// <summary>
@@ -705,23 +730,24 @@ namespace OpenSim.Region.Framework.Scenes
705 #endregion 730 #endregion
706 731
707 #region Constructor(s) 732 #region Constructor(s)
708 733
709 public ScenePresence( 734 public ScenePresence(
710 IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type) 735 IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type)
711 { 736 {
737 AttachmentsSyncLock = new Object();
738
712 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 739 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
713 m_sceneViewer = new SceneViewer(this); 740 m_sceneViewer = new SceneViewer(this);
714 m_animator = new ScenePresenceAnimator(this); 741 m_animator = new ScenePresenceAnimator(this);
715 PresenceType = type; 742 PresenceType = type;
716 m_DrawDistance = world.DefaultDrawDistance; 743 m_DrawDistance = world.DefaultDrawDistance;
717 m_rootRegionHandle = reginfo.RegionHandle; 744 m_rootRegionHandle = world.RegionInfo.RegionHandle;
718 m_controllingClient = client; 745 m_controllingClient = client;
719 m_firstname = m_controllingClient.FirstName; 746 m_firstname = m_controllingClient.FirstName;
720 m_lastname = m_controllingClient.LastName; 747 m_lastname = m_controllingClient.LastName;
721 m_name = String.Format("{0} {1}", m_firstname, m_lastname); 748 m_name = String.Format("{0} {1}", m_firstname, m_lastname);
722 m_scene = world; 749 m_scene = world;
723 m_uuid = client.AgentId; 750 m_uuid = client.AgentId;
724 m_regionInfo = reginfo;
725 m_localId = m_scene.AllocateLocalId(); 751 m_localId = m_scene.AllocateLocalId();
726 752
727 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); 753 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
@@ -983,7 +1009,7 @@ namespace OpenSim.Region.Framework.Scenes
983 Animator.ResetAnimations(); 1009 Animator.ResetAnimations();
984 1010
985// m_log.DebugFormat( 1011// m_log.DebugFormat(
986// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1012// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
987// Name, UUID, m_scene.RegionInfo.RegionName); 1013// Name, UUID, m_scene.RegionInfo.RegionName);
988 1014
989 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, 1015 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing,
@@ -1150,9 +1176,9 @@ namespace OpenSim.Region.Framework.Scenes
1150 m_callbackURI = null; 1176 m_callbackURI = null;
1151 } 1177 }
1152 1178
1153 //m_log.DebugFormat("Completed movement"); 1179 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1154 1180
1155 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1181 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1156 SendInitialData(); 1182 SendInitialData();
1157 1183
1158 // Create child agents in neighbouring regions 1184 // Create child agents in neighbouring regions
@@ -1217,7 +1243,9 @@ namespace OpenSim.Region.Framework.Scenes
1217 /// </summary> 1243 /// </summary>
1218 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 1244 public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
1219 { 1245 {
1220// m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); 1246// m_log.DebugFormat(
1247// "[SCENE PRESENCE]: In {0} received agent update from {1}",
1248// Scene.RegionInfo.RegionName, remoteClient.Name);
1221 1249
1222 //if (m_isChildAgent) 1250 //if (m_isChildAgent)
1223 //{ 1251 //{
@@ -1658,7 +1686,10 @@ namespace OpenSim.Region.Framework.Scenes
1658 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path 1686 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
1659 /// from start to finish. 1687 /// from start to finish.
1660 /// </param> 1688 /// </param>
1661 public void MoveToTarget(Vector3 pos, bool noFly) 1689 /// <param name="landAtTarget">
1690 /// If true and the avatar starts flying during the move then land at the target.
1691 /// </param>
1692 public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget)
1662 { 1693 {
1663 m_log.DebugFormat( 1694 m_log.DebugFormat(
1664 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", 1695 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@@ -1684,7 +1715,7 @@ namespace OpenSim.Region.Framework.Scenes
1684 1715
1685 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 1716 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
1686 // always slightly higher than the actual terrain height. 1717 // always slightly higher than the actual terrain height.
1687 // FIXME: This constrains NOC movements as well, so should be somewhere else. 1718 // FIXME: This constrains NPC movements as well, so should be somewhere else.
1688 if (pos.Z - terrainHeight < 0.2) 1719 if (pos.Z - terrainHeight < 0.2)
1689 pos.Z = terrainHeight; 1720 pos.Z = terrainHeight;
1690 1721
@@ -1697,9 +1728,25 @@ namespace OpenSim.Region.Framework.Scenes
1697 else if (pos.Z > terrainHeight) 1728 else if (pos.Z > terrainHeight)
1698 PhysicsActor.Flying = true; 1729 PhysicsActor.Flying = true;
1699 1730
1731 LandAtTarget = landAtTarget;
1700 MovingToTarget = true; 1732 MovingToTarget = true;
1701 MoveToPositionTarget = pos; 1733 MoveToPositionTarget = pos;
1702 1734
1735 // Rotate presence around the z-axis to point in same direction as movement.
1736 // Ignore z component of vector
1737 Vector3 localVectorToTarget3D = pos - AbsolutePosition;
1738 Vector3 localVectorToTarget2D = new Vector3((float)(localVectorToTarget3D.X), (float)(localVectorToTarget3D.Y), 0f);
1739
1740// m_log.DebugFormat("[SCENE PRESENCE]: Local vector to target is {0}", localVectorToTarget2D);
1741
1742 // Calculate the yaw.
1743 Vector3 angle = new Vector3(0, 0, (float)(Math.Atan2(localVectorToTarget2D.Y, localVectorToTarget2D.X)));
1744
1745// m_log.DebugFormat("[SCENE PRESENCE]: Angle is {0}", angle);
1746
1747 Rotation = Quaternion.CreateFromEulers(angle);
1748// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation);
1749
1703 Vector3 agent_control_v3 = new Vector3(); 1750 Vector3 agent_control_v3 = new Vector3();
1704 HandleMoveToTargetUpdate(ref agent_control_v3); 1751 HandleMoveToTargetUpdate(ref agent_control_v3);
1705 AddNewMovement(agent_control_v3); 1752 AddNewMovement(agent_control_v3);
@@ -2389,7 +2436,7 @@ namespace OpenSim.Region.Framework.Scenes
2389 Vector3 pos = m_pos; 2436 Vector3 pos = m_pos;
2390 pos.Z += m_appearance.HipOffset; 2437 pos.Z += m_appearance.HipOffset;
2391 2438
2392 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2439 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2393 2440
2394 remoteClient.SendPrimUpdate( 2441 remoteClient.SendPrimUpdate(
2395 this, 2442 this,
@@ -2476,6 +2523,7 @@ namespace OpenSim.Region.Framework.Scenes
2476 /// </summary> 2523 /// </summary>
2477 private void SendInitialData() 2524 private void SendInitialData()
2478 { 2525 {
2526 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
2479 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2527 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2480 // the inventory arrives 2528 // the inventory arrives
2481 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2529 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
@@ -2520,10 +2568,11 @@ namespace OpenSim.Region.Framework.Scenes
2520 /// </summary> 2568 /// </summary>
2521 public void SendAvatarDataToAllAgents() 2569 public void SendAvatarDataToAllAgents()
2522 { 2570 {
2571 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID);
2523 // only send update from root agents to other clients; children are only "listening posts" 2572 // only send update from root agents to other clients; children are only "listening posts"
2524 if (IsChildAgent) 2573 if (IsChildAgent)
2525 { 2574 {
2526 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2575 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2527 return; 2576 return;
2528 } 2577 }
2529 2578
@@ -2573,7 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes
2573 /// <param name="avatar"></param> 2622 /// <param name="avatar"></param>
2574 public void SendAvatarDataToAgent(ScenePresence avatar) 2623 public void SendAvatarDataToAgent(ScenePresence avatar)
2575 { 2624 {
2576// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); 2625 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
2577 2626
2578 avatar.ControllingClient.SendAvatarDataImmediate(this); 2627 avatar.ControllingClient.SendAvatarDataImmediate(this);
2579 if (Animator != null) 2628 if (Animator != null)
@@ -2586,10 +2635,11 @@ namespace OpenSim.Region.Framework.Scenes
2586 /// </summary> 2635 /// </summary>
2587 public void SendAppearanceToAllOtherAgents() 2636 public void SendAppearanceToAllOtherAgents()
2588 { 2637 {
2638 m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID);
2589 // only send update from root agents to other clients; children are only "listening posts" 2639 // only send update from root agents to other clients; children are only "listening posts"
2590 if (IsChildAgent) 2640 if (IsChildAgent)
2591 { 2641 {
2592 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2642 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2593 return; 2643 return;
2594 } 2644 }
2595 2645
@@ -2615,6 +2665,7 @@ namespace OpenSim.Region.Framework.Scenes
2615 /// </summary> 2665 /// </summary>
2616 public void SendOtherAgentsAppearanceToMe() 2666 public void SendOtherAgentsAppearanceToMe()
2617 { 2667 {
2668 //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID);
2618 m_perfMonMS = Util.EnvironmentTickCount(); 2669 m_perfMonMS = Util.EnvironmentTickCount();
2619 2670
2620 int count = 0; 2671 int count = 0;
@@ -2873,8 +2924,8 @@ namespace OpenSim.Region.Framework.Scenes
2873 /// </returns> 2924 /// </returns>
2874 protected int HaveNeighbor(Cardinals car, ref int[] fix) 2925 protected int HaveNeighbor(Cardinals car, ref int[] fix)
2875 { 2926 {
2876 uint neighbourx = m_regionInfo.RegionLocX; 2927 uint neighbourx = m_scene.RegionInfo.RegionLocX;
2877 uint neighboury = m_regionInfo.RegionLocY; 2928 uint neighboury = m_scene.RegionInfo.RegionLocY;
2878 2929
2879 int dir = (int)car; 2930 int dir = (int)car;
2880 2931
@@ -2894,8 +2945,8 @@ namespace OpenSim.Region.Framework.Scenes
2894 2945
2895 if (neighbourRegion == null) 2946 if (neighbourRegion == null)
2896 { 2947 {
2897 fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); 2948 fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx);
2898 fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); 2949 fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury);
2899 return dir * (-1); 2950 return dir * (-1);
2900 } 2951 }
2901 else 2952 else
@@ -3141,26 +3192,30 @@ namespace OpenSim.Region.Framework.Scenes
3141 catch { } 3192 catch { }
3142 3193
3143 // Attachment objects 3194 // Attachment objects
3144 if (m_attachments != null && m_attachments.Count > 0) 3195 lock (m_attachments)
3145 { 3196 {
3146 cAgent.AttachmentObjects = new List<ISceneObject>(); 3197 if (m_attachments.Count > 0)
3147 cAgent.AttachmentObjectStates = new List<string>();
3148// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3149 m_InTransitScriptStates.Clear();
3150 foreach (SceneObjectGroup sog in m_attachments)
3151 { 3198 {
3152 // We need to make a copy and pass that copy 3199 cAgent.AttachmentObjects = new List<ISceneObject>();
3153 // because of transfers withn the same sim 3200 cAgent.AttachmentObjectStates = new List<string>();
3154 ISceneObject clone = sog.CloneForNewScene(); 3201 // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3155 // Attachment module assumes that GroupPosition holds the offsets...! 3202 m_InTransitScriptStates.Clear();
3156 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; 3203
3157 ((SceneObjectGroup)clone).IsAttachment = false; 3204 foreach (SceneObjectGroup sog in m_attachments)
3158 cAgent.AttachmentObjects.Add(clone); 3205 {
3159 string state = sog.GetStateSnapshot(); 3206 // We need to make a copy and pass that copy
3160 cAgent.AttachmentObjectStates.Add(state); 3207 // because of transfers withn the same sim
3161 m_InTransitScriptStates.Add(state); 3208 ISceneObject clone = sog.CloneForNewScene();
3162 // Let's remove the scripts of the original object here 3209 // Attachment module assumes that GroupPosition holds the offsets...!
3163 sog.RemoveScriptInstances(true); 3210 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3211 ((SceneObjectGroup)clone).IsAttachment = false;
3212 cAgent.AttachmentObjects.Add(clone);
3213 string state = sog.GetStateSnapshot();
3214 cAgent.AttachmentObjectStates.Add(state);
3215 m_InTransitScriptStates.Add(state);
3216 // Let's remove the scripts of the original object here
3217 sog.RemoveScriptInstances(true);
3218 }
3164 } 3219 }
3165 } 3220 }
3166 } 3221 }
@@ -3277,6 +3332,10 @@ namespace OpenSim.Region.Framework.Scenes
3277 /// </summary> 3332 /// </summary>
3278 public void AddToPhysicalScene(bool isFlying) 3333 public void AddToPhysicalScene(bool isFlying)
3279 { 3334 {
3335// m_log.DebugFormat(
3336// "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}",
3337// Name, isFlying, Scene.RegionInfo.RegionName);
3338
3280 if (m_appearance.AvatarHeight == 0) 3339 if (m_appearance.AvatarHeight == 0)
3281 m_appearance.SetHeight(); 3340 m_appearance.SetHeight();
3282 3341
@@ -3317,7 +3376,7 @@ namespace OpenSim.Region.Framework.Scenes
3317 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 3376 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3318 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( 3377 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
3319 // as of this comment the interval is set in AddToPhysicalScene 3378 // as of this comment the interval is set in AddToPhysicalScene
3320 if (Animator!=null) 3379 if (Animator != null)
3321 Animator.UpdateMovementAnimations(); 3380 Animator.UpdateMovementAnimations();
3322 3381
3323 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3382 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
@@ -3398,7 +3457,8 @@ namespace OpenSim.Region.Framework.Scenes
3398 3457
3399 public void Close() 3458 public void Close()
3400 { 3459 {
3401 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); 3460 if (!IsChildAgent)
3461 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
3402 3462
3403 lock (m_knownChildRegions) 3463 lock (m_knownChildRegions)
3404 { 3464 {
@@ -3501,8 +3561,10 @@ namespace OpenSim.Region.Framework.Scenes
3501 /// <summary> 3561 /// <summary>
3502 /// This is currently just being done for information. 3562 /// This is currently just being done for information.
3503 /// </summary> 3563 /// </summary>
3504 public void ValidateAttachments() 3564 public bool ValidateAttachments()
3505 { 3565 {
3566 bool validated = true;
3567
3506 lock (m_attachments) 3568 lock (m_attachments)
3507 { 3569 {
3508 // Validate 3570 // Validate
@@ -3512,15 +3574,21 @@ namespace OpenSim.Region.Framework.Scenes
3512 { 3574 {
3513 m_log.WarnFormat( 3575 m_log.WarnFormat(
3514 "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null. Continuing", Name); 3576 "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null. Continuing", Name);
3577
3578 validated = false;
3515 } 3579 }
3516 else if (gobj.IsDeleted) 3580 else if (gobj.IsDeleted)
3517 { 3581 {
3518 m_log.WarnFormat( 3582 m_log.WarnFormat(
3519 "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted. Continuing", 3583 "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted. Continuing",
3520 gobj.Name, gobj.UUID, Name); 3584 gobj.Name, gobj.UUID, Name);
3585
3586 validated = false;
3521 } 3587 }
3522 } 3588 }
3523 } 3589 }
3590
3591 return validated;
3524 } 3592 }
3525 3593
3526 /// <summary> 3594 /// <summary>
@@ -3552,29 +3620,6 @@ namespace OpenSim.Region.Framework.Scenes
3552 } 3620 }
3553 } 3621 }
3554 3622
3555
3556 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3557 {
3558 m_controllingClient = client;
3559 m_regionInfo = region;
3560 m_scene = scene;
3561
3562 RegisterToEvents();
3563
3564 /*
3565 AbsolutePosition = client.StartPos;
3566
3567 Animations = new AvatarAnimations();
3568 Animations.LoadAnims();
3569
3570 m_animations = new List<UUID>();
3571 m_animations.Add(Animations.AnimsUUID["STAND"]);
3572 m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber);
3573
3574 SetDirectionVectors();
3575 */
3576 }
3577
3578 internal void PushForce(Vector3 impulse) 3623 internal void PushForce(Vector3 impulse)
3579 { 3624 {
3580 if (PhysicsActor != null) 3625 if (PhysicsActor != null)
@@ -3602,6 +3647,7 @@ namespace OpenSim.Region.Framework.Scenes
3602 obj.ignoreControls = (ScriptControlled)controls; 3647 obj.ignoreControls = (ScriptControlled)controls;
3603 obj.eventControls = (ScriptControlled)controls; 3648 obj.eventControls = (ScriptControlled)controls;
3604 } 3649 }
3650
3605 if (pass_on == 1 && accept == 1) 3651 if (pass_on == 1 && accept == 1)
3606 { 3652 {
3607 IgnoredControls = ScriptControlled.CONTROL_ZERO; 3653 IgnoredControls = ScriptControlled.CONTROL_ZERO;
@@ -3622,6 +3668,7 @@ namespace OpenSim.Region.Framework.Scenes
3622 scriptedcontrols[Script_item_UUID] = obj; 3668 scriptedcontrols[Script_item_UUID] = obj;
3623 } 3669 }
3624 } 3670 }
3671
3625 ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); 3672 ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
3626 } 3673 }
3627 3674
@@ -3803,4 +3850,4 @@ namespace OpenSim.Region.Framework.Scenes
3803 } 3850 }
3804 } 3851 }
3805 } 3852 }
3806} \ No newline at end of file 3853}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 1ea2329..80f198d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -52,22 +52,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 TestHelpers.InMethod(); 52 TestHelpers.InMethod();
53 53
54 Scene scene = SceneHelpers.SetupScene(); 54 Scene scene = SceneHelpers.SetupScene();
55 int partsToTestCount = 3;
55 56
56 string objName = "obj1"; 57 SceneObjectGroup so
57 UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); 58 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
58 59 SceneObjectPart[] parts = so.Parts;
59 SceneObjectPart part
60 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
61 { Name = objName, UUID = objUuid };
62 60
63 Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part), false), Is.True); 61 Assert.That(scene.AddNewSceneObject(so, false), Is.True);
64 62 SceneObjectGroup retrievedSo = scene.GetSceneObjectGroup(so.UUID);
65 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(objUuid); 63 SceneObjectPart[] retrievedParts = retrievedSo.Parts;
66 64
67 //m_log.Debug("retrievedPart : {0}", retrievedPart); 65 //m_log.Debug("retrievedPart : {0}", retrievedPart);
68 // If the parts have the same UUID then we will consider them as one and the same 66 // If the parts have the same UUID then we will consider them as one and the same
69 Assert.That(retrievedPart.Name, Is.EqualTo(objName)); 67 Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount));
70 Assert.That(retrievedPart.UUID, Is.EqualTo(objUuid)); 68
69 for (int i = 0; i < partsToTestCount; i++)
70 {
71 Assert.That(retrievedParts[i].Name, Is.EqualTo(parts[i].Name));
72 Assert.That(retrievedParts[i].UUID, Is.EqualTo(parts[i].UUID));
73 }
71 } 74 }
72 75
73 [Test] 76 [Test]
@@ -103,6 +106,39 @@ namespace OpenSim.Region.Framework.Scenes.Tests
103 Assert.That(retrievedPart.Name, Is.EqualTo(obj1Name)); 106 Assert.That(retrievedPart.Name, Is.EqualTo(obj1Name));
104 Assert.That(retrievedPart.UUID, Is.EqualTo(objUuid)); 107 Assert.That(retrievedPart.UUID, Is.EqualTo(objUuid));
105 } 108 }
109
110 /// <summary>
111 /// Test retrieving a scene object via the local id of one of its parts.
112 /// </summary>
113 [Test]
114 public void TestGetSceneObjectByPartLocalId()
115 {
116 TestHelpers.InMethod();
117
118 Scene scene = SceneHelpers.SetupScene();
119 int partsToTestCount = 3;
120
121 SceneObjectGroup so
122 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
123 SceneObjectPart[] parts = so.Parts;
124
125 scene.AddNewSceneObject(so, false);
126
127 // Test getting via the root part's local id
128 Assert.That(scene.GetGroupByPrim(so.LocalId), Is.Not.Null);
129
130 // Test getting via a non root part's local id
131 Assert.That(scene.GetGroupByPrim(parts[partsToTestCount - 1].LocalId), Is.Not.Null);
132
133 // Test that we don't get back an object for a local id that doesn't exist
134 Assert.That(scene.GetGroupByPrim(999), Is.Null);
135
136 // Now delete the scene object and check again
137 scene.DeleteSceneObject(so, false);
138
139 Assert.That(scene.GetGroupByPrim(so.LocalId), Is.Null);
140 Assert.That(scene.GetGroupByPrim(parts[partsToTestCount - 1].LocalId), Is.Null);
141 }
106 142
107 /// <summary> 143 /// <summary>
108 /// Test deleting an object from a scene. 144 /// Test deleting an object from a scene.
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
new file mode 100644
index 0000000..64c36ff
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -0,0 +1,135 @@
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 OpenSimulator 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 System.Reflection;
31using log4net;
32using Nini.Config;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock;
41
42namespace OpenSim.Region.Framework.Scenes.Tests
43{
44 [TestFixture]
45 public class ScenePresenceAutopilotTests
46 {
47 private TestScene m_scene;
48
49 [TestFixtureSetUp]
50 public void FixtureInit()
51 {
52 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
53 Util.FireAndForgetMethod = FireAndForgetMethod.None;
54 }
55
56 [TestFixtureTearDown]
57 public void TearDown()
58 {
59 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
60 // threads. Possibly, later tests should be rewritten not to worry about such things.
61 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
62 }
63
64 [SetUp]
65 public void Init()
66 {
67 m_scene = SceneHelpers.SetupScene();
68 }
69
70 [Test]
71 public void TestMove()
72 {
73 TestHelpers.InMethod();
74// log4net.Config.XmlConfigurator.Configure();
75
76 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
77
78 Vector3 startPos = sp.AbsolutePosition;
79// Vector3 startPos = new Vector3(128, 128, 30);
80
81 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
82 sp.PhysicsActor.Flying = true;
83
84 m_scene.Update();
85 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
86
87 Vector3 targetPos = startPos + new Vector3(0, 10, 0);
88 sp.MoveToTarget(targetPos, false, false);
89
90 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
91 Assert.That(
92 sp.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001));
93
94 m_scene.Update();
95
96 // We should really check the exact figure.
97 Assert.That(sp.AbsolutePosition.X, Is.EqualTo(startPos.X));
98 Assert.That(sp.AbsolutePosition.Y, Is.GreaterThan(startPos.Y));
99 Assert.That(sp.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
100 Assert.That(sp.AbsolutePosition.Z, Is.LessThan(targetPos.X));
101
102 for (int i = 0; i < 10; i++)
103 m_scene.Update();
104
105 double distanceToTarget = Util.GetDistanceTo(sp.AbsolutePosition, targetPos);
106 Assert.That(distanceToTarget, Is.LessThan(1), "Avatar not within 1 unit of target position on first move");
107 Assert.That(sp.AbsolutePosition, Is.EqualTo(targetPos));
108 Assert.That(sp.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
109
110 // Try a second movement
111 startPos = sp.AbsolutePosition;
112 targetPos = startPos + new Vector3(10, 0, 0);
113 sp.MoveToTarget(targetPos, false, false);
114
115 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
116 Assert.That(
117 sp.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001));
118
119 m_scene.Update();
120
121 // We should really check the exact figure.
122 Assert.That(sp.AbsolutePosition.X, Is.GreaterThan(startPos.X));
123 Assert.That(sp.AbsolutePosition.X, Is.LessThan(targetPos.X));
124 Assert.That(sp.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
125 Assert.That(sp.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
126
127 for (int i = 0; i < 10; i++)
128 m_scene.Update();
129
130 distanceToTarget = Util.GetDistanceTo(sp.AbsolutePosition, targetPos);
131 Assert.That(distanceToTarget, Is.LessThan(1), "Avatar not within 1 unit of target position on second move");
132 Assert.That(sp.AbsolutePosition, Is.EqualTo(targetPos));
133 }
134 }
135} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 77b1535..3acdaf8 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -43,11 +43,12 @@ namespace OpenSim.Region.Framework.Scenes
43 /// <summary> 43 /// <summary>
44 /// Gather uuids for a given entity. 44 /// Gather uuids for a given entity.
45 /// </summary> 45 /// </summary>
46 /// 46 /// <remarks>
47 /// This does a deep inspection of the entity to retrieve all the assets it uses (whether as textures, as scripts 47 /// This does a deep inspection of the entity to retrieve all the assets it uses (whether as textures, as scripts
48 /// contained in inventory, as scripts contained in objects contained in another object's inventory, etc. Assets 48 /// contained in inventory, as scripts contained in objects contained in another object's inventory, etc. Assets
49 /// are only retrieved when they are necessary to carry out the inspection (i.e. a serialized object needs to be 49 /// are only retrieved when they are necessary to carry out the inspection (i.e. a serialized object needs to be
50 /// retrieved to work out which assets it references). 50 /// retrieved to work out which assets it references).
51 /// </remarks>
51 public class UuidGatherer 52 public class UuidGatherer
52 { 53 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -76,11 +77,11 @@ namespace OpenSim.Region.Framework.Scenes
76 /// <summary> 77 /// <summary>
77 /// Gather all the asset uuids associated with the asset referenced by a given uuid 78 /// Gather all the asset uuids associated with the asset referenced by a given uuid
78 /// </summary> 79 /// </summary>
79 /// 80 /// <remarks>
80 /// This includes both those directly associated with 81 /// This includes both those directly associated with
81 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained 82 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
82 /// within this object). 83 /// within this object).
83 /// 84 /// </remarks>
84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 85 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
85 /// <param name="assetType">The type of the asset for the uuid given</param> 86 /// <param name="assetType">The type of the asset for the uuid given</param>
86 /// <param name="assetUuids">The assets gathered</param> 87 /// <param name="assetUuids">The assets gathered</param>
@@ -123,11 +124,11 @@ namespace OpenSim.Region.Framework.Scenes
123 /// <summary> 124 /// <summary>
124 /// Gather all the asset uuids associated with a given object. 125 /// Gather all the asset uuids associated with a given object.
125 /// </summary> 126 /// </summary>
126 /// 127 /// <remarks>
127 /// This includes both those directly associated with 128 /// This includes both those directly associated with
128 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained 129 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
129 /// within this object). 130 /// within this object).
130 /// 131 /// </remarks>
131 /// <param name="sceneObject">The scene object for which to gather assets</param> 132 /// <param name="sceneObject">The scene object for which to gather assets</param>
132 /// <param name="assetUuids">The assets gathered</param> 133 /// <param name="assetUuids">The assets gathered</param>
133 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) 134 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)