diff options
author | dahlia | 2015-06-10 01:26:38 -0700 |
---|---|---|
committer | dahlia | 2015-06-10 01:26:38 -0700 |
commit | 58972f65acc91c287fb3df0b76e3cc0e718a4806 (patch) | |
tree | 20a1540479aa14766a146b097b29b192a4b99032 /OpenSim | |
parent | Update libomv to current HEAD f75dccc313f3 (diff) | |
download | opensim-SC-58972f65acc91c287fb3df0b76e3cc0e718a4806.zip opensim-SC-58972f65acc91c287fb3df0b76e3cc0e718a4806.tar.gz opensim-SC-58972f65acc91c287fb3df0b76e3cc0e718a4806.tar.bz2 opensim-SC-58972f65acc91c287fb3df0b76e3cc0e718a4806.tar.xz |
SceneObjectPart.UpdateLookAt() now uses corrected libomv quaternion functions.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 57ec1ae..781c20c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -4909,25 +4909,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4909 | 4909 | ||
4910 | Quaternion currRot = GetWorldRotation(); | 4910 | Quaternion currRot = GetWorldRotation(); |
4911 | currRot.Normalize(); | 4911 | currRot.Normalize(); |
4912 | 4912 | ||
4913 | // difference between current orientation and desired orientation | 4913 | // difference between current orientation and desired orientation |
4914 | Quaternion dR = new Quaternion(currRot.X, currRot.Y, currRot.Z, -currRot.W) * APIDTarget; | 4914 | Quaternion dR = currRot / APIDTarget; |
4915 | 4915 | ||
4916 | // find axis of rotation to rotate to desired orientation | 4916 | // find axis and angle of rotation to rotate to desired orientation |
4917 | Vector3 axis = Vector3.UnitX; | 4917 | Vector3 axis = Vector3.UnitX; |
4918 | float s = (float)Math.Sqrt(1.0f - dR.W * dR.W); | 4918 | float angle; |
4919 | if (s >= 0.001) | 4919 | dR.GetAxisAngle(out axis, out angle); |
4920 | { | 4920 | axis = axis * currRot; |
4921 | float invS = 1.0f / s; | ||
4922 | if (dR.W < 0) invS = -invS; | ||
4923 | axis = new Vector3(dR.X * invS, dR.Y * invS, dR.Z * invS) * currRot; | ||
4924 | axis.Normalize(); | ||
4925 | } | ||
4926 | |||
4927 | // angle between current and desired orientation | ||
4928 | float angle = 2.0f * (float)Math.Acos(dR.W); | ||
4929 | if (angle > Math.PI) | ||
4930 | angle = 2.0f * (float)Math.PI - angle; | ||
4931 | 4921 | ||
4932 | // clamp strength to avoid overshoot | 4922 | // clamp strength to avoid overshoot |
4933 | float strength = 1.0f / APIDStrength; | 4923 | float strength = 1.0f / APIDStrength; |