diff options
author | Robert Adams | 2013-10-31 09:24:06 -0700 |
---|---|---|
committer | Robert Adams | 2013-10-31 09:24:06 -0700 |
commit | 39777db8ef0604ad228854ce226bb530c2d27239 (patch) | |
tree | e351cd0c09bb9af6c10776a494f53563b0ec480c /OpenSim/Region/Framework | |
parent | Merge branch 'master' into varregion (diff) | |
download | opensim-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')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/TerrainCompressor.cs | 35 |
2 files changed, 27 insertions, 28 deletions
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 6d245cb..d641c87 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -100,16 +100,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
100 | } | 100 | } |
101 | 101 | ||
102 | // ITerrainChannel.GetFloatsSerialized() | 102 | // ITerrainChannel.GetFloatsSerialized() |
103 | // NOTICE that the one dimensional form is ordered by Y!! | 103 | // This one dimensional version is ordered so height = map[y*sizeX+x]; |
104 | // DEPRECATED: don't use this function as it does not retain the dimensions of the terrain | ||
105 | // and the caller will probably do the wrong thing if the terrain is not the legacy 256x256. | ||
104 | public float[] GetFloatsSerialised() | 106 | public float[] GetFloatsSerialised() |
105 | { | 107 | { |
106 | int points = Width * Height; | 108 | int points = Width * Height; |
107 | float[] heights = new float[points]; | 109 | float[] heights = new float[points]; |
108 | 110 | ||
109 | int idx = 0; | 111 | int idx = 0; |
110 | for (int ii = 0; ii < Height; ii++) | 112 | for (int jj = 0; jj < Height; jj++) |
111 | for (int jj = 0; jj < Width; jj++) | 113 | for (int ii = 0; ii < Width; ii++) |
112 | heights[idx++] = m_terrainData[jj, ii]; | 114 | { |
115 | heights[idx++] = m_terrainData[ii, jj]; | ||
116 | } | ||
113 | 117 | ||
114 | return heights; | 118 | return heights; |
115 | } | 119 | } |
@@ -117,14 +121,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | // ITerrainChannel.GetDoubles() | 121 | // ITerrainChannel.GetDoubles() |
118 | public double[,] GetDoubles() | 122 | public double[,] GetDoubles() |
119 | { | 123 | { |
120 | int w = Width; | 124 | double[,] heights = new double[Width, Height]; |
121 | int l = Height; | ||
122 | double[,] heights = new double[w, l]; | ||
123 | 125 | ||
124 | int idx = 0; // index into serialized array | 126 | int idx = 0; // index into serialized array |
125 | for (int ii = 0; ii < w; ii++) | 127 | for (int ii = 0; ii < Width; ii++) |
126 | { | 128 | { |
127 | for (int jj = 0; jj < l; jj++) | 129 | for (int jj = 0; jj < Height; jj++) |
128 | { | 130 | { |
129 | heights[ii, jj] = (double)m_terrainData[ii, jj]; | 131 | heights[ii, jj] = (double)m_terrainData[ii, jj]; |
130 | idx++; | 132 | idx++; |
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 | ||