diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index 103359bf57..d7f1655155 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs @@ -103,7 +103,7 @@ namespace OpenSim.Framework { m_heightmap[x, y] = newVal; m_taint[x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize] = true; - m_log.DebugFormat("{0} set[{1},{2}] to {3} ({4})", LogHeader, x, y, value, newVal); + // m_log.DebugFormat("{0} set[{1},{2}] to {3} ({4})", LogHeader, x, y, value, newVal); } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 2b8a04f3e8..c8e7eb5b0c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1154,7 +1154,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// heightmap public virtual void SendLayerData(float[] map) { - Util.FireAndForget(DoSendLayerData, map); + Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData()); } /// @@ -1163,7 +1163,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private void DoSendLayerData(object o) { - float[] map = (float[])o; + TerrainData map = (TerrainData)o; try { @@ -1177,7 +1177,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP //} // Send LayerData in a spiral pattern. Fun! - SendLayerTopRight(map, 0, 0, 15, 15); + SendLayerTopRight(map, 0, 0, map.SizeX/Constants.TerrainPatchSize-1, map.SizeY/Constants.TerrainPatchSize-1); } catch (Exception e) { @@ -1185,7 +1185,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2) + private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2) { // Row for (int i = x1; i <= x2; i++) @@ -1199,7 +1199,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2); } - void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2) + void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2) { // Row in reverse for (int i = x2; i >= x1; i--) @@ -1231,6 +1231,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP // OutPacket(layerpack, ThrottleOutPacketType.Land); // } + // Legacy form of invocation that passes around a bare data array. + // Just ignore what was passed and use the real terrain info that is part of the scene. + public void SendLayerData(int px, int py, float[] map) + { + SendLayerData(px, py, m_scene.Heightmap.GetTerrainData()); + } + /// /// Sends a terrain packet for the point specified. /// This is a legacy call that has refarbed the terrain into a flat map of floats. @@ -1239,15 +1246,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Patch coordinate (x) 0..15 /// Patch coordinate (y) 0..15 /// heightmap - public void SendLayerData(int px, int py, float[] map) + public void SendLayerData(int px, int py, TerrainData terrData) { try { - // For unknown reasons, after this point, patch numbers are swapped X for y. - // That means, that for - /// - /// A 256 * 256 array of floating point values - /// specifying the height at each meter in the simulator + /// + /// Terrain data that can result in a meter square heightmap. /// /// - /// Array of indexes in the 16x16 grid of patches - /// for this simulator. For example if 1 and 17 are specified, patches - /// x=1,y=0 and x=1,y=1 are sent + /// Array of indexes in the grid of patches + /// for this simulator. + /// If creating a packet for multiple patches, there will be entries in + /// both the X and Y arrays for each of the patches. + /// For example if patches 1 and 17 are to be sent, + /// x[] = {1,1} and y[] = {0,1} which specifies the patches at + /// indexes <1,0> and <1,1> (presuming the terrain size is 16x16 patches). /// /// - /// Array of indexes in the 16x16 grid of patches - /// for this simulator. For example if 1 and 17 are specified, patches - /// x=1,y=0 and x=1,y=1 are sent + /// Array of indexes in the grid of patches. /// /// /// @@ -228,6 +222,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP header.PatchIDs += (patchX << 5); } + // m_log.DebugFormat("{0} CreatePatchFromHeightmap. patchX={1}, patchY={2}, DCOffset={3}, range={4}", + // LogHeader, patchX, patchY, header.DCOffset, header.Range); + // NOTE: No idea what prequant and postquant should be or what they do int wbits; int[] patch = CompressPatch(terrData, patchX, patchY, header, 10, out wbits); @@ -266,7 +263,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = patchX*16; i < (patchX + 1)*16; i++) { // short val = heightmap[j*pRegionSizeX + i]; - float val = terrData[j, i]; + float val = terrData[i, j]; if (val > zmax) zmax = val; if (val < zmin) zmin = val; } @@ -838,7 +835,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = patchX * Constants.TerrainPatchSize; i < iPatchLimit; i++) { // block[k++] = (heightmap[j*pRegionSizeX + i])*premult - sub; - block[k++] = terrData[j, i] - sub; + block[k++] = terrData[i, j] * premult - sub; } }