aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs486
1 files changed, 243 insertions, 243 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
index 3199ddc..8184f06 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
@@ -1,243 +1,243 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32 32
33namespace libTerrain 33namespace libTerrain
34{ 34{
35 partial class Channel 35 partial class Channel
36 { 36 {
37 /* Operator combination of channel datatypes */ 37 /* Operator combination of channel datatypes */
38 38
39 public static Channel operator +(Channel A, Channel B) 39 public static Channel operator +(Channel A, Channel B)
40 { 40 {
41 if (A.h != B.h) 41 if (A.h != B.h)
42 throw new Exception("Cannot add heightmaps, of different height."); 42 throw new Exception("Cannot add heightmaps, of different height.");
43 if (A.w != B.w) 43 if (A.w != B.w)
44 throw new Exception("Cannot add heightmaps, of different width."); 44 throw new Exception("Cannot add heightmaps, of different width.");
45 45
46 int x, y; 46 int x, y;
47 47
48 for (x = 0; x < A.w; x++) 48 for (x = 0; x < A.w; x++)
49 { 49 {
50 for (y = 0; y < A.h; y++) 50 for (y = 0; y < A.h; y++)
51 { 51 {
52 if (B.map[x, y] != 0) 52 if (B.map[x, y] != 0)
53 A.SetDiff(x, y); 53 A.SetDiff(x, y);
54 54
55 A.map[x, y] += B.map[x, y]; 55 A.map[x, y] += B.map[x, y];
56 } 56 }
57 } 57 }
58 58
59 return A; 59 return A;
60 } 60 }
61 61
62 public static Channel operator *(Channel A, Channel B) 62 public static Channel operator *(Channel A, Channel B)
63 { 63 {
64 if (A.h != B.h) 64 if (A.h != B.h)
65 throw new Exception("Cannot multiply heightmaps, of different height."); 65 throw new Exception("Cannot multiply heightmaps, of different height.");
66 if (A.w != B.w) 66 if (A.w != B.w)
67 throw new Exception("Cannot multiply heightmaps, of different width."); 67 throw new Exception("Cannot multiply heightmaps, of different width.");
68 68
69 int x, y; 69 int x, y;
70 70
71 for (x = 0; x < A.w; x++) 71 for (x = 0; x < A.w; x++)
72 { 72 {
73 for (y = 0; y < A.h; y++) 73 for (y = 0; y < A.h; y++)
74 { 74 {
75 A.map[x, y] *= B.map[x, y]; 75 A.map[x, y] *= B.map[x, y];
76 } 76 }
77 } 77 }
78 78
79 A.SetDiff(); 79 A.SetDiff();
80 80
81 return A; 81 return A;
82 } 82 }
83 83
84 public static Channel operator -(Channel A, Channel B) 84 public static Channel operator -(Channel A, Channel B)
85 { 85 {
86 if (A.h != B.h) 86 if (A.h != B.h)
87 throw new Exception("Cannot subtract heightmaps, of different height."); 87 throw new Exception("Cannot subtract heightmaps, of different height.");
88 if (A.w != B.w) 88 if (A.w != B.w)
89 throw new Exception("Cannot subtract heightmaps, of different width."); 89 throw new Exception("Cannot subtract heightmaps, of different width.");
90 90
91 int x, y; 91 int x, y;
92 92
93 for (x = 0; x < A.w; x++) 93 for (x = 0; x < A.w; x++)
94 { 94 {
95 for (y = 0; y < A.h; y++) 95 for (y = 0; y < A.h; y++)
96 { 96 {
97 if (B.map[x, y] != 0) 97 if (B.map[x, y] != 0)
98 A.SetDiff(x, y); 98 A.SetDiff(x, y);
99 A.map[x, y] -= B.map[x, y]; 99 A.map[x, y] -= B.map[x, y];
100 } 100 }
101 } 101 }
102 102
103 return A; 103 return A;
104 } 104 }
105 105
106 public static Channel operator /(Channel A, Channel B) 106 public static Channel operator /(Channel A, Channel B)
107 { 107 {
108 if (A.h != B.h) 108 if (A.h != B.h)
109 throw new Exception("Cannot divide heightmaps, of different height."); 109 throw new Exception("Cannot divide heightmaps, of different height.");
110 if (A.w != B.w) 110 if (A.w != B.w)
111 throw new Exception("Cannot divide heightmaps, of different width."); 111 throw new Exception("Cannot divide heightmaps, of different width.");
112 112
113 int x, y; 113 int x, y;
114 114
115 for (x = 0; x < A.w; x++) 115 for (x = 0; x < A.w; x++)
116 { 116 {
117 for (y = 0; y < A.h; y++) 117 for (y = 0; y < A.h; y++)
118 { 118 {
119 A.map[x, y] /= B.map[x, y]; 119 A.map[x, y] /= B.map[x, y];
120 } 120 }
121 } 121 }
122 122
123 A.SetDiff(); 123 A.SetDiff();
124 124
125 return A; 125 return A;
126 } 126 }
127 127
128 public static Channel operator ^(Channel A, Channel B) 128 public static Channel operator ^(Channel A, Channel B)
129 { 129 {
130 if (A.h != B.h) 130 if (A.h != B.h)
131 throw new Exception("Cannot divide heightmaps, of different height."); 131 throw new Exception("Cannot divide heightmaps, of different height.");
132 if (A.w != B.w) 132 if (A.w != B.w)
133 throw new Exception("Cannot divide heightmaps, of different width."); 133 throw new Exception("Cannot divide heightmaps, of different width.");
134 134
135 int x, y; 135 int x, y;
136 136
137 for (x = 0; x < A.w; x++) 137 for (x = 0; x < A.w; x++)
138 { 138 {
139 for (y = 0; y < A.h; y++) 139 for (y = 0; y < A.h; y++)
140 { 140 {
141 A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]); 141 A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]);
142 } 142 }
143 } 143 }
144 144
145 A.SetDiff(); 145 A.SetDiff();
146 146
147 return A; 147 return A;
148 } 148 }
149 149
150 150
151 /* Operator combination of channel and double datatypes */ 151 /* Operator combination of channel and double datatypes */
152 152
153 public static Channel operator +(Channel A, double B) 153 public static Channel operator +(Channel A, double B)
154 { 154 {
155 int x, y; 155 int x, y;
156 156
157 for (x = 0; x < A.w; x++) 157 for (x = 0; x < A.w; x++)
158 { 158 {
159 for (y = 0; y < A.h; y++) 159 for (y = 0; y < A.h; y++)
160 { 160 {
161 A.map[x, y] += B; 161 A.map[x, y] += B;
162 } 162 }
163 } 163 }
164 164
165 if (B != 0) 165 if (B != 0)
166 A.SetDiff(); 166 A.SetDiff();
167 167
168 return A; 168 return A;
169 } 169 }
170 170
171 public static Channel operator -(Channel A, double B) 171 public static Channel operator -(Channel A, double B)
172 { 172 {
173 int x, y; 173 int x, y;
174 174
175 for (x = 0; x < A.w; x++) 175 for (x = 0; x < A.w; x++)
176 { 176 {
177 for (y = 0; y < A.h; y++) 177 for (y = 0; y < A.h; y++)
178 { 178 {
179 A.map[x, y] -= B; 179 A.map[x, y] -= B;
180 } 180 }
181 } 181 }
182 182
183 if (B != 0) 183 if (B != 0)
184 A.SetDiff(); 184 A.SetDiff();
185 185
186 return A; 186 return A;
187 } 187 }
188 188
189 public static Channel operator *(Channel A, double B) 189 public static Channel operator *(Channel A, double B)
190 { 190 {
191 int x, y; 191 int x, y;
192 192
193 for (x = 0; x < A.w; x++) 193 for (x = 0; x < A.w; x++)
194 { 194 {
195 for (y = 0; y < A.h; y++) 195 for (y = 0; y < A.h; y++)
196 { 196 {
197 A.map[x, y] *= B; 197 A.map[x, y] *= B;
198 } 198 }
199 } 199 }
200 200
201 if (B != 1) 201 if (B != 1)
202 A.SetDiff(); 202 A.SetDiff();
203 203
204 return A; 204 return A;
205 } 205 }
206 206
207 public static Channel operator /(Channel A, double B) 207 public static Channel operator /(Channel A, double B)
208 { 208 {
209 int x, y; 209 int x, y;
210 210
211 for (x = 0; x < A.w; x++) 211 for (x = 0; x < A.w; x++)
212 { 212 {
213 for (y = 0; y < A.h; y++) 213 for (y = 0; y < A.h; y++)
214 { 214 {
215 A.map[x, y] /= B; 215 A.map[x, y] /= B;
216 } 216 }
217 } 217 }
218 218
219 if (B != 1) 219 if (B != 1)
220 A.SetDiff(); 220 A.SetDiff();
221 221
222 return A; 222 return A;
223 } 223 }
224 224
225 public static Channel operator ^(Channel A, double B) 225 public static Channel operator ^(Channel A, double B)
226 { 226 {
227 int x, y; 227 int x, y;
228 228
229 for (x = 0; x < A.w; x++) 229 for (x = 0; x < A.w; x++)
230 { 230 {
231 for (y = 0; y < A.h; y++) 231 for (y = 0; y < A.h; y++)
232 { 232 {
233 A.map[x, y] = Math.Pow(A.map[x,y],B); 233 A.map[x, y] = Math.Pow(A.map[x,y],B);
234 } 234 }
235 } 235 }
236 236
237 A.SetDiff(); 237 A.SetDiff();
238 238
239 return A; 239 return A;
240 } 240 }
241 241
242 } 242 }
243} 243}