aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs23
1 files changed, 9 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index c3a36dd..e031c01 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -211,21 +211,16 @@ namespace OpenSim.Region.ScriptEngine.Common
211 Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); 211 Quaternion vq = new Quaternion(v.x, v.y, v.z, 0);
212 Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); 212 Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s);
213 213
214 Quaternion result = (r * vq) * nq; 214 // adapted for operator * computing "b * a"
215 Quaternion result = nq * (vq * r);
215 216
216 return new Vector3(result.x, result.y, result.z); 217 return new Vector3(result.x, result.y, result.z);
217 } 218 }
218 219
219 // I *think* this is how it works.... 220 public static Vector3 operator /(Vector3 v, Quaternion r)
220 public static Vector3 operator /(Vector3 vec, Quaternion quat)
221 { 221 {
222 quat.s = -quat.s; 222 r.s = -r.s;
223 Quaternion vq = new Quaternion(vec.x, vec.y, vec.z, 0); 223 return v * r;
224 Quaternion nq = new Quaternion(-quat.x, -quat.y, -quat.z, quat.s);
225
226 Quaternion result = (quat * vq) * nq;
227
228 return new Vector3(result.x, result.y, result.z);
229 } 224 }
230 225
231 #endregion 226 #endregion
@@ -371,9 +366,8 @@ namespace OpenSim.Region.ScriptEngine.Common
371 366
372 public static Quaternion operator /(Quaternion a, Quaternion b) 367 public static Quaternion operator /(Quaternion a, Quaternion b)
373 { 368 {
374 Quaternion c = a * b; 369 b.s = -b.s;
375 c.s = c.s * -1; 370 return a * b;
376 return c;
377 } 371 }
378 372
379 public static Quaternion operator -(Quaternion a, Quaternion b) 373 public static Quaternion operator -(Quaternion a, Quaternion b)
@@ -381,7 +375,8 @@ namespace OpenSim.Region.ScriptEngine.Common
381 return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s); 375 return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s);
382 } 376 }
383 377
384 public static Quaternion operator *(Quaternion a, Quaternion b) 378 // using the equations below, we need to do "b * a" to be compatible with LSL
379 public static Quaternion operator *(Quaternion b, Quaternion a)
385 { 380 {
386 Quaternion c; 381 Quaternion c;
387 c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y; 382 c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y;