diff options
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs new file mode 100644 index 0000000..f2b4aed --- /dev/null +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | Redistribution and use in source and binary forms, with or without | ||
3 | modification, are permitted provided that the following conditions are | ||
4 | met: | ||
5 | |||
6 | * Redistributions of source code must retain the above copyright | ||
7 | notice, this list of conditions and the following disclaimer. | ||
8 | |||
9 | * Redistributions in binary form must reproduce the above | ||
10 | copyright notice, this list of conditions and the following | ||
11 | disclaimer in the documentation and/or other materials provided | ||
12 | with the distribution. | ||
13 | |||
14 | * Neither the name of libTerrain nor the names of | ||
15 | its contributors may be used to endorse or promote products | ||
16 | derived from this software without specific prior written | ||
17 | permission. | ||
18 | |||
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | using System; | ||
33 | using System.Collections.Generic; | ||
34 | using System.Text; | ||
35 | |||
36 | namespace libTerrain | ||
37 | { | ||
38 | partial class Channel | ||
39 | { | ||
40 | enum NEIGHBOURS | ||
41 | { | ||
42 | NEIGHBOUR_MOORE, | ||
43 | NEIGHBOUR_VONNEUMANN | ||
44 | }; | ||
45 | |||
46 | private int[] neighbours(NEIGHBOURS type, int index) | ||
47 | { | ||
48 | int[] coord = new int[2]; | ||
49 | |||
50 | index++; | ||
51 | |||
52 | switch (type) | ||
53 | { | ||
54 | case NEIGHBOURS.NEIGHBOUR_MOORE: | ||
55 | switch (index) | ||
56 | { | ||
57 | case 1: | ||
58 | coord[0] = -1; | ||
59 | coord[1] = -1; | ||
60 | break; | ||
61 | |||
62 | case 2: | ||
63 | coord[0] = -0; | ||
64 | coord[1] = -1; | ||
65 | break; | ||
66 | |||
67 | case 3: | ||
68 | coord[0] = +1; | ||
69 | coord[1] = -1; | ||
70 | break; | ||
71 | |||
72 | case 4: | ||
73 | coord[0] = -1; | ||
74 | coord[1] = -0; | ||
75 | break; | ||
76 | |||
77 | case 5: | ||
78 | coord[0] = -0; | ||
79 | coord[1] = -0; | ||
80 | break; | ||
81 | |||
82 | case 6: | ||
83 | coord[0] = +1; | ||
84 | coord[1] = -0; | ||
85 | break; | ||
86 | |||
87 | case 7: | ||
88 | coord[0] = -1; | ||
89 | coord[1] = +1; | ||
90 | break; | ||
91 | |||
92 | case 8: | ||
93 | coord[0] = -0; | ||
94 | coord[1] = +1; | ||
95 | break; | ||
96 | |||
97 | case 9: | ||
98 | coord[0] = +1; | ||
99 | coord[1] = +1; | ||
100 | break; | ||
101 | |||
102 | default: | ||
103 | break; | ||
104 | } | ||
105 | break; | ||
106 | |||
107 | case NEIGHBOURS.NEIGHBOUR_VONNEUMANN: | ||
108 | switch (index) | ||
109 | { | ||
110 | case 1: | ||
111 | coord[0] = 0; | ||
112 | coord[1] = -1; | ||
113 | break; | ||
114 | |||
115 | case 2: | ||
116 | coord[0] = -1; | ||
117 | coord[1] = 0; | ||
118 | break; | ||
119 | |||
120 | case 3: | ||
121 | coord[0] = +1; | ||
122 | coord[1] = 0; | ||
123 | break; | ||
124 | |||
125 | case 4: | ||
126 | coord[0] = 0; | ||
127 | coord[1] = +1; | ||
128 | break; | ||
129 | |||
130 | case 5: | ||
131 | coord[0] = -0; | ||
132 | coord[1] = -0; | ||
133 | break; | ||
134 | |||
135 | default: | ||
136 | break; | ||
137 | } | ||
138 | break; | ||
139 | } | ||
140 | |||
141 | return coord; | ||
142 | } | ||
143 | } | ||
144 | } | ||