aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs239
1 files changed, 0 insertions, 239 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
deleted file mode 100644
index 6e1386d..0000000
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
+++ /dev/null
@@ -1,239 +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;
29
30namespace libTerrain
31{
32 partial class Channel
33 {
34 /* Operator combination of channel datatypes */
35
36 public static Channel operator +(Channel A, Channel B)
37 {
38 if (A.h != B.h)
39 throw new Exception("Cannot add heightmaps, of different height.");
40 if (A.w != B.w)
41 throw new Exception("Cannot add heightmaps, of different width.");
42
43 int x, y;
44
45 for (x = 0; x < A.w; x++)
46 {
47 for (y = 0; y < A.h; y++)
48 {
49 if (B.map[x, y] != 0)
50 A.SetDiff(x, y);
51
52 A.map[x, y] += B.map[x, y];
53 }
54 }
55
56 return A;
57 }
58
59 public static Channel operator *(Channel A, Channel B)
60 {
61 if (A.h != B.h)
62 throw new Exception("Cannot multiply heightmaps, of different height.");
63 if (A.w != B.w)
64 throw new Exception("Cannot multiply heightmaps, of different width.");
65
66 int x, y;
67
68 for (x = 0; x < A.w; x++)
69 {
70 for (y = 0; y < A.h; y++)
71 {
72 A.map[x, y] *= B.map[x, y];
73 }
74 }
75
76 A.SetDiff();
77
78 return A;
79 }
80
81 public static Channel operator -(Channel A, Channel B)
82 {
83 if (A.h != B.h)
84 throw new Exception("Cannot subtract heightmaps, of different height.");
85 if (A.w != B.w)
86 throw new Exception("Cannot subtract heightmaps, of different width.");
87
88 int x, y;
89
90 for (x = 0; x < A.w; x++)
91 {
92 for (y = 0; y < A.h; y++)
93 {
94 if (B.map[x, y] != 0)
95 A.SetDiff(x, y);
96 A.map[x, y] -= B.map[x, y];
97 }
98 }
99
100 return A;
101 }
102
103 public static Channel operator /(Channel A, Channel B)
104 {
105 if (A.h != B.h)
106 throw new Exception("Cannot divide heightmaps, of different height.");
107 if (A.w != B.w)
108 throw new Exception("Cannot divide heightmaps, of different width.");
109
110 int x, y;
111
112 for (x = 0; x < A.w; x++)
113 {
114 for (y = 0; y < A.h; y++)
115 {
116 A.map[x, y] /= B.map[x, y];
117 }
118 }
119
120 A.SetDiff();
121
122 return A;
123 }
124
125 public static Channel operator ^(Channel A, Channel B)
126 {
127 if (A.h != B.h)
128 throw new Exception("Cannot divide heightmaps, of different height.");
129 if (A.w != B.w)
130 throw new Exception("Cannot divide heightmaps, of different width.");
131
132 int x, y;
133
134 for (x = 0; x < A.w; x++)
135 {
136 for (y = 0; y < A.h; y++)
137 {
138 A.map[x, y] = Math.Pow(A.map[x, y], B.map[x, y]);
139 }
140 }
141
142 A.SetDiff();
143
144 return A;
145 }
146
147
148 /* Operator combination of channel and double datatypes */
149
150 public static Channel operator +(Channel A, double B)
151 {
152 int x, y;
153
154 for (x = 0; x < A.w; x++)
155 {
156 for (y = 0; y < A.h; y++)
157 {
158 A.map[x, y] += B;
159 }
160 }
161
162 if (B != 0)
163 A.SetDiff();
164
165 return A;
166 }
167
168 public static Channel operator -(Channel A, double B)
169 {
170 int x, y;
171
172 for (x = 0; x < A.w; x++)
173 {
174 for (y = 0; y < A.h; y++)
175 {
176 A.map[x, y] -= B;
177 }
178 }
179
180 if (B != 0)
181 A.SetDiff();
182
183 return A;
184 }
185
186 public static Channel operator *(Channel A, double B)
187 {
188 int x, y;
189
190 for (x = 0; x < A.w; x++)
191 {
192 for (y = 0; y < A.h; y++)
193 {
194 A.map[x, y] *= B;
195 }
196 }
197
198 if (B != 1)
199 A.SetDiff();
200
201 return A;
202 }
203
204 public static Channel operator /(Channel A, double B)
205 {
206 int x, y;
207
208 for (x = 0; x < A.w; x++)
209 {
210 for (y = 0; y < A.h; y++)
211 {
212 A.map[x, y] /= B;
213 }
214 }
215
216 if (B != 1)
217 A.SetDiff();
218
219 return A;
220 }
221
222 public static Channel operator ^(Channel A, double B)
223 {
224 int x, y;
225
226 for (x = 0; x < A.w; x++)
227 {
228 for (y = 0; y < A.h; y++)
229 {
230 A.map[x, y] = Math.Pow(A.map[x, y], B);
231 }
232 }
233
234 A.SetDiff();
235
236 return A;
237 }
238 }
239}