From b30c23eba42f3df4e82a509de78876b679aad3e6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 02:50:39 +0100 Subject: [PATCH 1/2] convert a LSL rotation of <0,0,0,0> to <0,0,0,1> and not <0,0,1,0> in SitTarget. Something seems to be doing that before this gets called, but just in case... --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9772c5a4ae..089b4016bc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7099,7 +7099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // LSL quaternions can normalize to 0, normal Quaternions can't. if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) - rot.z = 1; // ZERO_ROTATION = 0,0,0,1 + rot.s = 1; // ZERO_ROTATION = 0,0,0,1 part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); part.SitTargetOrientation = Rot2Quaternion(rot); From 7bd274b3d34b5f7cbdc4e4d9e9f6915392b004b8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 04:59:09 +0100 Subject: [PATCH 2/2] Changed t adding the avatar dependent sit offset and not subtracting, so not to break inworld contents. SL ported scripts will show a sit error around 0.1m. Added respective compensation in LSL api to maintain coerence. Fixed several bugs still on SET/GET[link]PrimitiveParams[fast] and llGetObjectDetails() --- .../Region/Framework/Scenes/ScenePresence.cs | 6 +- .../Shared/Api/Implementation/LSL_Api.cs | 67 ++++++++++++------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 059d4c2945..87b4d9fdfd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2383,8 +2383,10 @@ namespace OpenSim.Region.Framework.Scenes Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; -// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; + + m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; + +// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 089b4016bc..fafeba20d5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7959,13 +7959,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position - pos -= sitpart.OffsetPosition; // remove sit part offset - - Quaternion rot = sitpart.RotationOffset; - pos *= Quaternion.Conjugate(rot); // removed sit part rotation - -// Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); -// pos += sitOffset; + if (sitpart != sitpart.ParentGroup.RootPart) + { + pos -= sitpart.OffsetPosition; // remove sit part offset + Quaternion rot = sitpart.RotationOffset; + pos *= Quaternion.Conjugate(rot); // removed sit part rotation + } + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f); + pos += sitOffset; finalPos = pos; positionChanged = true; @@ -7990,8 +7991,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rot = sitgrp.RootPart.RotationOffset * rot; } - Quaternion srot = sitpart.GetWorldRotation(); - rot = Quaternion.Conjugate(srot) * rot; // removed sit part world rotation + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation av.Rotation = rot; av.SendAvatarDataToAllAgents(); } @@ -8007,10 +8008,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation r = rules.GetQuaternionItem(idx++); Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation - - Quaternion srot = sitpart.RotationOffset; - rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation - + if (sitpart != sitpart.ParentGroup.RootPart) + { + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation + } av.Rotation = rot; av.SendAvatarDataToAllAgents(); } @@ -8956,12 +8958,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: - // can't use Abs pos to extract offset... -// Vector3 pos = avatar.AbsolutePosition; Vector3 pos = avatar.OffsetPosition; -// Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); -// pos -= sitOffset; + Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); + pos -= sitOffset; if( sitPart != null) pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); @@ -9151,7 +9151,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROT_LOCAL: Quaternion lrot = avatar.Rotation; - if (sitPart != null) + + if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) { lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset } @@ -9160,10 +9161,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POS_LOCAL: Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part -// Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); -// lpos -= lsitOffset; + Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); + lpos -= lsitOffset; - if (sitPart != null) + if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) { lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim } @@ -11819,12 +11820,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_String("")); break; case ScriptBaseClass.OBJECT_POS: - Vector3 avpos = av.AbsolutePosition; + Vector3 avpos; + + if (av.ParentID != 0 && av.ParentPart != null) + { + avpos = av.OffsetPosition; + + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); + avpos -= sitOffset; + + avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); + } + else + avpos = av.AbsolutePosition; + ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); break; case ScriptBaseClass.OBJECT_ROT: Quaternion avrot = av.Rotation; - if(av.ParentID != 0 && av.ParentPart != null) + if (av.ParentID != 0 && av.ParentPart != null) { avrot = av.ParentPart.GetWorldRotation() * avrot; } @@ -11896,8 +11910,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); break; case ScriptBaseClass.OBJECT_ROT: - Quaternion orot = obj.RotationOffset; - ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); +// Quaternion orot = obj.RotationOffset; +// ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); + + LSL_Rotation objrot = GetPartRot(obj); + ret.Add(objrot); break; case ScriptBaseClass.OBJECT_VELOCITY: Vector3 ovel = obj.Velocity;