aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
diff options
context:
space:
mode:
authorRobert Adams2013-10-31 09:24:06 -0700
committerRobert Adams2013-10-31 09:24:06 -0700
commit39777db8ef0604ad228854ce226bb530c2d27239 (patch)
treee351cd0c09bb9af6c10776a494f53563b0ec480c /OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
parentMerge branch 'master' into varregion (diff)
downloadopensim-SC-39777db8ef0604ad228854ce226bb530c2d27239.zip
opensim-SC-39777db8ef0604ad228854ce226bb530c2d27239.tar.gz
opensim-SC-39777db8ef0604ad228854ce226bb530c2d27239.tar.bz2
opensim-SC-39777db8ef0604ad228854ce226bb530c2d27239.tar.xz
varregion: fix problem of X/Y dimensions swapped and incorrect terrain
compression base computation. Complete replacement of float[] for terrain heightmap with TerrainData instance.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/TerrainCompressor.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainCompressor.cs35
1 files changed, 16 insertions, 19 deletions
diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
index e91c959..e4513ad 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
@@ -108,11 +108,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
108 return layer; 108 return layer;
109 } 109 }
110 110
111 // Legacy land packet generation gluing old land representation (heights) to compressed representation. 111 // Create a land packet for a single patch.
112 // This is an intermediate step in converting terrain into a variable sized heightmap. Some of the
113 // routines (like IClientAPI) only pass the float array of heights around. This entry
114 // converts that legacy representation into the more compact represenation used in
115 // TerrainData. Someday fix the plumbing between here and the scene.
116 public static LayerDataPacket CreateLandPacket(TerrainData terrData, int patchX, int patchY) 112 public static LayerDataPacket CreateLandPacket(TerrainData terrData, int patchX, int patchY)
117 { 113 {
118 int[] xPieces = new int[1]; 114 int[] xPieces = new int[1];
@@ -120,9 +116,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
120 xPieces[0] = patchX; // patch X dimension 116 xPieces[0] = patchX; // patch X dimension
121 yPieces[0] = patchY; 117 yPieces[0] = patchY;
122 118
123 m_log.DebugFormat("{0} CreateLandPacket. patchX={1}, patchY={2}, sizeX={3}, sizeY={4}",
124 LogHeader, patchX, patchY, terrData.SizeX, terrData.SizeY);
125
126 return CreateLandPacket(terrData, xPieces, yPieces, (int)TerrainPatch.LayerType.Land); 119 return CreateLandPacket(terrData, xPieces, yPieces, (int)TerrainPatch.LayerType.Land);
127 } 120 }
128 121
@@ -130,19 +123,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
130 /// Creates a LayerData packet for compressed land data given a full 123 /// Creates a LayerData packet for compressed land data given a full
131 /// simulator heightmap and an array of indices of patches to compress 124 /// simulator heightmap and an array of indices of patches to compress
132 /// </summary> 125 /// </summary>
133 /// <param name="heightmap"> 126 /// <param name="terrData">
134 /// A 256 * 256 array of floating point values 127 /// Terrain data that can result in a meter square heightmap.
135 /// specifying the height at each meter in the simulator
136 /// </param> 128 /// </param>
137 /// <param name="x"> 129 /// <param name="x">
138 /// Array of indexes in the 16x16 grid of patches 130 /// Array of indexes in the grid of patches
139 /// for this simulator. For example if 1 and 17 are specified, patches 131 /// for this simulator.
140 /// x=1,y=0 and x=1,y=1 are sent 132 /// If creating a packet for multiple patches, there will be entries in
133 /// both the X and Y arrays for each of the patches.
134 /// For example if patches 1 and 17 are to be sent,
135 /// x[] = {1,1} and y[] = {0,1} which specifies the patches at
136 /// indexes <1,0> and <1,1> (presuming the terrain size is 16x16 patches).
141 /// </param> 137 /// </param>
142 /// <param name="y"> 138 /// <param name="y">
143 /// Array of indexes in the 16x16 grid of patches 139 /// Array of indexes in the grid of patches.
144 /// for this simulator. For example if 1 and 17 are specified, patches
145 /// x=1,y=0 and x=1,y=1 are sent
146 /// </param> 140 /// </param>
147 /// <param name="type"></param> 141 /// <param name="type"></param>
148 /// <param name="pRegionSizeX"></param> 142 /// <param name="pRegionSizeX"></param>
@@ -228,6 +222,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
228 header.PatchIDs += (patchX << 5); 222 header.PatchIDs += (patchX << 5);
229 } 223 }
230 224
225 // m_log.DebugFormat("{0} CreatePatchFromHeightmap. patchX={1}, patchY={2}, DCOffset={3}, range={4}",
226 // LogHeader, patchX, patchY, header.DCOffset, header.Range);
227
231 // NOTE: No idea what prequant and postquant should be or what they do 228 // NOTE: No idea what prequant and postquant should be or what they do
232 int wbits; 229 int wbits;
233 int[] patch = CompressPatch(terrData, patchX, patchY, header, 10, out wbits); 230 int[] patch = CompressPatch(terrData, patchX, patchY, header, 10, out wbits);
@@ -266,7 +263,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
266 for (int i = patchX*16; i < (patchX + 1)*16; i++) 263 for (int i = patchX*16; i < (patchX + 1)*16; i++)
267 { 264 {
268 // short val = heightmap[j*pRegionSizeX + i]; 265 // short val = heightmap[j*pRegionSizeX + i];
269 float val = terrData[j, i]; 266 float val = terrData[i, j];
270 if (val > zmax) zmax = val; 267 if (val > zmax) zmax = val;
271 if (val < zmin) zmin = val; 268 if (val < zmin) zmin = val;
272 } 269 }
@@ -838,7 +835,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
838 for (int i = patchX * Constants.TerrainPatchSize; i < iPatchLimit; i++) 835 for (int i = patchX * Constants.TerrainPatchSize; i < iPatchLimit; i++)
839 { 836 {
840 // block[k++] = (heightmap[j*pRegionSizeX + i])*premult - sub; 837 // block[k++] = (heightmap[j*pRegionSizeX + i])*premult - sub;
841 block[k++] = terrData[j, i] - sub; 838 block[k++] = terrData[i, j] * premult - sub;
842 } 839 }
843 } 840 }
844 841