clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 OpenSimulator 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 | |||
28 | using System; |
||
29 | using NUnit.Framework; |
||
30 | using OpenSim.Framework; |
||
31 | using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes; |
||
32 | using OpenSim.Region.Framework.Scenes; |
||
33 | using OpenSim.Tests.Common; |
||
34 | |||
35 | namespace OpenSim.Region.CoreModules.World.Terrain.Tests |
||
36 | { |
||
37 | [TestFixture] |
||
38 | public class TerrainTest : OpenSimTestCase |
||
39 | { |
||
40 | [Test] |
||
41 | public void BrushTest() |
||
42 | { |
||
43 | int midRegion = (int)Constants.RegionSize / 2; |
||
44 | |||
45 | // Create a mask that covers only the left half of the region |
||
46 | bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; |
||
47 | int x; |
||
48 | int y; |
||
49 | for (x = 0; x < midRegion; x++) |
||
50 | { |
||
51 | for (y = 0; y < (int)Constants.RegionSize; y++) |
||
52 | { |
||
53 | allowMask[x,y] = true; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | // |
||
58 | // Test RaiseSphere |
||
59 | // |
||
60 | TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); |
||
61 | ITerrainPaintableEffect effect = new RaiseSphere(); |
||
62 | |||
63 | effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); |
||
64 | Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128)."); |
||
65 | Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128)."); |
||
66 | Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128)."); |
||
67 | Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128)."); |
||
68 | Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128)."); |
||
69 | // |
||
70 | // Test LowerSphere |
||
71 | // |
||
72 | map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); |
||
73 | for (x=0; x<map.Width; x++) |
||
74 | { |
||
75 | for (y=0; y<map.Height; y++) |
||
76 | { |
||
77 | map[x,y] = 1.0; |
||
78 | } |
||
79 | } |
||
80 | effect = new LowerSphere(); |
||
81 | |||
82 | effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); |
||
83 | Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); |
||
84 | Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); |
||
85 | Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128)."); |
||
86 | Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128)."); |
||
87 | Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128)."); |
||
88 | Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128)."); |
||
89 | } |
||
90 | |||
91 | [Test] |
||
92 | public void TerrainChannelTest() |
||
93 | { |
||
94 | TerrainChannel x = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); |
||
95 | Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly."); |
||
96 | |||
97 | x[0, 0] = 1.0; |
||
98 | Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly."); |
||
99 | |||
100 | x[0, 0] = 0; |
||
101 | x[0, 0] += 5.0; |
||
102 | x[0, 0] -= 1.0; |
||
103 | Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error."); |
||
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 | } |