aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs118
1 files changed, 0 insertions, 118 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
deleted file mode 100644
index 2acd5bc..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using NUnit.Framework;
30using OpenSim.Region.Framework.Scenes;
31using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
32
33namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests
34{
35 [TestFixture]
36 public class TerrainTest
37 {
38 [Test]
39 public void BrushTest()
40 {
41 bool[,] allowMask = new bool[256, 256];
42 int x;
43 int y;
44 for (x=0; x<128; x++)
45 {
46 for (y=0; y<256; y++)
47 {
48 allowMask[x,y] = true;
49 }
50 }
51
52 //
53 // Test RaiseSphere
54 //
55 TerrainChannel map = new TerrainChannel(256, 256);
56 ITerrainPaintableEffect effect = new RaiseSphere();
57
58 effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 0.1);
59 Assert.That(map[127, 128] > 0.0, "Raise brush should raising value at this point (127,128).");
60 Assert.That(map[124, 128] > 0.0, "Raise brush should raising value at this point (124,128).");
61 Assert.That(map[123, 128] == 0.0, "Raise brush should not change value at this point (123,128).");
62 Assert.That(map[128, 128] == 0.0, "Raise brush should not change value at this point (128,128).");
63 Assert.That(map[0, 128] == 0.0, "Raise brush should not change value at this point (0,128).");
64
65 //
66 // Test LowerSphere
67 //
68 map = new TerrainChannel(256, 256);
69 for (x=0; x<map.Width; x++)
70 {
71 for (y=0; y<map.Height; y++)
72 {
73 map[x,y] = 1.0;
74 }
75 }
76 effect = new LowerSphere();
77
78 effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 6.0);
79 Assert.That(map[127, 128] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
80 Assert.That(map[127, 128] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
81 Assert.That(map[124, 128] < 1.0, "Lower brush should lowering value at this point (124,128).");
82 Assert.That(map[123, 128] == 1.0, "Lower brush should not change value at this point (123,128).");
83 Assert.That(map[128, 128] == 1.0, "Lower brush should not change value at this point (128,128).");
84 Assert.That(map[0, 128] == 1.0, "Lower brush should not change value at this point (0,128).");
85 }
86
87 [Test]
88 public void TerrainChannelTest()
89 {
90 TerrainChannel x = new TerrainChannel(256, 256);
91 Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly.");
92
93 x[0, 0] = 1.0;
94 Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly.");
95
96 x[0, 0] = 0;
97 x[0, 0] += 5.0;
98 x[0, 0] -= 1.0;
99 Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error.");
100
101 x[0, 0] = Math.PI;
102 double[,] doublesExport = x.GetDoubles();
103 Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly.");
104
105 x[0, 0] = 1.0;
106 float[] floatsExport = x.GetFloatsSerialised();
107 Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly.");
108
109 x[0, 0] = 1.0;
110 Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
111 Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
112
113 TerrainChannel y = x.Copy();
114 Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly.");
115 Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly.");
116 }
117 }
118}