From d92069fb8b0a4f1ca51a24599ae308458c424e19 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 13 Jan 2011 04:44:04 +0000 Subject: [PATCH] Add llLookAt() kinetic. Reduce StandUp +x offset to 0.3M. --- .../Region/Framework/Scenes/ScenePresence.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8ad3ca3ea..927f78db1b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1866,7 +1866,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av if (m_physicsActor == null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 47492ea2a8..805b344567 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3023,9 +3023,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); */ - // Send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. - Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); - m_host.RotLookAt(q, (float)strength, (float)damping); + if (m_host.PhysActor != null && !m_host.PhysActor.IsPhysical) + { + // Part is non-phys, convert this to a llSetRot() + Vector3 tgt = new Vector3((float)target.x, (float)target.y, (float)target.z); + Vector3 dir = tgt - m_host.GroupPosition; + dir.Normalize(); + float tzrot = (float)Math.Atan2(dir.Y, dir.X); + float txy = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y)); + float terot = (float)Math.Atan2(-dir.Z, txy); + LSL_Vector az = new LSL_Vector(0.0f, 0.0f, tzrot); + LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f); + LSL_Types.Quaternion spin = llEuler2Rot(az); + LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin; + llSetRot(rot); + } + else + { + // Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. + Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); + m_host.RotLookAt(q, (float)strength, (float)damping); + } }