Merge branch 'master' into caps
commit
a0f3b23065
|
@ -2395,6 +2395,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
// vars to support reduced update frequency when velocity is unchanged
|
||||
private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
|
||||
private Vector3 lastPositionSentToAllClients = Vector3.Zero;
|
||||
private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount();
|
||||
|
||||
/// <summary>
|
||||
|
@ -2404,14 +2405,29 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
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)
|
||||
// Decrease update frequency when avatar is moving but velocity is
|
||||
// not changing.
|
||||
// If there is a mismatch between distance travelled and expected
|
||||
// distance based on last velocity sent and velocity hasnt changed,
|
||||
// then send a new terse update
|
||||
|
||||
float timeSinceLastUpdate = (currentTick - lastTerseUpdateToAllClientsTick) * 0.001f;
|
||||
|
||||
Vector3 expectedPosition = lastPositionSentToAllClients + lastVelocitySentToAllClients * timeSinceLastUpdate;
|
||||
|
||||
float distanceError = Vector3.Distance(OffsetPosition, expectedPosition);
|
||||
|
||||
float speed = Velocity.Length();
|
||||
float velocidyDiff = Vector3.Distance(lastVelocitySentToAllClients, Velocity);
|
||||
|
||||
if (speed < 0.01f // allow rotation updates if avatar position is unchanged
|
||||
|| Math.Abs(distanceError) > 0.25f // arbitrary distance error threshold
|
||||
|| velocidyDiff > 0.01f) // did velocity change from last update?
|
||||
{
|
||||
m_perfMonMS = currentTick;
|
||||
lastVelocitySentToAllClients = m_velocity;
|
||||
lastVelocitySentToAllClients = Velocity;
|
||||
lastTerseUpdateToAllClientsTick = currentTick;
|
||||
lastPositionSentToAllClients = OffsetPosition;
|
||||
|
||||
m_scene.ForEachClient(SendTerseUpdateToClient);
|
||||
|
||||
|
|
Loading…
Reference in New Issue