terrain replace double by float
parent
9eb5fd4330
commit
d10f11d310
|
@ -194,9 +194,6 @@ namespace OpenSim.Framework
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This one dimensional version is ordered so height = map[y*sizeX+x];
|
|
||||||
// DEPRECATED: don't use this function as it does not retain the dimensions of the terrain
|
|
||||||
// and the caller will probably do the wrong thing if the terrain is not the legacy 256x256.
|
|
||||||
public float[] GetFloatsSerialized()
|
public float[] GetFloatsSerialized()
|
||||||
{
|
{
|
||||||
int points = SizeX * SizeY;
|
int points = SizeX * SizeY;
|
||||||
|
@ -485,7 +482,8 @@ namespace OpenSim.Framework
|
||||||
for (int yy = 0; yy < SizeY; yy++)
|
for (int yy = 0; yy < SizeY; yy++)
|
||||||
for (int xx = 0; xx < SizeX; xx++)
|
for (int xx = 0; xx < SizeX; xx++)
|
||||||
{
|
{
|
||||||
bw.Write((float)m_heightmap[xx, yy]);
|
//bw.Write((float)m_heightmap[xx, yy]);
|
||||||
|
bw.Write((float)Math.Round(m_heightmap[xx, yy], 3, MidpointRounding.AwayFromZero));
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.Flush();
|
bw.Flush();
|
||||||
|
|
|
@ -68,14 +68,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillMap(ITerrainChannel map, double val)
|
private void FillMap(ITerrainChannel map, float val)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < map.Width; x++)
|
for (int x = 0; x < map.Width; x++)
|
||||||
for (int y = 0; y < map.Height; y++)
|
for (int y = 0; y < map.Height; y++)
|
||||||
map[x, y] = val;
|
map[x, y] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildTiles(ITerrainChannel map, double height)
|
private void BuildTiles(ITerrainChannel map, float height)
|
||||||
{
|
{
|
||||||
int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8);
|
int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8);
|
||||||
int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8);
|
int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8);
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
for (x = 0; x < sectionWidth; x++)
|
for (x = 0; x < sectionWidth; x++)
|
||||||
{
|
{
|
||||||
// Read a strip and continue
|
// Read a strip and continue
|
||||||
retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0);
|
retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0f);
|
||||||
bs.ReadBytes(11);
|
bs.ReadBytes(11);
|
||||||
}
|
}
|
||||||
// record that we wrote it
|
// record that we wrote it
|
||||||
|
@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; x < retval.Width; x++)
|
for (x = 0; x < retval.Width; x++)
|
||||||
{
|
{
|
||||||
retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0);
|
retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0f);
|
||||||
bs.ReadBytes(11); // Advance the stream to next bytes.
|
bs.ReadBytes(11); // Advance the stream to next bytes.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
for (int x = 0; x < sectionWidth; x++)
|
for (int x = 0; x < sectionWidth; x++)
|
||||||
{
|
{
|
||||||
// Read a strip and continue
|
// Read a strip and continue
|
||||||
retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0;
|
retval[x, y] = baseHeight + bs.ReadInt16() * (float)heightScale / 65536.0f;
|
||||||
}
|
}
|
||||||
// record that we wrote it
|
// record that we wrote it
|
||||||
currFileXOffset++;
|
currFileXOffset++;
|
||||||
|
@ -188,13 +188,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
eof = true;
|
eof = true;
|
||||||
// create new channel of proper size (now that we know it)
|
// create new channel of proper size (now that we know it)
|
||||||
retval = new TerrainChannel(w, h);
|
retval = new TerrainChannel(w, h);
|
||||||
double heightScale = (double)bs.ReadInt16() / 65536.0;
|
float heightScale = bs.ReadInt16() / 65536.0f;
|
||||||
double baseHeight = (double)bs.ReadInt16();
|
float baseHeight = bs.ReadInt16();
|
||||||
for (int y = 0; y < h; y++)
|
for (int y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < w; x++)
|
for (int x = 0; x < w; x++)
|
||||||
{
|
{
|
||||||
retval[x, y] = baseHeight + (double)bs.ReadInt16() * heightScale;
|
retval[x, y] = baseHeight + bs.ReadInt16() * heightScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -222,14 +222,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
BinaryWriter bs = new BinaryWriter(stream);
|
BinaryWriter bs = new BinaryWriter(stream);
|
||||||
|
|
||||||
//find the max and min heights on the map
|
//find the max and min heights on the map
|
||||||
double heightMax = map[0,0];
|
float heightMax = map[0,0];
|
||||||
double heightMin = map[0,0];
|
float heightMin = map[0,0];
|
||||||
|
|
||||||
for (int y = 0; y < map.Height; y++)
|
for (int y = 0; y < map.Height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < map.Width; x++)
|
for (int x = 0; x < map.Width; x++)
|
||||||
{
|
{
|
||||||
double current = map[x,y];
|
float current = map[x,y];
|
||||||
if (heightMax < current)
|
if (heightMax < current)
|
||||||
heightMax = current;
|
heightMax = current;
|
||||||
if (heightMin > current)
|
if (heightMin > current)
|
||||||
|
@ -237,13 +237,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double baseHeight = Math.Floor( (heightMax + heightMin) / 2d );
|
float baseHeight = (float)Math.Floor(0.5f * (heightMax + heightMin));
|
||||||
|
|
||||||
double horizontalScale = Math.Ceiling((heightMax - heightMin));
|
float horizontalScale = (float) Math.Ceiling((heightMax - heightMin));
|
||||||
|
|
||||||
// if we are completely flat add 1cm range to avoid NaN divisions
|
// if we are completely flat add 1cm range to avoid NaN divisions
|
||||||
if (horizontalScale < 0.01d)
|
if (horizontalScale < 0.01f)
|
||||||
horizontalScale = 0.01d;
|
horizontalScale = 0.01f;
|
||||||
|
|
||||||
Encoding enc = Encoding.ASCII;
|
Encoding enc = Encoding.ASCII;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
|
||||||
for (int y = startY; y <= endY; y++)
|
for (int y = startY; y <= endY; y++)
|
||||||
{
|
{
|
||||||
if (fillArea[x, y])
|
if (fillArea[x, y])
|
||||||
map[x, y] = (map[x, y] * (1.0 - strength)) + (height * strength);
|
map[x, y] = (map[x, y] * (1.0f - strength)) + (height * strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
|
||||||
{
|
{
|
||||||
if (fillArea[x, y])
|
if (fillArea[x, y])
|
||||||
{
|
{
|
||||||
double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
|
float noise = (float)TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
|
||||||
map[x, y] += noise * strength;
|
map[x, y] += noise * strength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
|
||||||
if(strength > 1.0f)
|
if(strength > 1.0f)
|
||||||
strength = 1.0f;
|
strength = 1.0f;
|
||||||
|
|
||||||
double[,] tweak = new double[endX - startX + 1, endX - startX + 1];
|
float[,] tweak = new float[endX - startX + 1, endY - startY + 1];
|
||||||
|
|
||||||
for (int x = startX, i = 0; x <= endX; x++, i++)
|
for (int x = startX, i = 0; x <= endX; x++, i++)
|
||||||
{
|
{
|
||||||
|
@ -57,17 +57,23 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
|
||||||
if (!fillArea[x, y])
|
if (!fillArea[x, y])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double average = 0.0;
|
float average = 0f;
|
||||||
int avgsteps = 0;
|
int avgsteps = 0;
|
||||||
|
|
||||||
for (int n = x - sx; n <= x + sx; ++n)
|
for (int n = x - sx; n <= x + sx; ++n)
|
||||||
|
{
|
||||||
|
if (n >= 0 && n < map.Width)
|
||||||
{
|
{
|
||||||
for (int l = y - sy; l < y + sy; ++l)
|
for (int l = y - sy; l < y + sy; ++l)
|
||||||
|
{
|
||||||
|
if (l >= 0 && l < map.Height)
|
||||||
{
|
{
|
||||||
avgsteps++;
|
avgsteps++;
|
||||||
average += map[n, l];
|
average += map[n, l];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tweak[i, j] = average / avgsteps;
|
tweak[i, j] = average / avgsteps;
|
||||||
}
|
}
|
||||||
|
@ -77,11 +83,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
|
||||||
{
|
{
|
||||||
for (int y = startY, j = 0; y <= endY; y++, j++)
|
for (int y = startY, j = 0; y <= endY; y++, j++)
|
||||||
{
|
{
|
||||||
double ty = tweak[i, j];
|
float ty = tweak[i, j];
|
||||||
if (ty == 0.0)
|
if (ty == 0.0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
map[x, y] = (1.0 - strength) * map[x, y] + strength * ty;
|
map[x, y] = (1.0f - strength) * map[x, y] + strength * ty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
// Calculate a cos-sphere and add it to the heighmap
|
// Calculate a cos-sphere and add it to the heighmap
|
||||||
double r = Math.Sqrt(dx2 + (y - ry) * (y - ry));
|
double r = Math.Sqrt(dx2 + (y - ry) * (y - ry));
|
||||||
double distancefactor = Math.Cos(r * size);
|
float distancefactor = (float)Math.Cos(r * size);
|
||||||
if (distancefactor > 0.0)
|
if (distancefactor > 0.0)
|
||||||
{
|
{
|
||||||
double newz = map[x, y] - distancefactor * strength;
|
float newz = map[x, y] - distancefactor * strength;
|
||||||
if (newz <= 0f)
|
if (newz <= 0f)
|
||||||
map[x, y] = 0f;
|
map[x, y] = 0f;
|
||||||
else
|
else
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distancefactor = strength * (1.0f - distancefactor);
|
distancefactor = strength * (1.0f - distancefactor);
|
||||||
double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
|
float noise = (float)TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
|
||||||
map[x, y] += noise * distancefactor;
|
map[x, y] += noise * distancefactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
|
|
||||||
// Calculate a cos-sphere and add it to the heighmap
|
// Calculate a cos-sphere and add it to the heighmap
|
||||||
double r = Math.Sqrt(dx2 + (y - ry) * (y - ry));
|
double r = Math.Sqrt(dx2 + (y - ry) * (y - ry));
|
||||||
double distancefactor = Math.Cos(r * size);
|
float distancefactor = (float)Math.Cos(r * size);
|
||||||
if (distancefactor > 0.0)
|
if (distancefactor > 0.0)
|
||||||
map[x, y] += distancefactor * strength;
|
map[x, y] += distancefactor * strength;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distancefactor = strength * (1.0f - distancefactor);
|
distancefactor = strength * (1.0f - distancefactor);
|
||||||
map[x, y] = (map[x, y] * (1.0 - distancefactor)) + (m_revertmap[x, y] * distancefactor);
|
map[x, y] = (map[x, y] * (1.0f - distancefactor)) + (m_revertmap[x, y] * distancefactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
float distancefactor;
|
float distancefactor;
|
||||||
float dx2;
|
float dx2;
|
||||||
|
|
||||||
double[,] tweak = new double[endX - startX + 1, endX - startX + 1];
|
float[,] tweak = new float[endX - startX + 1, endY - startY + 1];
|
||||||
int ssize = (int)(size + 0.5);
|
int ssize = (int)(size + 0.5);
|
||||||
if(ssize > 4)
|
if(ssize > 4)
|
||||||
ssize = 4;
|
ssize = 4;
|
||||||
|
@ -64,16 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
distancefactor = strength * (1.0f - distancefactor);
|
distancefactor = strength * (1.0f - distancefactor);
|
||||||
|
|
||||||
double average = 0.0;
|
float average = 0f;
|
||||||
int avgsteps = 0;
|
int avgsteps = 0;
|
||||||
|
|
||||||
for (int n = x - ssize; n <= x + ssize; ++n)
|
for (int n = x - ssize; n <= x + ssize; ++n)
|
||||||
{
|
{
|
||||||
if(n > 0 && n < map.Width)
|
if(n >= 0 && n < map.Width)
|
||||||
{
|
{
|
||||||
for (int l = y - ssize; l <= y + ssize; ++l)
|
for (int l = y - ssize; l <= y + ssize; ++l)
|
||||||
{
|
{
|
||||||
if (l > 0 && l < map.Height)
|
if (l >= 0 && l < map.Height)
|
||||||
{
|
{
|
||||||
avgsteps++;
|
avgsteps++;
|
||||||
average += map[n, l];
|
average += map[n, l];
|
||||||
|
@ -91,10 +91,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
|
||||||
{
|
{
|
||||||
for (int y = startY, j = 0; y <= endY; y++, j++)
|
for (int y = startY, j = 0; y <= endY; y++, j++)
|
||||||
{
|
{
|
||||||
double tz = tweak[i, j];
|
float tz = tweak[i, j];
|
||||||
if(tz != 0.0)
|
if(tz != 0.0)
|
||||||
{
|
{
|
||||||
double newz = map[x, y] - tz;
|
float newz = map[x, y] - tz;
|
||||||
if (newz > 0.0)
|
if (newz > 0.0)
|
||||||
map[x, y] = newz;
|
map[x, y] = newz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim]))
|
if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim]))
|
||||||
{
|
{
|
||||||
double endElevation = this.operate(buffer, data, xPos, yPos);
|
double endElevation = this.operate(buffer, data, xPos, yPos);
|
||||||
map[xPos, yPos] = endElevation;
|
map[xPos, yPos] = (float)endElevation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1564,8 +1564,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
for (int y = 0; y < m_channel.Height / 2; y++)
|
for (int y = 0; y < m_channel.Height / 2; y++)
|
||||||
{
|
{
|
||||||
double height = m_channel[x, y];
|
float height = m_channel[x, y];
|
||||||
double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y];
|
float flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y];
|
||||||
m_channel[x, y] = flippedHeight;
|
m_channel[x, y] = flippedHeight;
|
||||||
m_channel[x, (int)m_channel.Height - 1 - y] = height;
|
m_channel[x, (int)m_channel.Height - 1 - y] = height;
|
||||||
|
|
||||||
|
@ -1578,8 +1578,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
for (int x = 0; x < m_channel.Width / 2; x++)
|
for (int x = 0; x < m_channel.Width / 2; x++)
|
||||||
{
|
{
|
||||||
double height = m_channel[x, y];
|
float height = m_channel[x, y];
|
||||||
double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y];
|
float flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y];
|
||||||
m_channel[x, y] = flippedHeight;
|
m_channel[x, y] = flippedHeight;
|
||||||
m_channel[(int)m_channel.Width - 1 - x, y] = height;
|
m_channel[(int)m_channel.Width - 1 - x, y] = height;
|
||||||
|
|
||||||
|
@ -1594,11 +1594,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
|
|
||||||
private void InterfaceRescaleTerrain(Object[] args)
|
private void InterfaceRescaleTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
double desiredMin = (double)args[0];
|
float desiredMin = (float)args[0];
|
||||||
double desiredMax = (double)args[1];
|
float desiredMax = (float)args[1];
|
||||||
|
|
||||||
// determine desired scaling factor
|
// determine desired scaling factor
|
||||||
double desiredRange = desiredMax - desiredMin;
|
float desiredRange = desiredMax - desiredMin;
|
||||||
//m_log.InfoFormat("Desired {0}, {1} = {2}", new Object[] { desiredMin, desiredMax, desiredRange });
|
//m_log.InfoFormat("Desired {0}, {1} = {2}", new Object[] { desiredMin, desiredMax, desiredRange });
|
||||||
|
|
||||||
if (desiredRange == 0d)
|
if (desiredRange == 0d)
|
||||||
|
@ -1609,8 +1609,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//work out current heightmap range
|
//work out current heightmap range
|
||||||
double currMin = double.MaxValue;
|
float currMin = float.MaxValue;
|
||||||
double currMax = double.MinValue;
|
float currMax = float.MinValue;
|
||||||
|
|
||||||
int width = m_channel.Width;
|
int width = m_channel.Width;
|
||||||
int height = m_channel.Height;
|
int height = m_channel.Height;
|
||||||
|
@ -1619,7 +1619,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
for(int y = 0; y < height; y++)
|
for(int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
double currHeight = m_channel[x, y];
|
float currHeight = m_channel[x, y];
|
||||||
if (currHeight < currMin)
|
if (currHeight < currMin)
|
||||||
{
|
{
|
||||||
currMin = currHeight;
|
currMin = currHeight;
|
||||||
|
@ -1631,8 +1631,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double currRange = currMax - currMin;
|
float currRange = currMax - currMin;
|
||||||
double scale = desiredRange / currRange;
|
float scale = desiredRange / currRange;
|
||||||
|
|
||||||
//m_log.InfoFormat("Current {0}, {1} = {2}", new Object[] { currMin, currMax, currRange });
|
//m_log.InfoFormat("Current {0}, {1} = {2}", new Object[] { currMin, currMax, currRange });
|
||||||
//m_log.InfoFormat("Scale = {0}", scale);
|
//m_log.InfoFormat("Scale = {0}", scale);
|
||||||
|
@ -1642,7 +1642,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
{
|
{
|
||||||
for(int y = 0; y < height; y++)
|
for(int y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
double currHeight = m_channel[x, y] - currMin;
|
float currHeight = m_channel[x, y] - currMin;
|
||||||
m_channel[x, y] = desiredMin + (currHeight * scale);
|
m_channel[x, y] = desiredMin + (currHeight * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1652,7 +1652,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
|
|
||||||
private void InterfaceElevateTerrain(Object[] args)
|
private void InterfaceElevateTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
|
@ -1663,7 +1663,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
private void InterfaceMultiplyTerrain(Object[] args)
|
private void InterfaceMultiplyTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
|
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
for (y = 0; y < m_channel.Height; y++)
|
for (y = 0; y < m_channel.Height; y++)
|
||||||
|
@ -1673,7 +1673,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
private void InterfaceLowerTerrain(Object[] args)
|
private void InterfaceLowerTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
|
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
for (y = 0; y < m_channel.Height; y++)
|
for (y = 0; y < m_channel.Height; y++)
|
||||||
|
@ -1683,7 +1683,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
public void InterfaceFillTerrain(Object[] args)
|
public void InterfaceFillTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
|
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
for (y = 0; y < m_channel.Height; y++)
|
for (y = 0; y < m_channel.Height; y++)
|
||||||
|
@ -1693,7 +1693,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
private void InterfaceMinTerrain(Object[] args)
|
private void InterfaceMinTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
{
|
{
|
||||||
for(y = 0; y < m_channel.Height; y++)
|
for(y = 0; y < m_channel.Height; y++)
|
||||||
|
@ -1706,7 +1706,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
private void InterfaceMaxTerrain(Object[] args)
|
private void InterfaceMaxTerrain(Object[] args)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double val = (double)args[0];
|
float val = (float)args[0];
|
||||||
for (x = 0; x < m_channel.Width; x++)
|
for (x = 0; x < m_channel.Width; x++)
|
||||||
{
|
{
|
||||||
for(y = 0; y < m_channel.Height; y++)
|
for(y = 0; y < m_channel.Height; y++)
|
||||||
|
@ -1733,8 +1733,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
|
|
||||||
private void InterfaceShowDebugStats(Object[] args)
|
private void InterfaceShowDebugStats(Object[] args)
|
||||||
{
|
{
|
||||||
double max = Double.MinValue;
|
float max = float.MinValue;
|
||||||
double min = double.MaxValue;
|
float min = float.MaxValue;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
|
||||||
{
|
{
|
||||||
for (y=0; y<map.Height; y++)
|
for (y=0; y<map.Height; y++)
|
||||||
{
|
{
|
||||||
map[x,y] = 1.0;
|
map[x,y] = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
effect = new LowerSphere();
|
effect = new LowerSphere();
|
||||||
|
@ -96,19 +96,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
|
||||||
TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
|
TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
|
||||||
Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly.");
|
Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly.");
|
||||||
|
|
||||||
x[0, 0] = 1.0;
|
x[0, 0] = 1.0f;
|
||||||
Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly.");
|
Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly.");
|
||||||
|
|
||||||
x[0, 0] = 0;
|
x[0, 0] = 0;
|
||||||
x[0, 0] += 5.0;
|
x[0, 0] += 5.0f;
|
||||||
x[0, 0] -= 1.0;
|
x[0, 0] -= 1.0f;
|
||||||
Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error.");
|
Assert.That(x[0, 0] == 4.0f, "Terrain addition/subtraction error.");
|
||||||
|
|
||||||
x[0, 0] = 1.0;
|
x[0, 0] = 1.0f;
|
||||||
float[] floatsExport = x.GetFloatsSerialised();
|
float[] floatsExport = x.GetFloatsSerialised();
|
||||||
Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly.");
|
Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly.");
|
||||||
|
|
||||||
x[0, 0] = 1.0;
|
x[0, 0] = 1.0f;
|
||||||
Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
|
Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
|
||||||
Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
|
Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
int Height { get;} // Y dimension
|
int Height { get;} // Y dimension
|
||||||
int Altitude { get;} // Z dimension
|
int Altitude { get;} // Z dimension
|
||||||
|
|
||||||
double this[int x, int y] { get; set; }
|
float this[int x, int y] { get; set; }
|
||||||
|
|
||||||
float GetHeightAtXYZ(float x, float y, float z);
|
float GetHeightAtXYZ(float x, float y, float z);
|
||||||
|
|
||||||
|
|
|
@ -119,10 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return m_terrainData;
|
return m_terrainData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ITerrainChannel.GetFloatsSerialized()
|
|
||||||
// This one dimensional version is ordered so height = map[y*sizeX+x];
|
// This one dimensional version is ordered so height = map[y*sizeX+x];
|
||||||
// DEPRECATED: don't use this function as it does not retain the dimensions of the terrain
|
|
||||||
// and the caller will probably do the wrong thing if the terrain is not the legacy 256x256.
|
|
||||||
public float[] GetFloatsSerialised()
|
public float[] GetFloatsSerialised()
|
||||||
{
|
{
|
||||||
return m_terrainData.GetFloatsSerialized();
|
return m_terrainData.GetFloatsSerialized();
|
||||||
|
@ -147,12 +144,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
// ITerrainChannel.this[x,y]
|
// ITerrainChannel.this[x,y]
|
||||||
public double this[int x, int y]
|
public float this[int x, int y]
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
if (x < 0 || x >= Width || y < 0 || y >= Height)
|
if (x < 0 || x >= Width || y < 0 || y >= Height)
|
||||||
return 0;
|
return 0;
|
||||||
return (double)m_terrainData[x, y];
|
return m_terrainData[x, y];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -492,7 +489,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
float value;
|
float value;
|
||||||
value = BitConverter.ToSingle(dataArray, index);
|
value = BitConverter.ToSingle(dataArray, index);
|
||||||
index += 4;
|
index += 4;
|
||||||
this[x, y] = (double)value;
|
this[x, y] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
|
if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
|
||||||
{
|
{
|
||||||
World.Heightmap[x, y] = val;
|
World.Heightmap[x, y] = (float)val;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue