diff options
author | John Hurliman | 2009-10-30 03:01:15 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-30 03:01:15 -0700 |
commit | 8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e (patch) | |
tree | 2e364c6fbcbabb5cf920bb2782b426bee2f5bb01 | |
parent | * Moving parcel media and avatar update packets from the unthrottled category... (diff) | |
download | opensim-SC-8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e.zip opensim-SC-8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e.tar.gz opensim-SC-8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e.tar.bz2 opensim-SC-8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e.tar.xz |
* Fix for a potential race condition in ScenePresence.AbsolutePosition
* Unified the way region handles are stored and used in ScenePresence
* Fixed camera position for child agents
* CheckForSignificantMovement now checks avatar and camera position (both are important for scene prioritization)
* Removing debug code from the previous commit
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 78 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | 4 |
3 files changed, 42 insertions, 42 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b8c99cf..bd75f0c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -4952,8 +4952,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4952 | /// <param name="throttlePacketType">Throttling category for the packet</param> | 4952 | /// <param name="throttlePacketType">Throttling category for the packet</param> |
4953 | protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) | 4953 | protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) |
4954 | { | 4954 | { |
4955 | if (ChildAgentStatus()) | ||
4956 | Thread.Sleep(200); | ||
4957 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); | 4955 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); |
4958 | } | 4956 | } |
4959 | 4957 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9730cd5..6c0d9f2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -79,6 +79,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
79 | private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | 79 | private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); |
80 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); | 80 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
81 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | 81 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); |
82 | /// <summary> | ||
83 | /// Experimentally determined "fudge factor" to make sit-target positions | ||
84 | /// the same as in SecondLife. Fudge factor was tested for 36 different | ||
85 | /// test cases including prims of type box, sphere, cylinder, and torus, | ||
86 | /// with varying parameters for sit target location, prim size, prim | ||
87 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
88 | /// issue #1716 | ||
89 | /// </summary> | ||
90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | ||
82 | 91 | ||
83 | public UUID currentParcelUUID = UUID.Zero; | 92 | public UUID currentParcelUUID = UUID.Zero; |
84 | 93 | ||
@@ -115,18 +124,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | 124 | ||
116 | private float m_sitAvatarHeight = 2.0f; | 125 | private float m_sitAvatarHeight = 2.0f; |
117 | 126 | ||
118 | // experimentally determined "fudge factor" to make sit-target positions | ||
119 | // the same as in SecondLife. Fudge factor was tested for 36 different | ||
120 | // test cases including prims of type box, sphere, cylinder, and torus, | ||
121 | // with varying parameters for sit target location, prim size, prim | ||
122 | // rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
123 | // issue #1716 | ||
124 | private static readonly Vector3 m_sitTargetCorrectionOffset = new Vector3(0.1f, 0.0f, 0.3f); | ||
125 | private float m_godlevel; | 127 | private float m_godlevel; |
126 | 128 | ||
127 | private bool m_invulnerable = true; | 129 | private bool m_invulnerable = true; |
128 | 130 | ||
129 | private Vector3 m_LastChildAgentUpdatePosition; | 131 | private Vector3 m_lastChildAgentUpdatePosition; |
132 | private Vector3 m_lastChildAgentUpdateCamPosition; | ||
130 | 133 | ||
131 | private int m_perfMonMS; | 134 | private int m_perfMonMS; |
132 | 135 | ||
@@ -271,11 +274,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
271 | get { return m_godlevel; } | 274 | get { return m_godlevel; } |
272 | } | 275 | } |
273 | 276 | ||
274 | private readonly ulong m_regionHandle; | ||
275 | |||
276 | public ulong RegionHandle | 277 | public ulong RegionHandle |
277 | { | 278 | { |
278 | get { return m_regionHandle; } | 279 | get { return m_rootRegionHandle; } |
279 | } | 280 | } |
280 | 281 | ||
281 | public Vector3 CameraPosition | 282 | public Vector3 CameraPosition |
@@ -414,31 +415,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
414 | } | 415 | } |
415 | 416 | ||
416 | /// <summary> | 417 | /// <summary> |
417 | /// Absolute position of this avatar in 'region cordinates' | 418 | /// Position of this avatar relative to the region the avatar is in |
418 | /// </summary> | 419 | /// </summary> |
419 | public override Vector3 AbsolutePosition | 420 | public override Vector3 AbsolutePosition |
420 | { | 421 | { |
421 | get | 422 | get |
422 | { | 423 | { |
423 | if (m_physicsActor != null) | 424 | PhysicsActor actor = m_physicsActor; |
424 | { | 425 | if (actor != null) |
425 | m_pos.X = m_physicsActor.Position.X; | 426 | m_pos = actor.Position; |
426 | m_pos.Y = m_physicsActor.Position.Y; | ||
427 | m_pos.Z = m_physicsActor.Position.Z; | ||
428 | } | ||
429 | 427 | ||
430 | return m_parentPosition + m_pos; | 428 | return m_parentPosition + m_pos; |
431 | } | 429 | } |
432 | set | 430 | set |
433 | { | 431 | { |
434 | if (m_physicsActor != null) | 432 | PhysicsActor actor = m_physicsActor; |
433 | if (actor != null) | ||
435 | { | 434 | { |
436 | try | 435 | try |
437 | { | 436 | { |
438 | lock (m_scene.SyncRoot) | 437 | lock (m_scene.SyncRoot) |
439 | { | ||
440 | m_physicsActor.Position = value; | 438 | m_physicsActor.Position = value; |
441 | } | ||
442 | } | 439 | } |
443 | catch (Exception e) | 440 | catch (Exception e) |
444 | { | 441 | { |
@@ -466,8 +463,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | } | 463 | } |
467 | set | 464 | set |
468 | { | 465 | { |
469 | //m_log.DebugFormat("In {0} setting velocity of {1} to {2}", m_scene.RegionInfo.RegionName, Name, value); | ||
470 | |||
471 | PhysicsActor actor = m_physicsActor; | 466 | PhysicsActor actor = m_physicsActor; |
472 | if (actor != null) | 467 | if (actor != null) |
473 | { | 468 | { |
@@ -626,7 +621,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
626 | { | 621 | { |
627 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 622 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
628 | CreateSceneViewer(); | 623 | CreateSceneViewer(); |
629 | m_regionHandle = reginfo.RegionHandle; | 624 | m_rootRegionHandle = reginfo.RegionHandle; |
630 | m_controllingClient = client; | 625 | m_controllingClient = client; |
631 | m_firstname = m_controllingClient.FirstName; | 626 | m_firstname = m_controllingClient.FirstName; |
632 | m_lastname = m_controllingClient.LastName; | 627 | m_lastname = m_controllingClient.LastName; |
@@ -780,6 +775,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
780 | if (gm != null) | 775 | if (gm != null) |
781 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 776 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
782 | 777 | ||
778 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | ||
779 | |||
783 | m_scene.SetRootAgentScene(m_uuid); | 780 | m_scene.SetRootAgentScene(m_uuid); |
784 | 781 | ||
785 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 782 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
@@ -810,7 +807,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
810 | pos = emergencyPos; | 807 | pos = emergencyPos; |
811 | } | 808 | } |
812 | 809 | ||
813 | |||
814 | float localAVHeight = 1.56f; | 810 | float localAVHeight = 1.56f; |
815 | if (m_avHeight != 127.0f) | 811 | if (m_avHeight != 127.0f) |
816 | { | 812 | { |
@@ -905,6 +901,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
905 | m_isChildAgent = true; | 901 | m_isChildAgent = true; |
906 | m_scene.SwapRootAgentCount(true); | 902 | m_scene.SwapRootAgentCount(true); |
907 | RemoveFromPhysicalScene(); | 903 | RemoveFromPhysicalScene(); |
904 | |||
905 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into | ||
908 | 906 | ||
909 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 907 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
910 | } | 908 | } |
@@ -1823,7 +1821,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1823 | //Quaternion result = (sitTargetOrient * vq) * nq; | 1821 | //Quaternion result = (sitTargetOrient * vq) * nq; |
1824 | 1822 | ||
1825 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1823 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1826 | m_pos += m_sitTargetCorrectionOffset; | 1824 | m_pos += SIT_TARGET_ADJUSTMENT; |
1827 | m_bodyRot = sitTargetOrient; | 1825 | m_bodyRot = sitTargetOrient; |
1828 | //Rotation = sitTargetOrient; | 1826 | //Rotation = sitTargetOrient; |
1829 | m_parentPosition = part.AbsolutePosition; | 1827 | m_parentPosition = part.AbsolutePosition; |
@@ -2374,7 +2372,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2374 | 2372 | ||
2375 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); | 2373 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); |
2376 | 2374 | ||
2377 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 2375 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, |
2378 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); | 2376 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); |
2379 | 2377 | ||
2380 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2378 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
@@ -2739,7 +2737,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2739 | } | 2737 | } |
2740 | 2738 | ||
2741 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2739 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
2742 | if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance) | 2740 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2741 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | ||
2743 | { | 2742 | { |
2744 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2743 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2745 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2744 | cadu.ActiveGroupID = UUID.Zero.Guid; |
@@ -2753,7 +2752,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2753 | cadu.godlevel = m_godlevel; | 2752 | cadu.godlevel = m_godlevel; |
2754 | cadu.GroupAccess = 0; | 2753 | cadu.GroupAccess = 0; |
2755 | cadu.Position = new sLLVector3(AbsolutePosition); | 2754 | cadu.Position = new sLLVector3(AbsolutePosition); |
2756 | cadu.regionHandle = m_scene.RegionInfo.RegionHandle; | 2755 | cadu.regionHandle = m_rootRegionHandle; |
2757 | float multiplier = 1; | 2756 | float multiplier = 1; |
2758 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2757 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
2759 | if (innacurateNeighbors != 0) | 2758 | if (innacurateNeighbors != 0) |
@@ -2774,7 +2773,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2774 | 2773 | ||
2775 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2774 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2776 | 2775 | ||
2777 | m_LastChildAgentUpdatePosition = AbsolutePosition; | 2776 | m_lastChildAgentUpdatePosition = AbsolutePosition; |
2777 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2778 | } | 2778 | } |
2779 | } | 2779 | } |
2780 | 2780 | ||
@@ -3027,9 +3027,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3027 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3027 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; |
3028 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3028 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; |
3029 | 3029 | ||
3030 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | ||
3031 | |||
3030 | m_DrawDistance = cAgentData.Far; | 3032 | m_DrawDistance = cAgentData.Far; |
3031 | if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! | 3033 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
3032 | m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); | 3034 | m_pos = cAgentData.Position + offset; |
3033 | 3035 | ||
3034 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | 3036 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) |
3035 | { | 3037 | { |
@@ -3037,8 +3039,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3037 | ReprioritizeUpdates(); | 3039 | ReprioritizeUpdates(); |
3038 | } | 3040 | } |
3039 | 3041 | ||
3040 | // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region | 3042 | m_CameraCenter = cAgentData.Center + offset; |
3041 | m_CameraCenter = cAgentData.Center; | ||
3042 | 3043 | ||
3043 | m_avHeight = cAgentData.Size.Z; | 3044 | m_avHeight = cAgentData.Size.Z; |
3044 | //SetHeight(cAgentData.AVHeight); | 3045 | //SetHeight(cAgentData.AVHeight); |
@@ -3051,16 +3052,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3051 | m_sceneViewer.Reset(); | 3052 | m_sceneViewer.Reset(); |
3052 | 3053 | ||
3053 | //cAgentData.AVHeight; | 3054 | //cAgentData.AVHeight; |
3054 | //cAgentData.regionHandle; | 3055 | m_rootRegionHandle = cAgentData.RegionHandle; |
3055 | //m_velocity = cAgentData.Velocity; | 3056 | //m_velocity = cAgentData.Velocity; |
3056 | } | 3057 | } |
3057 | 3058 | ||
3058 | public void CopyTo(AgentData cAgent) | 3059 | public void CopyTo(AgentData cAgent) |
3059 | { | 3060 | { |
3060 | cAgent.AgentID = UUID; | 3061 | cAgent.AgentID = UUID; |
3061 | cAgent.RegionHandle = m_scene.RegionInfo.RegionHandle; | 3062 | cAgent.RegionHandle = m_rootRegionHandle; |
3062 | 3063 | ||
3063 | cAgent.Position = m_pos; | 3064 | cAgent.Position = AbsolutePosition; |
3064 | cAgent.Velocity = m_velocity; | 3065 | cAgent.Velocity = m_velocity; |
3065 | cAgent.Center = m_CameraCenter; | 3066 | cAgent.Center = m_CameraCenter; |
3066 | // Don't copy the size; it is inferred from apearance parameters | 3067 | // Don't copy the size; it is inferred from apearance parameters |
@@ -3157,7 +3158,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3157 | 3158 | ||
3158 | public void CopyFrom(AgentData cAgent) | 3159 | public void CopyFrom(AgentData cAgent) |
3159 | { | 3160 | { |
3160 | m_rootRegionHandle= cAgent.RegionHandle; | 3161 | m_rootRegionHandle = cAgent.RegionHandle; |
3162 | |||
3161 | m_callbackURI = cAgent.CallbackURI; | 3163 | m_callbackURI = cAgent.CallbackURI; |
3162 | 3164 | ||
3163 | m_pos = cAgent.Position; | 3165 | m_pos = cAgent.Position; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 19c0fea..f495022 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | 219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); |
220 | 220 | ||
221 | // Accepts 0 but rejects Constants.RegionSize | 221 | // Accepts 0 but rejects Constants.RegionSize |
222 | Vector3 pos = new Vector3(0,Constants.RegionSize-1,0); | 222 | Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); |
223 | presence.MakeRootAgent(pos,true); | 223 | presence.MakeRootAgent(pos,true); |
224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | 224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); |
225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | 225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); |
@@ -246,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
246 | scene2.AddNewClient(testclient); | 246 | scene2.AddNewClient(testclient); |
247 | 247 | ||
248 | ScenePresence presence = scene.GetScenePresence(agent1); | 248 | ScenePresence presence = scene.GetScenePresence(agent1); |
249 | presence.MakeRootAgent(new Vector3(0,Constants.RegionSize-1,0), true); | 249 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); |
250 | 250 | ||
251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | 251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); |
252 | 252 | ||