aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs120
1 files changed, 41 insertions, 79 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 56fd606..b6172d2 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1186,16 +1186,6 @@ namespace OpenSim.Region.Framework.Scenes
1186 if (gm != null) 1186 if (gm != null)
1187 Grouptitle = gm.GetGroupTitle(m_uuid); 1187 Grouptitle = gm.GetGroupTitle(m_uuid);
1188 1188
1189
1190 if ((m_teleportFlags & TeleportFlags.ViaHGLogin) != 0)
1191 {
1192 // The avatar is arriving from another grid. This means that we may have changed the
1193 // avatar's name to or from the special Hypergrid format ("First.Last @grid.example.com").
1194 // Unfortunately, due to a viewer bug, viewers don't always show the new name.
1195 // But we have a trick that can force them to update the name anyway.
1196// ForceViewersUpdateName();
1197 }
1198
1199 m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1189 m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1200 1190
1201 RegionHandle = m_scene.RegionInfo.RegionHandle; 1191 RegionHandle = m_scene.RegionInfo.RegionHandle;
@@ -1903,12 +1893,6 @@ namespace OpenSim.Region.Framework.Scenes
1903 1893
1904 if (!IsChildAgent) 1894 if (!IsChildAgent)
1905 { 1895 {
1906
1907 // ValidateAndSendAppearanceAndAgentData();
1908
1909 // do it here in line
1910 // so sequence is clear
1911
1912 // verify baked textures and cache 1896 // verify baked textures and cache
1913 bool cachedbaked = false; 1897 bool cachedbaked = false;
1914 1898
@@ -3454,40 +3438,52 @@ namespace OpenSim.Region.Framework.Scenes
3454 3438
3455 #region Overridden Methods 3439 #region Overridden Methods
3456 3440
3441 const float ROTATION_TOLERANCE = 0.01f;
3442 const float VELOCITY_TOLERANCE = 0.1f;
3443 const float LOWVELOCITYSQ = 0.1f;
3444 const float POSITION_LARGETOLERANCE = 5f;
3445 const float POSITION_SMALLTOLERANCE = 0.05f;
3446
3457 public override void Update() 3447 public override void Update()
3458 { 3448 {
3459 const float ROTATION_TOLERANCE = 0.01f; 3449 if(IsChildAgent || IsDeleted)
3460 const float VELOCITY_TOLERANCE = 0.001f; 3450 return;
3461 const float POSITION_TOLERANCE = 0.05f;
3462 3451
3463 if (IsChildAgent == false) 3452 CheckForBorderCrossing();
3464 {
3465 CheckForBorderCrossing();
3466 3453
3467 if (IsInTransit) 3454 if (IsInTransit || IsLoggingIn)
3468 return; 3455 return;
3456
3457 if (Appearance.AvatarSize != m_lastSize)
3458 SendAvatarDataToAllAgents();
3459
3460 if (!IsSatOnObject)
3461 {
3462 // this does need to be more complex later
3463 Vector3 vel = Velocity;
3464 Vector3 dpos = m_pos - m_lastPosition;
3465 if( Math.Abs(vel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE ||
3466 Math.Abs(vel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE ||
3467 Math.Abs(vel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE ||
3469 3468
3470 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 3469 Math.Abs(m_bodyRot.X - m_lastRotation.X) > ROTATION_TOLERANCE ||
3471 // grab the latest PhysicsActor velocity, whereas m_velocity is often 3470 Math.Abs(m_bodyRot.Y - m_lastRotation.Y) > ROTATION_TOLERANCE ||
3472 // storing a requested force instead of an actual traveling velocity 3471 Math.Abs(m_bodyRot.Z - m_lastRotation.Z) > ROTATION_TOLERANCE ||
3473 if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn)
3474 SendAvatarDataToAllAgents();
3475 3472
3476 if (!IsSatOnObject && ( 3473 Math.Abs(dpos.X) > POSITION_LARGETOLERANCE ||
3477 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || 3474 Math.Abs(dpos.Y) > POSITION_LARGETOLERANCE ||
3478 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 3475 Math.Abs(dpos.Z) > POSITION_LARGETOLERANCE ||
3479 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) 3476
3477 ( (Math.Abs(dpos.X) > POSITION_SMALLTOLERANCE ||
3478 Math.Abs(dpos.Y) > POSITION_SMALLTOLERANCE ||
3479 Math.Abs(dpos.Z) > POSITION_SMALLTOLERANCE)
3480 && vel.LengthSquared() < LOWVELOCITYSQ
3481 ))
3480 { 3482 {
3481 SendTerseUpdateToAllClients(); 3483 SendTerseUpdateToAllClients();
3482
3483 // Update the "last" values
3484 m_lastPosition = m_pos;
3485 m_lastRotation = Rotation;
3486 m_lastVelocity = Velocity;
3487 } 3484 }
3488
3489 CheckForSignificantMovement(); // sends update to the modules.
3490 } 3485 }
3486 CheckForSignificantMovement();
3491 } 3487 }
3492 3488
3493 #endregion 3489 #endregion
@@ -3576,50 +3572,16 @@ namespace OpenSim.Region.Framework.Scenes
3576 } 3572 }
3577 } 3573 }
3578 3574
3579
3580 // vars to support reduced update frequency when velocity is unchanged
3581 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
3582 private Vector3 lastPositionSentToAllClients = Vector3.Zero;
3583 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
3584
3585 /// <summary> 3575 /// <summary>
3586 /// Send a location/velocity/accelleration update to all agents in scene 3576 /// Send a location/velocity/accelleration update to all agents in scene
3587 /// </summary> 3577 /// </summary>
3588 public void SendTerseUpdateToAllClients() 3578 public void SendTerseUpdateToAllClients()
3589 { 3579 {
3590 int currentTick = Util.EnvironmentTickCount(); 3580 m_scene.ForEachScenePresence(SendTerseUpdateToAgent);
3591 3581 // Update the "last" values
3592 // Decrease update frequency when avatar is moving but velocity is 3582 m_lastPosition = m_pos;
3593 // not changing. 3583 m_lastRotation = m_bodyRot;
3594 // If there is a mismatch between distance travelled and expected 3584 m_lastVelocity = Velocity;
3595 // distance based on last velocity sent and velocity hasnt changed,
3596 // then send a new terse update
3597
3598 float timeSinceLastUpdate = (currentTick - lastTerseUpdateToAllClientsTick) * 0.001f;
3599
3600 Vector3 expectedPosition = lastPositionSentToAllClients + lastVelocitySentToAllClients * timeSinceLastUpdate;
3601
3602 float distanceError = Vector3.Distance(OffsetPosition, expectedPosition);
3603
3604 float speed = Velocity.Length();
3605 float velocityDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity);
3606
3607 // assuming 5 ms. worst case precision for timer, use 2x that
3608 // for distance error threshold
3609 float distanceErrorThreshold = speed * 0.01f;
3610
3611 if (speed < 0.01f // allow rotation updates if avatar position is unchanged
3612 || Math.Abs(distanceError) > distanceErrorThreshold
3613 || velocityDiff > 0.01f) // did velocity change from last update?
3614 {
3615 lastVelocitySentToAllClients = Velocity;
3616 lastTerseUpdateToAllClientsTick = currentTick;
3617 lastPositionSentToAllClients = OffsetPosition;
3618
3619 // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
3620// m_scene.ForEachClient(SendTerseUpdateToClient);
3621 m_scene.ForEachScenePresence(SendTerseUpdateToAgent);
3622 }
3623 TriggerScenePresenceUpdated(); 3585 TriggerScenePresenceUpdated();
3624 } 3586 }
3625 3587