Terrain: more double to float
parent
5d2ffdc35b
commit
d9d78c3423
|
@ -147,6 +147,9 @@ namespace OpenSim.Region.CoreModules.Framework.InterfaceCommander
|
|||
case "Integer":
|
||||
m_args[i].ArgumentValue = Int32.Parse(arg.ToString());
|
||||
break;
|
||||
case "Float":
|
||||
m_args[i].ArgumentValue = float.Parse(arg.ToString(), OpenSim.Framework.Culture.NumberFormatInfo);
|
||||
break;
|
||||
case "Double":
|
||||
m_args[i].ArgumentValue = Double.Parse(arg.ToString(), OpenSim.Framework.Culture.NumberFormatInfo);
|
||||
break;
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
/// <param name='y'>
|
||||
/// Y.
|
||||
/// </param>
|
||||
double operate(double[,] map, TerrainModifierData data, int x, int y);
|
||||
float operate(float[,] map, TerrainModifierData data, int x, int y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,10 +80,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
return val;
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = data.elevation - (data.elevation - data.bevelevation) * factor;
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float result = data.elevation - (data.elevation - data.bevelevation) * factor;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = map[x, y] - (data.elevation - (data.elevation - data.bevelevation) * factor);
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float result = map[x, y] - (data.elevation - (data.elevation - data.bevelevation) * factor);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = Math.Min(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]);
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float result = Math.Min(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = Math.Max(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]);
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float result = Math.Max(data.elevation - (data.elevation - data.bevelevation) * factor, map[x, y]);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,11 +96,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
return val;
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double noise = TerrainUtil.PerlinNoise2D((double)x / map.GetLength(0), (double)y / map.GetLength(1), 8, 1.0);
|
||||
return map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor) * (noise - .5);
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float noise = (float)TerrainUtil.PerlinNoise2D((double)x / map.GetLength(0), (double)y / map.GetLength(1), 8, 1.0);
|
||||
return map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor) * (noise - .5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,10 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor);
|
||||
float factor = this.computeBevel(data, x, y);
|
||||
float result = map[x, y] + (data.elevation - (data.elevation - data.bevelevation) * factor);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,22 +95,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
|||
return val;
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
public override float operate(float[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double[] scale = new double[3];
|
||||
float[] scale = new float[3];
|
||||
scale[0] = data.elevation;
|
||||
scale[1] = ((1.0 - scale[0]) * data.bevelevation) / 8.0;
|
||||
scale[2] = ((1.0 - scale[0]) * (1.0 - data.bevelevation)) / 16.0;
|
||||
scale[1] = ((1.0f - scale[0]) * data.bevelevation) / 8.0f;
|
||||
scale[2] = ((1.0f - scale[0]) * (1.0f - data.bevelevation)) / 16.0f;
|
||||
int xMax = map.GetLength(0);
|
||||
int yMax = map.GetLength(1);
|
||||
double result;
|
||||
float result;
|
||||
if ((x == 0) || (y == 0) || (x == (xMax - 1)) || (y == (yMax - 1)))
|
||||
{
|
||||
result = map[x, y];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0.0;
|
||||
result = 0.0f;
|
||||
for(int yPos = (y - 2); yPos < (y + 3); yPos++)
|
||||
{
|
||||
int yVal = (yPos <= 0) ? 0 : ((yPos < yMax) ? yPos : yMax - 1);
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
|
||||
public abstract string GetUsage();
|
||||
|
||||
public abstract double operate(double[,] map, TerrainModifierData data, int x, int y);
|
||||
public abstract float operate(float[,] map, TerrainModifierData data, int x, int y);
|
||||
|
||||
protected String parseParameters(string[] args, out TerrainModifierData data)
|
||||
{
|
||||
|
@ -153,8 +153,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
protected string parseFloat(String s, out float f)
|
||||
{
|
||||
string result;
|
||||
double d;
|
||||
if (Double.TryParse(s, out d))
|
||||
float d;
|
||||
if (float.TryParse(s, out d))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -213,7 +213,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
yMid = 0;
|
||||
}
|
||||
// m_log.DebugFormat("Apply {0} mask {1}x{2} @ {3},{4}", data.shape, xMax, yMax, xMid, yMid);
|
||||
double[,] buffer = map.GetDoubles();
|
||||
|
||||
float[,] buffer = new float[map.Width, map.Height];
|
||||
for (int x = data.x0; x < xMax; ++x)
|
||||
for (int y = data.y0; y < yMax; ++y)
|
||||
buffer[x,y] = map[x,y];
|
||||
|
||||
int yDim = yMax;
|
||||
while(--yDim >= 0)
|
||||
{
|
||||
|
@ -224,6 +229,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
while(--xDim >= 0)
|
||||
{
|
||||
int xPos = data.x0 + xDim - xMid;
|
||||
|
||||
if ((xPos >= 0) && (xPos < map.Width) && (mask[xDim, yDim]))
|
||||
{
|
||||
double endElevation = this.operate(buffer, data, xPos, yPos);
|
||||
|
@ -234,13 +240,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
}
|
||||
}
|
||||
|
||||
protected double computeBevel(TerrainModifierData data, int x, int y)
|
||||
protected float computeBevel(TerrainModifierData data, int x, int y)
|
||||
{
|
||||
int deltaX;
|
||||
int deltaY;
|
||||
int xMax;
|
||||
int yMax;
|
||||
double factor;
|
||||
float factor;
|
||||
if (data.bevel == "taper")
|
||||
{
|
||||
if (data.shape == "ellipse")
|
||||
|
@ -249,7 +255,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
deltaY = y - data.y0;
|
||||
xMax = data.dx;
|
||||
yMax = data.dy;
|
||||
factor = (double)((deltaX * deltaX) + (deltaY * deltaY));
|
||||
factor = ((deltaX * deltaX) + (deltaY * deltaY));
|
||||
factor /= ((xMax * xMax) + (yMax * yMax));
|
||||
}
|
||||
else
|
||||
|
@ -259,12 +265,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
yMax = data.dy / 2 + data.dy % 2;
|
||||
deltaX = Math.Abs(data.x0 + xMax - x);
|
||||
deltaY = Math.Abs(data.y0 + yMax - y);
|
||||
factor = Math.Max(((double)(deltaY) / yMax), ((double)(deltaX) / xMax));
|
||||
factor = Math.Max(((float)(deltaY) / yMax), ((float)(deltaX) / xMax));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 0.0;
|
||||
factor = 0.0f;
|
||||
}
|
||||
return factor;
|
||||
}
|
||||
|
|
|
@ -1832,19 +1832,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
Command fillRegionCommand =
|
||||
new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
|
||||
fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.",
|
||||
"Double");
|
||||
"Float");
|
||||
|
||||
Command elevateCommand =
|
||||
new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount.");
|
||||
elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double");
|
||||
elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Float");
|
||||
|
||||
Command lowerCommand =
|
||||
new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount.");
|
||||
lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double");
|
||||
lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Float");
|
||||
|
||||
Command multiplyCommand =
|
||||
new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified.");
|
||||
multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
|
||||
multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Float");
|
||||
|
||||
Command bakeRegionCommand =
|
||||
new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions baked map.");
|
||||
|
@ -1857,14 +1857,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
|
||||
Command rescaleCommand =
|
||||
new Command("rescale", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRescaleTerrain, "Rescales the current terrain to fit between the given min and max heights");
|
||||
rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Double");
|
||||
rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Double");
|
||||
rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Float");
|
||||
rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Float");
|
||||
|
||||
Command minCommand = new Command("min", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMinTerrain, "Sets the minimum terrain height to the specified value.");
|
||||
minCommand.AddArgument("min", "terrain height to use as minimum", "Double");
|
||||
minCommand.AddArgument("min", "terrain height to use as minimum", "Float");
|
||||
|
||||
Command maxCommand = new Command("max", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMaxTerrain, "Sets the maximum terrain height to the specified value.");
|
||||
maxCommand.AddArgument("min", "terrain height to use as maximum", "Double");
|
||||
maxCommand.AddArgument("min", "terrain height to use as maximum", "Float");
|
||||
|
||||
|
||||
// Debug
|
||||
|
|
Loading…
Reference in New Issue