diff options
author | Justin Clarke Casey | 2008-10-27 14:27:45 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-10-27 14:27:45 +0000 |
commit | 0d69e06779e23f10aba1a6bc38c1074ce3e133fc (patch) | |
tree | 9202255aa4450b50410bf990e5718df2efcf4bc0 /OpenSim/Region/Environment | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-SC_OLD-0d69e06779e23f10aba1a6bc38c1074ce3e133fc.zip opensim-SC_OLD-0d69e06779e23f10aba1a6bc38c1074ce3e133fc.tar.gz opensim-SC_OLD-0d69e06779e23f10aba1a6bc38c1074ce3e133fc.tar.bz2 opensim-SC_OLD-0d69e06779e23f10aba1a6bc38c1074ce3e133fc.tar.xz |
* Temporarily revert terrain changes in r6976 and reinstate unit test from r6977.
* If a change is going to affect a unit test, then please could we change the unit test at the same time? Otherwise this will never get done
* It also seems a bad idea to disable tests which start failing unless there's a very good reason
Diffstat (limited to 'OpenSim/Region/Environment')
3 files changed, 48 insertions, 79 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs index 290711f..fe82396 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs | |||
@@ -36,43 +36,29 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | |||
36 | 36 | ||
37 | public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) | 37 | public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) |
38 | { | 38 | { |
39 | int s = (int) (Math.Pow(2, strength) + 0.5); | 39 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
40 | 40 | duration = 0.03; //MCP Should be read from ini file | |
41 | |||
41 | int x; | 42 | int x; |
42 | int xFrom = (int)(rx-s+0.5); | 43 | for (x = 0; x < map.Width; x++) |
43 | int xTo = (int)(rx+s+0.5) + 1; | ||
44 | int yFrom = (int)(ry-s+0.5); | ||
45 | int yTo = (int)(ry+s+0.5) + 1; | ||
46 | |||
47 | if (xFrom < 0) | ||
48 | xFrom = 0; | ||
49 | |||
50 | if (yFrom < 0) | ||
51 | yFrom = 0; | ||
52 | |||
53 | if (xTo > map.Width) | ||
54 | xTo = map.Width; | ||
55 | |||
56 | if (yTo > map.Width) | ||
57 | yTo = map.Width; | ||
58 | |||
59 | for (x = xFrom; x < xTo; x++) | ||
60 | { | 44 | { |
61 | int y; | 45 | int y; |
62 | for (y = yFrom; y <= yTo; y++) | 46 | for (y = 0; y < map.Height; y++) |
63 | { | 47 | { |
64 | if (!mask[x,y]) | 48 | if (!mask[x,y]) |
65 | continue; | 49 | continue; |
66 | 50 | ||
67 | // Calculate a cos-sphere and add it to the heighmap | 51 | // Calculate a sphere and add it to the heighmap |
68 | double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); | 52 | double z = strength; |
69 | double z = Math.Cos(r * Math.PI / (s * 2)); | 53 | z *= z; |
54 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | ||
55 | |||
70 | if (z > 0.0) | 56 | if (z > 0.0) |
71 | map[x, y] -= z * duration; | 57 | map[x, y] -= z * duration; |
72 | } | 58 | } |
73 | } | 59 | } |
74 | |||
75 | } | 60 | } |
61 | |||
76 | #endregion | 62 | #endregion |
77 | } | 63 | } |
78 | } | 64 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index b1a52b0..92bac63 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -26,51 +26,34 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
32 | 30 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
34 | { | 32 | { |
35 | public class RaiseSphere : ITerrainPaintableEffect | 33 | public class RaiseSphere : ITerrainPaintableEffect |
36 | { | 34 | { |
37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
38 | #region ITerrainPaintableEffect Members | 35 | #region ITerrainPaintableEffect Members |
39 | 36 | ||
40 | 37 | ||
41 | public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) | 38 | public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) |
42 | { | 39 | { |
43 | int s = (int) (Math.Pow(2, strength) + 0.5); | 40 | duration = 0.03; //MCP Should be read from ini file |
41 | strength = TerrainUtil.MetersToSphericalStrength(strength); | ||
44 | 42 | ||
45 | int x; | 43 | int x; |
46 | int xFrom = (int)(rx-s+0.5); | 44 | for (x = 0; x < map.Width; x++) |
47 | int xTo = (int)(rx+s+0.5) + 1; | ||
48 | int yFrom = (int)(ry-s+0.5); | ||
49 | int yTo = (int)(ry+s+0.5) + 1; | ||
50 | |||
51 | if (xFrom < 0) | ||
52 | xFrom = 0; | ||
53 | |||
54 | if (yFrom < 0) | ||
55 | yFrom = 0; | ||
56 | |||
57 | if (xTo > map.Width) | ||
58 | xTo = map.Width; | ||
59 | |||
60 | if (yTo > map.Width) | ||
61 | yTo = map.Width; | ||
62 | |||
63 | for (x = xFrom; x < xTo; x++) | ||
64 | { | 45 | { |
65 | int y; | 46 | int y; |
66 | for (y = yFrom; y <= yTo; y++) | 47 | for (y = 0; y < map.Height; y++) |
67 | { | 48 | { |
68 | if (!mask[x,y]) | 49 | if (!mask[x,y]) |
69 | continue; | 50 | continue; |
70 | 51 | ||
71 | // Calculate a cos-sphere and add it to the heighmap | 52 | // Calculate a sphere and add it to the heighmap |
72 | double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); | 53 | double z = strength; |
73 | double z = Math.Cos(r * Math.PI / (s * 2)); | 54 | z *= z; |
55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | ||
56 | |||
74 | if (z > 0.0) | 57 | if (z > 0.0) |
75 | map[x, y] += z * duration; | 58 | map[x, y] += z * duration; |
76 | } | 59 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs index 4d9cf61..5b4bc8c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -34,34 +34,34 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests | |||
34 | [TestFixture] | 34 | [TestFixture] |
35 | public class TerrainTest | 35 | public class TerrainTest |
36 | { | 36 | { |
37 | // [Test] | 37 | [Test] |
38 | // public void BrushTest() | 38 | public void BrushTest() |
39 | // { | 39 | { |
40 | // TerrainChannel map = new TerrainChannel(256, 256); | 40 | TerrainChannel map = new TerrainChannel(256, 256); |
41 | // bool[,] allowMask = new bool[map.Width,map.Height]; | 41 | bool[,] allowMask = new bool[map.Width,map.Height]; |
42 | // int x; | 42 | int x; |
43 | // int y; | 43 | int y; |
44 | // for (x=0; x<map.Width; x++) | 44 | for (x=0; x<map.Width; x++) |
45 | // { | 45 | { |
46 | // for (y=0; y<map.Height; y++) | 46 | for (y=0; y<map.Height; y++) |
47 | // { | 47 | { |
48 | // allowMask[x,y] = true; | 48 | allowMask[x,y] = true; |
49 | // } | 49 | } |
50 | // } | 50 | } |
51 | // | 51 | |
52 | // ITerrainPaintableEffect effect = new RaiseSphere(); | 52 | ITerrainPaintableEffect effect = new RaiseSphere(); |
53 | // | 53 | |
54 | // effect.PaintEffect(map, allowMask, 128.0, 128.0, 23.0, 100, 0.1); | 54 | effect.PaintEffect(map, allowMask, 128.0, 128.0, 23.0, 100, 0.1); |
55 | // Assert.That(map[128, 128] > 0.0, "Raise brush not raising values."); | 55 | Assert.That(map[128, 128] > 0.0, "Raise brush not raising values."); |
56 | // Assert.That(map[0, 128] > 0.0, "Raise brush lowering edge values."); | 56 | Assert.That(map[0, 128] > 0.0, "Raise brush lowering edge values."); |
57 | // | 57 | |
58 | // map = new TerrainChannel(256, 256); | 58 | map = new TerrainChannel(256, 256); |
59 | // effect = new LowerSphere(); | 59 | effect = new LowerSphere(); |
60 | // | 60 | |
61 | // effect.PaintEffect(map, allowMask, 128.0, 128.0, -1, 100, 0.1); | 61 | effect.PaintEffect(map, allowMask, 128.0, 128.0, -1, 100, 0.1); |
62 | // Assert.That(map[128, 128] < 0.0, "Lower not lowering values."); | 62 | Assert.That(map[128, 128] < 0.0, "Lower not lowering values."); |
63 | // Assert.That(map[0, 128] < 0.0, "Lower brush affecting edge values."); | 63 | Assert.That(map[0, 128] < 0.0, "Lower brush affecting edge values."); |
64 | // } | 64 | } |
65 | 65 | ||
66 | [Test] | 66 | [Test] |
67 | public void TerrainChannelTest() | 67 | public void TerrainChannelTest() |