aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs41
1 files changed, 35 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 553b575..079223d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -253,6 +253,16 @@ namespace OpenSim.Region.Framework.Scenes
253 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 253 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
254 254
255 /// <summary> 255 /// <summary>
256 /// Copy of the script states while the agent is in transit. This state may
257 /// need to be placed back in case of transfer fail.
258 /// </summary>
259 public List<string> InTransitScriptStates
260 {
261 get { return m_InTransitScriptStates; }
262 }
263 private List<string> m_InTransitScriptStates = new List<string>();
264
265 /// <summary>
256 /// Implemented Control Flags 266 /// Implemented Control Flags
257 /// </summary> 267 /// </summary>
258 private enum Dir_ControlFlags 268 private enum Dir_ControlFlags
@@ -2812,6 +2822,7 @@ namespace OpenSim.Region.Framework.Scenes
2812 2822
2813 // vars to support reduced update frequency when velocity is unchanged 2823 // vars to support reduced update frequency when velocity is unchanged
2814 private Vector3 lastVelocitySentToAllClients = Vector3.Zero; 2824 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
2825 private Vector3 lastPositionSentToAllClients = Vector3.Zero;
2815 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount(); 2826 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
2816 2827
2817 /// <summary> 2828 /// <summary>
@@ -2821,14 +2832,29 @@ namespace OpenSim.Region.Framework.Scenes
2821 { 2832 {
2822 int currentTick = Util.EnvironmentTickCount(); 2833 int currentTick = Util.EnvironmentTickCount();
2823 2834
2824 // decrease update frequency when avatar is moving but velocity is not changing 2835 // Decrease update frequency when avatar is moving but velocity is
2825 if (m_velocity.Length() < 0.01f 2836 // not changing.
2826 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f 2837 // If there is a mismatch between distance travelled and expected
2827 || currentTick - lastTerseUpdateToAllClientsTick > 1500) 2838 // distance based on last velocity sent and velocity hasnt changed,
2839 // then send a new terse update
2840
2841 float timeSinceLastUpdate = (currentTick - lastTerseUpdateToAllClientsTick) * 0.001f;
2842
2843 Vector3 expectedPosition = lastPositionSentToAllClients + lastVelocitySentToAllClients * timeSinceLastUpdate;
2844
2845 float distanceError = Vector3.Distance(OffsetPosition, expectedPosition);
2846
2847 float speed = Velocity.Length();
2848 float velocidyDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity);
2849
2850 if (speed < 0.01f // allow rotation updates if avatar position is unchanged
2851 || Math.Abs(distanceError) > 0.25f // arbitrary distance error threshold
2852 || velocidyDiff > 0.01f) // did velocity change from last update?
2828 { 2853 {
2829 m_perfMonMS = currentTick; 2854 m_perfMonMS = currentTick;
2830 lastVelocitySentToAllClients = m_velocity; 2855 lastVelocitySentToAllClients = Velocity;
2831 lastTerseUpdateToAllClientsTick = currentTick; 2856 lastTerseUpdateToAllClientsTick = currentTick;
2857 lastPositionSentToAllClients = OffsetPosition;
2832 2858
2833 m_scene.ForEachClient(SendTerseUpdateToClient); 2859 m_scene.ForEachClient(SendTerseUpdateToClient);
2834 2860
@@ -3543,6 +3569,7 @@ namespace OpenSim.Region.Framework.Scenes
3543 cAgent.AttachmentObjects = new List<ISceneObject>(); 3569 cAgent.AttachmentObjects = new List<ISceneObject>();
3544 cAgent.AttachmentObjectStates = new List<string>(); 3570 cAgent.AttachmentObjectStates = new List<string>();
3545 IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); 3571 IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3572 m_InTransitScriptStates.Clear();
3546 foreach (SceneObjectGroup sog in m_attachments) 3573 foreach (SceneObjectGroup sog in m_attachments)
3547 { 3574 {
3548 // We need to make a copy and pass that copy 3575 // We need to make a copy and pass that copy
@@ -3552,7 +3579,9 @@ namespace OpenSim.Region.Framework.Scenes
3552 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; 3579 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3553 ((SceneObjectGroup)clone).RootPart.IsAttachment = false; 3580 ((SceneObjectGroup)clone).RootPart.IsAttachment = false;
3554 cAgent.AttachmentObjects.Add(clone); 3581 cAgent.AttachmentObjects.Add(clone);
3555 cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot()); 3582 string state = sog.GetStateSnapshot();
3583 cAgent.AttachmentObjectStates.Add(state);
3584 m_InTransitScriptStates.Add(state);
3556 // Let's remove the scripts of the original object here 3585 // Let's remove the scripts of the original object here
3557 sog.RemoveScriptInstances(true); 3586 sog.RemoveScriptInstances(true);
3558 } 3587 }