diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 136b613..3a0b8ed 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | |||
@@ -60,20 +60,22 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
60 | { | 60 | { |
61 | return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">"; | 61 | return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">"; |
62 | } | 62 | } |
63 | |||
63 | public static bool operator ==(Vector3 lhs, Vector3 rhs) | 64 | public static bool operator ==(Vector3 lhs, Vector3 rhs) |
64 | { | 65 | { |
65 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); | 66 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); |
66 | } | 67 | } |
68 | |||
67 | public static bool operator !=(Vector3 lhs, Vector3 rhs) | 69 | public static bool operator !=(Vector3 lhs, Vector3 rhs) |
68 | { | 70 | { |
69 | return !(lhs == rhs); | 71 | return !(lhs == rhs); |
70 | } | 72 | } |
73 | |||
71 | public override int GetHashCode() | 74 | public override int GetHashCode() |
72 | { | 75 | { |
73 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode()); | 76 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode()); |
74 | } | 77 | } |
75 | 78 | ||
76 | |||
77 | public override bool Equals(object o) | 79 | public override bool Equals(object o) |
78 | { | 80 | { |
79 | if (!(o is Vector3)) return false; | 81 | if (!(o is Vector3)) return false; |
@@ -91,10 +93,12 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
91 | { | 93 | { |
92 | return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); | 94 | return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); |
93 | } | 95 | } |
96 | |||
94 | public static Vector3 operator -(Vector3 lhs, Vector3 rhs) | 97 | public static Vector3 operator -(Vector3 lhs, Vector3 rhs) |
95 | { | 98 | { |
96 | return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); | 99 | return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); |
97 | } | 100 | } |
101 | |||
98 | public static Vector3 operator *(Vector3 lhs, Vector3 rhs) | 102 | public static Vector3 operator *(Vector3 lhs, Vector3 rhs) |
99 | { | 103 | { |
100 | return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); | 104 | return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); |
@@ -145,6 +149,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
145 | 149 | ||
146 | return new Vector3(result.x, result.y, result.z); | 150 | return new Vector3(result.x, result.y, result.z); |
147 | } | 151 | } |
152 | |||
148 | // I *think* this is how it works.... | 153 | // I *think* this is how it works.... |
149 | public static Vector3 operator /(Vector3 vec, Quaternion quat) | 154 | public static Vector3 operator /(Vector3 vec, Quaternion quat) |
150 | { | 155 | { |
@@ -163,6 +168,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
163 | { | 168 | { |
164 | return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); | 169 | return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); |
165 | } | 170 | } |
171 | |||
166 | public static Vector3 Cross(Vector3 v1, Vector3 v2) | 172 | public static Vector3 Cross(Vector3 v1, Vector3 v2) |
167 | { | 173 | { |
168 | return new Vector3 | 174 | return new Vector3 |
@@ -172,10 +178,12 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
172 | v1.x * v2.y - v1.y * v2.x | 178 | v1.x * v2.y - v1.y * v2.x |
173 | ); | 179 | ); |
174 | } | 180 | } |
181 | |||
175 | public static float Mag(Vector3 v) | 182 | public static float Mag(Vector3 v) |
176 | { | 183 | { |
177 | return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); | 184 | return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); |
178 | } | 185 | } |
186 | |||
179 | public static Vector3 Norm(Vector3 vector) | 187 | public static Vector3 Norm(Vector3 vector) |
180 | { | 188 | { |
181 | float mag = Mag(vector); | 189 | float mag = Mag(vector); |
@@ -215,7 +223,6 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
215 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode()); | 223 | return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode()); |
216 | } | 224 | } |
217 | 225 | ||
218 | |||
219 | public override bool Equals(object o) | 226 | public override bool Equals(object o) |
220 | { | 227 | { |
221 | if (!(o is Quaternion)) return false; | 228 | if (!(o is Quaternion)) return false; |
@@ -224,6 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
224 | 231 | ||
225 | return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; | 232 | return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; |
226 | } | 233 | } |
234 | |||
227 | public override string ToString() | 235 | public override string ToString() |
228 | { | 236 | { |
229 | return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + s.ToString() + ">"; | 237 | return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + s.ToString() + ">"; |
@@ -257,19 +265,23 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
257 | public class list | 265 | public class list |
258 | { | 266 | { |
259 | private object[] m_data; | 267 | private object[] m_data; |
268 | |||
260 | public list(params object[] args) | 269 | public list(params object[] args) |
261 | { | 270 | { |
262 | m_data = new object[args.Length]; | 271 | m_data = new object[args.Length]; |
263 | m_data = args; | 272 | m_data = args; |
264 | } | 273 | } |
274 | |||
265 | public int Length | 275 | public int Length |
266 | { | 276 | { |
267 | get { return m_data.Length; } | 277 | get { return m_data.Length; } |
268 | } | 278 | } |
279 | |||
269 | public object[] Data | 280 | public object[] Data |
270 | { | 281 | { |
271 | get { return m_data; } | 282 | get { return m_data; } |
272 | } | 283 | } |
284 | |||
273 | public static list operator +(list a, list b) | 285 | public static list operator +(list a, list b) |
274 | { | 286 | { |
275 | object[] tmp; | 287 | object[] tmp; |
@@ -278,6 +290,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
278 | b.Data.CopyTo(tmp, a.Length); | 290 | b.Data.CopyTo(tmp, a.Length); |
279 | return new list(tmp); | 291 | return new list(tmp); |
280 | } | 292 | } |
293 | |||
281 | public list GetSublist(int start, int end) | 294 | public list GetSublist(int start, int end) |
282 | { | 295 | { |
283 | Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); | 296 | Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); |
@@ -292,8 +305,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
292 | end = m_data.Length + end; | 305 | end = m_data.Length + end; |
293 | } | 306 | } |
294 | 307 | ||
295 | // Case start < end | 308 | // Case start <= end |
296 | |||
297 | if (start <= end) | 309 | if (start <= end) |
298 | { | 310 | { |
299 | if (start >= m_data.Length) | 311 | if (start >= m_data.Length) |
@@ -350,6 +362,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
350 | output = output + "]"; | 362 | output = output + "]"; |
351 | return output; | 363 | return output; |
352 | } | 364 | } |
365 | |||
353 | public override string ToString() | 366 | public override string ToString() |
354 | { | 367 | { |
355 | string output; | 368 | string output; |
@@ -366,5 +379,4 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
366 | } | 379 | } |
367 | } | 380 | } |
368 | } | 381 | } |
369 | |||
370 | } | 382 | } |