diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index 209c991fa2..d6bfed4ee2 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -103,8 +103,8 @@ namespace OpenSim.Framework /// Finished, Same Sim FinishedViaSameSim = 1 << 29, /// Agent coming into the grid from another grid - ViaHGLogin = 1 << 30 + ViaHGLogin = 1 << 30, + notViaHGLogin = 0xbffffff } - } } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 9ab1092402..252ee3e513 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1146,8 +1146,8 @@ namespace OpenSim.Framework bool CanSendLayerData(); - void SendLayerData(float[] map); - void SendLayerData(int px, int py, float[] map); + void SendLayerData(); + void SendLayerData(int[] map); void SendWindData(int version, Vector2[] windSpeeds); void SendCloudData(int version, float[] cloudCover); diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index f99dd003f3..7b9942719e 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs @@ -82,7 +82,7 @@ namespace OpenSim.Framework public abstract double[,] GetDoubles(); public abstract void GetPatchMinMax(int px, int py, out float zmin, out float zmax); - public abstract void GetPatchBlock(ref float[] block, int px, int py, float sub, float premult); + public abstract void GetPatchBlock(float[] block, int px, int py, float sub, float premult); public abstract TerrainData Clone(); } @@ -279,34 +279,47 @@ namespace OpenSim.Framework return ret; } - public override void GetPatchMinMax(int px, int py, out float zmin, out float zmax) + public override unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax) { zmax = float.MinValue; zmin = float.MaxValue; - int startx = px * 16; + int stride = m_heightmap.GetLength(1); + + int startx = px * 16 * stride; + int endx = (px + 1) * 16 * stride; int starty = py * 16; - for (int i = startx; i < startx + 16; i++) + fixed (float* map = m_heightmap) { - for (int j = starty; j < starty + 16; j++) + for (int i = startx; i < endx; i += stride) { - float val = m_heightmap[i, j]; - if (val > zmax) zmax = val; - if (val < zmin) zmin = val; + float* p = &map[i]; + for (int j = starty; j < starty + 16; j++) + { + float val = p[j]; + if (val > zmax) zmax = val; + if (val < zmin) zmin = val; + } } } } - public override void GetPatchBlock(ref float[] block, int px, int py, float sub, float premult) + public override unsafe void GetPatchBlock(float[] _block, int px, int py, float sub, float premult) { int k = 0; - int startX = px * 16; + int stride = m_heightmap.GetLength(1); + + int startX = px * 16 * stride; + int endX = (px + 1) * 16 * stride; int startY = py * 16; - for (int y = startY; y < startY + 16; y++) + fixed(float* block = _block, map = m_heightmap) { - for (int x = startX; x < startX + 16; x++) + for (int y = startY; y < startY + 16; y++) { - block[k++] = (m_heightmap[x, y] - sub) * premult; + for (int x = startX; x < endX; x += stride) + { + block[k++] = (map[x + y] - sub) * premult; + } } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index b61bdeb647..d197f5cf7c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1185,13 +1185,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// region's patches to the client. /// /// heightmap - public virtual void SendLayerData(float[] map) + public virtual void SendLayerData() { - Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData(), "LLClientView.DoSendLayerData"); - - // Send it sync, and async. It's not that much data - // and it improves user experience just so much! -// DoSendLayerData(map); + Util.FireAndForget(DoSendLayerData, null, "LLClientView.DoSendLayerData"); } /// @@ -1200,21 +1196,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private void DoSendLayerData(object o) { - TerrainData map = (TerrainData)o; - + TerrainData map = m_scene.Heightmap.GetTerrainData(); try { - // Send LayerData in typerwriter pattern - //for (int y = 0; y < 16; y++) - //{ - // for (int x = 0; x < 16; x++) - // { - // SendLayerData(x, y, map); - // } - //} - // Send LayerData in a spiral pattern. Fun! - SendLayerTopRight(map, 0, 0, map.SizeX / Constants.TerrainPatchSize - 1, map.SizeY / Constants.TerrainPatchSize - 1); + SendLayerTopRight(0, 0, map.SizeX / Constants.TerrainPatchSize - 1, map.SizeY / Constants.TerrainPatchSize - 1); } catch (Exception e) { @@ -1222,63 +1208,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2) + private void SendLayerTopRight(int x1, int y1, int x2, int y2) { + int[] p = new int[2]; + // Row - for (int i = x1; i <= x2; i++) - SendLayerData(i, y1, map); + p[1] = y1; + for (int i = x1; i <= x2; ++i) + { + p[0] = i; + SendLayerData(p); + } // Column - for (int j = y1 + 1; j <= y2; j++) - SendLayerData(x2, j, map); + p[0] = x2; + for (int j = y1 + 1; j <= y2; ++j) + { + p[1] = j; + SendLayerData(p); + } if (x2 - x1 > 0 && y2 - y1 > 0) - SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2); + SendLayerBottomLeft(x1, y1 + 1, x2 - 1, y2); } - void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2) + void SendLayerBottomLeft(int x1, int y1, int x2, int y2) { + int[] p = new int[2]; + // Row in reverse - for (int i = x2; i >= x1; i--) - SendLayerData(i, y2, map); + p[1] = y2; + for (int i = x2; i >= x1; --i) + { + p[0] = i; + SendLayerData(p); + } // Column in reverse - for (int j = y2 - 1; j >= y1; j--) - SendLayerData(x1, j, map); + p[0] = x1; + for (int j = y2 - 1; j >= y1; --j) + { + p[1] = j; + SendLayerData(p); + } if (x2 - x1 > 0 && y2 - y1 > 0) - SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1); + SendLayerTopRight(x1 + 1, y1, x2, y2 - 1); } - - // 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. - // As a HORRIBLE kludge in an attempt to not change the definition of IClientAPI, - // there is a special form for specifying multiple terrain patches to send. - // The form is to pass 'px' as negative the number of patches to send and to - // pass the float array as pairs of patch X and Y coordinates. So, passing 'px' - // as -2 and map= [3, 5, 8, 4] would mean to send two terrain heightmap patches - // and the patches to send are <3,5> and <8,4>. - public void SendLayerData(int px, int py, float[] map) + public void SendLayerData(int[] map) { - if (px >= 0) + if(map == null) + return; + + try { - SendLayerData(px, py, m_scene.Heightmap.GetTerrainData()); + List packets = OpenSimTerrainCompressor.CreateLayerDataPackets(m_scene.Heightmap.GetTerrainData(), map); + foreach (LayerDataPacket pkt in packets) + OutPacket(pkt, ThrottleOutPacketType.Land); } - else + catch (Exception e) { - int numPatches = -px; - int[] xPatches = new int[numPatches]; - int[] yPatches = new int[numPatches]; - for (int pp = 0; pp < numPatches; pp++) - { - xPatches[pp] = (int)map[pp * 2]; - yPatches[pp] = (int)map[pp * 2 + 1]; - } - - // DebugSendingPatches("SendLayerData", xPatches, yPatches); - - SendLayerData(xPatches, yPatches, m_scene.Heightmap.GetTerrainData()); + m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e); } } @@ -1298,43 +1289,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - /// - - /// Sends a terrain packet for the point specified. - /// This is a legacy call that has refarbed the terrain into a flat map of floats. - /// We just use the terrain from the region we know about. - /// - /// Patch coordinate (x) 0..15 - /// Patch coordinate (y) 0..15 - /// heightmap - public void SendLayerData(int px, int py, TerrainData terrData) - { - int[] xPatches = new[] { px }; - int[] yPatches = new[] { py }; - SendLayerData(xPatches, yPatches, terrData); - } - - private void SendLayerData(int[] px, int[] py, TerrainData terrData) - { - try - { - byte landPacketType; - if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) - landPacketType = (byte)TerrainPatch.LayerType.LandExtended; - else - landPacketType = (byte)TerrainPatch.LayerType.Land; - - List packets = OpenSimTerrainCompressor.CreateLayerDataPackets(terrData, px, py, landPacketType); - foreach(LayerDataPacket pkt in packets) - OutPacket(pkt, ThrottleOutPacketType.Land); - } - catch (Exception e) - { - m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e); - } - } - - // wind caching private static Dictionary lastWindVersion = new Dictionary(); private static Dictionary> lastWindPackets = diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 5f3578232b..35d29a5adb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -866,21 +866,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); for (int i = 0; i < packetCount; i++) - { - byte[] data = datas[i]; -// if (!SendPacketData(udpClient, data, packet.Type, category, method)) -// packetQueued = true; - SendPacketData(udpClient, data, packet.Type, category, method); - } + SendPacketData(udpClient, datas[i], packet.Type, category, method); } else { byte[] data = packet.ToBytes(); -// if (!SendPacketData(udpClient, data, packet.Type, category, method)) -// packetQueued = true; SendPacketData(udpClient, data, packet.Type, category, method); } - PacketPool.Instance.ReturnPacket(packet); } @@ -908,7 +900,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (zerocount != 0) { dest[zerolen++] = 0x00; - dest[zerolen++] = (byte)zerocount; + dest[zerolen++] = zerocount; zerocount = 0; } @@ -919,10 +911,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (zerocount != 0) { dest[zerolen++] = 0x00; - dest[zerolen++] = (byte)zerocount; + dest[zerolen++] = zerocount; } - return (int)zerolen; + return zerolen; } /// /// Start the process of sending a packet to the client. diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 65d4c4a37a..a786568a93 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -592,7 +592,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain else { // The traditional way is to call into the protocol stack to send them all. - pClient.SendLayerData(new float[10]); + pClient.SendLayerData(); } } @@ -1066,13 +1066,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain // Legacy update sending where the update is sent out as soon as noticed // We know the actual terrain data that is passed is ignored so this passes a dummy heightmap. //float[] heightMap = terrData.GetFloatsSerialized(); - float[] heightMap = new float[10]; + int[] map = new int[]{ x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize }; m_scene.ForEachClient( delegate (IClientAPI controller) { - controller.SendLayerData(x / Constants.TerrainPatchSize, - y / Constants.TerrainPatchSize, - heightMap); + controller.SendLayerData(map); } ); } @@ -1131,14 +1129,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain } */ - float[] patchPieces = new float[toSend.Count * 2]; + int[] patchPieces = new int[toSend.Count * 2]; int pieceIndex = 0; foreach (PatchesToSend pts in toSend) { patchPieces[pieceIndex++] = pts.PatchX; patchPieces[pieceIndex++] = pts.PatchY; } - pups.Presence.ControllingClient.SendLayerData(-toSend.Count, 0, patchPieces); + pups.Presence.ControllingClient.SendLayerData(patchPieces); } if (pups.sendAll && toSend.Count < 1024) SendAllModifiedPatchs(pups); @@ -1206,16 +1204,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain npatchs = patchs.Count; if (npatchs > 0) { - int[] xPieces = new int[npatchs]; - int[] yPieces = new int[npatchs]; - float[] patchPieces = new float[npatchs * 2]; + int[] patchPieces = new int[npatchs * 2]; int pieceIndex = 0; foreach (PatchesToSend pts in patchs) { patchPieces[pieceIndex++] = pts.PatchX; patchPieces[pieceIndex++] = pts.PatchY; } - pups.Presence.ControllingClient.SendLayerData(-npatchs, 0, patchPieces); + pups.Presence.ControllingClient.SendLayerData(patchPieces); } } @@ -1457,8 +1453,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { //m_log.Debug("Terrain packet unacked, resending patch: " + patchX + " , " + patchY); // SendLayerData does not use the heightmap parameter. This kludge is so as to not change IClientAPI. - float[] heightMap = new float[10]; - client.SendLayerData(patchX, patchY, heightMap); + client.SendLayerData(new int[]{patchX, patchY}); } private void StoreUndoState() diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs index d3f27373d2..2070463938 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs @@ -155,16 +155,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP return iout; } + static double tt; // new using terrain data and patchs indexes - public static List CreateLayerDataPackets(TerrainData terrData, int[] x, int[] y, byte landPacketType) + public static List CreateLayerDataPackets(TerrainData terrData, int[] map) { List ret = new List(); - byte[] data = new byte[x.Length * 256 * 2]; + int numberPatchs = map.Length / 2; + byte[] data = new byte[numberPatchs * 256 * 2]; //create packet and global header LayerDataPacket layer = new LayerDataPacket(); + byte landPacketType; + if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) + landPacketType = (byte)TerrainPatch.LayerType.LandExtended; + else + landPacketType = (byte)TerrainPatch.LayerType.Land; + layer.LayerID.Type = landPacketType; BitPack bitpack = new BitPack(data, 0); @@ -172,11 +180,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP bitpack.PackBitsFromByte(16); bitpack.PackBitsFromByte(landPacketType); - for (int i = 0; i < x.Length; i++) - { - CreatePatchFromTerrainData(bitpack, terrData, x[i], y[i]); + tt = 0; - if (bitpack.BytePos > 980 && i != x.Length - 1) + int s; + for (int i = 0; i < numberPatchs; i++) + { + s = 2 * i; + tt -= Util.GetTimeStampMS(); + CreatePatchFromTerrainData(bitpack, terrData, map[s], map[s + 1]); + tt += Util.GetTimeStampMS(); + + if (bitpack.BytePos > 980 && i != numberPatchs - 1) { //finish this packet bitpack.PackBitsFromByte(END_OF_PATCHES); @@ -284,7 +298,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP output.PackBits(header.PatchIDs, 10); } - private static void EncodePatch(BitPack output, int[] patch, int postquant, int wbits) + private unsafe static void EncodePatch(BitPack output, int[] _patch, int postquant, int wbits) { int maxwbitssize = (1 << wbits) - 1; @@ -296,60 +310,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP int lastZeroindx = 256 - postquant; - if (lastZeroindx != 256) - patch[lastZeroindx] = 0; - - int i = 0; - while(i < 256) + fixed(int * patch = _patch) { - int temp = patch[i]; + if (lastZeroindx != 256) + patch[lastZeroindx] = 0; - if (temp == 0) + int i = 0; + while(i < 256) { - int j = i + 1; - while(j < lastZeroindx) + int temp = patch[i]; + + if (temp == 0) { - if (patch[j] != 0) - break; - ++j; + int j = i + 1; + while(j < lastZeroindx) + { + if (patch[j] != 0) + break; + ++j; + } + + if (j == lastZeroindx) + { + output.PackBits(ZERO_EOB, 2); + return; + } + + i = j - i; + while(i > 8) + { + output.PackBitsFromByte(ZERO_CODE); + i -= 8; + } + if( i > 0) + output.PackBitsFromByte(ZERO_CODE, i); + i = j; + continue; } - if (j == lastZeroindx) + if (temp < 0) { - output.PackBits(ZERO_EOB, 2); - return; - } + temp *= -1; + if (temp > maxwbitssize) + temp = maxwbitssize; - i = j - i; - while(i > 8) + output.PackBits(NEGATIVE_VALUE, 3); + output.PackBits(temp, wbits); + } + else { - output.PackBitsFromByte(ZERO_CODE); - i -= 8; + if (temp > maxwbitssize) + temp = maxwbitssize; + + output.PackBits(POSITIVE_VALUE, 3); + output.PackBits(temp, wbits); } - if( i > 0) - output.PackBitsFromByte(ZERO_CODE, i); - i = j; - continue; + ++i; } - - if (temp < 0) - { - temp *= -1; - if (temp > maxwbitssize) - temp = maxwbitssize; - - output.PackBits(NEGATIVE_VALUE, 3); - output.PackBits(temp, wbits); - } - else - { - if (temp > maxwbitssize) - temp = maxwbitssize; - - output.PackBits(POSITIVE_VALUE, 3); - output.PackBits(temp, wbits); - } - ++i; } } @@ -369,7 +386,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP header.QuantWBits = wordsize; header.QuantWBits |= wordsize << 4; - terrData.GetPatchBlock(ref block, patchX, patchY, sub, premult); + terrData.GetPatchBlock(block, patchX, patchY, sub, premult); wbits = (prequant >> 1); @@ -391,20 +408,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private static void BuildQuantizeTable16() + private unsafe static void BuildQuantizeTable16() { const float oosob = 2.0f / 16; - for (int j = 0; j < 16; j++) + fixed(float* fQuantizeTable16 = QuantizeTable16) { - int c = j * 16; - for (int i = 0; i < 16; i++) + for (int j = 0; j < 16; j++) { - QuantizeTable16[c + i] = oosob / (1.0f + 2.0f * (i + j)); + int c = j * 16; + for (int i = 0; i < 16; i++) + { + fQuantizeTable16[c + i] = oosob / (1.0f + 2.0f * (i + j)); + } } } } - private static void BuildCopyMatrix16() + private unsafe static void BuildCopyMatrix16() { bool diag = false; bool right = true; @@ -412,42 +432,45 @@ namespace OpenSim.Region.ClientStack.LindenUDP int j = 0; int count = 0; - while (i < 16 && j < 16) + fixed (int* fCopyMatrix16 = CopyMatrix16) { - CopyMatrix16[j * 16 + i] = count++; - - if (!diag) + while (i < 16 && j < 16) { - if (right) - { - if (i < 15) i++; - else j++; + fCopyMatrix16[j * 16 + i] = count++; - right = false; - diag = true; + if (!diag) + { + if (right) + { + if (i < 15) i++; + else j++; + + right = false; + diag = true; + } + else + { + if (j < 15 ) j++; + else i++; + + right = true; + diag = true; + } } else { - if (j < 15 ) j++; - else i++; - - right = true; - diag = true; - } - } - else - { - if (right) - { - i++; - j--; - if (i == 15 || j == 0) diag = false; - } - else - { - i--; - j++; - if (j == 15 || i == 0) diag = false; + if (right) + { + i++; + j--; + if (i == 15 || j == 0) diag = false; + } + else + { + i--; + j++; + if (j == 15 || i == 0) diag = false; + } } } } @@ -455,9 +478,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Initialization - - - #region DCT /* DCT (Discrete Cosine Transform) @@ -506,9 +526,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP const float W16_8R = 0.70710678118654752440f; - static void dct16x16(float[] a, int[] iout, ref int wbits) + unsafe static void dct16x16(float[] _a, int[] _iout, ref int wbits) { - float[] tmp = new float[256]; + float[] _tmp = new float[256]; float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; float x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i; @@ -523,479 +543,483 @@ namespace OpenSim.Region.ClientStack.LindenUDP int wbitsMaxValue = 1 << wbits; bool dowbits = wbits < 17; - for (j = 0, k = 0; j < 256; j += 16, k++) + fixed (float* a = _a, tmp = _tmp, fQuantizeTable16 = QuantizeTable16) + fixed (int* iout = _iout, fCopyMatrix16 = CopyMatrix16) { - x4r = a[0 + j] - a[15 + j]; - xr = a[0 + j] + a[15 + j]; - x4i = a[8 + j] - a[7 + j]; - xi = a[8 + j] + a[7 + j]; - x0r = xr + xi; - x0i = xr - xi; - x5r = a[2 + j] - a[13 + j]; - xr = a[2 + j] + a[13 + j]; - x5i = a[10 + j] - a[5 + j]; - xi = a[10 + j] + a[5 + j]; - x1r = xr + xi; - x1i = xr - xi; - x6r = a[4 + j] - a[11 + j]; - xr = a[4 + j] + a[11 + j]; - x6i = a[12 + j] - a[3 + j]; - xi = a[12 + j] + a[3 + j]; - x2r = xr + xi; - x2i = xr - xi; - x7r = a[6 + j] - a[9 + j]; - xr = a[6 + j] + a[9 + j]; - x7i = a[14 + j] - a[1 + j]; - xi = a[14 + j] + a[1 + j]; - x3r = xr + xi; - x3i = xr - xi; - xr = x0r + x2r; - xi = x1r + x3r; - tmp[k] = C16_8R * (xr + xi); // - tmp[8 * 16 + k] = C16_8R * (xr - xi); // - xr = x0r - x2r; - xi = x1r - x3r; - tmp[4 * 16 + k] = C16_4R * xr - C16_4I * xi; // - tmp[12 * 16 + k] = C16_4R * xi + C16_4I * xr; // - x0r = W16_8R * (x1i - x3i); - x2r = W16_8R * (x1i + x3i); - xr = x0i + x0r; - xi = x2r + x2i; - tmp[2 * 16 + k] = C16_2R * xr - C16_2I * xi; // - tmp[14 * 16 + k] = C16_2R * xi + C16_2I * xr; // - xr = x0i - x0r; - xi = x2r - x2i; - tmp[6 * 16 + k] = C16_6R * xr - C16_6I * xi; // - tmp[10 * 16 + k] = C16_6R * xi + C16_6I * xr; // - xr = W16_8R * (x6r - x6i); - xi = W16_8R * (x6i + x6r); - x6r = x4r - xr; - x6i = x4i - xi; - x4r += xr; - x4i += xi; - xr = W16_4I * x7r - W16_4R * x7i; - xi = W16_4I * x7i + W16_4R * x7r; - x7r = W16_4R * x5r - W16_4I * x5i; - x7i = W16_4R * x5i + W16_4I * x5r; - x5r = x7r + xr; - x5i = x7i + xi; - x7r -= xr; - x7i -= xi; - xr = x4r + x5r; - xi = x5i + x4i; - tmp[16 + k] = C16_1R * xr - C16_1I * xi; // - tmp[15 * 16 + k] = C16_1R * xi + C16_1I * xr; // - xr = x4r - x5r; - xi = x5i - x4i; - tmp[7 * 16 + k] = C16_7R * xr - C16_7I * xi; // - tmp[9 * 16 + k] = C16_7R * xi + C16_7I * xr; // - xr = x6r - x7i; - xi = x7r + x6i; - tmp[5 * 16 + k] = C16_5R * xr - C16_5I * xi; // - tmp[11 * 16 + k] = C16_5R * xi + C16_5I * xr; // - xr = x6r + x7i; - xi = x7r - x6i; - tmp[3 * 16 + k] = C16_3R * xr - C16_3I * xi; // - tmp[13 * 16 + k] = C16_3R * xi + C16_3I * xr; // - } - - for (j = 0, k = 0; j < 256; j += 16, k++) - { - x4r = tmp[0 + j] - tmp[15 + j]; - xr = tmp[0 + j] + tmp[15 + j]; - x4i = tmp[8 + j] - tmp[7 + j]; - xi = tmp[8 + j] + tmp[7 + j]; - x0r = xr + xi; - x0i = xr - xi; - x5r = tmp[2 + j] - tmp[13 + j]; - xr = tmp[2 + j] + tmp[13 + j]; - x5i = tmp[10 + j] - tmp[5 + j]; - xi = tmp[10 + j] + tmp[5 + j]; - x1r = xr + xi; - x1i = xr - xi; - x6r = tmp[4 + j] - tmp[11 + j]; - xr = tmp[4 + j] + tmp[11 + j]; - x6i = tmp[12 + j] - tmp[3 + j]; - xi = tmp[12 + j] + tmp[3 + j]; - x2r = xr + xi; - x2i = xr - xi; - x7r = tmp[6 + j] - tmp[9 + j]; - xr = tmp[6 + j] + tmp[9 + j]; - x7i = tmp[14 + j] - tmp[1 + j]; - xi = tmp[14 + j] + tmp[1 + j]; - x3r = xr + xi; - x3i = xr - xi; - xr = x0r + x2r; - xi = x1r + x3r; - - //tmp[0 + k] = C16_8R * (xr + xi); // - ftmp = C16_8R * (xr + xi); - itmp = (int)(ftmp * QuantizeTable16[k]); - iout[CopyMatrix16[k]] = itmp; - - if (dowbits) + for (j = 0, k = 0; j < 256; j += 16, k++) { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) - { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) - { - dowbits = false; - break; - } - } + x4r = a[0 + j] - a[15 + j]; + xr = a[0 + j] + a[15 + j]; + x4i = a[8 + j] - a[7 + j]; + xi = a[8 + j] + a[7 + j]; + x0r = xr + xi; + x0i = xr - xi; + x5r = a[2 + j] - a[13 + j]; + xr = a[2 + j] + a[13 + j]; + x5i = a[10 + j] - a[5 + j]; + xi = a[10 + j] + a[5 + j]; + x1r = xr + xi; + x1i = xr - xi; + x6r = a[4 + j] - a[11 + j]; + xr = a[4 + j] + a[11 + j]; + x6i = a[12 + j] - a[3 + j]; + xi = a[12 + j] + a[3 + j]; + x2r = xr + xi; + x2i = xr - xi; + x7r = a[6 + j] - a[9 + j]; + xr = a[6 + j] + a[9 + j]; + x7i = a[14 + j] - a[1 + j]; + xi = a[14 + j] + a[1 + j]; + x3r = xr + xi; + x3i = xr - xi; + xr = x0r + x2r; + xi = x1r + x3r; + tmp[k] = C16_8R * (xr + xi); // + tmp[8 * 16 + k] = C16_8R * (xr - xi); // + xr = x0r - x2r; + xi = x1r - x3r; + tmp[4 * 16 + k] = C16_4R * xr - C16_4I * xi; // + tmp[12 * 16 + k] = C16_4R * xi + C16_4I * xr; // + x0r = W16_8R * (x1i - x3i); + x2r = W16_8R * (x1i + x3i); + xr = x0i + x0r; + xi = x2r + x2i; + tmp[2 * 16 + k] = C16_2R * xr - C16_2I * xi; // + tmp[14 * 16 + k] = C16_2R * xi + C16_2I * xr; // + xr = x0i - x0r; + xi = x2r - x2i; + tmp[6 * 16 + k] = C16_6R * xr - C16_6I * xi; // + tmp[10 * 16 + k] = C16_6R * xi + C16_6I * xr; // + xr = W16_8R * (x6r - x6i); + xi = W16_8R * (x6i + x6r); + x6r = x4r - xr; + x6i = x4i - xi; + x4r += xr; + x4i += xi; + xr = W16_4I * x7r - W16_4R * x7i; + xi = W16_4I * x7i + W16_4R * x7r; + x7r = W16_4R * x5r - W16_4I * x5i; + x7i = W16_4R * x5i + W16_4I * x5r; + x5r = x7r + xr; + x5i = x7i + xi; + x7r -= xr; + x7i -= xi; + xr = x4r + x5r; + xi = x5i + x4i; + tmp[16 + k] = C16_1R * xr - C16_1I * xi; // + tmp[15 * 16 + k] = C16_1R * xi + C16_1I * xr; // + xr = x4r - x5r; + xi = x5i - x4i; + tmp[7 * 16 + k] = C16_7R * xr - C16_7I * xi; // + tmp[9 * 16 + k] = C16_7R * xi + C16_7I * xr; // + xr = x6r - x7i; + xi = x7r + x6i; + tmp[5 * 16 + k] = C16_5R * xr - C16_5I * xi; // + tmp[11 * 16 + k] = C16_5R * xi + C16_5I * xr; // + xr = x6r + x7i; + xi = x7r - x6i; + tmp[3 * 16 + k] = C16_3R * xr - C16_3I * xi; // + tmp[13 * 16 + k] = C16_3R * xi + C16_3I * xr; // } - //tmp[8 * Constants.TerrainPatchSize + k] = C16_8R * (xr - xi); // - ftmp = C16_8R * (xr - xi); - indx = 8 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) + for (j = 0, k = 0; j < 256; j += 16, k++) { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + x4r = tmp[0 + j] - tmp[15 + j]; + xr = tmp[0 + j] + tmp[15 + j]; + x4i = tmp[8 + j] - tmp[7 + j]; + xi = tmp[8 + j] + tmp[7 + j]; + x0r = xr + xi; + x0i = xr - xi; + x5r = tmp[2 + j] - tmp[13 + j]; + xr = tmp[2 + j] + tmp[13 + j]; + x5i = tmp[10 + j] - tmp[5 + j]; + xi = tmp[10 + j] + tmp[5 + j]; + x1r = xr + xi; + x1i = xr - xi; + x6r = tmp[4 + j] - tmp[11 + j]; + xr = tmp[4 + j] + tmp[11 + j]; + x6i = tmp[12 + j] - tmp[3 + j]; + xi = tmp[12 + j] + tmp[3 + j]; + x2r = xr + xi; + x2i = xr - xi; + x7r = tmp[6 + j] - tmp[9 + j]; + xr = tmp[6 + j] + tmp[9 + j]; + x7i = tmp[14 + j] - tmp[1 + j]; + xi = tmp[14 + j] + tmp[1 + j]; + x3r = xr + xi; + x3i = xr - xi; + xr = x0r + x2r; + xi = x1r + x3r; + + //tmp[0 + k] = C16_8R * (xr + xi); // + ftmp = C16_8R * (xr + xi); + itmp = (int)(ftmp * fQuantizeTable16[k]); + iout[fCopyMatrix16[k]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = x0r - x2r; - xi = x1r - x3r; + //tmp[8 * Constants.TerrainPatchSize + k] = C16_8R * (xr - xi); // + ftmp = C16_8R * (xr - xi); + indx = 8 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[4 * Constants.TerrainPatchSize + k] = C16_4R * xr - C16_4I * xi; // - ftmp = C16_4R * xr - C16_4I * xi; - indx = 4 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[12 * Constants.TerrainPatchSize + k] = C16_4R * xi + C16_4I * xr; // - ftmp = C16_4R * xi + C16_4I * xr; - indx = 12 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = x0r - x2r; + xi = x1r - x3r; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[4 * Constants.TerrainPatchSize + k] = C16_4R * xr - C16_4I * xi; // + ftmp = C16_4R * xr - C16_4I * xi; + indx = 4 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - x0r = W16_8R * (x1i - x3i); - x2r = W16_8R * (x1i + x3i); - xr = x0i + x0r; - xi = x2r + x2i; + //tmp[12 * Constants.TerrainPatchSize + k] = C16_4R * xi + C16_4I * xr; // + ftmp = C16_4R * xi + C16_4I * xr; + indx = 12 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[2 * Constants.TerrainPatchSize + k] = C16_2R * xr - C16_2I * xi; // - ftmp = C16_2R * xr - C16_2I * xi; - indx = 2 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[14 * Constants.TerrainPatchSize + k] = C16_2R * xi + C16_2I * xr; // - ftmp = C16_2R * xi + C16_2I * xr; - indx = 14 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + x0r = W16_8R * (x1i - x3i); + x2r = W16_8R * (x1i + x3i); + xr = x0i + x0r; + xi = x2r + x2i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[2 * Constants.TerrainPatchSize + k] = C16_2R * xr - C16_2I * xi; // + ftmp = C16_2R * xr - C16_2I * xi; + indx = 2 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = x0i - x0r; - xi = x2r - x2i; + //tmp[14 * Constants.TerrainPatchSize + k] = C16_2R * xi + C16_2I * xr; // + ftmp = C16_2R * xi + C16_2I * xr; + indx = 14 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[6 * Constants.TerrainPatchSize + k] = C16_6R * xr - C16_6I * xi; // - ftmp = C16_6R * xr - C16_6I * xi; - indx = 6 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[10 * Constants.TerrainPatchSize + k] = C16_6R * xi + C16_6I * xr; // - ftmp = C16_6R * xi + C16_6I * xr; - indx = 10 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = x0i - x0r; + xi = x2r - x2i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[6 * Constants.TerrainPatchSize + k] = C16_6R * xr - C16_6I * xi; // + ftmp = C16_6R * xr - C16_6I * xi; + indx = 6 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = W16_8R * (x6r - x6i); - xi = W16_8R * (x6i + x6r); - x6r = x4r - xr; - x6i = x4i - xi; - x4r += xr; - x4i += xi; - xr = W16_4I * x7r - W16_4R * x7i; - xi = W16_4I * x7i + W16_4R * x7r; - x7r = W16_4R * x5r - W16_4I * x5i; - x7i = W16_4R * x5i + W16_4I * x5r; - x5r = x7r + xr; - x5i = x7i + xi; - x7r -= xr; - x7i -= xi; - xr = x4r + x5r; - xi = x5i + x4i; + //tmp[10 * Constants.TerrainPatchSize + k] = C16_6R * xi + C16_6I * xr; // + ftmp = C16_6R * xi + C16_6I * xr; + indx = 10 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[1 * Constants.TerrainPatchSize + k] = C16_1R * xr - C16_1I * xi; // - ftmp = C16_1R * xr - C16_1I * xi; - indx = 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[15 * Constants.TerrainPatchSize + k] = C16_1R * xi + C16_1I * xr; // - ftmp = C16_1R * xi + C16_1I * xr; - indx = 15 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = W16_8R * (x6r - x6i); + xi = W16_8R * (x6i + x6r); + x6r = x4r - xr; + x6i = x4i - xi; + x4r += xr; + x4i += xi; + xr = W16_4I * x7r - W16_4R * x7i; + xi = W16_4I * x7i + W16_4R * x7r; + x7r = W16_4R * x5r - W16_4I * x5i; + x7i = W16_4R * x5i + W16_4I * x5r; + x5r = x7r + xr; + x5i = x7i + xi; + x7r -= xr; + x7i -= xi; + xr = x4r + x5r; + xi = x5i + x4i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[1 * Constants.TerrainPatchSize + k] = C16_1R * xr - C16_1I * xi; // + ftmp = C16_1R * xr - C16_1I * xi; + indx = 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = x4r - x5r; - xi = x5i - x4i; + //tmp[15 * Constants.TerrainPatchSize + k] = C16_1R * xi + C16_1I * xr; // + ftmp = C16_1R * xi + C16_1I * xr; + indx = 15 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[7 * Constants.TerrainPatchSize + k] = C16_7R * xr - C16_7I * xi; // - ftmp = C16_7R * xr - C16_7I * xi; - indx = 7 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[9 * Constants.TerrainPatchSize + k] = C16_7R * xi + C16_7I * xr; // - ftmp = C16_7R * xi + C16_7I * xr; - indx = 9 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = x4r - x5r; + xi = x5i - x4i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[7 * Constants.TerrainPatchSize + k] = C16_7R * xr - C16_7I * xi; // + ftmp = C16_7R * xr - C16_7I * xi; + indx = 7 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = x6r - x7i; - xi = x7r + x6i; + //tmp[9 * Constants.TerrainPatchSize + k] = C16_7R * xi + C16_7I * xr; // + ftmp = C16_7R * xi + C16_7I * xr; + indx = 9 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[5 * Constants.TerrainPatchSize + k] = C16_5R * xr - C16_5I * xi; // - ftmp = C16_5R * xr - C16_5I * xi; - indx = 5 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[11 * Constants.TerrainPatchSize + k] = C16_5R * xi + C16_5I * xr; // - ftmp = C16_5R * xi + C16_5I * xr; - indx = 11 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = x6r - x7i; + xi = x7r + x6i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[5 * Constants.TerrainPatchSize + k] = C16_5R * xr - C16_5I * xi; // + ftmp = C16_5R * xr - C16_5I * xi; + indx = 5 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - xr = x6r + x7i; - xi = x7r - x6i; + //tmp[11 * Constants.TerrainPatchSize + k] = C16_5R * xi + C16_5I * xr; // + ftmp = C16_5R * xi + C16_5I * xr; + indx = 11 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; - //tmp[3 * Constants.TerrainPatchSize + k] = C16_3R * xr - C16_3I * xi; // - ftmp = C16_3R * xr - C16_3I * xi; - indx = 3 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; - - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } - } - //tmp[13 * Constants.TerrainPatchSize + k] = C16_3R * xi + C16_3I * xr; // - ftmp = C16_3R * xi + C16_3I * xr; - indx = 13 * 16 + k; - itmp = (int)(ftmp * QuantizeTable16[indx]); - iout[CopyMatrix16[indx]] = itmp; + xr = x6r + x7i; + xi = x7r - x6i; - if (dowbits) - { - if (itmp < 0) itmp *= -1; - while (itmp > wbitsMaxValue) + //tmp[3 * Constants.TerrainPatchSize + k] = C16_3R * xr - C16_3I * xi; // + ftmp = C16_3R * xr - C16_3I * xi; + indx = 3 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) { - wbits++; - wbitsMaxValue = 1 << wbits; - if (wbits == maxwbits) + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) { - dowbits = false; - break; + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } + } + } + + //tmp[13 * Constants.TerrainPatchSize + k] = C16_3R * xi + C16_3I * xr; // + ftmp = C16_3R * xi + C16_3I * xr; + indx = 13 * 16 + k; + itmp = (int)(ftmp * fQuantizeTable16[indx]); + iout[fCopyMatrix16[indx]] = itmp; + + if (dowbits) + { + if (itmp < 0) itmp *= -1; + while (itmp > wbitsMaxValue) + { + wbits++; + wbitsMaxValue = 1 << wbits; + if (wbits == maxwbits) + { + dowbits = false; + break; + } } } } diff --git a/OpenSim/Region/Framework/Scenes/TerrainUtil.cs b/OpenSim/Region/Framework/Scenes/TerrainUtil.cs index 79ce908c87..7f76e01f74 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainUtil.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainUtil.cs @@ -62,17 +62,13 @@ namespace OpenSim.Region.Framework.Scenes double h10 = map[(int) x + stepSize, (int) y]; double h01 = map[(int) x, (int) y + stepSize]; double h11 = map[(int) x + stepSize, (int) y + stepSize]; - double h1 = h00; - double h2 = h10; - double h3 = h01; - double h4 = h11; - double a00 = h1; - double a10 = h2 - h1; - double a01 = h3 - h1; - double a11 = h1 - h2 - h3 + h4; + double a00 = h00; + double a10 = h10 - h00; + double a01 = h01 - h00; + double a11 = h11 - h10 - h01 + h00; double partialx = x - (int) x; - double partialz = y - (int) y; - double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); + double partialy = y - (int) y; + double hi = a00 + (a10 * partialx) + (a01 * partialy) + (a11 * partialx * partialy); return hi; } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index c7b781839e..0fc724b379 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1014,19 +1014,16 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server return false; } - public void SendLayerData(float[] map) + public void SendLayerData() { - } - public void SendLayerData(int px, int py, float[] map) + public void SendLayerData(int[] map) { - } public void SendWindData(int version, Vector2[] windSpeeds) { - } public void SendCloudData(int version, float[] cloudCover) diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index c66126800e..516f9eb4bd 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -630,9 +630,7 @@ namespace OpenSim.Region.OptionalModules.Materials if (faceEntry != null) { faceEntry.MaterialID = id; - //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); - // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually sop.Shape.TextureEntry = te.GetBytes(); } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 0758fc9735..9c130618fc 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -742,14 +742,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; } - public virtual void SendLayerData(float[] map) + public virtual void SendLayerData() { } - public virtual void SendLayerData(int px, int py, float[] map) - { - } - public virtual void SendLayerData(int px, int py, float[] map, bool track) + public void SendLayerData(int[] map) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index ecf3785b31..de9ab98779 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -653,14 +653,11 @@ namespace OpenSim.Tests.Common return false; } - public virtual void SendLayerData(float[] map) + public virtual void SendLayerData() { } - public virtual void SendLayerData(int px, int py, float[] map) - { - } - public virtual void SendLayerData(int px, int py, float[] map, bool track) + public void SendLayerData(int[] map) { }