'terrain modify' command for area-of-effect operations
Signed-off-by: Michael Cerquoni <nebadon2025@gmail.com>inv-download
parent
8676b017b2
commit
4bf62e11b6
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
{
|
||||
public interface ITerrainModifier
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the feature.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Empty string if successful, otherwise error message.
|
||||
/// </returns>
|
||||
/// <param name='map'>
|
||||
/// ITerrainChannel holding terrain data.
|
||||
/// </param>
|
||||
/// <param name='args'>
|
||||
/// command-line arguments from console.
|
||||
/// </param>
|
||||
string ModifyTerrain(ITerrainChannel map, string[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string describing the usage.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A string describing parameters for creating the feature.
|
||||
/// Format is "feature-name <arg1> <arg2> ..."
|
||||
/// </returns>
|
||||
string GetUsage();
|
||||
|
||||
/// <summary>
|
||||
/// Apply the appropriate operation on the specified map, at (x, y).
|
||||
/// </summary>
|
||||
/// <param name='map'>
|
||||
/// Map.
|
||||
/// </param>
|
||||
/// <param name='data'>
|
||||
/// Data.
|
||||
/// </param>
|
||||
/// <param name='x'>
|
||||
/// X.
|
||||
/// </param>
|
||||
/// <param name='y'>
|
||||
/// Y.
|
||||
/// </param>
|
||||
double operate(double[,] map, TerrainModifierData data, int x, int y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class FillModifier : TerrainModifier
|
||||
{
|
||||
|
||||
public FillModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "fill <height> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<height2>]"
|
||||
+ "\nSets all points within the specified range to the specified value.";
|
||||
return val;
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double factor = this.computeBevel(data, x, y);
|
||||
double result = data.elevation - (data.elevation - data.bevelevation) * factor;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class LowerModifier : TerrainModifier
|
||||
{
|
||||
public LowerModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "lower <delta> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<delta2>]"
|
||||
+ "\nLowers all points within the specified range by the specified amount.";
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public override double operate(double[,] 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);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class MaxModifier : TerrainModifier
|
||||
{
|
||||
public MaxModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "max <height> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<height2>]"
|
||||
+ "\nEnsures that all points within the specified range are no higher than the specified value.";
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public override double operate(double[,] 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]);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class MinModifier : TerrainModifier
|
||||
{
|
||||
public MinModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "min <height> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<height2>]"
|
||||
+ "\nEnsures that all points within the specified range are no lower than the specified value.";
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public override double operate(double[,] 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]);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class RaiseModifier : TerrainModifier
|
||||
{
|
||||
public RaiseModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "raise <delta> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<delta2>]"
|
||||
+ "\nRaises all points within the specified range by the specified amount.";
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public override double operate(double[,] 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);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using OpenSim.Region.CoreModules.World.Terrain;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain.Modifiers
|
||||
{
|
||||
public class SmoothModifier : TerrainModifier
|
||||
{
|
||||
public SmoothModifier(ITerrainModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModifyTerrain(ITerrainChannel map, string[] args)
|
||||
{
|
||||
string val;
|
||||
string result;
|
||||
if (args.Length < 3)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
TerrainModifierData data;
|
||||
result = this.parseParameters(args, out data);
|
||||
|
||||
// Context-specific validation
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (data.bevel == "taper")
|
||||
{
|
||||
if (data.bevelevation < 0.01 || data.bevelevation > 0.99)
|
||||
{
|
||||
result = String.Format("Taper must be 0.01 to 0.99 {0}", data.bevelevation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.bevelevation = 2.0f / 3.0f;
|
||||
}
|
||||
|
||||
if (data.elevation < 0.0 || data.elevation > 1.0)
|
||||
{
|
||||
result = String.Format("Scaling factor must be 0.0 to 1.0: {0}", data.elevation);
|
||||
}
|
||||
|
||||
if (data.shape == String.Empty)
|
||||
{
|
||||
data.shape = "rectangle";
|
||||
data.x0 = 0;
|
||||
data.y0 = 0;
|
||||
data.dx = map.Width;
|
||||
data.dy = map.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// if it's all good, then do the work
|
||||
if (result == String.Empty)
|
||||
{
|
||||
this.applyModification(map, data);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string GetUsage()
|
||||
{
|
||||
string val = "smooth <strength> [ -rec=x1,y1,dx[,dy] | -ell=x0,y0,rx[,ry] ] [-taper=<fraction>]"
|
||||
+ "\nSmooths all points within the specified range using a simple averaging algorithm.";
|
||||
return val;
|
||||
}
|
||||
|
||||
public override double operate(double[,] map, TerrainModifierData data, int x, int y)
|
||||
{
|
||||
double[] scale = new double[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;
|
||||
int xMax = map.GetLength(0);
|
||||
int yMax = map.GetLength(1);
|
||||
double result;
|
||||
if ((x == 0) || (y == 0) || (x == (xMax - 1)) || (y == (yMax - 1)))
|
||||
{
|
||||
result = map[x, y];
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0.0;
|
||||
for(int yPos = (y - 2); yPos < (y + 3); yPos++)
|
||||
{
|
||||
int yVal = (yPos <= 0) ? 0 : ((yPos < yMax) ? yPos : yMax - 1);
|
||||
for(int xPos = (x - 2); xPos < (x + 3); xPos++)
|
||||
{
|
||||
int xVal = (xPos <= 0) ? 0 : ((xPos < xMax) ? xPos : xMax - 1);
|
||||
int dist = Math.Max(Math.Abs(x - xVal), Math.Abs(y - yVal));
|
||||
result += map[xVal, yVal] * scale[dist];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
{
|
||||
public abstract class TerrainModifier : ITerrainModifier
|
||||
{
|
||||
protected ITerrainModule m_module;
|
||||
protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected TerrainModifier(ITerrainModule module)
|
||||
{
|
||||
m_module = module;
|
||||
}
|
||||
|
||||
public abstract string ModifyTerrain(ITerrainChannel map, string[] args);
|
||||
|
||||
public abstract string GetUsage();
|
||||
|
||||
public abstract double operate(double[,] map, TerrainModifierData data, int x, int y);
|
||||
|
||||
protected String parseParameters(string[] args, out TerrainModifierData data)
|
||||
{
|
||||
string val;
|
||||
string arg;
|
||||
string result;
|
||||
data = new TerrainModifierData();
|
||||
data.shape = String.Empty;
|
||||
data.bevel = String.Empty;
|
||||
data.dx = 0;
|
||||
data.dy = 0;
|
||||
if (args.Length < 4)
|
||||
{
|
||||
result = "Usage: " + GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = this.parseFloat(args[3], out data.elevation);
|
||||
}
|
||||
if (result == String.Empty)
|
||||
{
|
||||
int index = 3;
|
||||
while(++index < args.Length && result == String.Empty)
|
||||
{
|
||||
arg = args[index];
|
||||
// check for shape
|
||||
if (arg.StartsWith("-rec=") || arg.StartsWith("-ell="))
|
||||
{
|
||||
if (data.shape != String.Empty)
|
||||
{
|
||||
result = "Only 1 '-rec' or '-ell' parameter is permitted.";
|
||||
}
|
||||
else
|
||||
{
|
||||
data.shape = arg.StartsWith("-ell=") ? "ellipse" : "rectangle";
|
||||
val = arg.Substring(arg.IndexOf("=") + 1);
|
||||
string[] coords = val.Split(new char[] {','});
|
||||
if ((coords.Length < 3) || (coords.Length > 4))
|
||||
{
|
||||
result = String.Format("Bad format for shape parameter {0}", arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = this.parseInt(coords[0], out data.x0);
|
||||
if (result == String.Empty)
|
||||
{
|
||||
result = this.parseInt(coords[1], out data.y0);
|
||||
}
|
||||
if (result == String.Empty)
|
||||
{
|
||||
result = this.parseInt(coords[2], out data.dx);
|
||||
}
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if (coords.Length == 4)
|
||||
{
|
||||
result = this.parseInt(coords[3], out data.dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.dy = data.dx;
|
||||
}
|
||||
}
|
||||
if (result == String.Empty)
|
||||
{
|
||||
if ((data.dx <= 0) || (data.dy <= 0))
|
||||
{
|
||||
result = "Shape sizes must be positive integers";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = String.Format("Bad value in shape parameters {0}", arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (arg.StartsWith("-taper="))
|
||||
{
|
||||
if (data.bevel != String.Empty)
|
||||
{
|
||||
result = "Only 1 '-taper' parameter is permitted.";
|
||||
}
|
||||
else
|
||||
{
|
||||
data.bevel = "taper";
|
||||
val = arg.Substring(arg.IndexOf("=") + 1);
|
||||
result = this.parseFloat(val, out data.bevelevation);
|
||||
if (result != String.Empty)
|
||||
{
|
||||
result = String.Format("Bad format for taper parameter {0}", arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = String.Format("Unrecognized parameter {0}", arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected string parseFloat(String s, out float f)
|
||||
{
|
||||
string result;
|
||||
double d;
|
||||
if (Double.TryParse(s, out d))
|
||||
{
|
||||
try
|
||||
{
|
||||
f = (float)d;
|
||||
result = String.Empty;
|
||||
}
|
||||
catch(InvalidCastException)
|
||||
{
|
||||
result = String.Format("{0} is invalid", s);
|
||||
f = -1.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f = -1.0f;
|
||||
result = String.Format("{0} is invalid", s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected string parseInt(String s, out int i)
|
||||
{
|
||||
string result;
|
||||
if (Int32.TryParse(s, out i))
|
||||
{
|
||||
result = String.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = String.Format("{0} is invalid", s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void applyModification(ITerrainChannel map, TerrainModifierData data)
|
||||
{
|
||||
bool[,] mask;
|
||||
int xMax;
|
||||
int yMax;
|
||||
int xMid;
|
||||
int yMid;
|
||||
if (data.shape == "ellipse")
|
||||
{
|
||||
mask = this.ellipticalMask(data.dx, data.dy);
|
||||
xMax = mask.GetLength(0);
|
||||
yMax = mask.GetLength(1);
|
||||
xMid = xMax / 2 + xMax % 2;
|
||||
yMid = yMax / 2 + yMax % 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = this.rectangularMask(data.dx, data.dy);
|
||||
xMax = mask.GetLength(0);
|
||||
yMax = mask.GetLength(1);
|
||||
xMid = 0;
|
||||
yMid = 0;
|
||||
}
|
||||
// m_log.DebugFormat("Apply {0} mask {1}x{2} @ {3},{4}", data.shape, xMax, yMax, xMid, yMid);
|
||||
double[,] buffer = map.GetDoubles();
|
||||
int yDim = yMax;
|
||||
while(--yDim >= 0)
|
||||
{
|
||||
int yPos = data.y0 + yDim - yMid;
|
||||
if ((yPos >= 0) && (yPos < map.Height))
|
||||
{
|
||||
int xDim = xMax;
|
||||
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);
|
||||
map[xPos, yPos] = endElevation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected double computeBevel(TerrainModifierData data, int x, int y)
|
||||
{
|
||||
int deltaX;
|
||||
int deltaY;
|
||||
int xMax;
|
||||
int yMax;
|
||||
double factor;
|
||||
if (data.bevel == "taper")
|
||||
{
|
||||
if (data.shape == "ellipse")
|
||||
{
|
||||
deltaX = x - data.x0;
|
||||
deltaY = y - data.y0;
|
||||
xMax = data.dx;
|
||||
yMax = data.dy;
|
||||
factor = (double)((deltaX * deltaX) + (deltaY * deltaY));
|
||||
factor /= ((xMax * xMax) + (yMax * yMax));
|
||||
}
|
||||
else
|
||||
{
|
||||
// pyramid
|
||||
xMax = data.dx / 2 + data.dx % 2;
|
||||
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));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 0.0;
|
||||
}
|
||||
return factor;
|
||||
}
|
||||
|
||||
private bool[,] rectangularMask(int xSize, int ySize)
|
||||
{
|
||||
bool[,] mask = new bool[xSize, ySize];
|
||||
int yPos = ySize;
|
||||
while(--yPos >= 0)
|
||||
{
|
||||
int xPos = xSize;
|
||||
while(--xPos >= 0)
|
||||
{
|
||||
mask[xPos, yPos] = true;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fast ellipse-based derivative of Bresenham algorithm.
|
||||
* https://web.archive.org/web/20120225095359/http://homepage.smc.edu/kennedy_john/belipse.pdf
|
||||
*/
|
||||
private bool[,] ellipticalMask(int xRadius, int yRadius)
|
||||
{
|
||||
long twoASquared = 2L * xRadius * xRadius;
|
||||
long twoBSquared = 2L * yRadius * yRadius;
|
||||
|
||||
bool[,] mask = new bool[2 * xRadius + 1, 2 * yRadius + 1];
|
||||
|
||||
long ellipseError = 0L;
|
||||
long stoppingX = twoBSquared * xRadius;
|
||||
long stoppingY = 0L;
|
||||
long xChange = yRadius * yRadius * (1L - 2L * xRadius);
|
||||
long yChange = xRadius * xRadius;
|
||||
|
||||
int xPos = xRadius;
|
||||
int yPos = 0;
|
||||
|
||||
// first set of points
|
||||
while(stoppingX >= stoppingY)
|
||||
{
|
||||
int yUpper = yRadius + yPos;
|
||||
int yLower = yRadius - yPos;
|
||||
// fill in the mask
|
||||
int xNow = xPos;
|
||||
while(xNow >= 0)
|
||||
{
|
||||
mask[xRadius + xNow, yUpper] = true;
|
||||
mask[xRadius - xNow, yUpper] = true;
|
||||
mask[xRadius + xNow, yLower] = true;
|
||||
mask[xRadius - xNow, yLower] = true;
|
||||
--xNow;
|
||||
}
|
||||
yPos++;
|
||||
stoppingY += twoASquared;
|
||||
ellipseError += yChange;
|
||||
yChange += twoASquared;
|
||||
if ((2L * ellipseError + xChange) > 0L)
|
||||
{
|
||||
xPos--;
|
||||
stoppingX -= twoBSquared;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquared;
|
||||
}
|
||||
}
|
||||
|
||||
// second set of points
|
||||
xPos = 0;
|
||||
yPos = yRadius;
|
||||
xChange = yRadius * yRadius;
|
||||
yChange = xRadius * xRadius * (1L - 2L * yRadius);
|
||||
|
||||
ellipseError = 0L;
|
||||
stoppingX = 0L;
|
||||
stoppingY = twoASquared * yRadius;
|
||||
|
||||
while(stoppingX <= stoppingY)
|
||||
{
|
||||
int xUpper = xRadius + xPos;
|
||||
int xLower = xRadius - xPos;
|
||||
// fill in the mask
|
||||
int yNow = yPos;
|
||||
while(yNow >= 0)
|
||||
{
|
||||
mask[xUpper, yRadius + yNow] = true;
|
||||
mask[xUpper, yRadius - yNow] = true;
|
||||
mask[xLower, yRadius + yNow] = true;
|
||||
mask[xLower, yRadius - yNow] = true;
|
||||
--yNow;
|
||||
}
|
||||
xPos++;
|
||||
stoppingX += twoBSquared;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquared;
|
||||
if ((2L * ellipseError + yChange) > 0L)
|
||||
{
|
||||
yPos--;
|
||||
stoppingY -= twoASquared;
|
||||
ellipseError += yChange;
|
||||
yChange += twoASquared;
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Terrain
|
||||
{
|
||||
public struct TerrainModifierData
|
||||
{
|
||||
public float elevation;
|
||||
public string shape;
|
||||
public int x0;
|
||||
public int y0;
|
||||
public int dx;
|
||||
public int dy;
|
||||
public string bevel;
|
||||
public float bevelevation;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,6 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@ -43,6 +42,7 @@ using OpenSim.Framework.Console;
|
|||
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
||||
using OpenSim.Region.CoreModules.World.Terrain.FileLoaders;
|
||||
using OpenSim.Region.CoreModules.World.Terrain.Features;
|
||||
using OpenSim.Region.CoreModules.World.Terrain.Modifiers;
|
||||
using OpenSim.Region.CoreModules.World.Terrain.FloodBrushes;
|
||||
using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
|
@ -90,26 +90,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
#pragma warning restore 414
|
||||
|
||||
private readonly Commander m_commander = new Commander("terrain");
|
||||
|
||||
private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects =
|
||||
new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>();
|
||||
|
||||
private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
|
||||
|
||||
private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
|
||||
new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
|
||||
|
||||
private Dictionary<string, ITerrainEffect> m_plugineffects;
|
||||
|
||||
private Dictionary<string, ITerrainFeature> m_featureEffects =
|
||||
new Dictionary<string, ITerrainFeature>();
|
||||
|
||||
private Dictionary<string, ITerrainModifier> m_modifyOperations =
|
||||
new Dictionary<string, ITerrainModifier>();
|
||||
private ITerrainChannel m_channel;
|
||||
private ITerrainChannel m_revert;
|
||||
private Scene m_scene;
|
||||
private volatile bool m_tainted;
|
||||
private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
|
||||
|
||||
private String m_InitialTerrain = "pinhead-island";
|
||||
|
||||
// If true, send terrain patch updates to clients based on their view distance
|
||||
|
@ -136,14 +131,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
{
|
||||
return (updateCount > 0);
|
||||
}
|
||||
|
||||
public void SetByXY(int x, int y, bool state)
|
||||
{
|
||||
this.SetByPatch(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, state);
|
||||
}
|
||||
|
||||
public bool GetByPatch(int patchX, int patchY)
|
||||
{
|
||||
return updated[patchX, patchY];
|
||||
}
|
||||
|
||||
public void SetByPatch(int patchX, int patchY, bool state)
|
||||
{
|
||||
bool prevState = updated[patchX, patchY];
|
||||
|
@ -153,6 +151,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
updateCount--;
|
||||
updated[patchX, patchY] = state;
|
||||
}
|
||||
|
||||
public void SetAll(bool state)
|
||||
{
|
||||
updateCount = 0;
|
||||
|
@ -201,8 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
|
||||
#region ICommandableModule Members
|
||||
|
||||
public ICommander CommandInterface
|
||||
{
|
||||
public ICommander CommandInterface {
|
||||
get { return m_commander; }
|
||||
}
|
||||
|
||||
|
@ -304,13 +302,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
{
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
public Type ReplaceableInterface {
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
public string Name {
|
||||
get { return "TerrainModule"; }
|
||||
}
|
||||
|
||||
|
@ -664,6 +660,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
// Terrain Feature effects
|
||||
m_featureEffects["rectangle"] = new RectangleFeature(this);
|
||||
|
||||
// Terrain Modifier operations
|
||||
m_modifyOperations["min"] = new MinModifier(this);
|
||||
m_modifyOperations["max"] = new MaxModifier(this);
|
||||
m_modifyOperations["raise"] = new RaiseModifier(this);
|
||||
m_modifyOperations["lower"] = new LowerModifier(this);
|
||||
m_modifyOperations["fill"] = new FillModifier(this);
|
||||
m_modifyOperations["smooth"] = new SmoothModifier(this);
|
||||
|
||||
// Filesystem load/save loaders
|
||||
m_loaders[".r32"] = new RAW32();
|
||||
m_loaders[".f32"] = m_loaders[".r32"];
|
||||
|
@ -1019,12 +1023,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
public int PatchX;
|
||||
public int PatchY;
|
||||
public float Dist;
|
||||
|
||||
public PatchesToSend(int pX, int pY, float pDist)
|
||||
{
|
||||
PatchX = pX;
|
||||
PatchY = pY;
|
||||
Dist = pDist;
|
||||
}
|
||||
|
||||
public int CompareTo(PatchesToSend other)
|
||||
{
|
||||
return Dist.CompareTo(other.Dist);
|
||||
|
@ -1668,6 +1674,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
// Add Feature command to Scene, since Command object requires fixed-length arglists
|
||||
m_scene.AddCommand("Terrain", this, "terrain feature",
|
||||
"terrain feature <type> <parameters...>", "Constructs a feature of the requested type.", FeatureCommand);
|
||||
// Add Modify command to Scene, since Command object requires fixed-length arglists
|
||||
m_scene.AddCommand("Terrain", this, "terrain modify",
|
||||
"terrain modify <operation> <value> [<area>] [<taper>]",
|
||||
"Modifies the terrain as instructed." +
|
||||
"\nEach operation can be limited to an area of effect:" +
|
||||
"\n * -ell=x,y,rx[,ry] constrains the operation to an ellipse centred at x,y" +
|
||||
"\n * -rec=x,y,dx[,dy] constrains the operation to a rectangle based at x,y" +
|
||||
"\nEach operation can have its effect tapered based on distance from centre:" +
|
||||
"\n * elliptical operations taper as cones" +
|
||||
"\n * rectangular operations taper as pyramids"
|
||||
,
|
||||
ModifyCommand);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1704,6 +1722,41 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
}
|
||||
MainConsole.Instance.Output(result);
|
||||
}
|
||||
|
||||
public void ModifyCommand(string module, string[] cmd)
|
||||
{
|
||||
string result;
|
||||
if (cmd.Length > 2)
|
||||
{
|
||||
string operationType = cmd[2];
|
||||
|
||||
ITerrainModifier operation;
|
||||
if (!m_modifyOperations.TryGetValue(operationType, out operation))
|
||||
{
|
||||
result = String.Format("Terrain Modify \"{0}\" not found.", operationType);
|
||||
}
|
||||
else if ((cmd.Length > 3) && (cmd[3] == "usage"))
|
||||
{
|
||||
result = "Usage: " + operation.GetUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = operation.ModifyTerrain(m_channel, cmd);
|
||||
}
|
||||
|
||||
if (result == String.Empty)
|
||||
{
|
||||
result = "Modified terrain";
|
||||
m_log.DebugFormat("Performed terrain operation {0}", operationType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "Usage: <operation-name> <arg1> <arg2>...";
|
||||
}
|
||||
MainConsole.Instance.Output(result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue