aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityBase.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs235
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs67
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs94
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs135
11 files changed, 425 insertions, 226 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 4925175..904a657 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -181,8 +181,8 @@ TrySetMovementAnimation("STAND");
181 bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); 181 bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
182 bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); 182 bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
183 bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); 183 bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG);
184 //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; 184 bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
185 //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; 185 bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
186 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; 186 bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
187 bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; 187 bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
188 //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; 188 //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY;
@@ -404,7 +404,17 @@ TrySetMovementAnimation("STAND");
404 else if (m_scenePresence.SetAlwaysRun) 404 else if (m_scenePresence.SetAlwaysRun)
405 return "RUN"; 405 return "RUN";
406 else 406 else
407 return "WALK"; 407 {
408 // Not walking
409 if (move.Z < 0)
410 return "CROUCH";
411 else if (heldTurnLeft)
412 return "TURNLEFT";
413 else if (heldTurnRight)
414 return "TURNRIGHT";
415 else
416 return "WALK";
417 }
408 } 418 }
409// rm for jumping else 419// rm for jumping else
410 else if (!m_jumping) // add for jumping 420 else if (!m_jumping) // add for jumping
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 088839d..12688bd 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -119,6 +119,11 @@ namespace OpenSim.Region.Framework.Scenes
119 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) 119 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
120 { 120 {
121 m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); 121 m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop");
122
123 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
124 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as
125 // number seperators.
126 Culture.SetCurrentCulture();
122 127
123 while (InventoryDeQueueAndDelete()) 128 while (InventoryDeQueueAndDelete())
124 { 129 {
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs
index 213431a..680a4a3 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;
@@ -108,11 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
108 } 115 }
109 116
110 /// <summary> 117 /// <summary>
111 ///
112 /// </summary>
113 public abstract void UpdateMovement();
114
115 /// <summary>
116 /// Performs any updates that need to be done at each frame, as opposed to immediately. 118 /// Performs any updates that need to be done at each frame, as opposed to immediately.
117 /// These included scheduled updates and updates that occur due to physics processing. 119 /// These included scheduled updates and updates that occur due to physics processing.
118 /// </summary> 120 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c2ec5d0..53f0f2e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -261,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes
261 item.AssetID = asset.FullID; 261 item.AssetID = asset.FullID;
262 group.UpdateInventoryItem(item); 262 group.UpdateInventoryItem(item);
263 263
264 part.GetProperties(remoteClient); 264 part.SendPropertiesToClient(remoteClient);
265 265
266 // Trigger rerunning of script (use TriggerRezScript event, see RezScript) 266 // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
267 ArrayList errors = new ArrayList(); 267 ArrayList errors = new ArrayList();
@@ -316,6 +316,10 @@ namespace OpenSim.Region.Framework.Scenes
316 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID, 316 public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
317 UUID itemID, InventoryItemBase itemUpd) 317 UUID itemID, InventoryItemBase itemUpd)
318 { 318 {
319// m_log.DebugFormat(
320// "[USER INVENTORY]: Updating asset for item {0} {1}, transaction ID {2} for {3}",
321// itemID, itemUpd.Name, transactionID, remoteClient.Name);
322
319 // This one will let people set next perms on items in agent 323 // This one will let people set next perms on items in agent
320 // inventory. Rut-Roh. Whatever. Make this secure. Yeah. 324 // inventory. Rut-Roh. Whatever. Make this secure. Yeah.
321 // 325 //
@@ -368,8 +372,7 @@ namespace OpenSim.Region.Framework.Scenes
368 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 372 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
369 if (agentTransactions != null) 373 if (agentTransactions != null)
370 { 374 {
371 agentTransactions.HandleItemUpdateFromTransaction( 375 agentTransactions.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
372 remoteClient, transactionID, item);
373 } 376 }
374 } 377 }
375 } 378 }
@@ -1005,7 +1008,7 @@ namespace OpenSim.Region.Framework.Scenes
1005 } 1008 }
1006 1009
1007 group.RemoveInventoryItem(localID, itemID); 1010 group.RemoveInventoryItem(localID, itemID);
1008 part.GetProperties(remoteClient); 1011 part.SendPropertiesToClient(remoteClient);
1009 } 1012 }
1010 } 1013 }
1011 1014
@@ -1283,7 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes
1283 1286
1284 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) 1287 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1285 { 1288 {
1286 destPart.GetProperties(avatar.ControllingClient); 1289 destPart.SendPropertiesToClient(avatar.ControllingClient);
1287 } 1290 }
1288 } 1291 }
1289 1292
@@ -1446,7 +1449,7 @@ namespace OpenSim.Region.Framework.Scenes
1446 m_log.InfoFormat( 1449 m_log.InfoFormat(
1447 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1450 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1448 item.Name, primLocalID, remoteClient.Name); 1451 item.Name, primLocalID, remoteClient.Name);
1449 part.GetProperties(remoteClient); 1452 part.SendPropertiesToClient(remoteClient);
1450 if (!Permissions.BypassPermissions()) 1453 if (!Permissions.BypassPermissions())
1451 { 1454 {
1452 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1455 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
@@ -1534,7 +1537,7 @@ namespace OpenSim.Region.Framework.Scenes
1534 1537
1535 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1538 if (part.Inventory.UpdateInventoryItem(itemInfo))
1536 { 1539 {
1537 part.GetProperties(remoteClient); 1540 part.SendPropertiesToClient(remoteClient);
1538 } 1541 }
1539 } 1542 }
1540 } 1543 }
@@ -1586,7 +1589,7 @@ namespace OpenSim.Region.Framework.Scenes
1586 // m_log.InfoFormat("[PRIMINVENTORY]: " + 1589 // m_log.InfoFormat("[PRIMINVENTORY]: " +
1587 // "Rezzed script {0} into prim local ID {1} for user {2}", 1590 // "Rezzed script {0} into prim local ID {1} for user {2}",
1588 // item.inventoryName, localID, remoteClient.Name); 1591 // item.inventoryName, localID, remoteClient.Name);
1589 part.GetProperties(remoteClient); 1592 part.SendPropertiesToClient(remoteClient);
1590 part.ParentGroup.ResumeScripts(); 1593 part.ParentGroup.ResumeScripts();
1591 } 1594 }
1592 else 1595 else
@@ -1644,7 +1647,7 @@ namespace OpenSim.Region.Framework.Scenes
1644 taskItem.AssetID = asset.FullID; 1647 taskItem.AssetID = asset.FullID;
1645 1648
1646 part.Inventory.AddInventoryItem(taskItem, false); 1649 part.Inventory.AddInventoryItem(taskItem, false);
1647 part.GetProperties(remoteClient); 1650 part.SendPropertiesToClient(remoteClient);
1648 1651
1649 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1652 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1650 part.ParentGroup.ResumeScripts(); 1653 part.ParentGroup.ResumeScripts();
@@ -1758,7 +1761,7 @@ namespace OpenSim.Region.Framework.Scenes
1758 1761
1759 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar)) 1762 if (TryGetScenePresence(srcTaskItem.OwnerID, out avatar))
1760 { 1763 {
1761 destPart.GetProperties(avatar.ControllingClient); 1764 destPart.SendPropertiesToClient(avatar.ControllingClient);
1762 } 1765 }
1763 } 1766 }
1764 1767
@@ -2217,7 +2220,7 @@ namespace OpenSim.Region.Framework.Scenes
2217 SceneObjectPart part = GetSceneObjectPart(localID); 2220 SceneObjectPart part = GetSceneObjectPart(localID);
2218 if (part == null) 2221 if (part == null)
2219 continue; 2222 continue;
2220 part.GetProperties(remoteClient); 2223 part.SendPropertiesToClient(remoteClient);
2221 } 2224 }
2222 } 2225 }
2223 2226
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 9da57a8..575079f 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 c5bb2b2..b288c8a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -896,6 +896,8 @@ namespace OpenSim.Region.Framework.Scenes
896 896
897 if (dm != null) 897 if (dm != null)
898 m_eventManager.OnPermissionError += dm.SendAlertToUser; 898 m_eventManager.OnPermissionError += dm.SendAlertToUser;
899
900 m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement;
899 } 901 }
900 902
901 public override string GetSimulatorVersion() 903 public override string GetSimulatorVersion()
@@ -1198,87 +1200,6 @@ namespace OpenSim.Region.Framework.Scenes
1198 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1200 m_dialogModule = RequestModuleInterface<IDialogModule>();
1199 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1201 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1200 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1202 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1201
1202 // Shoving this in here for now, because we have the needed
1203 // interfaces at this point
1204 //
1205 // TODO: Find a better place for this
1206 //
1207 while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
1208 {
1209 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", m_regInfo.EstateSettings.EstateName);
1210 List<char> excluded = new List<char>(new char[1]{' '});
1211 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
1212 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
1213
1214 UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last);
1215
1216 if (account == null)
1217 {
1218 // Create a new account
1219 account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty);
1220 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
1221 {
1222 account.ServiceURLs = new Dictionary<string, object>();
1223 account.ServiceURLs["HomeURI"] = string.Empty;
1224 account.ServiceURLs["GatekeeperURI"] = string.Empty;
1225 account.ServiceURLs["InventoryServerURI"] = string.Empty;
1226 account.ServiceURLs["AssetServerURI"] = string.Empty;
1227 }
1228
1229 if (UserAccountService.StoreUserAccount(account))
1230 {
1231 string password = MainConsole.Instance.PasswdPrompt("Password");
1232 string email = MainConsole.Instance.CmdPrompt("Email", "");
1233
1234 account.Email = email;
1235 UserAccountService.StoreUserAccount(account);
1236
1237 bool success = false;
1238 success = AuthenticationService.SetPassword(account.PrincipalID, password);
1239 if (!success)
1240 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
1241 first, last);
1242
1243 GridRegion home = null;
1244 if (GridService != null)
1245 {
1246 List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero);
1247 if (defaultRegions != null && defaultRegions.Count >= 1)
1248 home = defaultRegions[0];
1249
1250 if (GridUserService != null && home != null)
1251 GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1252 else
1253 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1254 first, last);
1255
1256 }
1257 else
1258 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
1259 first, last);
1260
1261 if (InventoryService != null)
1262 success = InventoryService.CreateUserInventory(account.PrincipalID);
1263 if (!success)
1264 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.",
1265 first, last);
1266
1267
1268 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last);
1269
1270 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1271 m_regInfo.EstateSettings.Save();
1272 }
1273 else
1274 m_log.ErrorFormat("[SCENE]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
1275 }
1276 else
1277 {
1278 m_regInfo.EstateSettings.EstateOwner = account.PrincipalID;
1279 m_regInfo.EstateSettings.Save();
1280 }
1281 }
1282 } 1203 }
1283 1204
1284 #endregion 1205 #endregion
@@ -1382,28 +1303,12 @@ namespace OpenSim.Region.Framework.Scenes
1382 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1303 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1383 } 1304 }
1384 1305
1385 if (RegionStatus != RegionStatus.SlaveScene) 1306 if (Frame % m_update_events == 0)
1386 { 1307 {
1387 if (Frame % m_update_events == 0) 1308 int evMS = Util.EnvironmentTickCount();
1388 { 1309 UpdateEvents();
1389 int evMS = Util.EnvironmentTickCount(); 1310 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1390 UpdateEvents(); 1311 }
1391 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1392 }
1393
1394 if (Frame % m_update_backup == 0)
1395 {
1396 int backMS = Util.EnvironmentTickCount();
1397 UpdateStorageBackup();
1398 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1399 }
1400
1401 if (Frame % m_update_terrain == 0)
1402 {
1403 int terMS = Util.EnvironmentTickCount();
1404 UpdateTerrain();
1405 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1406 }
1407 1312
1408 // if (Frame % m_update_land == 0) 1313 // if (Frame % m_update_land == 0)
1409 // { 1314 // {
@@ -1412,26 +1317,46 @@ namespace OpenSim.Region.Framework.Scenes
1412 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1317 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1413 // } 1318 // }
1414 1319
1415 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1320 if (Frame % m_update_backup == 0)
1416 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1321 {
1417 lastCompletedFrame = Util.EnvironmentTickCount(); 1322 int backMS = Util.EnvironmentTickCount();
1418 1323 UpdateStorageBackup();
1419 // if (Frame%m_update_avatars == 0) 1324 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1420 // UpdateInWorldTime(); 1325 }
1421 StatsReporter.AddPhysicsFPS(physicsFPS); 1326
1422 StatsReporter.AddTimeDilation(TimeDilation); 1327 if (Frame % m_update_terrain == 0)
1423 StatsReporter.AddFPS(1); 1328 {
1424 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); 1329 int terMS = Util.EnvironmentTickCount();
1425 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); 1330 UpdateTerrain();
1426 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); 1331 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1427 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1428 StatsReporter.addFrameMS(frameMS);
1429 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1430 StatsReporter.addOtherMS(otherMS);
1431 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1432 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1433 } 1332 }
1434 1333
1334 //if (Frame % m_update_land == 0)
1335 //{
1336 // int ldMS = Util.EnvironmentTickCount();
1337 // UpdateLand();
1338 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1339 //}
1340
1341 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1342 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1343 lastCompletedFrame = Util.EnvironmentTickCount();
1344
1345 // if (Frame%m_update_avatars == 0)
1346 // UpdateInWorldTime();
1347 StatsReporter.AddPhysicsFPS(physicsFPS);
1348 StatsReporter.AddTimeDilation(TimeDilation);
1349 StatsReporter.AddFPS(1);
1350 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1351 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1352 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1353 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1354 StatsReporter.addFrameMS(frameMS);
1355 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1356 StatsReporter.addOtherMS(otherMS);
1357 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1358 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1359
1435 if (LoginsDisabled && Frame == 20) 1360 if (LoginsDisabled && Frame == 20)
1436 { 1361 {
1437 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1362 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
@@ -2603,9 +2528,7 @@ namespace OpenSim.Region.Framework.Scenes
2603 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2528 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2604 2529
2605 if (AttachmentsModule != null) 2530 if (AttachmentsModule != null)
2606 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2531 AttachmentsModule.AttachObject(sp, grp, 0, false);
2607
2608 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2609 } 2532 }
2610 else 2533 else
2611 { 2534 {
@@ -5477,7 +5400,7 @@ namespace OpenSim.Region.Framework.Scenes
5477 return true; 5400 return true;
5478 } 5401 }
5479 5402
5480 public void StartTimerWatchdog() 5403 public void StartTimerWatchdog()
5481 { 5404 {
5482 m_timerWatchdog.Interval = 1000; 5405 m_timerWatchdog.Interval = 1000;
5483 m_timerWatchdog.Elapsed += TimerWatchdog; 5406 m_timerWatchdog.Elapsed += TimerWatchdog;
@@ -5488,6 +5411,70 @@ namespace OpenSim.Region.Framework.Scenes
5488 public void TimerWatchdog(object sender, ElapsedEventArgs e) 5411 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5489 { 5412 {
5490 CheckHeartbeat(); 5413 CheckHeartbeat();
5414 }
5415
5416 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5417 /// autopilot that moves an avatar to a sit target!.
5418 /// </summary>
5419 /// <remarks>
5420 /// This is not intended as a permament location for this method.
5421 /// </remarks>
5422 /// <param name="presence"></param>
5423 private void HandleOnSignificantClientMovement(ScenePresence presence)
5424 {
5425 if (presence.MovingToTarget)
5426 {
5427 double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
5428// m_log.DebugFormat(
5429// "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
5430// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
5431
5432 // Check the error term of the current position in relation to the target position
5433 if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
5434 {
5435 // We are close enough to the target
5436// m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name);
5437
5438 presence.Velocity = Vector3.Zero;
5439 presence.AbsolutePosition = presence.MoveToPositionTarget;
5440 presence.ResetMoveToTarget();
5441
5442 if (presence.PhysicsActor.Flying)
5443 {
5444 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
5445 // the target if flying.
5446 // We really need to be more subtle (slow the avatar as it approaches the target) or at
5447 // least be able to set collision status once, rather than 5 times to give it enough
5448 // weighting so that that PhysicsActor thinks it really is colliding.
5449 for (int i = 0; i < 5; i++)
5450 presence.PhysicsActor.IsColliding = true;
5451
5452 if (presence.LandAtTarget)
5453 presence.PhysicsActor.Flying = false;
5454
5455// Vector3 targetPos = presence.MoveToPositionTarget;
5456// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
5457// if (targetPos.Z - terrainHeight < 0.2)
5458// {
5459// presence.PhysicsActor.Flying = false;
5460// }
5461 }
5462
5463// m_log.DebugFormat(
5464// "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
5465// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
5466 }
5467 else
5468 {
5469// m_log.DebugFormat(
5470// "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
5471// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
5472
5473 Vector3 agent_control_v3 = new Vector3();
5474 presence.HandleMoveToTargetUpdate(ref agent_control_v3);
5475 presence.AddNewMovement(agent_control_v3);
5476 }
5477 }
5491 } 5478 }
5492 } 5479 }
5493} 5480}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 3e1439d..7493368 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1312,13 +1312,6 @@ namespace OpenSim.Region.Framework.Scenes
1312 part.ClearUndoState(); 1312 part.ClearUndoState();
1313 } 1313 }
1314 1314
1315 public override void UpdateMovement()
1316 {
1317 SceneObjectPart[] parts = m_parts.GetArray();
1318 for (int i = 0; i < parts.Length; i++)
1319 parts[i].UpdateMovement();
1320 }
1321
1322 public ushort GetTimeDilation() 1315 public ushort GetTimeDilation()
1323 { 1316 {
1324 return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); 1317 return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
@@ -1486,7 +1479,15 @@ namespace OpenSim.Region.Framework.Scenes
1486 avatar.StandUp(); 1479 avatar.StandUp();
1487 1480
1488 if (!silent) 1481 if (!silent)
1482 {
1489 part.UpdateFlag = 0; 1483 part.UpdateFlag = 0;
1484 if (part == m_rootPart)
1485 {
1486 if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) ||
1487 (AttachmentPoint < 31) || (AttachmentPoint > 38))
1488 avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint>() {part.LocalId});
1489 }
1490 }
1490 }); 1491 });
1491 } 1492 }
1492 1493
@@ -1939,7 +1940,7 @@ namespace OpenSim.Region.Framework.Scenes
1939 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); 1940 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1940 if (avatar != null) 1941 if (avatar != null)
1941 { 1942 {
1942 avatar.MoveToTarget(target, false); 1943 avatar.MoveToTarget(target, false, false);
1943 } 1944 }
1944 } 1945 }
1945 else 1946 else
@@ -2104,8 +2105,6 @@ namespace OpenSim.Region.Framework.Scenes
2104 2105
2105 #endregion 2106 #endregion
2106 2107
2107 #region Scheduling
2108
2109 public override void Update() 2108 public override void Update()
2110 { 2109 {
2111 // Check that the group was not deleted before the scheduled update 2110 // Check that the group was not deleted before the scheduled update
@@ -2256,7 +2255,14 @@ namespace OpenSim.Region.Framework.Scenes
2256 parts[i].SendTerseUpdateToAllClients(); 2255 parts[i].SendTerseUpdateToAllClients();
2257 } 2256 }
2258 2257
2259 #endregion 2258 /// <summary>
2259 /// Send metadata about the root prim (name, description, sale price, etc.) to a client.
2260 /// </summary>
2261 /// <param name="client"></param>
2262 public void SendPropertiesToClient(IClientAPI client)
2263 {
2264 m_rootPart.SendPropertiesToClient(client);
2265 }
2260 2266
2261 #region SceneGroupPart Methods 2267 #region SceneGroupPart Methods
2262 2268
@@ -2752,15 +2758,6 @@ namespace OpenSim.Region.Framework.Scenes
2752 } 2758 }
2753 2759
2754 /// <summary> 2760 /// <summary>
2755 /// Return metadata about a prim (name, description, sale price, etc.)
2756 /// </summary>
2757 /// <param name="client"></param>
2758 public void GetProperties(IClientAPI client)
2759 {
2760 m_rootPart.GetProperties(client);
2761 }
2762
2763 /// <summary>
2764 /// Set the name of a prim 2761 /// Set the name of a prim
2765 /// </summary> 2762 /// </summary>
2766 /// <param name="name"></param> 2763 /// <param name="name"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0c3b404..1a96f1b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -804,7 +804,7 @@ namespace OpenSim.Region.Framework.Scenes
804 if (av.LinkedPrim == m_uuid) 804 if (av.LinkedPrim == m_uuid)
805 { 805 {
806 Vector3 offset = (m_offsetPosition - oldpos); 806 Vector3 offset = (m_offsetPosition - oldpos);
807 av.OffsetPosition += offset; 807 av.AbsolutePosition += offset;
808 av.SendAvatarDataToAllAgents(); 808 av.SendAvatarDataToAllAgents();
809 } 809 }
810 } 810 }
@@ -1357,8 +1357,6 @@ namespace OpenSim.Region.Framework.Scenes
1357 1357
1358 #endregion Public Properties with only Get 1358 #endregion Public Properties with only Get
1359 1359
1360 #region Private Methods
1361
1362 private uint ApplyMask(uint val, bool set, uint mask) 1360 private uint ApplyMask(uint val, bool set, uint mask)
1363 { 1361 {
1364 if (set) 1362 if (set)
@@ -1371,14 +1369,35 @@ namespace OpenSim.Region.Framework.Scenes
1371 } 1369 }
1372 } 1370 }
1373 1371
1374 private void SendObjectPropertiesToClient(UUID AgentID) 1372 /// <summary>
1373 /// Clear all pending updates of parts to clients
1374 /// </summary>
1375 private void ClearUpdateSchedule()
1376 {
1377 m_updateFlag = 0;
1378 }
1379
1380 /// <summary>
1381 /// Send this part's properties (name, description, inventory serial, base mask, etc.) to a client
1382 /// </summary>
1383 /// <param name="client"></param>
1384 public void SendPropertiesToClient(IClientAPI client)
1385 {
1386 client.SendObjectPropertiesReply(this);
1387 }
1388
1389 /// <summary>
1390 /// For the scene object group to which this part belongs, send that scene object's root part properties to a client.
1391 /// </summary>
1392 /// <param name="AgentID"></param>
1393 private void SendRootPartPropertiesToClient(UUID AgentID)
1375 { 1394 {
1376 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) 1395 m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
1377 { 1396 {
1378 // Ugly reference :( 1397 // Ugly reference :(
1379 if (avatar.UUID == AgentID) 1398 if (avatar.UUID == AgentID)
1380 { 1399 {
1381 m_parentGroup.GetProperties(avatar.ControllingClient); 1400 m_parentGroup.SendPropertiesToClient(avatar.ControllingClient);
1382 } 1401 }
1383 }); 1402 });
1384 } 1403 }
@@ -1407,8 +1426,6 @@ namespace OpenSim.Region.Framework.Scenes
1407 // } 1426 // }
1408 // } 1427 // }
1409 1428
1410 #endregion Private Methods
1411
1412 #region Public Methods 1429 #region Public Methods
1413 1430
1414 public void ResetExpire() 1431 public void ResetExpire()
@@ -1752,20 +1769,6 @@ namespace OpenSim.Region.Framework.Scenes
1752 Name, LocalId, id); 1769 Name, LocalId, id);
1753 } 1770 }
1754 1771
1755 public static SceneObjectPart Create()
1756 {
1757 SceneObjectPart part = new SceneObjectPart();
1758 part.UUID = UUID.Random();
1759
1760 PrimitiveBaseShape shape = PrimitiveBaseShape.Create();
1761 part.Shape = shape;
1762
1763 part.Name = "Object";
1764 part._ownerID = UUID.Random();
1765
1766 return part;
1767 }
1768
1769 /// <summary> 1772 /// <summary>
1770 /// Do a physics property update for a NINJA joint. 1773 /// Do a physics property update for a NINJA joint.
1771 /// </summary> 1774 /// </summary>
@@ -2077,11 +2080,6 @@ namespace OpenSim.Region.Framework.Scenes
2077 return Vector3.Zero; 2080 return Vector3.Zero;
2078 } 2081 }
2079 2082
2080 public void GetProperties(IClientAPI client)
2081 {
2082 client.SendObjectPropertiesReply(this);
2083 }
2084
2085 /// <summary> 2083 /// <summary>
2086 /// Method for a prim to get it's world position from the group. 2084 /// Method for a prim to get it's world position from the group.
2087 /// </summary> 2085 /// </summary>
@@ -3055,6 +3053,10 @@ namespace OpenSim.Region.Framework.Scenes
3055 if (ParentGroup.IsDeleted) 3053 if (ParentGroup.IsDeleted)
3056 return; 3054 return;
3057 3055
3056 if (ParentGroup.IsAttachment && (ParentGroup.AttachedAvatar != remoteClient.AgentId) &&
3057 (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38))
3058 return;
3059
3058 clientFlags &= ~(uint) PrimFlags.CreateSelected; 3060 clientFlags &= ~(uint) PrimFlags.CreateSelected;
3059 3061
3060 if (remoteClient.AgentId == _ownerID) 3062 if (remoteClient.AgentId == _ownerID)
@@ -3500,7 +3502,7 @@ namespace OpenSim.Region.Framework.Scenes
3500 { 3502 {
3501 _groupID = groupID; 3503 _groupID = groupID;
3502 if (client != null) 3504 if (client != null)
3503 GetProperties(client); 3505 SendPropertiesToClient(client);
3504 m_updateFlag = 2; 3506 m_updateFlag = 2;
3505 } 3507 }
3506 3508
@@ -4242,10 +4244,6 @@ namespace OpenSim.Region.Framework.Scenes
4242 } 4244 }
4243 } 4245 }
4244 4246
4245 public virtual void UpdateMovement()
4246 {
4247 }
4248
4249 /// <summary> 4247 /// <summary>
4250 /// 4248 ///
4251 /// </summary> 4249 /// </summary>
@@ -4320,10 +4318,10 @@ namespace OpenSim.Region.Framework.Scenes
4320 4318
4321 break; 4319 break;
4322 } 4320 }
4323 SendFullUpdateToAllClients();
4324 4321
4325 SendObjectPropertiesToClient(AgentID); 4322 SendFullUpdateToAllClients();
4326 4323
4324 SendRootPartPropertiesToClient(AgentID);
4327 } 4325 }
4328 } 4326 }
4329 4327
@@ -4844,7 +4842,8 @@ namespace OpenSim.Region.Framework.Scenes
4844 if (ParentGroup.IsDeleted) 4842 if (ParentGroup.IsDeleted)
4845 return; 4843 return;
4846 4844
4847 if (ParentGroup.IsAttachment && ParentGroup.RootPart != this) 4845 if (ParentGroup.IsAttachment && ((ParentGroup.RootPart != this) ||
4846 ((ParentGroup.AttachedAvatar != remoteClient.AgentId) && (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38))))
4848 return; 4847 return;
4849 4848
4850 // Causes this thread to dig into the Client Thread Data. 4849 // Causes this thread to dig into the Client Thread Data.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index f6b690c..4edc220 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -988,11 +988,16 @@ namespace OpenSim.Region.Framework.Scenes
988 988
989 private bool CreateInventoryFileName() 989 private bool CreateInventoryFileName()
990 { 990 {
991// m_log.DebugFormat(
992// "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}",
993// m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial);
994
991 if (m_inventoryFileName == String.Empty || 995 if (m_inventoryFileName == String.Empty ||
992 m_inventoryFileNameSerial < m_inventorySerial) 996 m_inventoryFileNameSerial < m_inventorySerial)
993 { 997 {
994 m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; 998 m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
995 m_inventoryFileNameSerial = m_inventorySerial; 999 m_inventoryFileNameSerial = m_inventorySerial;
1000
996 return true; 1001 return true;
997 } 1002 }
998 1003
@@ -1025,6 +1030,12 @@ namespace OpenSim.Region.Framework.Scenes
1025 return; 1030 return;
1026 } 1031 }
1027 1032
1033 if (m_items.Count == 0) // No inventory
1034 {
1035 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1036 return;
1037 }
1038
1028 if (!changed) 1039 if (!changed)
1029 { 1040 {
1030 if (m_inventoryFileData.Length > 2) 1041 if (m_inventoryFileData.Length > 2)
@@ -1096,10 +1107,12 @@ namespace OpenSim.Region.Framework.Scenes
1096 if (m_inventoryFileData.Length > 2) 1107 if (m_inventoryFileData.Length > 2)
1097 { 1108 {
1098 xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); 1109 xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
1110 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
1111 Util.StringToBytes256(m_inventoryFileName));
1112 return;
1099 } 1113 }
1100 1114
1101 client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, 1115 client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
1102 Util.StringToBytes256(m_inventoryFileName));
1103 } 1116 }
1104 1117
1105 /// <summary> 1118 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index fa6945c..dee9bc3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes
71 { 71 {
72// ~ScenePresence() 72// ~ScenePresence()
73// { 73// {
74// m_log.Debug("[ScenePresence] Destructor called"); 74// m_log.Debug("[SCENE PRESENCE] Destructor called");
75// } 75// }
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -191,8 +191,6 @@ namespace OpenSim.Region.Framework.Scenes
191 191
192 private Quaternion m_bodyRot = Quaternion.Identity; 192 private Quaternion m_bodyRot = Quaternion.Identity;
193 193
194 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
195
196 private const int LAND_VELOCITYMAG_MAX = 12; 194 private const int LAND_VELOCITYMAG_MAX = 12;
197 195
198 public bool IsRestrictedToRegion; 196 public bool IsRestrictedToRegion;
@@ -238,6 +236,11 @@ namespace OpenSim.Region.Framework.Scenes
238 public Vector3 MoveToPositionTarget { get; private set; } 236 public Vector3 MoveToPositionTarget { get; private set; }
239 private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); 237 private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
240 238
239 /// <summary>
240 /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying).
241 /// </summary>
242 public bool LandAtTarget { get; private set; }
243
241 private bool m_followCamAuto; 244 private bool m_followCamAuto;
242 245
243 private int m_movementUpdateCount; 246 private int m_movementUpdateCount;
@@ -492,7 +495,13 @@ namespace OpenSim.Region.Framework.Scenes
492 PhysicsActor actor = m_physicsActor; 495 PhysicsActor actor = m_physicsActor;
493// if (actor != null) 496// if (actor != null)
494 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! 497 if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting!
498 {
495 m_pos = actor.Position; 499 m_pos = actor.Position;
500
501// m_log.DebugFormat(
502// "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!",
503// m_pos, Name, Scene.RegionInfo.RegionName);
504 }
496 else 505 else
497 { 506 {
498 // Obtain the correct position of a seated avatar. 507 // Obtain the correct position of a seated avatar.
@@ -536,20 +545,28 @@ namespace OpenSim.Region.Framework.Scenes
536 } 545 }
537 catch (Exception e) 546 catch (Exception e)
538 { 547 {
539 m_log.Error("[SCENEPRESENCE]: ABSOLUTE POSITION " + e.Message); 548 m_log.Error("[SCENE PRESENCE]: ABSOLUTE POSITION " + e.Message);
540 } 549 }
541 } 550 }
542 551
543 if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! 552// Changed this to update unconditionally to make npose work
553// if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting!
544 m_pos = value; 554 m_pos = value;
545 m_parentPosition = Vector3.Zero; 555 m_parentPosition = Vector3.Zero;
556
557// m_log.DebugFormat(
558// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
559// Scene.RegionInfo.RegionName, Name, m_pos);
546 } 560 }
547 } 561 }
548 562
563 /// <summary>
564 /// If sitting, returns the offset position from the prim the avatar is sitting on.
565 /// Otherwise, returns absolute position in the scene.
566 /// </summary>
549 public Vector3 OffsetPosition 567 public Vector3 OffsetPosition
550 { 568 {
551 get { return m_pos; } 569 get { return m_pos; }
552 set { m_pos = value; }
553 } 570 }
554 571
555 /// <summary> 572 /// <summary>
@@ -561,8 +578,14 @@ namespace OpenSim.Region.Framework.Scenes
561 { 578 {
562 PhysicsActor actor = m_physicsActor; 579 PhysicsActor actor = m_physicsActor;
563 if (actor != null) 580 if (actor != null)
581 {
564 m_velocity = actor.Velocity; 582 m_velocity = actor.Velocity;
565 583
584// m_log.DebugFormat(
585// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
586// m_velocity, Name, Scene.RegionInfo.RegionName);
587 }
588
566 return m_velocity; 589 return m_velocity;
567 } 590 }
568 set 591 set
@@ -577,11 +600,15 @@ namespace OpenSim.Region.Framework.Scenes
577 } 600 }
578 catch (Exception e) 601 catch (Exception e)
579 { 602 {
580 m_log.Error("[SCENEPRESENCE]: VELOCITY " + e.Message); 603 m_log.Error("[SCENE PRESENCE]: VELOCITY " + e.Message);
581 } 604 }
582 } 605 }
583 606
584 m_velocity = value; 607 m_velocity = value;
608
609// m_log.DebugFormat(
610// "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}",
611// Scene.RegionInfo.RegionName, Name, m_velocity);
585 } 612 }
586 } 613 }
587 614
@@ -620,12 +647,6 @@ namespace OpenSim.Region.Framework.Scenes
620 } 647 }
621 } 648 }
622 649
623 public Quaternion PreviousRotation
624 {
625 get { return m_bodyRotPrevious; }
626 set { m_bodyRotPrevious = value; }
627 }
628
629 /// <summary> 650 /// <summary>
630 /// If this is true, agent doesn't have a representation in this scene. 651 /// If this is true, agent doesn't have a representation in this scene.
631 /// this is an agent 'looking into' this scene from a nearby scene(region) 652 /// this is an agent 'looking into' this scene from a nearby scene(region)
@@ -1126,7 +1147,7 @@ namespace OpenSim.Region.Framework.Scenes
1126 Animator.ResetAnimations(); 1147 Animator.ResetAnimations();
1127 1148
1128// m_log.DebugFormat( 1149// m_log.DebugFormat(
1129// "[SCENEPRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1150// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
1130// Name, UUID, m_scene.RegionInfo.RegionName); 1151// Name, UUID, m_scene.RegionInfo.RegionName);
1131 1152
1132 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing, 1153 // Don't zero out the velocity since this can cause problems when an avatar is making a region crossing,
@@ -1302,7 +1323,7 @@ namespace OpenSim.Region.Framework.Scenes
1302 m_callbackURI = null; 1323 m_callbackURI = null;
1303 } 1324 }
1304 1325
1305 //m_log.DebugFormat("Completed movement"); 1326 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1306 1327
1307 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1328 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1308 SendInitialData(); 1329 SendInitialData();
@@ -1813,7 +1834,10 @@ namespace OpenSim.Region.Framework.Scenes
1813 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path 1834 /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
1814 /// from start to finish. 1835 /// from start to finish.
1815 /// </param> 1836 /// </param>
1816 public void MoveToTarget(Vector3 pos, bool noFly) 1837 /// <param name="landAtTarget">
1838 /// If true and the avatar starts flying during the move then land at the target.
1839 /// </param>
1840 public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget)
1817 { 1841 {
1818 m_log.DebugFormat( 1842 m_log.DebugFormat(
1819 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", 1843 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@@ -1839,7 +1863,7 @@ namespace OpenSim.Region.Framework.Scenes
1839 1863
1840 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 1864 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
1841 // always slightly higher than the actual terrain height. 1865 // always slightly higher than the actual terrain height.
1842 // FIXME: This constrains NOC movements as well, so should be somewhere else. 1866 // FIXME: This constrains NPC movements as well, so should be somewhere else.
1843 if (pos.Z - terrainHeight < 0.2) 1867 if (pos.Z - terrainHeight < 0.2)
1844 pos.Z = terrainHeight; 1868 pos.Z = terrainHeight;
1845 1869
@@ -1852,9 +1876,25 @@ namespace OpenSim.Region.Framework.Scenes
1852 else if (pos.Z > terrainHeight) 1876 else if (pos.Z > terrainHeight)
1853 PhysicsActor.Flying = true; 1877 PhysicsActor.Flying = true;
1854 1878
1879 LandAtTarget = landAtTarget;
1855 MovingToTarget = true; 1880 MovingToTarget = true;
1856 MoveToPositionTarget = pos; 1881 MoveToPositionTarget = pos;
1857 1882
1883 // Rotate presence around the z-axis to point in same direction as movement.
1884 // Ignore z component of vector
1885 Vector3 localVectorToTarget3D = pos - AbsolutePosition;
1886 Vector3 localVectorToTarget2D = new Vector3((float)(localVectorToTarget3D.X), (float)(localVectorToTarget3D.Y), 0f);
1887
1888// m_log.DebugFormat("[SCENE PRESENCE]: Local vector to target is {0}", localVectorToTarget2D);
1889
1890 // Calculate the yaw.
1891 Vector3 angle = new Vector3(0, 0, (float)(Math.Atan2(localVectorToTarget2D.Y, localVectorToTarget2D.X)));
1892
1893// m_log.DebugFormat("[SCENE PRESENCE]: Angle is {0}", angle);
1894
1895 Rotation = Quaternion.CreateFromEulers(angle);
1896// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation);
1897
1858 Vector3 agent_control_v3 = new Vector3(); 1898 Vector3 agent_control_v3 = new Vector3();
1859 HandleMoveToTargetUpdate(ref agent_control_v3); 1899 HandleMoveToTargetUpdate(ref agent_control_v3);
1860 AddNewMovement(agent_control_v3); 1900 AddNewMovement(agent_control_v3);
@@ -2744,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes
2744 Vector3 pos = m_pos; 2784 Vector3 pos = m_pos;
2745 pos.Z += m_appearance.HipOffset; 2785 pos.Z += m_appearance.HipOffset;
2746 2786
2747 //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2787 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity);
2748 2788
2749 remoteClient.SendPrimUpdate( 2789 remoteClient.SendPrimUpdate(
2750 this, 2790 this,
@@ -2831,6 +2871,7 @@ namespace OpenSim.Region.Framework.Scenes
2831 /// </summary> 2871 /// </summary>
2832 private void SendInitialData() 2872 private void SendInitialData()
2833 { 2873 {
2874 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
2834 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2875 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2835 // the inventory arrives 2876 // the inventory arrives
2836 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2877 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
@@ -2875,10 +2916,11 @@ namespace OpenSim.Region.Framework.Scenes
2875 /// </summary> 2916 /// </summary>
2876 public void SendAvatarDataToAllAgents() 2917 public void SendAvatarDataToAllAgents()
2877 { 2918 {
2919 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID);
2878 // only send update from root agents to other clients; children are only "listening posts" 2920 // only send update from root agents to other clients; children are only "listening posts"
2879 if (IsChildAgent) 2921 if (IsChildAgent)
2880 { 2922 {
2881 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2923 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2882 return; 2924 return;
2883 } 2925 }
2884 2926
@@ -2928,7 +2970,7 @@ namespace OpenSim.Region.Framework.Scenes
2928 /// <param name="avatar"></param> 2970 /// <param name="avatar"></param>
2929 public void SendAvatarDataToAgent(ScenePresence avatar) 2971 public void SendAvatarDataToAgent(ScenePresence avatar)
2930 { 2972 {
2931// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); 2973 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
2932 2974
2933 avatar.ControllingClient.SendAvatarDataImmediate(this); 2975 avatar.ControllingClient.SendAvatarDataImmediate(this);
2934 if (Animator != null) 2976 if (Animator != null)
@@ -2941,10 +2983,11 @@ namespace OpenSim.Region.Framework.Scenes
2941 /// </summary> 2983 /// </summary>
2942 public void SendAppearanceToAllOtherAgents() 2984 public void SendAppearanceToAllOtherAgents()
2943 { 2985 {
2986 m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} ({1})", Name, UUID);
2944 // only send update from root agents to other clients; children are only "listening posts" 2987 // only send update from root agents to other clients; children are only "listening posts"
2945 if (IsChildAgent) 2988 if (IsChildAgent)
2946 { 2989 {
2947 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent"); 2990 m_log.Warn("[SCENE PRESENCE] attempt to send avatar data from a child agent");
2948 return; 2991 return;
2949 } 2992 }
2950 2993
@@ -2970,6 +3013,7 @@ namespace OpenSim.Region.Framework.Scenes
2970 /// </summary> 3013 /// </summary>
2971 public void SendOtherAgentsAppearanceToMe() 3014 public void SendOtherAgentsAppearanceToMe()
2972 { 3015 {
3016 //m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} ({1})", Name, UUID);
2973 m_perfMonMS = Util.EnvironmentTickCount(); 3017 m_perfMonMS = Util.EnvironmentTickCount();
2974 3018
2975 int count = 0; 3019 int count = 0;
@@ -3618,7 +3662,7 @@ namespace OpenSim.Region.Framework.Scenes
3618 /// <summary> 3662 /// <summary>
3619 /// Handles part of the PID controller function for moving an avatar. 3663 /// Handles part of the PID controller function for moving an avatar.
3620 /// </summary> 3664 /// </summary>
3621 public override void UpdateMovement() 3665 public void UpdateMovement()
3622 { 3666 {
3623 if (m_forceToApply.HasValue) 3667 if (m_forceToApply.HasValue)
3624 { 3668 {
@@ -3637,6 +3681,10 @@ namespace OpenSim.Region.Framework.Scenes
3637 /// </summary> 3681 /// </summary>
3638 public void AddToPhysicalScene(bool isFlying) 3682 public void AddToPhysicalScene(bool isFlying)
3639 { 3683 {
3684// m_log.DebugFormat(
3685// "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}",
3686// Name, isFlying, Scene.RegionInfo.RegionName);
3687
3640 if (m_appearance.AvatarHeight == 0) 3688 if (m_appearance.AvatarHeight == 0)
3641 m_appearance.SetHeight(); 3689 m_appearance.SetHeight();
3642 3690
@@ -4340,4 +4388,4 @@ namespace OpenSim.Region.Framework.Scenes
4340 } 4388 }
4341 } 4389 }
4342 } 4390 }
4343} \ No newline at end of file 4391}
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