aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-02 19:54:53 +0100
committerUbitUmarov2015-09-02 19:54:53 +0100
commita11edceb00b5b86f825bd957bdac9edb91f893dd (patch)
treec192eae26f3aadf365a66f32fc6d9ade2f0a0c61 /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentbad merge? (diff)
downloadopensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.zip
opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.gz
opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.bz2
opensim-SC-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.xz
seems to compile ( tests comented out)
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs1019
1 files changed, 149 insertions, 870 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4bccb7d..022a90d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -299,6 +299,7 @@ namespace OpenSim.Region.Framework.Scenes
299// private int m_lastColCount = -1; //KF: Look for Collision chnages 299// private int m_lastColCount = -1; //KF: Look for Collision chnages
300// private int m_updateCount = 0; //KF: Update Anims for a while 300// private int m_updateCount = 0; //KF: Update Anims for a while
301// private static readonly int UPDATE_COUNT = 10; // how many frames to update for 301// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
302 private List<uint> m_lastColliders = new List<uint>();
302 303
303 private TeleportFlags m_teleportFlags; 304 private TeleportFlags m_teleportFlags;
304 public TeleportFlags TeleportFlags 305 public TeleportFlags TeleportFlags
@@ -361,6 +362,9 @@ namespace OpenSim.Region.Framework.Scenes
361 //private int m_moveToPositionStateStatus; 362 //private int m_moveToPositionStateStatus;
362 //***************************************************** 363 //*****************************************************
363 364
365 private bool m_collisionEventFlag = false;
366 private object m_collisionEventLock = new Object();
367
364 private int m_movementAnimationUpdateCounter = 0; 368 private int m_movementAnimationUpdateCounter = 0;
365 369
366 public Vector3 PrevSitOffset { get; set; } 370 public Vector3 PrevSitOffset { get; set; }
@@ -377,7 +381,6 @@ namespace OpenSim.Region.Framework.Scenes
377 } 381 }
378 } 382 }
379 383
380 public bool SentInitialDataToClient { get; private set; }
381 384
382 /// <summary> 385 /// <summary>
383 /// Copy of the script states while the agent is in transit. This state may 386 /// Copy of the script states while the agent is in transit. This state may
@@ -438,12 +441,6 @@ namespace OpenSim.Region.Framework.Scenes
438 private object m_originRegionIDAccessLock = new object(); 441 private object m_originRegionIDAccessLock = new object();
439 442
440 /// <summary> 443 /// <summary>
441 /// Triggered on entity transfer after to allow CompleteMovement() to proceed after we have received an
442 /// UpdateAgent from the originating region.ddkjjkj
443 /// </summary>
444 private AutoResetEvent m_updateAgentReceivedAfterTransferEvent = new AutoResetEvent(false);
445
446 /// <summary>
447 /// Used by the entity transfer module to signal when the presence should not be closed because a subsequent 444 /// Used by the entity transfer module to signal when the presence should not be closed because a subsequent
448 /// teleport is reusing the connection. 445 /// teleport is reusing the connection.
449 /// </summary> 446 /// </summary>
@@ -470,11 +467,6 @@ namespace OpenSim.Region.Framework.Scenes
470 public uint MovementFlag { get; private set; } 467 public uint MovementFlag { get; private set; }
471 468
472 /// <summary> 469 /// <summary>
473 /// Set this if we need to force a movement update on the next received AgentUpdate from the viewer.
474 /// </summary>
475 private const uint ForceUpdateMovementFlagValue = uint.MaxValue;
476
477 /// <summary>
478 /// Is the agent stop control flag currently active? 470 /// Is the agent stop control flag currently active?
479 /// </summary> 471 /// </summary>
480 public bool AgentControlStopActive { get; private set; } 472 public bool AgentControlStopActive { get; private set; }
@@ -653,12 +645,6 @@ namespace OpenSim.Region.Framework.Scenes
653 // in the sim unless the avatar is on a sit target. While 645 // in the sim unless the avatar is on a sit target. While
654 // on a sit target, m_pos will contain the desired offset 646 // on a sit target, m_pos will contain the desired offset
655 // without the parent rotation applied. 647 // without the parent rotation applied.
656<<<<<<< HEAD
657 SceneObjectPart sitPart = ParentPart;
658
659 if (sitPart != null)
660 return sitPart.ParentGroup.AbsolutePosition + (m_pos * sitPart.GetWorldRotation());
661=======
662 if (ParentPart != null) 648 if (ParentPart != null)
663 { 649 {
664 SceneObjectPart rootPart = ParentPart.ParentGroup.RootPart; 650 SceneObjectPart rootPart = ParentPart.ParentGroup.RootPart;
@@ -667,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
667 if (rootPart != null) 653 if (rootPart != null)
668 return rootPart.AbsolutePosition + (m_pos * rootPart.GetWorldRotation()); 654 return rootPart.AbsolutePosition + (m_pos * rootPart.GetWorldRotation());
669 } 655 }
670>>>>>>> avn/ubitvar
671 } 656 }
672 657
673 return m_pos; 658 return m_pos;
@@ -721,11 +706,8 @@ namespace OpenSim.Region.Framework.Scenes
721 } 706 }
722 707
723 /// <summary> 708 /// <summary>
724 /// Velocity of the avatar with respect to its local reference frame. 709 /// Current velocity of the avatar.
725 /// </summary> 710 /// </summary>
726 /// <remarks>
727 /// So when sat on a vehicle this will be 0. To get velocity with respect to the world use GetWorldVelocity()
728 /// </remarks>
729 public override Vector3 Velocity 711 public override Vector3 Velocity
730 { 712 {
731 get 713 get
@@ -738,21 +720,12 @@ namespace OpenSim.Region.Framework.Scenes
738// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", 720// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
739// m_velocity, Name, Scene.RegionInfo.RegionName); 721// m_velocity, Name, Scene.RegionInfo.RegionName);
740 } 722 }
741// else if (ParentPart != null)
742// {
743// return ParentPart.ParentGroup.Velocity;
744// }
745 723
746 return m_velocity; 724 return m_velocity;
747 } 725 }
748 726
749 set 727 set
750 { 728 {
751// Util.PrintCallStack();
752// m_log.DebugFormat(
753// "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}",
754// Scene.RegionInfo.RegionName, Name, value);
755
756 if (PhysicsActor != null) 729 if (PhysicsActor != null)
757 { 730 {
758 try 731 try
@@ -765,7 +738,11 @@ namespace OpenSim.Region.Framework.Scenes
765 } 738 }
766 } 739 }
767 740
768 m_velocity = value; 741 m_velocity = value;
742
743// m_log.DebugFormat(
744// "[SCENE PRESENCE]: In {0} set velocity of {1} to {2}",
745// Scene.RegionInfo.RegionName, Name, m_velocity);
769 } 746 }
770 } 747 }
771 748
@@ -849,15 +826,21 @@ namespace OpenSim.Region.Framework.Scenes
849 } 826 }
850 827
851 /// <summary> 828 /// <summary>
852 /// Get rotation relative to the world. 829 /// Gets the world rotation of this presence.
853 /// </summary> 830 /// </summary>
831 /// <remarks>
832 /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
833 /// </remarks>
854 /// <returns></returns> 834 /// <returns></returns>
855 public Quaternion GetWorldRotation() 835 public Quaternion GetWorldRotation()
856 { 836 {
857 SceneObjectPart sitPart = ParentPart; 837 if (IsSatOnObject)
838 {
839 SceneObjectPart sitPart = ParentPart;
858 840
859 if (sitPart != null) 841 if (sitPart != null)
860 return sitPart.GetWorldRotation() * Rotation; 842 return sitPart.GetWorldRotation() * Rotation;
843 }
861 844
862 return Rotation; 845 return Rotation;
863 } 846 }
@@ -924,7 +907,7 @@ no information to check this
924 } 907 }
925 908
926 private bool m_mouseLook; 909 private bool m_mouseLook;
927// private bool m_leftButtonDown; 910 private bool m_leftButtonDown;
928 911
929 private bool m_inTransit; 912 private bool m_inTransit;
930 913
@@ -991,12 +974,7 @@ no information to check this
991 { 974 {
992 get { return Util.GetViewerName(m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode)); } 975 get { return Util.GetViewerName(m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode)); }
993 } 976 }
994 977
995 /// <summary>
996 /// Count of how many terse updates we have sent out. It doesn't matter if this overflows.
997 /// </summary>
998 private int m_terseUpdateCount;
999
1000 #endregion 978 #endregion
1001 979
1002 #region Constructor(s) 980 #region Constructor(s)
@@ -1012,8 +990,7 @@ no information to check this
1012 Animator = new ScenePresenceAnimator(this); 990 Animator = new ScenePresenceAnimator(this);
1013 Overrides = new MovementAnimationOverrides(); 991 Overrides = new MovementAnimationOverrides();
1014 PresenceType = type; 992 PresenceType = type;
1015 // DrawDistance = world.DefaultDrawDistance; 993 DrawDistance = world.DefaultDrawDistance;
1016 DrawDistance = Constants.RegionSize;
1017 RegionHandle = world.RegionInfo.RegionHandle; 994 RegionHandle = world.RegionInfo.RegionHandle;
1018 ControllingClient = client; 995 ControllingClient = client;
1019 Firstname = ControllingClient.FirstName; 996 Firstname = ControllingClient.FirstName;
@@ -1021,7 +998,7 @@ no information to check this
1021 m_name = String.Format("{0} {1}", Firstname, Lastname); 998 m_name = String.Format("{0} {1}", Firstname, Lastname);
1022 m_scene = world; 999 m_scene = world;
1023 m_uuid = client.AgentId; 1000 m_uuid = client.AgentId;
1024 LocalId = m_scene.AllocatePresenceLocalId(); 1001 LocalId = m_scene.AllocateLocalId();
1025 1002
1026 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); 1003 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
1027 if (account != null) 1004 if (account != null)
@@ -1103,21 +1080,6 @@ no information to check this
1103 1080
1104 private void SetDirectionVectors() 1081 private void SetDirectionVectors()
1105 { 1082 {
1106<<<<<<< HEAD
1107 Dir_Vectors[0] = Vector3.UnitX; //FORWARD
1108 Dir_Vectors[1] = -Vector3.UnitX; //BACK
1109 Dir_Vectors[2] = Vector3.UnitY; //LEFT
1110 Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
1111 Dir_Vectors[4] = Vector3.UnitZ; //UP
1112 Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
1113 Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
1114 Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
1115 Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE
1116 Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE
1117 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
1118 }
1119
1120=======
1121 Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD 1083 Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD
1122 Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK 1084 Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK
1123 Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT 1085 Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT
@@ -1131,27 +1093,6 @@ no information to check this
1131 Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge 1093 Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge
1132 Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge 1094 Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge
1133 } 1095 }
1134
1135/* dont see any use for this
1136 private Vector3[] GetWalkDirectionVectors()
1137 {
1138 Vector3[] vector = new Vector3[12];
1139 vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD
1140 vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK
1141 vector[2] = Vector3.UnitY; //LEFT
1142 vector[3] = -Vector3.UnitY; //RIGHT
1143 vector[4] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP
1144 vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN
1145 vector[6] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD_NUDGE
1146 vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE
1147 vector[8] = Vector3.UnitY; //LEFT_NUDGE
1148 vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
1149 vector[10] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP_NUDGE
1150 vector[11] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE
1151 return vector;
1152 }
1153*/
1154>>>>>>> avn/ubitvar
1155 #endregion 1096 #endregion
1156 1097
1157 #region Status Methods 1098 #region Status Methods
@@ -1203,14 +1144,9 @@ no information to check this
1203 } 1144 }
1204 else 1145 else
1205 { 1146 {
1206<<<<<<< HEAD
1207 part.AddSittingAvatar(this);
1208 // ParentPosition = part.GetWorldPosition();
1209=======
1210 part.ParentGroup.AddAvatar(UUID); 1147 part.ParentGroup.AddAvatar(UUID);
1211 if (part.SitTargetPosition != Vector3.Zero) 1148 if (part.SitTargetPosition != Vector3.Zero)
1212 part.SitTargetAvatar = UUID; 1149 part.SitTargetAvatar = UUID;
1213>>>>>>> avn/ubitvar
1214 ParentID = part.LocalId; 1150 ParentID = part.LocalId;
1215 ParentPart = part; 1151 ParentPart = part;
1216 m_pos = PrevSitOffset; 1152 m_pos = PrevSitOffset;
@@ -1222,8 +1158,6 @@ no information to check this
1222 { 1158 {
1223 IsLoggingIn = false; 1159 IsLoggingIn = false;
1224 } 1160 }
1225
1226 IsChildAgent = false;
1227 } 1161 }
1228 1162
1229 m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1163 m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@@ -1237,7 +1171,7 @@ no information to check this
1237 if (gm != null) 1171 if (gm != null)
1238 Grouptitle = gm.GetGroupTitle(m_uuid); 1172 Grouptitle = gm.GetGroupTitle(m_uuid);
1239 1173
1240<<<<<<< HEAD 1174
1241 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode); 1175 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode);
1242 uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags; 1176 uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags;
1243 if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0) 1177 if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0)
@@ -1246,75 +1180,18 @@ no information to check this
1246 // avatar's name to or from the special Hypergrid format ("First.Last @grid.example.com"). 1180 // avatar's name to or from the special Hypergrid format ("First.Last @grid.example.com").
1247 // Unfortunately, due to a viewer bug, viewers don't always show the new name. 1181 // Unfortunately, due to a viewer bug, viewers don't always show the new name.
1248 // But we have a trick that can force them to update the name anyway. 1182 // But we have a trick that can force them to update the name anyway.
1249 ForceViewersUpdateName(); 1183// ForceViewersUpdateName();
1250 } 1184 }
1251======= 1185
1252 m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1186 m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1253>>>>>>> avn/ubitvar
1254 1187
1255 RegionHandle = m_scene.RegionInfo.RegionHandle; 1188 RegionHandle = m_scene.RegionInfo.RegionHandle;
1256 1189
1257 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 1190 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
1258 m_log.DebugFormat("[MakeRootAgent] TriggerSetRootAgentScene: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1191 m_log.DebugFormat("[MakeRootAgent] TriggerSetRootAgentScene: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1259 1192
1260<<<<<<< HEAD
1261 UUID groupUUID = ControllingClient.ActiveGroupId;
1262 string groupName = string.Empty;
1263 ulong groupPowers = 0;
1264
1265 // ----------------------------------
1266 // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status
1267 try
1268 {
1269 if (groupUUID != UUID.Zero && gm != null)
1270 {
1271 GroupRecord record = gm.GetGroupRecord(groupUUID);
1272 if (record != null)
1273 groupName = record.GroupName;
1274
1275 GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid);
1276
1277 if (groupMembershipData != null)
1278 groupPowers = groupMembershipData.GroupPowers;
1279 }
1280
1281 ControllingClient.SendAgentDataUpdate(
1282 m_uuid, groupUUID, Firstname, Lastname, groupPowers, groupName, Grouptitle);
1283 }
1284 catch (Exception e)
1285 {
1286 m_log.Error("[AGENTUPDATE]: Error ", e);
1287 }
1288 // ------------------------------------
1289
1290 if (ParentID == 0)
1291 {
1292 // Moved this from SendInitialData to ensure that Appearance is initialized
1293 // before the inventory is processed in MakeRootAgent. This fixes a race condition
1294 // related to the handling of attachments
1295 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
1296
1297 /* RA 20140111: Commented out these TestBorderCross's.
1298 * Not sure why this code is here. It is not checking all the borders
1299 * and 'in region' sanity checking is done in CheckAndAdjustLandingPoint and below.
1300 if (m_scene.TestBorderCross(pos, Cardinals.E))
1301 {
1302 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
1303 pos.X = crossedBorder.BorderLine.Z - 1;
1304 }
1305
1306 if (m_scene.TestBorderCross(pos, Cardinals.N))
1307 {
1308 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
1309 pos.Y = crossedBorder.BorderLine.Z - 1;
1310 }
1311 */
1312
1313=======
1314
1315 if (ParentID == 0) 1193 if (ParentID == 0)
1316 { 1194 {
1317>>>>>>> avn/ubitvar
1318 CheckAndAdjustLandingPoint(ref pos); 1195 CheckAndAdjustLandingPoint(ref pos);
1319 1196
1320 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 1197 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
@@ -1350,30 +1227,18 @@ no information to check this
1350// 1227//
1351 if (m_teleportFlags == TeleportFlags.Default) 1228 if (m_teleportFlags == TeleportFlags.Default)
1352 { 1229 {
1230 Vector3 vel = Velocity;
1353 AddToPhysicalScene(isFlying); 1231 AddToPhysicalScene(isFlying);
1354// 1232 if (PhysicsActor != null)
1355// Console.WriteLine( 1233 PhysicsActor.SetMomentum(vel);
1356// "Set velocity of {0} in {1} to {2} from input velocity of {3} on MakeRootAgent",
1357// Name, Scene.Name, PhysicsActor.Velocity, vel);
1358// }
1359 } 1234 }
1360 else 1235 else
1361 { 1236 {
1362 AddToPhysicalScene(isFlying); 1237 AddToPhysicalScene(isFlying);
1363<<<<<<< HEAD
1364 }
1365 1238
1366 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1367 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
1368 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset
1369 // the value to a negative position which does not trigger the border cross.
1370 // This may not be the best location for this.
1371 CheckForBorderCrossing();
1372=======
1373 // reset camera to avatar pos 1239 // reset camera to avatar pos
1374 CameraPosition = pos; 1240 CameraPosition = pos;
1375 } 1241 }
1376>>>>>>> avn/ubitvar
1377 1242
1378 if (ForceFly) 1243 if (ForceFly)
1379 { 1244 {
@@ -1383,40 +1248,6 @@ no information to check this
1383 { 1248 {
1384 Flying = false; 1249 Flying = false;
1385 } 1250 }
1386<<<<<<< HEAD
1387 }
1388
1389 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
1390 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
1391 // elsewhere anyway
1392 // Animator.SendAnimPack();
1393
1394 m_scene.SwapRootAgentCount(false);
1395
1396 if (Scene.AttachmentsModule != null)
1397 {
1398 // The initial login scene presence is already root when it gets here
1399 // and it has already rezzed the attachments and started their scripts.
1400 // We do the following only for non-login agents, because their scripts
1401 // haven't started yet.
1402 if (PresenceType == PresenceType.Npc || IsRealLogin(m_teleportFlags))
1403 {
1404 WorkManager.RunJob(
1405 "RezAttachments",
1406 o => Scene.AttachmentsModule.RezAttachments(this),
1407 null,
1408 string.Format("Rez attachments for {0} in {1}", Name, Scene.Name));
1409 }
1410 else
1411 {
1412 WorkManager.RunJob(
1413 "StartAttachmentScripts",
1414 o => RestartAttachmentScripts(),
1415 null,
1416 string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name),
1417 true);
1418 }
1419=======
1420 1251
1421 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a 1252 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1422 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it 1253 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
@@ -1427,28 +1258,16 @@ no information to check this
1427 1258
1428 // its not 1259 // its not
1429// CheckForBorderCrossing(); 1260// CheckForBorderCrossing();
1430>>>>>>> avn/ubitvar
1431 } 1261 }
1262
1432 1263
1433 m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1264 m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1434 m_scene.SwapRootAgentCount(false); 1265 m_scene.SwapRootAgentCount(false);
1435 1266
1436<<<<<<< HEAD
1437 SendAvatarDataToAllClients();
1438
1439 // send the animations of the other presences to me
1440 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
1441 {
1442 if (presence != this)
1443 presence.Animator.SendAnimPackToClient(ControllingClient);
1444 });
1445=======
1446>>>>>>> avn/ubitvar
1447
1448 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1267 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
1449 // stall on the border crossing since the existing child agent will still have the last movement 1268 // stall on the border crossing since the existing child agent will still have the last movement
1450 // recorded, which stops the input from being processed. 1269 // recorded, which stops the input from being processed.
1451 MovementFlag = ForceUpdateMovementFlagValue; 1270 MovementFlag = 0;
1452 1271
1453 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1272 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1454 m_log.DebugFormat("[MakeRootAgent] TriggerOnMakeRootAgent and done: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1273 m_log.DebugFormat("[MakeRootAgent] TriggerOnMakeRootAgent and done: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@@ -1500,12 +1319,13 @@ no information to check this
1500 /// Group Title. So the following trick makes viewers update the avatar's name by briefly changing 1319 /// Group Title. So the following trick makes viewers update the avatar's name by briefly changing
1501 /// the group title (to "(Loading)"), and then restoring it. 1320 /// the group title (to "(Loading)"), and then restoring it.
1502 /// </remarks> 1321 /// </remarks>
1322/*
1503 public void ForceViewersUpdateName() 1323 public void ForceViewersUpdateName()
1504 { 1324 {
1505 m_log.DebugFormat("[SCENE PRESENCE]: Forcing viewers to update the avatar name for " + Name); 1325 m_log.DebugFormat("[SCENE PRESENCE]: Forcing viewers to update the avatar name for " + Name);
1506 1326
1507 UseFakeGroupTitle = true; 1327 UseFakeGroupTitle = true;
1508 SendAvatarDataToAllClients(false); 1328
1509 1329
1510 Util.FireAndForget(o => 1330 Util.FireAndForget(o =>
1511 { 1331 {
@@ -1519,7 +1339,7 @@ no information to check this
1519 SendAvatarDataToAllClients(false); 1339 SendAvatarDataToAllClients(false);
1520 }, null, "Scenepresence.ForceViewersUpdateName"); 1340 }, null, "Scenepresence.ForceViewersUpdateName");
1521 } 1341 }
1522 1342*/
1523 public int GetStateSource() 1343 public int GetStateSource()
1524 { 1344 {
1525 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID); 1345 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID);
@@ -1557,11 +1377,6 @@ no information to check this
1557 lock (m_originRegionIDAccessLock) 1377 lock (m_originRegionIDAccessLock)
1558 m_originRegionID = UUID.Zero; 1378 m_originRegionID = UUID.Zero;
1559 1379
1560 // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating
1561 // from the source simulator has completed on a V2 teleport.
1562 lock (m_originRegionIDAccessLock)
1563 m_originRegionID = UUID.Zero;
1564
1565 // Reset these so that teleporting in and walking out isn't seen 1380 // Reset these so that teleporting in and walking out isn't seen
1566 // as teleporting back 1381 // as teleporting back
1567 TeleportFlags = TeleportFlags.Default; 1382 TeleportFlags = TeleportFlags.Default;
@@ -1609,9 +1424,10 @@ no information to check this
1609 if (PhysicsActor != null) 1424 if (PhysicsActor != null)
1610 { 1425 {
1611// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; 1426// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
1612 PhysicsActor.UnSubscribeEvents(); 1427
1613 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; 1428 PhysicsActor.OnOutOfBounds -= OutOfBoundsCall;
1614 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; 1429 PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
1430 PhysicsActor.UnSubscribeEvents();
1615 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); 1431 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
1616 PhysicsActor = null; 1432 PhysicsActor = null;
1617 } 1433 }
@@ -1649,6 +1465,8 @@ no information to check this
1649 else 1465 else
1650 PhysicsActor.SetMomentum(vel); 1466 PhysicsActor.SetMomentum(vel);
1651 } 1467 }
1468
1469 SendTerseUpdateToAllClients();
1652 } 1470 }
1653 1471
1654 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) 1472 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY)
@@ -1680,6 +1498,7 @@ no information to check this
1680 } 1498 }
1681 } 1499 }
1682 } 1500 }
1501 SendTerseUpdateToAllClients();
1683 } 1502 }
1684 1503
1685 public void StopFlying() 1504 public void StopFlying()
@@ -1915,17 +1734,7 @@ no information to check this
1915 public void SetSize(Vector3 size, float feetoffset) 1734 public void SetSize(Vector3 size, float feetoffset)
1916 { 1735 {
1917 if (PhysicsActor != null && !IsChildAgent) 1736 if (PhysicsActor != null && !IsChildAgent)
1918<<<<<<< HEAD
1919 {
1920 // Eventually there will be a physics call that sets avatar size that includes offset info.
1921 // For the moment, just set the size as passed.
1922 PhysicsActor.Size = size;
1923 // PhysicsActor.setAvatarSize(size, feetoffset);
1924 }
1925=======
1926 PhysicsActor.setAvatarSize(size, feetoffset); 1737 PhysicsActor.setAvatarSize(size, feetoffset);
1927
1928>>>>>>> avn/ubitvar
1929 } 1738 }
1930 1739
1931 private bool WaitForUpdateAgent(IClientAPI client) 1740 private bool WaitForUpdateAgent(IClientAPI client)
@@ -1934,13 +1743,23 @@ no information to check this
1934 // (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination, 1743 // (which triggers Scene.IncomingUpdateChildAgent(AgentData cAgentData) here in the destination,
1935 // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the 1744 // m_originRegionID is UUID.Zero; after, it's non-Zero. The CompleteMovement sequence initiated from the
1936 // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero 1745 // viewer (in turn triggered by the source region sending it a TeleportFinish event) waits until it's non-zero
1937 m_updateAgentReceivedAfterTransferEvent.WaitOne(10000); 1746// m_updateAgentReceivedAfterTransferEvent.WaitOne(10000);
1938 1747 int count = 50;
1939 UUID originID = UUID.Zero; 1748 UUID originID = UUID.Zero;
1940 1749
1941 lock (m_originRegionIDAccessLock) 1750 lock (m_originRegionIDAccessLock)
1942 originID = m_originRegionID; 1751 originID = m_originRegionID;
1943 1752
1753
1754 while (originID.Equals(UUID.Zero) && count-- > 0)
1755 {
1756 lock (m_originRegionIDAccessLock)
1757 originID = m_originRegionID;
1758
1759 m_log.DebugFormat("[SCENE PRESENCE]: Agent {0} waiting for update in {1}", client.Name, Scene.Name);
1760 Thread.Sleep(200);
1761 }
1762
1944 if (originID.Equals(UUID.Zero)) 1763 if (originID.Equals(UUID.Zero))
1945 { 1764 {
1946 // Movement into region will fail 1765 // Movement into region will fail
@@ -1970,40 +1789,6 @@ no information to check this
1970 1789
1971 m_inTransit = true; 1790 m_inTransit = true;
1972 1791
1973<<<<<<< HEAD
1974 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); // Get this ahead of time because IsInTransit modifies 'm_AgentControlFlags'
1975
1976 IsInTransit = true;
1977 try
1978 {
1979 // Make sure it's not a login agent. We don't want to wait for updates during login
1980 if (!(PresenceType == PresenceType.Npc || IsRealLogin(m_teleportFlags)))
1981 {
1982 // Let's wait until UpdateAgent (called by departing region) is done
1983 if (!WaitForUpdateAgent(client))
1984 // The sending region never sent the UpdateAgent data, we have to refuse
1985 return;
1986 }
1987
1988 Vector3 look = Velocity;
1989
1990 // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1991 if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1))
1992 {
1993 look = new Vector3(0.99f, 0.042f, 0);
1994 }
1995
1996 // Prevent teleporting to an underground location
1997 // (may crash client otherwise)
1998 //
1999 Vector3 pos = AbsolutePosition;
2000 float ground = m_scene.GetGroundHeight(pos.X, pos.Y);
2001 if (pos.Z < ground + 1.5f)
2002 {
2003 pos.Z = ground + 1.5f;
2004 AbsolutePosition = pos;
2005 }
2006=======
2007 try 1792 try
2008 { 1793 {
2009 // Make sure it's not a login agent. We don't want to wait for updates during login 1794 // Make sure it's not a login agent. We don't want to wait for updates during login
@@ -2019,103 +1804,16 @@ no information to check this
2019 m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1804 m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2020 1805
2021 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1806 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
2022>>>>>>> avn/ubitvar
2023 1807
2024 if (!MakeRootAgent(AbsolutePosition, flying)) 1808 if (!MakeRootAgent(AbsolutePosition, flying))
2025 { 1809 {
2026 m_log.DebugFormat( 1810 m_log.DebugFormat(
2027<<<<<<< HEAD
2028 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
2029=======
2030 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", 1811 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
2031>>>>>>> avn/ubitvar
2032 Name, Scene.Name); 1812 Name, Scene.Name);
2033 1813
2034 return; 1814 return;
2035 } 1815 }
2036 1816
2037<<<<<<< HEAD
2038 // Tell the client that we're totally ready
2039 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2040
2041 // Child agents send initial data up in LLUDPServer.HandleUseCircuitCode()
2042 if (!SentInitialDataToClient)
2043 SendInitialDataToClient();
2044
2045 // m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
2046
2047 if (!string.IsNullOrEmpty(m_callbackURI))
2048 {
2049 // We cannot sleep here since this would hold up the inbound packet processing thread, as
2050 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
2051 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
2052 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
2053 // region as the current region, meaning that a close sent before then will fail the teleport.
2054 // System.Threading.Thread.Sleep(2000);
2055
2056 m_log.DebugFormat(
2057 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
2058 client.Name, client.AgentId, m_callbackURI);
2059
2060 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
2061 m_callbackURI = null;
2062 }
2063 // else
2064 // {
2065 // m_log.DebugFormat(
2066 // "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
2067 // client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
2068 // }
2069
2070 ValidateAndSendAppearanceAndAgentData();
2071
2072 // Create child agents in neighbouring regions
2073 if (openChildAgents && !IsChildAgent)
2074 {
2075 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2076 if (m_agentTransfer != null)
2077 {
2078 // Note: this call can take a while, because it notifies each of the simulator's neighbours.
2079 // It's important that we don't allow the avatar to cross regions meanwhile, as that will
2080 // cause serious errors. We've prevented that from happening by setting IsInTransit=true.
2081 m_agentTransfer.EnableChildAgents(this);
2082 }
2083
2084 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
2085 if (friendsModule != null)
2086 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
2087
2088 }
2089
2090 // XXX: If we force an update after activity has completed, then multiple attachments do appear correctly on a destination region
2091 // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
2092 // This may be due to viewer code or it may be something we're not doing properly simulator side.
2093 WorkManager.RunJob(
2094 "ScheduleAttachmentsForFullUpdate",
2095 o => ScheduleAttachmentsForFullUpdate(),
2096 null,
2097 string.Format("Schedule attachments for full update for {0} in {1}", Name, Scene.Name),
2098 true);
2099
2100 // m_log.DebugFormat(
2101 // "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
2102 // client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
2103 }
2104 finally
2105 {
2106 IsInTransit = false;
2107 }
2108 }
2109
2110 private void ScheduleAttachmentsForFullUpdate()
2111 {
2112 lock (m_attachments)
2113 {
2114 foreach (SceneObjectGroup sog in m_attachments)
2115 sog.ScheduleGroupForFullUpdate();
2116 }
2117 }
2118=======
2119 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1817 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2120 1818
2121 Vector3 look = Lookat; 1819 Vector3 look = Lookat;
@@ -2134,7 +1832,7 @@ no information to check this
2134 1832
2135 if (!IsChildAgent && !isNPC) 1833 if (!IsChildAgent && !isNPC)
2136 { 1834 {
2137 InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46); 1835 InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (FolderType)46);
2138 if (cof == null) 1836 if (cof == null)
2139 COF = UUID.Zero; 1837 COF = UUID.Zero;
2140 else 1838 else
@@ -2197,9 +1895,6 @@ no information to check this
2197 // so sequence is clear 1895 // so sequence is clear
2198 1896
2199 // verify baked textures and cache 1897 // verify baked textures and cache
2200>>>>>>> avn/ubitvar
2201
2202
2203 bool cachedbaked = false; 1898 bool cachedbaked = false;
2204 1899
2205 if (isNPC) 1900 if (isNPC)
@@ -2484,23 +2179,16 @@ no information to check this
2484 // When we get to the point of re-computing neighbors everytime this 2179 // When we get to the point of re-computing neighbors everytime this
2485 // changes, then start using the agent's drawdistance rather than the 2180 // changes, then start using the agent's drawdistance rather than the
2486 // region's draw distance. 2181 // region's draw distance.
2487<<<<<<< HEAD
2488 DrawDistance = agentData.Far;
2489 // DrawDistance = Scene.DefaultDrawDistance;
2490=======
2491 2182
2492 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); 2183 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance);
2493 2184
2494// DrawDistance = Scene.DefaultDrawDistance;
2495>>>>>>> avn/ubitvar
2496
2497 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 2185 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
2498 2186
2499 // FIXME: This does not work as intended because the viewer only sends the lbutton down when the button 2187 // FIXME: This does not work as intended because the viewer only sends the lbutton down when the button
2500 // is first pressed, not whilst it is held down. If this is required in the future then need to look 2188 // is first pressed, not whilst it is held down. If this is required in the future then need to look
2501 // for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not 2189 // for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not
2502 // received (e.g. on holding LMB down on the avatar in a viewer). 2190 // received (e.g. on holding LMB down on the avatar in a viewer).
2503// m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 2191 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
2504 2192
2505 #endregion Inputs 2193 #endregion Inputs
2506 2194
@@ -2592,14 +2280,6 @@ no information to check this
2592 2280
2593 bool update_movementflag = false; 2281 bool update_movementflag = false;
2594 2282
2595 // If we were just made root agent then we must perform movement updates for the first AgentUpdate that
2596 // we get
2597 if (MovementFlag == ForceUpdateMovementFlagValue)
2598 {
2599 MovementFlag = 0;
2600 update_movementflag = true;
2601 }
2602
2603 if (agentData.UseClientAgentPosition) 2283 if (agentData.UseClientAgentPosition)
2604 { 2284 {
2605 MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; 2285 MovingToTarget = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f;
@@ -2631,8 +2311,6 @@ no information to check this
2631 { 2311 {
2632 bool bAllowUpdateMoveToPosition = false; 2312 bool bAllowUpdateMoveToPosition = false;
2633 2313
2634<<<<<<< HEAD
2635=======
2636 Vector3[] dirVectors; 2314 Vector3[] dirVectors;
2637 2315
2638 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying 2316 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
@@ -2642,8 +2320,6 @@ no information to check this
2642// else 2320// else
2643 dirVectors = Dir_Vectors; 2321 dirVectors = Dir_Vectors;
2644 2322
2645
2646>>>>>>> avn/ubitvar
2647 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 2323 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
2648 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 2324 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
2649 { 2325 {
@@ -2865,12 +2541,8 @@ no information to check this
2865 // When we get to the point of re-computing neighbors everytime this 2541 // When we get to the point of re-computing neighbors everytime this
2866 // changes, then start using the agent's drawdistance rather than the 2542 // changes, then start using the agent's drawdistance rather than the
2867 // region's draw distance. 2543 // region's draw distance.
2868<<<<<<< HEAD 2544
2869 DrawDistance = agentData.Far;
2870 // DrawDistance = Scene.DefaultDrawDistance;
2871=======
2872 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); 2545 DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance);
2873>>>>>>> avn/ubitvar
2874 2546
2875 // Check if Client has camera in 'follow cam' or 'build' mode. 2547 // Check if Client has camera in 'follow cam' or 'build' mode.
2876 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); 2548 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
@@ -3064,54 +2736,63 @@ no information to check this
3064 || pos.Y < 0 || pos.Y >= regionSize.Y 2736 || pos.Y < 0 || pos.Y >= regionSize.Y
3065 || pos.Z < 0) 2737 || pos.Z < 0)
3066 return; 2738 return;
3067 2739
3068 Scene targetScene = m_scene; 2740 Scene targetScene = m_scene;
3069
3070// Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2);
3071// pos += heightAdjust;
3072//
3073// // Anti duck-walking measure
3074// if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f)
3075// {
3076//// m_log.DebugFormat("[SCENE PRESENCE]: Adjusting MoveToPosition from {0} to {1}", pos, AbsolutePosition);
3077// pos.Z = AbsolutePosition.Z;
3078// }
3079
3080 // Get terrain height for sub-region in a megaregion if necessary 2741 // Get terrain height for sub-region in a megaregion if necessary
3081<<<<<<< HEAD
3082=======
3083 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
3084 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
3085 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
3086 // If X and Y is NaN, target_region will be null
3087 if (target_region == null)
3088 return;
3089 UUID target_regionID = target_region.RegionID;
3090 Scene targetScene = m_scene;
3091>>>>>>> avn/ubitvar
3092
3093 //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too?
3094
3095 if (regionCombinerModule != null) 2742 if (regionCombinerModule != null)
3096 { 2743 {
3097 int x = (int)((m_scene.RegionInfo.WorldLocX) + pos.X); 2744 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
3098 int y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); 2745 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
3099 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); 2746 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
3100
3101<<<<<<< HEAD
3102 // If X and Y is NaN, target_region will be null 2747 // If X and Y is NaN, target_region will be null
3103 if (target_region == null) 2748 if (target_region == null)
3104 return; 2749 return;
3105 2750 UUID target_regionID = target_region.RegionID;
3106 SceneManager.Instance.TryGetScene(target_region.RegionID, out targetScene); 2751 SceneManager.Instance.TryGetScene(target_region.RegionID, out targetScene);
3107 } 2752 }
3108 2753
3109 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; 2754
3110======= 2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
3111 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; 2792 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
3112 // dont try to land underground 2793 // dont try to land underground
3113 terrainHeight += Appearance.AvatarHeight / 2; 2794 terrainHeight += Appearance.AvatarHeight / 2;
3114>>>>>>> avn/ubitvar 2795
3115 pos.Z = Math.Max(terrainHeight, pos.Z); 2796 pos.Z = Math.Max(terrainHeight, pos.Z);
3116 2797
3117 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 2798 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@@ -3120,26 +2801,15 @@ no information to check this
3120 if (pos.Z - terrainHeight < 0.2) 2801 if (pos.Z - terrainHeight < 0.2)
3121 pos.Z = terrainHeight; 2802 pos.Z = terrainHeight;
3122 2803
3123<<<<<<< HEAD
3124=======
3125// m_log.DebugFormat( 2804// m_log.DebugFormat(
3126// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", 2805// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
3127// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 2806// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
3128 2807
3129
3130>>>>>>> avn/ubitvar
3131 if (noFly) 2808 if (noFly)
3132 Flying = false; 2809 Flying = false;
3133 else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying) 2810 else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying)
3134 Flying = true; 2811 Flying = true;
3135 2812
3136// m_log.DebugFormat(
3137// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
3138// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
3139
3140 if (noFly)
3141 Flying = false;
3142
3143 LandAtTarget = landAtTarget; 2813 LandAtTarget = landAtTarget;
3144 MovingToTarget = true; 2814 MovingToTarget = true;
3145 MoveToPositionTarget = pos; 2815 MoveToPositionTarget = pos;
@@ -3214,13 +2884,10 @@ no information to check this
3214 } 2884 }
3215 } 2885 }
3216 2886
3217<<<<<<< HEAD
3218=======
3219 part.ParentGroup.DeleteAvatar(UUID); 2887 part.ParentGroup.DeleteAvatar(UUID);
3220 2888
3221 Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset; 2889 Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset;
3222 Vector3 sitPartWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation; 2890 Vector3 sitPartWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation;
3223>>>>>>> avn/ubitvar
3224 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 2891 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
3225 2892
3226 ParentID = 0; 2893 ParentID = 0;
@@ -3248,25 +2915,9 @@ no information to check this
3248 standRotationZ.Z = 0f; 2915 standRotationZ.Z = 0f;
3249 } 2916 }
3250 2917
3251<<<<<<< HEAD
3252 //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
3253 //Vector3 standPos = ParentPosition;
3254
3255// Vector3 standPositionAdjustment
3256// = part.SitTargetPosition + new Vector3(0.5f, 0f, m_sitAvatarHeight / 2f);
3257 Vector3 adjustmentForSitPosition = OffsetPosition * part.ParentGroup.GroupRotation - SIT_TARGET_ADJUSTMENT * part.GetWorldRotation();
3258
3259 // XXX: This is based on the physics capsule sizes. Need to find a better way to read this rather than
3260 // hardcoding here.
3261 Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation;
3262
3263 Vector3 standPos = part.ParentGroup.AbsolutePosition + adjustmentForSitPosition + adjustmentForSitPose;
3264=======
3265 Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight + .3f) * standRotationZ; 2918 Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight + .3f) * standRotationZ;
3266 2919
3267 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; 2920 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose;
3268>>>>>>> avn/ubitvar
3269
3270 m_pos = standPos; 2921 m_pos = standPos;
3271 } 2922 }
3272 2923
@@ -3277,16 +2928,9 @@ no information to check this
3277 2928
3278 if (satOnObject) 2929 if (satOnObject)
3279 { 2930 {
3280<<<<<<< HEAD
3281 SendAvatarDataToAllClients();
3282 m_requestedSitTargetID = 0;
3283 2931
3284 part.RemoveSittingAvatar(this);
3285
3286=======
3287 m_requestedSitTargetID = 0; 2932 m_requestedSitTargetID = 0;
3288 part.RemoveSittingAvatar(UUID); 2933 part.RemoveSittingAvatar(UUID);
3289>>>>>>> avn/ubitvar
3290 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 2934 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3291 2935
3292 SendAvatarDataToAllAgents(); 2936 SendAvatarDataToAllAgents();
@@ -3386,37 +3030,11 @@ no information to check this
3386 3030
3387 Velocity = Vector3.Zero; 3031 Velocity = Vector3.Zero;
3388 3032
3389 part.AddSittingAvatar(this); 3033 part.AddSittingAvatar(UUID);
3390 3034
3391 cameraAtOffset = part.GetCameraAtOffset(); 3035 cameraAtOffset = part.GetCameraAtOffset();
3392
3393 if (!part.IsRoot && cameraAtOffset == Vector3.Zero)
3394 cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
3395
3396 bool cameraEyeOffsetFromRootForChild = false;
3397 cameraEyeOffset = part.GetCameraEyeOffset(); 3036 cameraEyeOffset = part.GetCameraEyeOffset();
3398 3037
3399 if (!part.IsRoot && cameraEyeOffset == Vector3.Zero)
3400 {
3401 cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
3402 cameraEyeOffsetFromRootForChild = true;
3403 }
3404
3405 if ((cameraEyeOffset != Vector3.Zero && !cameraEyeOffsetFromRootForChild) || cameraAtOffset != Vector3.Zero)
3406 {
3407 if (!part.IsRoot)
3408 {
3409 cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
3410 cameraAtOffset += part.OffsetPosition;
3411 }
3412
3413 cameraEyeOffset += part.OffsetPosition;
3414 }
3415
3416// m_log.DebugFormat(
3417// "[SCENE PRESENCE]: Using cameraAtOffset {0}, cameraEyeOffset {1} for sit on {2} by {3} in {4}",
3418// cameraAtOffset, cameraEyeOffset, part.Name, Name, Scene.Name);
3419
3420 forceMouselook = part.GetForceMouselook(); 3038 forceMouselook = part.GetForceMouselook();
3421 3039
3422 if (!part.IsRoot) 3040 if (!part.IsRoot)
@@ -3560,7 +3178,7 @@ no information to check this
3560 Velocity = Vector3.Zero; 3178 Velocity = Vector3.Zero;
3561 m_AngularVelocity = Vector3.Zero; 3179 m_AngularVelocity = Vector3.Zero;
3562 3180
3563 part.AddSittingAvatar(this); 3181 part.AddSittingAvatar(UUID);
3564 3182
3565 Vector3 cameraAtOffset = part.GetCameraAtOffset(); 3183 Vector3 cameraAtOffset = part.GetCameraAtOffset();
3566 Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); 3184 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
@@ -3596,6 +3214,7 @@ no information to check this
3596 3214
3597 3215
3598 m_requestedSitTargetID = 0; 3216 m_requestedSitTargetID = 0;
3217 part.ParentGroup.AddAvatar(UUID);
3599 3218
3600 ParentPart = part; 3219 ParentPart = part;
3601 ParentID = part.LocalId; 3220 ParentID = part.LocalId;
@@ -3607,9 +3226,6 @@ no information to check this
3607 Animator.TrySetMovementAnimation("SIT_GROUND"); 3226 Animator.TrySetMovementAnimation("SIT_GROUND");
3608 else 3227 else
3609 Animator.TrySetMovementAnimation("SIT"); 3228 Animator.TrySetMovementAnimation("SIT");
3610<<<<<<< HEAD
3611 SendAvatarDataToAllClients();
3612=======
3613*/ 3229*/
3614 if (status == 3) 3230 if (status == 3)
3615 sitAnimation = "SIT_GROUND"; 3231 sitAnimation = "SIT_GROUND";
@@ -3617,8 +3233,6 @@ no information to check this
3617 sitAnimation = "SIT"; 3233 sitAnimation = "SIT";
3618 3234
3619 Animator.SetMovementAnimations("SIT"); 3235 Animator.SetMovementAnimations("SIT");
3620>>>>>>> avn/ubitvar
3621
3622 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3236 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3623 } 3237 }
3624 3238
@@ -3654,40 +3268,27 @@ no information to check this
3654 3268
3655 //Quaternion result = (sitTargetOrient * vq) * nq; 3269 //Quaternion result = (sitTargetOrient * vq) * nq;
3656 3270
3657 double x, y, z, m1, m2; 3271 double x, y, z, m;
3658 3272
3659 Quaternion r = sitTargetOrient; 3273 Quaternion r = sitTargetOrient;
3660 m1 = r.X * r.X + r.Y * r.Y; 3274 m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W;
3661 m2 = r.Z * r.Z + r.W * r.W;
3662
3663 // Rotate the vector <0, 0, 1>
3664 x = 2 * (r.X * r.Z + r.Y * r.W);
3665 y = 2 * (-r.X * r.W + r.Y * r.Z);
3666 z = m2 - m1;
3667
3668 // Set m to be the square of the norm of r.
3669 double m = m1 + m2;
3670 3275
3671 // This constant is emperically determined to be what is used in SL. 3276 if (Math.Abs(1.0 - m) > 0.000001)
3672 // See also http://opensimulator.org/mantis/view.php?id=7096
3673 double offset = 0.05;
3674
3675 // Normally m will be ~ 1, but if someone passed a handcrafted quaternion
3676 // to llSitTarget with values so small that squaring them is rounded off
3677 // to zero, then m could be zero. The result of this floating point
3678 // round off error (causing us to skip this impossible normalization)
3679 // is only 5 cm.
3680 if (m > 0.000001)
3681 { 3277 {
3682 offset /= m; 3278 m = 1.0 / Math.Sqrt(m);
3279 r.X *= (float)m;
3280 r.Y *= (float)m;
3281 r.Z *= (float)m;
3282 r.W *= (float)m;
3683 } 3283 }
3684 3284
3285 x = 2 * (r.X * r.Z + r.Y * r.W);
3286 y = 2 * (-r.X * r.W + r.Y * r.Z);
3287 z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W;
3685 Vector3 up = new Vector3((float)x, (float)y, (float)z); 3288 Vector3 up = new Vector3((float)x, (float)y, (float)z);
3686 Vector3 sitOffset = up * (float)offset; 3289 Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
3687 3290
3688 // sitOffset is in Avatar Center coordinates: from origin to 'sitTargetPos + SIT_TARGET_ADJUSTMENT'. 3291 Vector3 newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
3689 // So, we need to _substract_ it to get to the origin of the Avatar Center.
3690 Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
3691 Quaternion newRot; 3292 Quaternion newRot;
3692 3293
3693 if (part.IsRoot) 3294 if (part.IsRoot)
@@ -3720,7 +3321,8 @@ no information to check this
3720// Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); 3321// Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId);
3721 } 3322 }
3722 3323
3723 ParentPart = part; 3324 part.ParentGroup.AddAvatar(UUID);
3325 ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
3724 ParentID = m_requestedSitTargetID; 3326 ParentID = m_requestedSitTargetID;
3725 m_AngularVelocity = Vector3.Zero; 3327 m_AngularVelocity = Vector3.Zero;
3726 Velocity = Vector3.Zero; 3328 Velocity = Vector3.Zero;
@@ -3733,13 +3335,8 @@ no information to check this
3733 { 3335 {
3734 sitAnimation = part.SitAnimation; 3336 sitAnimation = part.SitAnimation;
3735 } 3337 }
3736<<<<<<< HEAD
3737 Animator.TrySetMovementAnimation(sitAnimation);
3738 SendAvatarDataToAllClients();
3739=======
3740// Animator.TrySetMovementAnimation(sitAnimation); 3338// Animator.TrySetMovementAnimation(sitAnimation);
3741 Animator.SetMovementAnimations("SIT"); 3339 Animator.SetMovementAnimations("SIT");
3742>>>>>>> avn/ubitvar
3743 TriggerScenePresenceUpdated(); 3340 TriggerScenePresenceUpdated();
3744 } 3341 }
3745 } 3342 }
@@ -3801,25 +3398,10 @@ no information to check this
3801 // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", 3398 // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}",
3802 // vec, Rotation, thisAddSpeedModifier, Name); 3399 // vec, Rotation, thisAddSpeedModifier, Name);
3803 3400
3804<<<<<<< HEAD
3805 Quaternion rot = Rotation;
3806 if (!Flying && PresenceType != PresenceType.Npc)
3807 {
3808 // The only situation in which we care about X and Y is avatar flying. The rest of the time
3809 // these parameters are not relevant for determining avatar movement direction and cause issues such
3810 // as wrong walk speed if the camera is rotated.
3811 rot.X = 0;
3812 rot.Y = 0;
3813 rot.Normalize();
3814 }
3815
3816 Vector3 direc = vec * rot;
3817=======
3818 // rotate from avatar coord space to world 3401 // rotate from avatar coord space to world
3819 // for now all controls assume this is only a rotation around Z 3402 // for now all controls assume this is only a rotation around Z
3820 // if not all checks below need to be done before this rotation 3403 // if not all checks below need to be done before this rotation
3821 Vector3 direc = vec * Rotation; 3404 Vector3 direc = vec * Rotation;
3822>>>>>>> avn/ubitvar
3823 direc.Normalize(); 3405 direc.Normalize();
3824 3406
3825 // mouse look situation ? 3407 // mouse look situation ?
@@ -3869,6 +3451,10 @@ no information to check this
3869 3451
3870 public override void Update() 3452 public override void Update()
3871 { 3453 {
3454 const float ROTATION_TOLERANCE = 0.01f;
3455 const float VELOCITY_TOLERANCE = 0.001f;
3456 const float POSITION_TOLERANCE = 0.05f;
3457
3872 if (IsChildAgent == false) 3458 if (IsChildAgent == false)
3873 { 3459 {
3874 CheckForBorderCrossing(); 3460 CheckForBorderCrossing();
@@ -3880,21 +3466,11 @@ no information to check this
3880 // grab the latest PhysicsActor velocity, whereas m_velocity is often 3466 // grab the latest PhysicsActor velocity, whereas m_velocity is often
3881 // storing a requested force instead of an actual traveling velocity 3467 // storing a requested force instead of an actual traveling velocity
3882 if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) 3468 if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn)
3883 SendAvatarDataToAllClients(); 3469 SendAvatarDataToAllAgents();
3884 3470
3885 // Allow any updates for sitting avatars to that llSetPrimitiveLinkParams() can work for very 3471 if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
3886 // small increments (e.g. sit position adjusters). An alternative may be to eliminate the tolerance 3472 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
3887 // checks on all updates but the ramifications of this would need careful consideration. 3473 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
3888 bool updateClients
3889 = IsSatOnObject && (Rotation != m_lastRotation || Velocity != m_lastVelocity || m_pos != m_lastPosition);
3890
3891 if (!updateClients)
3892 updateClients
3893 = !Rotation.ApproxEquals(m_lastRotation, Scene.RootRotationUpdateTolerance)
3894 || !Velocity.ApproxEquals(m_lastVelocity, Scene.RootVelocityUpdateTolerance)
3895 || !m_pos.ApproxEquals(m_lastPosition, Scene.RootPositionUpdateTolerance);
3896
3897 if (updateClients)
3898 { 3474 {
3899 SendTerseUpdateToAllClients(); 3475 SendTerseUpdateToAllClients();
3900 3476
@@ -3904,12 +3480,6 @@ no information to check this
3904 m_lastVelocity = Velocity; 3480 m_lastVelocity = Velocity;
3905 } 3481 }
3906 3482
3907<<<<<<< HEAD
3908 if (Scene.AllowAvatarCrossing)
3909 CheckForBorderCrossing();
3910
3911=======
3912>>>>>>> avn/ubitvar
3913 CheckForSignificantMovement(); // sends update to the modules. 3483 CheckForSignificantMovement(); // sends update to the modules.
3914 } 3484 }
3915 } 3485 }
@@ -3918,8 +3488,6 @@ no information to check this
3918 3488
3919 #region Update Client(s) 3489 #region Update Client(s)
3920 3490
3921<<<<<<< HEAD
3922=======
3923 public void SendUpdateToAgent(ScenePresence p) 3491 public void SendUpdateToAgent(ScenePresence p)
3924 { 3492 {
3925 IClientAPI remoteClient = p.ControllingClient; 3493 IClientAPI remoteClient = p.ControllingClient;
@@ -3949,7 +3517,6 @@ no information to check this
3949 ControllingClient.SendAgentTerseUpdate(p); 3517 ControllingClient.SendAgentTerseUpdate(p);
3950 } 3518 }
3951 3519
3952>>>>>>> avn/ubitvar
3953 /// <summary> 3520 /// <summary>
3954 /// Sends a location update to the client connected to this scenePresence 3521 /// Sends a location update to the client connected to this scenePresence
3955 /// via entity updates 3522 /// via entity updates
@@ -3961,29 +3528,6 @@ no information to check this
3961 // server. 3528 // server.
3962 if (remoteClient.IsActive) 3529 if (remoteClient.IsActive)
3963 { 3530 {
3964 if (Scene.RootTerseUpdatePeriod > 1)
3965 {
3966// Console.WriteLine(
3967// "{0} {1} {2} {3} {4} {5} for {6} to {7}",
3968// remoteClient.AgentId, UUID, remoteClient.SceneAgent.IsChildAgent, m_terseUpdateCount, Scene.RootTerseUpdatePeriod, Velocity.ApproxEquals(Vector3.Zero, 0.001f), Name, remoteClient.Name);
3969 if (remoteClient.AgentId != UUID
3970 && !remoteClient.SceneAgent.IsChildAgent
3971 && m_terseUpdateCount % Scene.RootTerseUpdatePeriod != 0
3972 && !Velocity.ApproxEquals(Vector3.Zero, 0.001f))
3973 {
3974// m_log.DebugFormat("[SCENE PRESENCE]: Discarded update from {0} to {1}, args {2} {3} {4} {5} {6} {7}",
3975// Name, remoteClient.Name, remoteClient.AgentId, UUID, remoteClient.SceneAgent.IsChildAgent, m_terseUpdateCount, Scene.RootTerseUpdatePeriod, Velocity.ApproxEquals(Vector3.Zero, 0.001f));
3976
3977 return;
3978 }
3979 }
3980
3981 if (Scene.ChildTerseUpdatePeriod > 1
3982 && remoteClient.SceneAgent.IsChildAgent
3983 && m_terseUpdateCount % Scene.ChildTerseUpdatePeriod != 0
3984 && !Velocity.ApproxEquals(Vector3.Zero, 0.001f))
3985 return;
3986
3987 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); 3531 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3988 remoteClient.SendEntityUpdate( 3532 remoteClient.SendEntityUpdate(
3989 this, 3533 this,
@@ -4054,10 +3598,6 @@ no information to check this
4054 float speed = Velocity.Length(); 3598 float speed = Velocity.Length();
4055 float velocityDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity); 3599 float velocityDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity);
4056 3600
4057// m_log.DebugFormat(
4058// "[SCENE PRESENCE]: Delta-v {0}, lastVelocity {1}, Velocity {2} for {3} in {4}",
4059// velocidyDiff, lastVelocitySentToAllClients, Velocity, Name, Scene.Name);
4060
4061 // assuming 5 ms. worst case precision for timer, use 2x that 3601 // assuming 5 ms. worst case precision for timer, use 2x that
4062 // for distance error threshold 3602 // for distance error threshold
4063 float distanceErrorThreshold = speed * 0.01f; 3603 float distanceErrorThreshold = speed * 0.01f;
@@ -4066,17 +3606,11 @@ no information to check this
4066 || Math.Abs(distanceError) > distanceErrorThreshold 3606 || Math.Abs(distanceError) > distanceErrorThreshold
4067 || velocityDiff > 0.01f) // did velocity change from last update? 3607 || velocityDiff > 0.01f) // did velocity change from last update?
4068 { 3608 {
4069// m_log.DebugFormat(
4070// "[SCENE PRESENCE]: Update triggered with speed {0}, distanceError {1}, distanceThreshold {2}, delta-v {3} for {4} in {5}",
4071// speed, distanceError, distanceErrorThreshold, velocidyDiff, Name, Scene.Name);
4072
4073 lastVelocitySentToAllClients = Velocity; 3609 lastVelocitySentToAllClients = Velocity;
4074 lastTerseUpdateToAllClientsTick = currentTick; 3610 lastTerseUpdateToAllClientsTick = currentTick;
4075 lastPositionSentToAllClients = OffsetPosition; 3611 lastPositionSentToAllClients = OffsetPosition;
4076 3612
4077 m_terseUpdateCount++; 3613 // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
4078
4079// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
4080// m_scene.ForEachClient(SendTerseUpdateToClient); 3614// m_scene.ForEachClient(SendTerseUpdateToClient);
4081 m_scene.ForEachScenePresence(SendTerseUpdateToAgent); 3615 m_scene.ForEachScenePresence(SendTerseUpdateToAgent);
4082 } 3616 }
@@ -4103,24 +3637,14 @@ no information to check this
4103 ControllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); 3637 ControllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations);
4104 } 3638 }
4105 3639
4106 public void SendInitialDataToClient() 3640 public void SendInitialDataToMe()
4107 { 3641 {
4108 SentInitialDataToClient = true;
4109
4110 // Send all scene object to the new client 3642 // Send all scene object to the new client
4111 WorkManager.RunJob("SendInitialDataToClient", delegate 3643 Util.FireAndForget(delegate
4112 { 3644 {
4113// m_log.DebugFormat(
4114// "[SCENE PRESENCE]: Sending initial data to {0} agent {1} in {2}, tp flags {3}",
4115// IsChildAgent ? "child" : "root", Name, Scene.Name, m_teleportFlags);
4116
4117 // we created a new ScenePresence (a new child agent) in a fresh region. 3645 // we created a new ScenePresence (a new child agent) in a fresh region.
4118 // Request info about all the (root) agents in this region 3646 // Request info about all the (root) agents in this region
4119 // Note: This won't send data *to* other clients in that region (children don't send) 3647 // Note: This won't send data *to* other clients in that region (children don't send)
4120<<<<<<< HEAD
4121 SendOtherAgentsAvatarDataToClient();
4122 SendOtherAgentsAppearanceToClient();
4123=======
4124 if (m_teleportFlags <= 0) 3648 if (m_teleportFlags <= 0)
4125 { 3649 {
4126 ILandChannel landch = m_scene.LandChannel; 3650 ILandChannel landch = m_scene.LandChannel;
@@ -4129,7 +3653,6 @@ no information to check this
4129 landch.sendClientInitialLandInfo(ControllingClient); 3653 landch.sendClientInitialLandInfo(ControllingClient);
4130 } 3654 }
4131 } 3655 }
4132>>>>>>> avn/ubitvar
4133 3656
4134 SendOtherAgentsAvatarFullToMe(); 3657 SendOtherAgentsAvatarFullToMe();
4135 EntityBase[] entities = Scene.Entities.GetEntities(); 3658 EntityBase[] entities = Scene.Entities.GetEntities();
@@ -4138,13 +3661,9 @@ no information to check this
4138 if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) 3661 if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment)
4139 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 3662 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
4140 } 3663 }
4141<<<<<<< HEAD
4142 }, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true);
4143=======
4144 }); 3664 });
4145>>>>>>> avn/ubitvar
4146 } 3665 }
4147 3666
4148 /// <summary> 3667 /// <summary>
4149 /// Do everything required once a client completes its movement into a region and becomes 3668 /// Do everything required once a client completes its movement into a region and becomes
4150 /// a root agent. 3669 /// a root agent.
@@ -4171,17 +3690,6 @@ no information to check this
4171 if (m_scene.AvatarFactory != null) 3690 if (m_scene.AvatarFactory != null)
4172 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 3691 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
4173 } 3692 }
4174<<<<<<< HEAD
4175
4176 // This agent just became root. We are going to tell everyone about it. The process of
4177 // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it
4178 // again here... this comes after the cached appearance check because the avatars
4179 // appearance goes into the avatar update packet
4180 SendAvatarDataToAllClients();
4181
4182 // This invocation always shows up in the viewer logs as an error. Is it needed?
4183 SendAppearanceToClient(this);
4184=======
4185 3693
4186 // send avatar object to all viewers so they cross it into region 3694 // send avatar object to all viewers so they cross it into region
4187 bool newhide = m_currentParcelHide; 3695 bool newhide = m_currentParcelHide;
@@ -4197,7 +3705,6 @@ no information to check this
4197 } 3705 }
4198 3706
4199 SendAppearanceToAgent(this); 3707 SendAppearanceToAgent(this);
4200>>>>>>> avn/ubitvar
4201 3708
4202 m_inTransit = false; 3709 m_inTransit = false;
4203 3710
@@ -4220,13 +3727,6 @@ no information to check this
4220 if (p.UUID == UUID) 3727 if (p.UUID == UUID)
4221 return; 3728 return;
4222 3729
4223<<<<<<< HEAD
4224 // If the avatars baked textures are all in the cache, then we have a
4225 // complete appearance... send it out, if not, then we'll send it when
4226 // the avatar finishes updating its appearance
4227 SendAppearanceToAllOtherClients();
4228 }
4229=======
4230 // get the avatar, then a kill if can't see it 3730 // get the avatar, then a kill if can't see it
4231 p.SendInitialAvatarDataToAgent(this); 3731 p.SendInitialAvatarDataToAgent(this);
4232 3732
@@ -4240,19 +3740,13 @@ no information to check this
4240 }); 3740 });
4241 3741
4242 m_scene.StatsReporter.AddAgentUpdates(count); 3742 m_scene.StatsReporter.AddAgentUpdates(count);
4243>>>>>>> avn/ubitvar
4244 }
4245
4246 public void SendAvatarDataToAllClients()
4247 {
4248 SendAvatarDataToAllClients(true);
4249 } 3743 }
4250 3744
4251 /// <summary> 3745 /// <summary>
4252 /// Send this agent's avatar data to all other root and child agents in the scene 3746 /// Send this agent's avatar data to all other root and child agents in the scene
4253 /// This agent must be root. This avatar will receive its own update. 3747 /// This agent must be root. This avatar will receive its own update.
4254 /// </summary> 3748 /// </summary>
4255 public void SendAvatarDataToAllClients(bool full) 3749 public void SendAvatarDataToAllAgents()
4256 { 3750 {
4257 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID); 3751 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAllAgents: {0} ({1})", Name, UUID);
4258 // only send update from root agents to other clients; children are only "listening posts" 3752 // only send update from root agents to other clients; children are only "listening posts"
@@ -4269,47 +3763,18 @@ no information to check this
4269 3763
4270 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 3764 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
4271 { 3765 {
4272<<<<<<< HEAD
4273 if (full)
4274 SendAvatarDataToClient(scenePresence);
4275 else
4276 scenePresence.ControllingClient.SendAvatarDataImmediate(this);
4277=======
4278 SendAvatarDataToAgent(scenePresence); 3766 SendAvatarDataToAgent(scenePresence);
4279>>>>>>> avn/ubitvar
4280 count++; 3767 count++;
4281 }); 3768 });
4282 3769
4283 m_scene.StatsReporter.AddAgentUpdates(count); 3770 m_scene.StatsReporter.AddAgentUpdates(count);
4284 } 3771 }
4285
4286<<<<<<< HEAD
4287 /// <summary>
4288 /// Send avatar data for all other root agents to this agent, this agent
4289 /// can be either a child or root
4290 /// </summary>
4291 public void SendOtherAgentsAvatarDataToClient()
4292=======
4293 // sends avatar object to all clients so they cross it into region 3772 // sends avatar object to all clients so they cross it into region
4294 // then sends kills to hide 3773 // then sends kills to hide
4295 public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences) 3774 public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences)
4296>>>>>>> avn/ubitvar
4297 { 3775 {
4298 m_lastSize = Appearance.AvatarSize; 3776 m_lastSize = Appearance.AvatarSize;
4299 int count = 0; 3777 int count = 0;
4300<<<<<<< HEAD
4301 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
4302 {
4303 // only send information about other root agents
4304 if (scenePresence.UUID == UUID)
4305 return;
4306
4307 scenePresence.SendAvatarDataToClient(this);
4308 count++;
4309 });
4310=======
4311>>>>>>> avn/ubitvar
4312
4313 foreach (ScenePresence p in presences) 3778 foreach (ScenePresence p in presences)
4314 { 3779 {
4315 p.ControllingClient.SendAvatarDataImmediate(this); 3780 p.ControllingClient.SendAvatarDataImmediate(this);
@@ -4337,16 +3802,11 @@ no information to check this
4337 /// Send avatar data to an agent. 3802 /// Send avatar data to an agent.
4338 /// </summary> 3803 /// </summary>
4339 /// <param name="avatar"></param> 3804 /// <param name="avatar"></param>
4340 public void SendAvatarDataToClient(ScenePresence avatar) 3805 public void SendAvatarDataToAgent(ScenePresence avatar)
4341 { 3806 {
4342<<<<<<< HEAD
4343 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToClient from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
4344
4345=======
4346 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); 3807 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
4347 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) 3808 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200)
4348 return; 3809 return;
4349>>>>>>> avn/ubitvar
4350 avatar.ControllingClient.SendAvatarDataImmediate(this); 3810 avatar.ControllingClient.SendAvatarDataImmediate(this);
4351 } 3811 }
4352 3812
@@ -4354,18 +3814,14 @@ no information to check this
4354 { 3814 {
4355 avatar.ControllingClient.SendAvatarDataImmediate(this); 3815 avatar.ControllingClient.SendAvatarDataImmediate(this);
4356 } 3816 }
4357 3817
4358 /// <summary> 3818 /// <summary>
4359 /// Send this agent's appearance to all other root and child agents in the scene 3819 /// Send this agent's appearance to all other root and child agents in the scene
4360 /// This agent must be root. 3820 /// This agent must be root.
4361 /// </summary> 3821 /// </summary>
4362 public void SendAppearanceToAllOtherClients() 3822 public void SendAppearanceToAllOtherAgents()
4363 { 3823 {
4364<<<<<<< HEAD
4365// m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherClients: {0} {1}", Name, UUID);
4366=======
4367 // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); 3824 // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID);
4368>>>>>>> avn/ubitvar
4369 3825
4370 // only send update from root agents to other clients; children are only "listening posts" 3826 // only send update from root agents to other clients; children are only "listening posts"
4371 if (IsChildAgent) 3827 if (IsChildAgent)
@@ -4379,51 +3835,21 @@ no information to check this
4379 3835
4380 int count = 0; 3836 int count = 0;
4381 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 3837 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
4382 { 3838 {
4383 // only send information to other root agents 3839 // only send information to other root agents
4384 if (scenePresence.UUID == UUID) 3840 if (scenePresence.UUID == UUID)
4385 return; 3841 return;
4386
4387 SendAppearanceToClient(scenePresence);
4388 count++;
4389 });
4390<<<<<<< HEAD
4391
4392 m_scene.StatsReporter.AddAgentUpdates(count);
4393 }
4394
4395 /// <summary>
4396 /// Send appearance from all other root agents to this agent. this agent
4397 /// can be either root or child
4398 /// </summary>
4399 public void SendOtherAgentsAppearanceToClient()
4400 {
4401// m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToClient {0} {1}", Name, UUID);
4402
4403 int count = 0;
4404 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
4405 {
4406 // only send information about other root agents
4407 if (scenePresence.UUID == UUID)
4408 return;
4409
4410 scenePresence.SendAppearanceToClient(this);
4411 count++;
4412 });
4413 3842
4414======= 3843 SendAppearanceToAgent(scenePresence);
4415>>>>>>> avn/ubitvar 3844 count++;
3845 });
4416 m_scene.StatsReporter.AddAgentUpdates(count); 3846 m_scene.StatsReporter.AddAgentUpdates(count);
4417 } 3847 }
4418 3848
4419 /// <summary> 3849 public void SendAppearanceToAgent(ScenePresence avatar)
4420 /// Send appearance data to an agent.
4421 /// </summary>
4422 /// <param name="avatar"></param>
4423 public void SendAppearanceToClient(ScenePresence avatar)
4424 { 3850 {
4425// m_log.DebugFormat( 3851 // m_log.DebugFormat(
4426// "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); 3852 // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
4427 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) 3853 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200)
4428 return; 3854 return;
4429 SendAppearanceToAgentNF(avatar); 3855 SendAppearanceToAgentNF(avatar);
@@ -4574,81 +4000,6 @@ no information to check this
4574 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) 4000 if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero)
4575 return; 4001 return;
4576 4002
4577<<<<<<< HEAD
4578 if (IsInTransit)
4579 return;
4580
4581 Vector3 pos2 = AbsolutePosition;
4582 Vector3 origPosition = pos2;
4583 Vector3 vel = Velocity;
4584
4585 // Compute the future avatar position.
4586 // If the avatar will be crossing, we force the crossing to happen now
4587 // in the hope that this will make the avatar movement smoother when crossing.
4588 pos2 += vel * 0.05f;
4589
4590 if (m_scene.PositionIsInCurrentRegion(pos2))
4591 return;
4592
4593 m_log.DebugFormat("{0} CheckForBorderCrossing: position outside region. {1} in {2} at pos {3}",
4594 LogHeader, Name, Scene.Name, pos2);
4595
4596 // Disconnect from the current region
4597 bool isFlying = Flying;
4598 RemoveFromPhysicalScene();
4599
4600 // pos2 is the forcasted position so make that the 'current' position so the crossing
4601 // code will move us into the newly addressed region.
4602 m_pos = pos2;
4603
4604 if (CrossToNewRegion())
4605 {
4606 AddToPhysicalScene(isFlying);
4607 }
4608 else
4609 {
4610 // Tried to make crossing happen but it failed.
4611 if (m_requestedSitTargetUUID == UUID.Zero)
4612 {
4613 m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader);
4614
4615 Velocity = Vector3.Zero;
4616 AbsolutePosition = EnforceSanityOnPosition(origPosition);
4617
4618 AddToPhysicalScene(isFlying);
4619 }
4620 }
4621 }
4622
4623 // Given a position, make sure it is within the current region.
4624 // If just outside some border, the returned position will be just inside the border on that side.
4625 private Vector3 EnforceSanityOnPosition(Vector3 origPosition)
4626 {
4627 const float borderFudge = 0.1f;
4628 Vector3 ret = origPosition;
4629
4630 // Sanity checking on the position to make sure it is in the region we couldn't cross from
4631 float extentX = (float)m_scene.RegionInfo.RegionSizeX;
4632 float extentY = (float)m_scene.RegionInfo.RegionSizeY;
4633 IRegionCombinerModule combiner = m_scene.RequestModuleInterface<IRegionCombinerModule>();
4634 if (combiner != null)
4635 {
4636 // If a mega-region, the size could be much bigger
4637 Vector2 megaExtent = combiner.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
4638 extentX = megaExtent.X;
4639 extentY = megaExtent.Y;
4640 }
4641 if (ret.X < 0)
4642 ret.X = borderFudge;
4643 else if (ret.X >= extentX)
4644 ret.X = extentX - borderFudge;
4645 if (ret.Y < 0)
4646 ret.Y = borderFudge;
4647 else if (ret.Y >= extentY)
4648 ret.Y = extentY - borderFudge;
4649
4650 return ret;
4651=======
4652 Vector3 pos2 = AbsolutePosition; 4003 Vector3 pos2 = AbsolutePosition;
4653 Vector3 vel = Velocity; 4004 Vector3 vel = Velocity;
4654 4005
@@ -4710,8 +4061,6 @@ no information to check this
4710 4061
4711 AddToPhysicalScene(isFlying); 4062 AddToPhysicalScene(isFlying);
4712 } 4063 }
4713
4714>>>>>>> avn/ubitvar
4715 } 4064 }
4716 4065
4717 /// <summary> 4066 /// <summary>
@@ -4779,16 +4128,6 @@ no information to check this
4779 // Don't close the agent on this region yet 4128 // Don't close the agent on this region yet
4780 if (handle != Scene.RegionInfo.RegionHandle) 4129 if (handle != Scene.RegionInfo.RegionHandle)
4781 { 4130 {
4782<<<<<<< HEAD
4783 uint x, y;
4784 Util.RegionHandleToRegionLoc(handle, out x, out y);
4785
4786// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
4787// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
4788 float dist = (float)Math.Max(Scene.DefaultDrawDistance,
4789 (float)Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY));
4790 if (Util.IsOutsideView(dist, x, newRegionX, y, newRegionY))
4791=======
4792 Util.RegionHandleToRegionLoc(handle, out x, out y); 4131 Util.RegionHandleToRegionLoc(handle, out x, out y);
4793 if (m_knownChildRegionsSizeInfo.TryGetValue(handle, out regInfo)) 4132 if (m_knownChildRegionsSizeInfo.TryGetValue(handle, out regInfo))
4794 { 4133 {
@@ -4802,7 +4141,6 @@ no information to check this
4802 } 4141 }
4803 } 4142 }
4804 else 4143 else
4805>>>>>>> avn/ubitvar
4806 { 4144 {
4807 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY, 4145 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY,
4808 (int)Constants.RegionSize, (int)Constants.RegionSize, newRegionSizeX, newRegionSizeY)) 4146 (int)Constants.RegionSize, (int)Constants.RegionSize, newRegionSizeX, newRegionSizeY))
@@ -4875,8 +4213,7 @@ no information to check this
4875 return; 4213 return;
4876 4214
4877 CopyFrom(cAgentData); 4215 CopyFrom(cAgentData);
4878 4216
4879 m_updateAgentReceivedAfterTransferEvent.Set();
4880 } 4217 }
4881 4218
4882 private static Vector3 marker = new Vector3(-1f, -1f, -1f); 4219 private static Vector3 marker = new Vector3(-1f, -1f, -1f);
@@ -4895,23 +4232,11 @@ no information to check this
4895 if (!IsChildAgent) 4232 if (!IsChildAgent)
4896 return; 4233 return;
4897 4234
4898<<<<<<< HEAD
4899// m_log.DebugFormat(
4900// "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}",
4901// Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position);
4902
4903 // Find the distance (in meters) between the two regions
4904 // XXX: We cannot use Util.RegionLocToHandle() here because a negative value will silently overflow the
4905 // uint
4906 int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize);
4907 int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize);
4908=======
4909 RegionHandle = cAgentData.RegionHandle; 4235 RegionHandle = cAgentData.RegionHandle;
4910 4236
4911 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); 4237 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY);
4912 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; 4238 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize;
4913 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; 4239 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize;
4914>>>>>>> avn/ubitvar
4915 4240
4916 Vector3 offset = new Vector3(shiftx, shifty, 0f); 4241 Vector3 offset = new Vector3(shiftx, shifty, 0f);
4917 4242
@@ -4919,11 +4244,7 @@ no information to check this
4919 // changes, then start using the agent's drawdistance rather than the 4244 // changes, then start using the agent's drawdistance rather than the
4920 // region's draw distance. 4245 // region's draw distance.
4921 DrawDistance = cAgentData.Far; 4246 DrawDistance = cAgentData.Far;
4922<<<<<<< HEAD
4923 // DrawDistance = Scene.DefaultDrawDistance;
4924=======
4925// DrawDistance = Scene.DefaultDrawDistance; 4247// DrawDistance = Scene.DefaultDrawDistance;
4926>>>>>>> avn/ubitvar
4927 4248
4928 if (cAgentData.Position != marker) // UGH!! 4249 if (cAgentData.Position != marker) // UGH!!
4929 m_pos = cAgentData.Position + offset; 4250 m_pos = cAgentData.Position + offset;
@@ -5038,10 +4359,6 @@ no information to check this
5038 4359
5039 private void CopyFrom(AgentData cAgent) 4360 private void CopyFrom(AgentData cAgent)
5040 { 4361 {
5041<<<<<<< HEAD
5042=======
5043
5044>>>>>>> avn/ubitvar
5045 m_callbackURI = cAgent.CallbackURI; 4362 m_callbackURI = cAgent.CallbackURI;
5046// m_log.DebugFormat( 4363// m_log.DebugFormat(
5047// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", 4364// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
@@ -5060,9 +4377,6 @@ no information to check this
5060 // changes, then start using the agent's drawdistance rather than the 4377 // changes, then start using the agent's drawdistance rather than the
5061 // region's draw distance. 4378 // region's draw distance.
5062 DrawDistance = cAgent.Far; 4379 DrawDistance = cAgent.Far;
5063<<<<<<< HEAD
5064 // DrawDistance = Scene.DefaultDrawDistance;
5065=======
5066 //DrawDistance = Scene.DefaultDrawDistance; 4380 //DrawDistance = Scene.DefaultDrawDistance;
5067 4381
5068 if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0) 4382 if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0)
@@ -5073,7 +4387,6 @@ no information to check this
5073 } 4387 }
5074 KnownRegions = cAgent.ChildrenCapSeeds; 4388 KnownRegions = cAgent.ChildrenCapSeeds;
5075 } 4389 }
5076>>>>>>> avn/ubitvar
5077 4390
5078 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 4391 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
5079 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 4392 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
@@ -5135,35 +4448,10 @@ no information to check this
5135 Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState; 4448 Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState;
5136 4449
5137 if (Scene.AttachmentsModule != null) 4450 if (Scene.AttachmentsModule != null)
5138<<<<<<< HEAD
5139 {
5140 // If the JobEngine is running we can schedule this job now and continue rather than waiting for all
5141 // attachments to copy, which might take a long time in the Hypergrid case as the entire inventory
5142 // graph is inspected for each attachments and assets possibly fetched.
5143 //
5144 // We don't need to worry about a race condition as the job to later start the scripts is also
5145 // JobEngine scheduled and so will always occur after this task.
5146 // XXX: This will not be true if JobEngine ever gets more than one thread.
5147 WorkManager.RunJob(
5148 "CopyAttachments",
5149 o => Scene.AttachmentsModule.CopyAttachments(cAgent, this),
5150 null,
5151 string.Format("Copy attachments for {0} entering {1}", Name, Scene.Name),
5152 true);
5153 }
5154
5155 // This must occur after attachments are copied or scheduled to be copied, as it releases the CompleteMovement() calling thread
5156 // originating from the client completing a teleport. Otherwise, CompleteMovement() code to restart
5157 // script attachments can outrace this thread.
5158 lock (m_originRegionIDAccessLock)
5159 m_originRegionID = cAgent.RegionID;
5160=======
5161 Scene.AttachmentsModule.CopyAttachments(cAgent, this); 4451 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
5162 4452
5163 lock (m_originRegionIDAccessLock) 4453 lock (m_originRegionIDAccessLock)
5164 m_originRegionID = cAgent.RegionID; 4454 m_originRegionID = cAgent.RegionID;
5165
5166>>>>>>> avn/ubitvar
5167 } 4455 }
5168 4456
5169 public bool CopyAgent(out IAgentData agent) 4457 public bool CopyAgent(out IAgentData agent)
@@ -5212,22 +4500,13 @@ no information to check this
5212 if (Appearance.AvatarHeight == 0) 4500 if (Appearance.AvatarHeight == 0)
5213// Appearance.SetHeight(); 4501// Appearance.SetHeight();
5214 Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); 4502 Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f));
5215
5216/*
5217 PhysicsActor = scene.AddAvatar(
5218 LocalId, Firstname + "." + Lastname, pVec,
5219 new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying);
5220*/
5221 4503
5222<<<<<<< HEAD 4504 PhysicsScene scene = m_scene.PhysicsScene;
5223 PhysicsActor = m_scene.PhysicsScene.AddAvatar( 4505 Vector3 pVec = AbsolutePosition;
5224 LocalId, Firstname + "." + Lastname, AbsolutePosition, Velocity, 4506
5225 Appearance.AvatarBoxSize, isFlying);
5226=======
5227 PhysicsActor = scene.AddAvatar( 4507 PhysicsActor = scene.AddAvatar(
5228 LocalId, Firstname + "." + Lastname, pVec, 4508 LocalId, Firstname + "." + Lastname, pVec,
5229 Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); 4509 Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying);
5230>>>>>>> avn/ubitvar
5231 4510
5232 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 4511 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
5233 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 4512 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;