* 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> /// <param name="o"></param>
private void DoSendLayerData(object o) private void DoSendLayerData(object o)
{ {
float[] map = (float[])o; float[] map = LLHeightFieldMoronize((float[])o);
try try
{ {
for (int y = 0; y < 16; y++) //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)
//{ //{
// SendLayerPacket(map, y, x); // for (int x = 0; x < 16; x++)
// Thread.Sleep(150); // {
// SendLayerData(x, y, map);
// } // }
for (int x = 0; x < 16; x++) //}
{
SendLayerData(x, y, LLHeightFieldMoronize(map)); // Send LayerData in a spiral pattern. Fun!
Thread.Sleep(35); SendLayerTopRight(map, 0, 0, 15, 15);
}
}
} }
catch (Exception e) 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> /// <summary>
/// Sends a set of four patches (x, x+1, ..., x+3) to the client /// Sends a set of four patches (x, x+1, ..., x+3) to the client
/// </summary> /// </summary>
@ -854,22 +877,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
try try
{ {
int[] patches = new int[1]; int[] patches = new int[] { py * 16 + px };
int patchx, patchy; float[] heightmap = (map.Length == 65536) ?
patchx = px; map :
patchy = py; LLHeightFieldMoronize(map);
patches[0] = patchx + 0 + patchy * 16; LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
layerpack.Header.Reliable = true;
LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
layerpack.Header.Zerocoded = true;
OutPacket(layerpack, ThrottleOutPacketType.Land); OutPacket(layerpack, ThrottleOutPacketType.Land);
} }
catch (Exception e) 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, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
} }
//Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536); //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
return returnmap; return returnmap;
@ -10381,7 +10400,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion #endregion
#region LookupItem #region LookupItem
private struct LookupItem { private struct LookupItem
{
internal MinHeap<MinHeapItem> Heap; internal MinHeap<MinHeapItem> Heap;
internal IHandle Handle; internal IHandle Handle;
} }

View File

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