network traffic reduction - decrease update frequency for moving avatars when velocity is unchanged
parent
1505fbb647
commit
16f6f55f2d
|
@ -2340,12 +2340,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
#region Update Client(s)
|
#region Update Client(s)
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a location update to the client connected to this scenePresence
|
/// Sends a location update to the client connected to this scenePresence
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
public void SendTerseUpdateToClient(IClientAPI remoteClient)
|
public void SendTerseUpdateToClient(IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
|
|
||||||
// If the client is inactive, it's getting its updates from another
|
// If the client is inactive, it's getting its updates from another
|
||||||
// server.
|
// server.
|
||||||
if (remoteClient.IsActive)
|
if (remoteClient.IsActive)
|
||||||
|
@ -2367,17 +2369,32 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// vars to support reduced update frequency when velocity is unchanged
|
||||||
|
private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
|
||||||
|
private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send a location/velocity/accelleration update to all agents in scene
|
/// Send a location/velocity/accelleration update to all agents in scene
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendTerseUpdateToAllClients()
|
public void SendTerseUpdateToAllClients()
|
||||||
{
|
{
|
||||||
m_perfMonMS = Util.EnvironmentTickCount();
|
int currentTick = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
|
// decrease update frequency when avatar is moving but velocity is not changing
|
||||||
|
if (m_velocity.Length() < 0.01f
|
||||||
|
|| Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f
|
||||||
|
|| currentTick - lastTerseUpdateToAllClientsTick > 1500)
|
||||||
|
{
|
||||||
|
m_perfMonMS = currentTick;
|
||||||
|
lastVelocitySentToAllClients = m_velocity;
|
||||||
|
lastTerseUpdateToAllClientsTick = currentTick;
|
||||||
|
|
||||||
m_scene.ForEachClient(SendTerseUpdateToClient);
|
m_scene.ForEachClient(SendTerseUpdateToClient);
|
||||||
|
|
||||||
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
|
public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
|
||||||
{
|
{
|
||||||
|
@ -3268,10 +3285,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
m_updateflag = true;
|
m_updateflag = true;
|
||||||
|
|
||||||
// The magic constant 0.95f seems to make walking feel less jerky,
|
Velocity = force;
|
||||||
// probably because it hackishly accounts for the overall latency of
|
|
||||||
// these Velocity updates -- Diva
|
|
||||||
Velocity = force * .95F;
|
|
||||||
|
|
||||||
m_forceToApply = null;
|
m_forceToApply = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue