aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs20
1 files changed, 17 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5b86735..feab35c 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,27 @@ 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
2409 // not changing.
2410 // If there is a mismatch between distance travelled and expected
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 absoluteDistanceError = (float)Math.Abs(Vector3.Distance(m_pos, expectedPosition));
2419
2420
2408 if (m_velocity.Length() < 0.01f 2421 if (m_velocity.Length() < 0.01f
2409 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f 2422 || absoluteDistanceError > 0.25f // arbitrary distance error threshold
2410 || currentTick - lastTerseUpdateToAllClientsTick > 1500) 2423 || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f)
2411 { 2424 {
2412 m_perfMonMS = currentTick; 2425 m_perfMonMS = currentTick;
2413 lastVelocitySentToAllClients = m_velocity; 2426 lastVelocitySentToAllClients = m_velocity;
2414 lastTerseUpdateToAllClientsTick = currentTick; 2427 lastTerseUpdateToAllClientsTick = currentTick;
2428 lastPositionSentToAllClients = m_pos;
2415 2429
2416 m_scene.ForEachClient(SendTerseUpdateToClient); 2430 m_scene.ForEachClient(SendTerseUpdateToClient);
2417 2431