* 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

arthursv
Teravus Ovares (Dan Olivares) 2009-08-07 18:40:56 -04:00
parent a1a09297bc
commit c8a68fb3fb
14 changed files with 126 additions and 74 deletions

View File

@ -485,7 +485,7 @@ ELSE
/// <returns></returns>
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
/// <returns></returns>
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)

View File

@ -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
/// <returns></returns>
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)

View File

@ -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();

View File

@ -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
/// <returns></returns>
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();

View File

@ -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;
}

View File

@ -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<map.Width; x++)
{
for (y=0; y<map.Height; y++)
@ -75,19 +76,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
}
effect = new LowerSphere();
effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 6.0);
Assert.That(map[127, 128] >= 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;

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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))

View File

@ -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());

View File

@ -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();

View File

@ -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;

View File

@ -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
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);
}
}

View File

@ -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;
}