aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs26
1 files changed, 21 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5b86735..1e90d56 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2395,6 +2395,7 @@ namespace OpenSim.Region.Framework.Scenes
2395 2395
2396 // vars to support reduced update frequency when velocity is unchanged 2396 // vars to support reduced update frequency when velocity is unchanged
2397 private Vector3 lastVelocitySentToAllClients = Vector3.Zero; 2397 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
2398 private Vector3 lastPositionSentToAllClients = Vector3.Zero;
2398 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount(); 2399 private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
2399 2400
2400 /// <summary> 2401 /// <summary>
@@ -2404,14 +2405,29 @@ namespace OpenSim.Region.Framework.Scenes
2404 { 2405 {
2405 int currentTick = Util.EnvironmentTickCount(); 2406 int currentTick = Util.EnvironmentTickCount();
2406 2407
2407 // decrease update frequency when avatar is moving but velocity is not changing 2408 // Decrease update frequency when avatar is moving but velocity is
2408 if (m_velocity.Length() < 0.01f 2409 // not changing.
2409 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f 2410 // If there is a mismatch between distance travelled and expected
2410 || currentTick - lastTerseUpdateToAllClientsTick > 1500) 2411 // distance based on last velocity sent and velocity hasnt changed,
2412 // then send a new terse update
2413
2414 float timeSinceLastUpdate = (currentTick - lastTerseUpdateToAllClientsTick) * 0.001f;
2415
2416 Vector3 expectedPosition = lastPositionSentToAllClients + lastVelocitySentToAllClients * timeSinceLastUpdate;
2417
2418 float distanceError = Vector3.Distance(OffsetPosition, expectedPosition);
2419
2420 float speed = Velocity.Length();
2421 float velocidyDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity);
2422
2423 if (speed < 0.01f // allow rotation updates if avatar position is unchanged
2424 || Math.Abs(distanceError) > 0.25f // arbitrary distance error threshold
2425 || velocidyDiff > 0.01f) // did velocity change from last update?
2411 { 2426 {
2412 m_perfMonMS = currentTick; 2427 m_perfMonMS = currentTick;
2413 lastVelocitySentToAllClients = m_velocity; 2428 lastVelocitySentToAllClients = Velocity;
2414 lastTerseUpdateToAllClientsTick = currentTick; 2429 lastTerseUpdateToAllClientsTick = currentTick;
2430 lastPositionSentToAllClients = OffsetPosition;
2415 2431
2416 m_scene.ForEachClient(SendTerseUpdateToClient); 2432 m_scene.ForEachClient(SendTerseUpdateToClient);
2417 2433