aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainCompressor.cs67
2 files changed, 64 insertions, 22 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 3b0c775..dbe85d0 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -1355,22 +1355,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1355 { 1355 {
1356 try 1356 try
1357 { 1357 {
1358 int PatchesAssumedToFit = 3; 1358 List<LayerDataPacket> packets = OpenSimTerrainCompressor.CreateTerrainPatchsPacket(terrData, px, py);
1359 for (int pcnt = 0; pcnt < px.Length; pcnt += PatchesAssumedToFit) 1359 foreach(LayerDataPacket pkt in packets)
1360 { 1360 OutPacket(pkt, ThrottleOutPacketType.Land);
1361 int remaining = Math.Min(px.Length - pcnt, PatchesAssumedToFit);
1362 int[] xPatches = new int[remaining];
1363 int[] yPatches = new int[remaining];
1364 for (int ii = 0; ii < remaining; ii++)
1365 {
1366 xPatches[ii] = px[pcnt + ii];
1367 yPatches[ii] = py[pcnt + ii];
1368 }
1369 LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, xPatches, yPatches);
1370 // DebugSendingPatches("SendLayerDataInternal", xPatches, yPatches);
1371
1372 OutPacket(layerpack, ThrottleOutPacketType.Land);
1373 }
1374 } 1361 }
1375 catch (Exception e) 1362 catch (Exception e)
1376 { 1363 {
diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
index fc8f8cd..beca578 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
@@ -27,9 +27,11 @@
27 27
28/* Freely adapted from the Aurora version of the terrain compressor. 28/* Freely adapted from the Aurora version of the terrain compressor.
29 * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/ 29 * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/
30 * Aurora version created from libOpenMetaverse Library terrain compressor
30 */ 31 */
31 32
32using System; 33using System;
34using System.Collections.Generic;
33using System.Reflection; 35using System.Reflection;
34 36
35using log4net; 37using log4net;
@@ -156,15 +158,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
156 /// <returns></returns> 158 /// <returns></returns>
157 public static LayerDataPacket CreateLandPacket(TerrainData terrData, int[] x, int[] y, byte type) 159 public static LayerDataPacket CreateLandPacket(TerrainData terrData, int[] x, int[] y, byte type)
158 { 160 {
159 LayerDataPacket layer = new LayerDataPacket {LayerID = {Type = type}}; 161 LayerDataPacket layer = new LayerDataPacket();
160 162 layer.LayerID.Type = type;
161 TerrainPatch.GroupHeader header = new TerrainPatch.GroupHeader
162 {Stride = STRIDE, PatchSize = Constants.TerrainPatchSize};
163 163
164 byte[] data = new byte[x.Length * Constants.TerrainPatchSize * Constants.TerrainPatchSize * 2]; 164 byte[] data = new byte[x.Length * Constants.TerrainPatchSize * Constants.TerrainPatchSize * 2];
165 BitPack bitpack = new BitPack(data, 0); 165 BitPack bitpack = new BitPack(data, 0);
166 bitpack.PackBits(header.Stride, 16); 166 bitpack.PackBits(STRIDE, 16);
167 bitpack.PackBits(header.PatchSize, 8); 167 bitpack.PackBits(Constants.TerrainPatchSize, 8);
168 bitpack.PackBits(type, 8); 168 bitpack.PackBits(type, 8);
169 169
170 for (int i = 0; i < x.Length; i++) 170 for (int i = 0; i < x.Length; i++)
@@ -178,7 +178,62 @@ namespace OpenSim.Region.ClientStack.LindenUDP
178 return layer; 178 return layer;
179 } 179 }
180 180
181 public static List<LayerDataPacket> CreateTerrainPatchsPacket(TerrainData terrData, int[] x, int[] y)
182 {
183 List<LayerDataPacket> ret = new List<LayerDataPacket>();
184
185 // normal or large region
186 byte landPacketType;
187 if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize)
188 landPacketType = (byte)TerrainPatch.LayerType.LandExtended;
189 else
190 landPacketType = (byte)TerrainPatch.LayerType.Land;
191
192 //create packet and global header
193 LayerDataPacket layer = new LayerDataPacket();
194
195 layer.LayerID.Type = landPacketType;
196
197 byte[] data = new byte[x.Length * Constants.TerrainPatchSize * Constants.TerrainPatchSize * 2];
198 BitPack bitpack = new BitPack(data, 0);
199 bitpack.PackBits(STRIDE, 16);
200 bitpack.PackBits(Constants.TerrainPatchSize, 8);
201 bitpack.PackBits(landPacketType, 8);
202
203 for (int i = 0; i < x.Length; i++)
204 {
205 CreatePatchFromHeightmap(bitpack, terrData, x[i], y[i]);
206 if (bitpack.BytePos > 1000 && i != x.Length - 1)
207 {
208 //finish this packet
209 bitpack.PackBits(END_OF_PATCHES, 8);
210
211 layer.LayerData.Data = new byte[bitpack.BytePos + 1];
212 Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1);
213 ret.Add(layer);
214
215 // start another
216 layer = new LayerDataPacket();
217 layer.LayerID.Type = landPacketType;
218
219 bitpack = new BitPack(data, 0);
220 bitpack.PackBits(STRIDE, 16);
221 bitpack.PackBits(Constants.TerrainPatchSize, 8);
222 bitpack.PackBits(landPacketType, 8);
223 }
224 }
225
226 bitpack.PackBits(END_OF_PATCHES, 8);
227
228 layer.LayerData.Data = new byte[bitpack.BytePos + 1];
229 Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1);
230 ret.Add(layer);
231
232 return ret;
233 }
234
181 // Unused: left for historical reference. 235 // Unused: left for historical reference.
236 // nopes.. in use by clouds and wind
182 public static void CreatePatch(BitPack output, float[] patchData, int x, int y, int pRegionSizeX, int pRegionSizeY) 237 public static void CreatePatch(BitPack output, float[] patchData, int x, int y, int pRegionSizeX, int pRegionSizeY)
183 { 238 {
184 TerrainPatch.Header header = PrescanPatch(patchData); 239 TerrainPatch.Header header = PrescanPatch(patchData);