diff options
author | UbitUmarov | 2018-04-14 23:34:16 +0100 |
---|---|---|
committer | UbitUmarov | 2018-04-14 23:34:16 +0100 |
commit | fced731e701fc17e907a26f0f9ef1f0f9f291976 (patch) | |
tree | 64a447e510f200bc4d7a058de2a101c5ee7f1e83 /OpenSim/Region | |
parent | robust create user: allow new userid to be to generate a new random one; ha... (diff) | |
download | opensim-SC-fced731e701fc17e907a26f0f9ef1f0f9f291976.zip opensim-SC-fced731e701fc17e907a26f0f9ef1f0f9f291976.tar.gz opensim-SC-fced731e701fc17e907a26f0f9ef1f0f9f291976.tar.bz2 opensim-SC-fced731e701fc17e907a26f0f9ef1f0f9f291976.tar.xz |
save a few ns on lsl vector rotations
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 1c152be..0c17a90 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -270,13 +270,15 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
270 | // Vector-Rotation Math | 270 | // Vector-Rotation Math |
271 | public static Vector3 operator *(Vector3 v, Quaternion r) | 271 | public static Vector3 operator *(Vector3 v, Quaternion r) |
272 | { | 272 | { |
273 | Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); | 273 | double rx = r.s * v.x + r.y * v.z - r.z * v.y; |
274 | Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); | 274 | double ry = r.s * v.y + r.z * v.x - r.x * v.z; |
275 | double rz = r.s * v.z + r.x * v.y - r.y * v.x; | ||
275 | 276 | ||
276 | // adapted for operator * computing "b * a" | 277 | v.x += 2.0f * (rz * r.y - ry * r.z); |
277 | Quaternion result = nq * (vq * r); | 278 | v.y += 2.0f * (rx * r.z - rz * r.x); |
279 | v.z += 2.0f * (ry * r.x - rx * r.y); | ||
278 | 280 | ||
279 | return new Vector3(result.x, result.y, result.z); | 281 | return v; |
280 | } | 282 | } |
281 | 283 | ||
282 | public static Vector3 operator /(Vector3 v, Quaternion r) | 284 | public static Vector3 operator /(Vector3 v, Quaternion r) |