This commit is contained in:
UbitUmarov
2017-07-20 11:30:12 +01:00
60 changed files with 2493 additions and 41860 deletions

View File

@@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden
PollServiceMeshEventArgs args;
if (m_pollservices.TryGetValue(user, out args))
{
args.UpdateThrottle(imagethrottle, p);
args.UpdateThrottle(imagethrottle);
}
}
@@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden
base(null, uri, null, null, null, null, pId, int.MaxValue)
{
m_scene = scene;
m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId);
m_throttler = new MeshCapsDataThrottler(100000);
// x is request id, y is userid
HasEvents = (x, y) =>
{
lock (responses)
{
bool ret = m_throttler.hasEvents(x, responses);
m_throttler.ProcessTime();
return ret;
}
@@ -271,8 +270,8 @@ namespace OpenSim.Region.ClientStack.Linden
}
finally
{
m_throttler.ProcessTime();
responses.Remove(x);
m_throttler.PassTime();
}
}
};
@@ -285,6 +284,7 @@ namespace OpenSim.Region.ClientStack.Linden
reqinfo.request = y;
m_queue.Enqueue(reqinfo);
m_throttler.PassTime();
};
// this should never happen except possible on shutdown
@@ -364,12 +364,15 @@ namespace OpenSim.Region.ClientStack.Linden
};
}
m_throttler.ProcessTime();
m_throttler.PassTime();
}
internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
internal void UpdateThrottle(int pthrottle)
{
m_throttler.UpdateThrottle(pimagethrottle, p);
int tmp = 2 * pthrottle;
if(tmp < 10000)
tmp = 10000;
m_throttler.ThrottleBytes = tmp;
}
}
@@ -423,24 +426,15 @@ namespace OpenSim.Region.ClientStack.Linden
internal sealed class MeshCapsDataThrottler
{
private double lastTimeElapsed = 0;
private double BytesSent = 0;
private volatile int currenttime = 0;
private volatile int lastTimeElapsed = 0;
private volatile int BytesSent = 0;
private int CapSetThrottle = 0;
private readonly Scene m_scene;
private ThrottleOutPacketType Throttle;
private readonly UUID User;
public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser)
public MeshCapsDataThrottler(int pBytes)
{
if(pBytes < 10000)
pBytes = 10000;
ThrottleBytes = pBytes;
if(ThrottleBytes < 10000)
ThrottleBytes = 10000;
lastTimeElapsed = Util.EnvironmentTickCount();
Throttle = ThrottleOutPacketType.Asset;
m_scene = pScene;
User = puser;
lastTimeElapsed = Util.GetTimeStampMS();
}
public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
@@ -470,46 +464,22 @@ namespace OpenSim.Region.ClientStack.Linden
return haskey;
}
public void ProcessTime()
public void PassTime()
{
PassTime();
}
private void PassTime()
double currenttime = Util.GetTimeStampMS();
double timeElapsed = currenttime - lastTimeElapsed;
if(timeElapsed < 50.0)
return;
int add = (int)(ThrottleBytes * timeElapsed * 0.001);
if (add >= 1000)
{
currenttime = Util.EnvironmentTickCount();
int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
if (timeElapsed >= 100)
{
lastTimeElapsed = currenttime;
BytesSent -= (ThrottleBytes * timeElapsed / 1000);
BytesSent -= add;
if (BytesSent < 0) BytesSent = 0;
}
}
private void AlterThrottle(int setting, ScenePresence p)
{
p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
public int ThrottleBytes;
}
public int ThrottleBytes
{
get { return CapSetThrottle; }
set
{
if (value > 10000)
CapSetThrottle = value;
else
CapSetThrottle = 10000;
}
}
internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
{
// Client set throttle !
CapSetThrottle = 2 * pimagethrottle;
ProcessTime();
}
}
}
}

View File

@@ -221,7 +221,7 @@ namespace OpenSim.Region.ClientStack.Linden
private HashSet<UUID> dropedResponses = new HashSet<UUID>();
private Scene m_scene;
private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000);
private CapsDataThrottler m_throttler = new CapsDataThrottler(100000);
public PollServiceTextureEventArgs(UUID pId, Scene scene) :
base(null, "", null, null, null, null, pId, int.MaxValue)
{
@@ -232,7 +232,6 @@ namespace OpenSim.Region.ClientStack.Linden
lock (responses)
{
bool ret = m_throttler.hasEvents(x, responses);
m_throttler.ProcessTime();
return ret;
}
@@ -258,6 +257,7 @@ namespace OpenSim.Region.ClientStack.Linden
finally
{
responses.Remove(x);
m_throttler.PassTime();
}
}
};
@@ -282,6 +282,7 @@ namespace OpenSim.Region.ClientStack.Linden
}
}
m_queue.Enqueue(reqinfo);
m_throttler.PassTime();
};
// this should never happen except possible on shutdown
@@ -381,14 +382,15 @@ namespace OpenSim.Region.ClientStack.Linden
response = response
};
}
m_throttler.ProcessTime();
m_throttler.PassTime();
}
internal void UpdateThrottle(int pimagethrottle)
{
m_throttler.ThrottleBytes = 2 * pimagethrottle;
if(m_throttler.ThrottleBytes < 10000)
m_throttler.ThrottleBytes = 10000;
int tmp = 2 * pimagethrottle;
if(tmp < 10000)
tmp = 10000;
m_throttler.ThrottleBytes = tmp;
}
}
@@ -456,15 +458,14 @@ namespace OpenSim.Region.ClientStack.Linden
internal sealed class CapsDataThrottler
{
private volatile int currenttime = 0;
private volatile int lastTimeElapsed = 0;
private double lastTimeElapsed = 0;
private volatile int BytesSent = 0;
public CapsDataThrottler(int pBytes, int max, int min)
public CapsDataThrottler(int pBytes)
{
if(pBytes < 10000)
pBytes = 10000;
ThrottleBytes = pBytes;
if(ThrottleBytes < 10000)
ThrottleBytes = 10000;
lastTimeElapsed = Util.EnvironmentTickCount();
lastTimeElapsed = Util.GetTimeStampMS();
}
public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses)
{
@@ -497,20 +498,17 @@ namespace OpenSim.Region.ClientStack.Linden
return haskey;
}
public void ProcessTime()
public void PassTime()
{
PassTime();
}
private void PassTime()
double currenttime = Util.GetTimeStampMS();
double timeElapsed = currenttime - lastTimeElapsed;
if(timeElapsed < 50.0)
return;
int add = (int)(ThrottleBytes * timeElapsed * 0.001);
if (add >= 1000)
{
currenttime = Util.EnvironmentTickCount();
int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
//processTimeBasedActions(responses);
if (timeElapsed >= 100)
{
lastTimeElapsed = currenttime;
BytesSent -= (ThrottleBytes * timeElapsed / 1000);
BytesSent -= add;
if (BytesSent < 0) BytesSent = 0;
}
}

View File

@@ -4137,6 +4137,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Vector3 mypos = Vector3.Zero;
ScenePresence mysp = (ScenePresence)SceneAgent;
bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
// we should have a presence
if(mysp == null)
return;
@@ -4151,8 +4152,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
while (maxUpdatesBytes > 0)
{
lock (m_entityUpdates.SyncRoot)
if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
break;
{
if(orderedDequeue)
{
if (!m_entityUpdates.TryOrderedDequeue(out update, out timeinqueue))
break;
}
else
{
if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
break;
}
}
PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
@@ -4850,6 +4861,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
// new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
EntityUpdate iupdate;
Int32 timeinqueue; // this is just debugging code & can be dropped later
@@ -4857,8 +4869,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
while (maxUpdateBytes > 0)
{
lock (m_entityProps.SyncRoot)
if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
break;
{
if(orderedDequeue)
{
if (!m_entityProps.TryOrderedDequeue(out iupdate, out timeinqueue))
break;
}
else
{
if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
break;
}
}
ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
if (update.SendFamilyProps)
@@ -5526,6 +5548,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
#region Helper Methods
private void ClampVectorForUint(ref Vector3 v, float max)
{
float a,b;
a = Math.Abs(v.X);
b = Math.Abs(v.Y);
if(b > a)
a = b;
b= Math.Abs(v.Z);
if(b > a)
a = b;
if (a > max)
{
a = max / a;
v.X *= a;
v.Y *= a;
v.Z *= a;
}
}
protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
{
@@ -5616,11 +5658,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
pos += 12;
// Velocity
ClampVectorForUint(ref velocity, 128f);
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
// Acceleration
ClampVectorForUint(ref acceleration, 64f);
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
@@ -5632,6 +5676,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
// Angular Velocity
ClampVectorForUint(ref angularVelocity, 64f);
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
@@ -5753,7 +5798,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//update.JointPivot = Vector3.Zero;
//update.JointType = 0;
update.Material = part.Material;
update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
/*
if (data.ParentGroup.IsAttachment)
{
@@ -5832,8 +5876,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
update.Scale = part.Shape.Scale;
update.Text = Util.StringToBytes256(part.Text);
update.MediaURL = Util.StringToBytes256(part.MediaUrl);
update.Text = Util.StringToBytes(part.Text, 255);
update.MediaURL = Util.StringToBytes(part.MediaUrl, 255);
#region PrimFlags
@@ -6234,20 +6278,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param>
private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{
float vdelta = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
if((vdelta > VDELTA))
return true;
if(Math.Abs(x.CameraCenter.X - m_thisAgentUpdateArgs.CameraCenter.X) > VDELTA ||
Math.Abs(x.CameraCenter.Y - m_thisAgentUpdateArgs.CameraCenter.Y) > VDELTA ||
Math.Abs(x.CameraCenter.Z - m_thisAgentUpdateArgs.CameraCenter.Z) > VDELTA ||
vdelta = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
if((vdelta > VDELTA))
return true;
Math.Abs(x.CameraAtAxis.X - m_thisAgentUpdateArgs.CameraAtAxis.X) > VDELTA ||
Math.Abs(x.CameraAtAxis.Y - m_thisAgentUpdateArgs.CameraAtAxis.Y) > VDELTA ||
// Math.Abs(x.CameraAtAxis.Z - m_thisAgentUpdateArgs.CameraAtAxis.Z) > VDELTA ||
vdelta = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
if((vdelta > VDELTA))
return true;
Math.Abs(x.CameraLeftAxis.X - m_thisAgentUpdateArgs.CameraLeftAxis.X) > VDELTA ||
Math.Abs(x.CameraLeftAxis.Y - m_thisAgentUpdateArgs.CameraLeftAxis.Y) > VDELTA ||
// Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA ||
vdelta = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
if((vdelta > VDELTA))
Math.Abs(x.CameraUpAxis.X - m_thisAgentUpdateArgs.CameraUpAxis.X) > VDELTA ||
Math.Abs(x.CameraUpAxis.Y - m_thisAgentUpdateArgs.CameraUpAxis.Y) > VDELTA
// Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA ||
)
return true;
return false;