From c8a68fb3fbac0d99b53a62bb062232c0d5695d3c Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 7 Aug 2009 18:40:56 -0400 Subject: * Remove hard coded 256 limitations from various places. There's no more 256m limitation within the OpenSimulator framework, however, the LLClient ClientView does not support regions larger then 256 meters so, if you try and make your region larger by setting Constants.RegionSize = 512; in OpenSim.Framework.Constants.cs, the terrain will not display on clients using the LLUDP protocol --- OpenSim/Data/MSSQL/MSSQLRegionData.cs | 12 +++--- OpenSim/Data/MySQL/MySQLRegionData.cs | 12 +++--- OpenSim/Data/NHibernate/NHibernateRegionData.cs | 4 +- OpenSim/Data/SQLite/SQLiteRegionData.cs | 18 ++++----- .../Scripting/EMailModules/EmailModule.cs | 5 ++- .../CoreModules/World/Terrain/Tests/TerrainTest.cs | 39 +++++++++--------- .../CoreModules/World/WorldMap/MapImageModule.cs | 3 +- .../World/WorldMap/ShadedMapTileRenderer.cs | 17 ++++---- .../World/WorldMap/TexturedMapTileRenderer.cs | 12 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 13 ++++++ .../Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 10 ++++- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 4 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 47 +++++++++++++++++----- .../Region/Physics/OdePlugin/Tests/ODETestClass.cs | 4 +- 14 files changed, 126 insertions(+), 74 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 0fe8de7..d79d32b 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs @@ -485,7 +485,7 @@ ELSE /// public double[,] LoadTerrain(UUID regionID) { - double[,] terrain = new double[256, 256]; + double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; terrain.Initialize(); string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; @@ -502,9 +502,9 @@ ELSE { MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); BinaryReader br = new BinaryReader(str); - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { terrain[x, y] = br.ReadDouble(); } @@ -749,12 +749,12 @@ VALUES /// private static Array serializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream(65536 * sizeof(double)); + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { double height = val[x, y]; if (height == 0.0) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 09564de..2166845 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -583,16 +583,16 @@ namespace OpenSim.Data.MySQL { while (reader.Read()) { - terrain = new double[256,256]; + terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; terrain.Initialize(); MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]); int rev = 0; BinaryReader br = new BinaryReader(mstr); - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { terrain[x, y] = br.ReadDouble(); } @@ -1141,12 +1141,12 @@ namespace OpenSim.Data.MySQL /// private static Array SerializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream(65536*sizeof (double)); + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { double height = val[x, y]; if (height == 0.0) diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 3f04f68..26ec500 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -376,8 +376,8 @@ namespace OpenSim.Data.NHibernate // BinaryWriter bw = new BinaryWriter(str); // // // TODO: COMPATIBILITY - Add byte-order conversions -// for (int x = 0; x < 256; x++) -// for (int y = 0; y < 256; y++) +// for (int x = 0; x < (int)Constants.RegionSize; x++) +// for (int y = 0; y < (int)Constants.RegionSize; y++) // bw.Write(val[x, y]); // // return str.ToArray(); diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 2f9f59d..3555caf 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -571,7 +571,7 @@ namespace OpenSim.Data.SQLite { lock (ds) { - double[,] terret = new double[256,256]; + double[,] terret = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; terret.Initialize(); String sql = "select RegionUUID, Revision, Heightfield from terrain" + @@ -589,9 +589,9 @@ namespace OpenSim.Data.SQLite // TODO: put this into a function MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); BinaryReader br = new BinaryReader(str); - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { terret[x, y] = br.ReadDouble(); } @@ -1427,12 +1427,12 @@ namespace OpenSim.Data.SQLite /// private static Array serializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream(65536*sizeof (double)); + MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < (int)Constants.RegionSize; x++) + for (int y = 0; y < (int)Constants.RegionSize; y++) bw.Write(val[x, y]); return str.ToArray(); @@ -1443,12 +1443,12 @@ namespace OpenSim.Data.SQLite // row["RegionUUID"] = regionUUID; // row["Revision"] = rev; -// MemoryStream str = new MemoryStream(65536*sizeof (double)); + // MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize )*sizeof (double)); // BinaryWriter bw = new BinaryWriter(str); // // TODO: COMPATIBILITY - Add byte-order conversions -// for (int x = 0; x < 256; x++) -// for (int y = 0; y < 256; y++) + // for (int x = 0; x < (int)Constants.RegionSize; x++) + // for (int y = 0; y < (int)Constants.RegionSize; y++) // bw.Write(val[x, y]); // row["Heightfield"] = str.ToArray(); diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 905239b..83f004d 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -34,6 +34,7 @@ using DotNetOpenMail.SmtpAuth; using log4net; using Nini.Config; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -205,8 +206,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules if (part != null) { ObjectRegionName = s.RegionInfo.RegionName; - uint localX = (s.RegionInfo.RegionLocX * 256); - uint localY = (s.RegionInfo.RegionLocY * 256); + uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); + uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; return part; } diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs index 9660092..3d4f762 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs @@ -27,6 +27,7 @@ using System; using NUnit.Framework; +using OpenSim.Framework; using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes; using OpenSim.Region.Framework.Scenes; @@ -38,12 +39,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests [Test] public void BrushTest() { - bool[,] allowMask = new bool[256, 256]; + bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; int x; int y; - for (x=0; x<128; x++) + for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++) { - for (y=0; y<256; y++) + for (y = 0; y < (int)Constants.RegionSize; y++) { allowMask[x,y] = true; } @@ -52,20 +53,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests // // Test RaiseSphere // - TerrainChannel map = new TerrainChannel(256, 256); + TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); ITerrainPaintableEffect effect = new RaiseSphere(); - effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 0.1); - Assert.That(map[127, 128] > 0.0, "Raise brush should raising value at this point (127,128)."); - Assert.That(map[124, 128] > 0.0, "Raise brush should raising value at this point (124,128)."); - Assert.That(map[123, 128] == 0.0, "Raise brush should not change value at this point (123,128)."); - Assert.That(map[128, 128] == 0.0, "Raise brush should not change value at this point (128,128)."); - Assert.That(map[0, 128] == 0.0, "Raise brush should not change value at this point (0,128)."); + effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1); + Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128)."); + Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128)."); + Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128)."); + Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128)."); + Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128)."); // // Test LowerSphere // - map = new TerrainChannel(256, 256); + map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); for (x=0; x= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); - Assert.That(map[127, 128] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); - Assert.That(map[124, 128] < 1.0, "Lower brush should lowering value at this point (124,128)."); - Assert.That(map[123, 128] == 1.0, "Lower brush should not change value at this point (123,128)."); - Assert.That(map[128, 128] == 1.0, "Lower brush should not change value at this point (128,128)."); - Assert.That(map[0, 128] == 1.0, "Lower brush should not change value at this point (0,128)."); + effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0); + Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); + Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); + Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128)."); + Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128)."); + Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128)."); + Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128)."); } [Test] public void TerrainChannelTest() { - TerrainChannel x = new TerrainChannel(256, 256); + TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); x[0, 0] = 1.0; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs index 7afada3..d1d3045 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs @@ -33,6 +33,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenMetaverse.Imaging; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -97,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } terrainRenderer.Initialise(m_scene, m_config); - Bitmap mapbmp = new Bitmap(256, 256); + Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize); //long t = System.Environment.TickCount; //for (int i = 0; i < 10; ++i) { terrainRenderer.TerrainToBitmap(mapbmp); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs index 1836026..f39cf68 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs @@ -30,6 +30,7 @@ using System.Drawing; using System.Reflection; using log4net; using Nini.Config; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.World.WorldMap @@ -60,9 +61,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap float low = 255; float high = 0; - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { float hmval = (float)hm[x, y]; if (hmval < low) @@ -74,12 +75,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < (int)Constants.RegionSize; y++) { // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left - int yr = 255 - y; + int yr = ((int)Constants.RegionSize - 1) - y; float heightvalue = (float)hm[x, y]; @@ -111,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap float hfvalue = (float)hm[x, y]; float hfvaluecompare = 0f; - if ((x + 1 < 256) && (y + 1 < 256)) + if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize)) { hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there } @@ -176,7 +177,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (ShadowDebugContinue) { - if ((x - 1 > 0) && (yr + 1 < 256)) + if ((x - 1 > 0) && (yr + 1 < (int)Constants.RegionSize)) { color = mapbmp.GetPixel(x - 1, yr + 1); int r = color.R; @@ -231,7 +232,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap terraincorruptedwarningsaid = true; } Color black = Color.Black; - mapbmp.SetPixel(x, (256 - y) - 1, black); + mapbmp.SetPixel(x, ((int)Constants.RegionSize - y) - 1, black); } } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs index 0364e7b..97ee451 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs @@ -306,15 +306,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap double[,] hm = m_scene.Heightmap.GetDoubles(); - for (int x = 0; x < 256; x++) + for (int x = 0; x < (int)Constants.RegionSize; x++) { - float columnRatio = x / 255f; // 0 - 1, for interpolation - for (int y = 0; y < 256; y++) + float columnRatio = x / ((float)Constants.RegionSize - 1); // 0 - 1, for interpolation + for (int y = 0; y < (int)Constants.RegionSize; y++) { - float rowRatio = y / 255f; // 0 - 1, for interpolation + float rowRatio = y / ((float)Constants.RegionSize - 1); // 0 - 1, for interpolation // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left - int yr = 255 - y; + int yr = ((int)Constants.RegionSize - 1) - y; float heightvalue = getHeight(hm, x, y); if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue)) @@ -366,7 +366,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // Shade the terrain for shadows - if (x < 255 && y < 255) + if (x < ((int)Constants.RegionSize - 1) && y < ((int)Constants.RegionSize - 1)) { float hfvaluecompare = getHeight(hm, x + 1, y + 1); // light from north-east => look at land height there if (Single.IsInfinity(hfvaluecompare) || Single.IsNaN(hfvaluecompare)) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b48cf62..e344da3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1192,6 +1192,19 @@ namespace OpenSim.Region.Framework.Scenes Heightmap = new TerrainChannel(map); } } + catch (IOException e) + { + + m_log.Warn("[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString() + " Regenerating"); + + // Non standard region size. If there's an old terrain in the database, it might read past the buffer + if ((int)Constants.RegionSize != 256) + { + Heightmap = new TerrainChannel(); + + m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); + } + } catch (Exception e) { m_log.Warn("[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString()); diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs index a7bf2d6..2cc5d41 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs @@ -216,8 +216,14 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero); tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero); - AxisLockLinearLow = new btVector3(-256,-256,-256); - AxisLockLinearHigh = new btVector3(512, 512, 512); + + AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize); + int regionsize = (int) Constants.RegionSize; + + if (regionsize == 256) + regionsize = 512; + + AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize); _target_velocity = new PhysicsVector(0, 0, 0); _velocity = new PhysicsVector(); diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index b8af77d..b556395 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1096,8 +1096,8 @@ namespace OpenSim.Region.Physics.OdePlugin // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) if (vec.X < 0.0f) vec.X = 0.0f; if (vec.Y < 0.0f) vec.Y = 0.0f; - if (vec.X > 255.95f) vec.X = 255.95f; - if (vec.Y > 255.95f) vec.Y = 255.95f; + if (vec.X > (int)Constants.RegionSize - 0.05f) vec.X = (int)Constants.RegionSize - 0.05f; + if (vec.Y > (int)Constants.RegionSize - 0.05f) vec.Y = (int)Constants.RegionSize - 0.05f; _position.X = vec.X; _position.Y = vec.Y; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 9805ff5..50dc91d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -304,6 +304,13 @@ namespace OpenSim.Region.Physics.OdePlugin public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); + private uint heightmapWidth = m_regionWidth + 1; + private uint heightmapHeight = m_regionHeight + 1; + + private uint heightmapWidthSamples; + + private uint heightmapHeightSamples; + private volatile int m_global_contactcount = 0; private ODERayCastRequestManager m_rayCastManager; @@ -3271,27 +3278,49 @@ namespace OpenSim.Region.Physics.OdePlugin // this._heightmap[i] = (double)heightMap[i]; // dbm (danx0r) -- creating a buffer zone of one extra sample all around _origheightmap = heightMap; // Used for Fly height. Kitto Flora - const uint heightmapWidth = m_regionWidth + 2; - const uint heightmapHeight = m_regionHeight + 2; - const uint heightmapWidthSamples = 2*m_regionWidth + 2; - const uint heightmapHeightSamples = 2*m_regionHeight + 2; + uint heightmapWidth = m_regionWidth + 1; + uint heightmapHeight = m_regionHeight + 1; + + uint heightmapWidthSamples; + + uint heightmapHeightSamples; + if (((int)Constants.RegionSize) == 256) + { + heightmapWidthSamples = 2*m_regionWidth + 2; + heightmapHeightSamples = 2*m_regionHeight + 2; + heightmapWidth++; + heightmapHeight++; + } + else + { + heightmapWidthSamples = m_regionWidth + 1; + heightmapHeightSamples = m_regionHeight + 1; + } + const float scale = 1.0f; const float offset = 0.0f; const float thickness = 0.2f; const int wrap = 0; + //Double resolution - heightMap = ResizeTerrain512Interpolation(heightMap); + if (((int)Constants.RegionSize) == 256) + heightMap = ResizeTerrain512Interpolation(heightMap); + + int regionsize = (int)Constants.RegionSize; + if (regionsize == 256) + regionsize = 512; + float hfmin = 2000; float hfmax = -2000; for (int x = 0; x < heightmapWidthSamples; x++) { for (int y = 0; y < heightmapHeightSamples; y++) { - int xx = Util.Clip(x - 1, 0, 511); - int yy = Util.Clip(y - 1, 0, 511); + int xx = Util.Clip(x - 1, 0, regionsize - 1); + int yy = Util.Clip(y - 1, 0, regionsize - 1); - float val = heightMap[yy*512 + xx]; + float val = heightMap[yy*regionsize + xx]; _heightmap[x*heightmapHeightSamples + y] = val; hfmin = (val < hfmin) ? val : hfmin; hfmax = (val > hfmax) ? val : hfmax; @@ -3332,7 +3361,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); d.GeomSetRotation(LandGeom, ref R); - d.GeomSetPosition(LandGeom, 128, 128, 0); + d.GeomSetPosition(LandGeom, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, 0); } } diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs index 7d748fd..b186175 100644 --- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs +++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs @@ -56,8 +56,8 @@ namespace OpenSim.Region.Physics.OdePlugin ps = cbt.GetScene("test"); // Initializing Physics Scene. ps.Initialise(imp.GetMesher(),null); - float[] _heightmap = new float[256 * 256]; - for (int i = 0; i<(256*256);i++) + float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; + for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) { _heightmap[i] = 21f; } -- cgit v1.1