* Optimized sending of terrain data

* Send terrain data in a spiral pattern instead of a typewriter pattern (placeholder until terrain data becomes part of the interest list management)
* Added a debug line when resent packets are being sent
prioritization
John Hurliman 2009-10-19 18:50:31 -07:00
parent fdce1be3db
commit 0a6ea33ac8
2 changed files with 180 additions and 155 deletions

View File

@ -800,32 +800,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="o"></param>
private void DoSendLayerData(object o)
{
float[] map = (float[])o;
float[] map = LLHeightFieldMoronize((float[])o);
try
{
for (int y = 0; y < 16; y++)
{
// For some terrains, sending more than one terrain patch at once results in a libsecondlife exception
// see http://opensimulator.org/mantis/view.php?id=1662
//for (int x = 0; x < 16; x += 4)
//for (int y = 0; y < 16; y++)
//{
// SendLayerPacket(map, y, x);
// Thread.Sleep(150);
// for (int x = 0; x < 16; x++)
// {
// SendLayerData(x, y, map);
// }
for (int x = 0; x < 16; x++)
{
SendLayerData(x, y, LLHeightFieldMoronize(map));
Thread.Sleep(35);
}
}
//}
// Send LayerData in a spiral pattern. Fun!
SendLayerTopRight(map, 0, 0, 15, 15);
}
catch (Exception e)
{
m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e);
m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
}
}
private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
{
// Row
for (int i = x1; i <= x2; i++)
SendLayerData(i, y1, map);
// Column
for (int j = y1 + 1; j <= y2; j++)
SendLayerData(x2, j, map);
if (x2 - x1 > 0)
SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
}
void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
{
// Row in reverse
for (int i = x2; i >= x1; i--)
SendLayerData(i, y2, map);
// Column in reverse
for (int j = y2 - 1; j >= y1; j--)
SendLayerData(x1, j, map);
if (x2 - x1 > 0)
SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
}
/// <summary>
/// Sends a set of four patches (x, x+1, ..., x+3) to the client
/// </summary>
@ -854,22 +877,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
try
{
int[] patches = new int[1];
int patchx, patchy;
patchx = px;
patchy = py;
int[] patches = new int[] { py * 16 + px };
float[] heightmap = (map.Length == 65536) ?
map :
LLHeightFieldMoronize(map);
patches[0] = patchx + 0 + patchy * 16;
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
layerpack.Header.Zerocoded = true;
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
layerpack.Header.Reliable = true;
OutPacket(layerpack, ThrottleOutPacketType.Land);
}
catch (Exception e)
{
m_log.Warn("[client]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString());
m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
}
}
@ -898,7 +918,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
}
//Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
return returnmap;
@ -10381,7 +10400,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
#region LookupItem
private struct LookupItem {
private struct LookupItem
{
internal MinHeap<MinHeapItem> Heap;
internal IHandle Handle;
}

View File

@ -372,8 +372,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void ResendUnacked(LLUDPClient udpClient)
{
if (udpClient.IsConnected && udpClient.NeedAcks.Count > 0)
{
if (!udpClient.IsConnected)
return;
// Disconnect an agent if no packets are received for some time
//FIXME: Make 60 an .ini setting
if (Environment.TickCount - udpClient.TickLastPacketReceived > 1000 * 60)
@ -384,11 +385,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
}
if (udpClient.NeedAcks.Count > 0)
{
// Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);
if (expiredPackets != null)
{
m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID);
// Resend packets
for (int i = 0; i < expiredPackets.Count; i++)
{