diff options
author | UbitUmarov | 2015-09-23 00:01:32 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-23 00:01:32 +0100 |
commit | ccfb561e8db04a35559cd7091680fa523d7dbe57 (patch) | |
tree | 22de22a04c25cdd3bda78a895747459d985c3f56 /OpenSim/Region/Framework | |
parent | fix GetPacketsQueuedCount typos in last commit (diff) | |
download | opensim-SC-ccfb561e8db04a35559cd7091680fa523d7dbe57.zip opensim-SC-ccfb561e8db04a35559cd7091680fa523d7dbe57.tar.gz opensim-SC-ccfb561e8db04a35559cd7091680fa523d7dbe57.tar.bz2 opensim-SC-ccfb561e8db04a35559cd7091680fa523d7dbe57.tar.xz |
change the encapsulation of compressed land patchs in llUDP packets
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/TerrainCompressor.cs | 67 |
1 files changed, 61 insertions, 6 deletions
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 | ||
32 | using System; | 33 | using System; |
34 | using System.Collections.Generic; | ||
33 | using System.Reflection; | 35 | using System.Reflection; |
34 | 36 | ||
35 | using log4net; | 37 | using 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); |