From 33a062612f9fafcb7b4c0e8ac60937c448ce3c10 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 21 Jan 2019 06:05:21 +0000 Subject: remove terraindata abstraction layer, since we only have heightmap type --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 89 ++++++++++------------ OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 14 ++-- .../Region/Framework/Scenes/TerrainCompressor.cs | 5 -- 3 files changed, 47 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 13b3ffb..abda29a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -410,8 +410,7 @@ namespace OpenSim.Region.Framework.Scenes m_particleSystem = Utils.EmptyBytes; Rezzed = DateTime.UtcNow; Description = String.Empty; - DynAttrs = new DAMap(); - + // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log @@ -3475,7 +3474,29 @@ namespace OpenSim.Region.Framework.Scenes private const float ANGVELOCITY_TOLERANCE = 0.005f; private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary private const double TIME_MS_TOLERANCE = 200.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds. - + + private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max) + { + float a, b; + + a = Math.Abs(v.X); + b = Math.Abs(v.Y); + if (b > a) + a = b; + b = Math.Abs(v.Z); + if (b > a) + a = b; + + if (a > max) + { + a = max / a; + v.X *= a; + v.Y *= a; + v.Z *= a; + } + return v; + } + /// /// Tell all the prims which have had updates scheduled /// @@ -3491,73 +3512,43 @@ namespace OpenSim.Region.Framework.Scenes if(current == PrimUpdateFlags.TerseUpdate) { - Vector3 curvel = Velocity; - Vector3 curacc = Acceleration; - Vector3 angvel = AngularVelocity; - while(true) // just to avoid ugly goto { double elapsed = now - m_lastUpdateSentTime; if (elapsed > TIME_MS_TOLERANCE) break; - if( Math.Abs(curacc.X - m_lastAcceleration.X) > VELOCITY_TOLERANCE || - Math.Abs(curacc.Y - m_lastAcceleration.Y) > VELOCITY_TOLERANCE || - Math.Abs(curacc.Z - m_lastAcceleration.Z) > VELOCITY_TOLERANCE) + if ( !Acceleration.ApproxEquals(m_lastAcceleration, VELOCITY_TOLERANCE)) break; - if( Math.Abs(curvel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || - Math.Abs(curvel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE || - Math.Abs(curvel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE) + Vector3 curvel = ClampVectorForTerseUpdate(Velocity, 128f); + Vector3 tmp = ClampVectorForTerseUpdate(m_lastVelocity, 128f); + if (!curvel.ApproxEquals(tmp, VELOCITY_TOLERANCE)) break; - float vx = Math.Abs(curvel.X); - if(vx > 128.0) - break; - float vy = Math.Abs(curvel.Y); - if(vy > 128.0) - break; - float vz = Math.Abs(curvel.Z); - if(vz > 128.0) - break; - - if(vx < VELOCITY_TOLERANCE && vy < VELOCITY_TOLERANCE && vz < VELOCITY_TOLERANCE - ) + if (Math.Abs(curvel.X) < 1e-4 && Math.Abs(curvel.Y) < 1e-4 && Math.Abs(curvel.Z) < 1e-4) { - if(!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + if (!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) break; - if(vx < 1e-4 && vy < 1e-4 && vz < 1e-4 && - ( - Math.Abs(m_lastVelocity.X) > 1e-4 || + if ( Math.Abs(m_lastVelocity.X) > 1e-4 || Math.Abs(m_lastVelocity.Y) > 1e-4 || Math.Abs(m_lastVelocity.Z) > 1e-4 - )) - break; - } - - if( Math.Abs(angvel.X - m_lastAngularVelocity.X) > ANGVELOCITY_TOLERANCE || - Math.Abs(angvel.Y - m_lastAngularVelocity.Y) > ANGVELOCITY_TOLERANCE || - Math.Abs(angvel.Z - m_lastAngularVelocity.Z) > ANGVELOCITY_TOLERANCE) + ) break; + } - // viewer interpolators have a limit of 64rad/s - float ax = Math.Abs(angvel.X); - if(ax > 64.0) - break; - float ay = Math.Abs(angvel.Y); - if(ay > 64.0) - break; - float az = Math.Abs(angvel.Z); - if(az > 64.0) + Vector3 angvel = ClampVectorForTerseUpdate(AngularVelocity, 64f); + tmp = ClampVectorForTerseUpdate(m_lastAngularVelocity, 64f); + if (!angvel.ApproxEquals(tmp, ANGVELOCITY_TOLERANCE)) break; - if ( - ax < ANGVELOCITY_TOLERANCE && - ay < ANGVELOCITY_TOLERANCE && - az < ANGVELOCITY_TOLERANCE && + if ( Math.Abs(AngularVelocity.X) < 1e-4 && + Math.Abs(AngularVelocity.Y) < 1e-4 && + Math.Abs(AngularVelocity.Z) < 1e-4 && !RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ) break; + return; } } diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 92fd314..96d2dc4 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes // Default, not-often-used builder public TerrainChannel() { - m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); + m_terrainData = new TerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); FlatLand(); // PinHeadIsland(); } @@ -69,14 +69,14 @@ namespace OpenSim.Region.Framework.Scenes // Create terrain of given size public TerrainChannel(int pX, int pY) { - m_terrainData = new HeightmapTerrainData(pX, pY, (int)Constants.RegionHeight); + m_terrainData = new TerrainData(pX, pY, (int)Constants.RegionHeight); } // Create terrain of specified size and initialize with specified terrain. // TODO: join this with the terrain initializers. public TerrainChannel(String type, int pX, int pY, int pZ) { - m_terrainData = new HeightmapTerrainData(pX, pY, pZ); + m_terrainData = new TerrainData(pX, pY, pZ); if (type.Equals("flat")) FlatLand(); else @@ -90,7 +90,7 @@ namespace OpenSim.Region.Framework.Scenes int hmSizeX = pM.GetLength(0); int hmSizeY = pM.GetLength(1); - m_terrainData = new HeightmapTerrainData(pSizeX, pSizeY, pAltitude); + m_terrainData = new TerrainData(pSizeX, pSizeY, pAltitude); for (int xx = 0; xx < pSizeX; xx++) for (int yy = 0; yy < pSizeY; yy++) @@ -309,7 +309,7 @@ namespace OpenSim.Region.Framework.Scenes int tmpY = baseY + baseY / 2; int centreX = tmpX / 2; int centreY = tmpY / 2; - TerrainData terrain_tmp = new HeightmapTerrainData(tmpX, tmpY, (int)Constants.RegionHeight); + TerrainData terrain_tmp = new TerrainData(tmpX, tmpY, (int)Constants.RegionHeight); for (int xx = 0; xx < tmpX; xx++) for (int yy = 0; yy < tmpY; yy++) terrain_tmp[xx, yy] = -65535f; //use this height like an 'alpha' mask channel @@ -483,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); int index = 0; - m_terrainData = new HeightmapTerrainData(Height, Width, (int)Constants.RegionHeight); + m_terrainData = new TerrainData(Height, Width, (int)Constants.RegionHeight); for (int y = 0; y < Height; y++) { @@ -530,7 +530,7 @@ namespace OpenSim.Region.Framework.Scenes { XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); - m_terrainData = new HeightmapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); + m_terrainData = new TerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); } // Fill the heightmap with the center bump terrain diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs index 2070463..fa17102 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs @@ -155,7 +155,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP return iout; } - static double tt; // new using terrain data and patchs indexes public static List CreateLayerDataPackets(TerrainData terrData, int[] map) { @@ -180,15 +179,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP bitpack.PackBitsFromByte(16); bitpack.PackBitsFromByte(landPacketType); - tt = 0; - 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) { -- cgit v1.1