From 6483470ec5e9000fb6a85bbdfe5b79be6f336a74 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 17 Dec 2009 02:54:02 -0500 Subject: Fix GetWorldRotation(), and a host of related Sit fixes. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 73 +++++++++++----------- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 6 +- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 778e384..4495eda 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1775,7 +1775,7 @@ namespace OpenSim.Region.Framework.Scenes { Quaternion newRot; - if (this.LinkNum == 0) + if (this.LinkNum < 2) //KF Single or root prim { newRot = RotationOffset; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c67463a..865f649 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1661,14 +1661,14 @@ namespace OpenSim.Region.Framework.Scenes // Rotation is the sittiing Av's rotation Quaternion partRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partRot = part.ParentGroup.RootPart.RotationOffset; - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim partRot = part.GetWorldRotation(); - } +// } Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av @@ -1763,14 +1763,14 @@ namespace OpenSim.Region.Framework.Scenes bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); Quaternion partRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partRot = part.ParentGroup.RootPart.RotationOffset; - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partRot = part.ParentGroup.RootPart.RotationOffset; +// } +// else +// { // single or child prim partRot = part.GetWorldRotation(); - } +// } Quaternion partIRot = Quaternion.Inverse(partRot); //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); // Sit analysis rewritten by KF 091125 @@ -1846,15 +1846,15 @@ namespace OpenSim.Region.Framework.Scenes Vector3 offsetr; // = offset * partIRot; // KF: In a linkset, offsetr needs to be relative to the group root! 091208 // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); - if (part.LinkNum < 2) - { // Single, or Root prim of linkset, target is ClickOffset * RootRot + // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. + // { // Single, or Root prim of linkset, target is ClickOffset * RootRot offsetr = offset * partIRot; - } - else - { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) - offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + - (offset * partRot); - } +// + // else + // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) + // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + + // (offset * partRot); + // } //Console.WriteLine(" "); //Console.WriteLine("link number ={0}", part.LinkNum); @@ -2170,6 +2170,7 @@ namespace OpenSim.Region.Framework.Scenes { if (part != null) { +//Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); if (part.GetAvatarOnSitTarget() == UUID) { //Console.WriteLine("Scripted Sit"); @@ -2190,14 +2191,14 @@ namespace OpenSim.Region.Framework.Scenes // Non-scripted sit by Kitto Flora 21Nov09 // Calculate angle of line from prim to Av Quaternion partIRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); - } - else - { // single or child prim +// if (part.LinkNum == 1) +// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); - } +// } Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); float x_diff = ( m_avInitialPos.X - sitTargetPos.X); @@ -2253,14 +2254,14 @@ namespace OpenSim.Region.Framework.Scenes // collisionPoint.Z = global sit surface height SceneObjectPart part = m_scene.GetSceneObjectPart(localid); Quaternion partIRot; - if (part.LinkNum == 1) - { // Root prim of linkset - partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); - } - else - { // single or child prim +// if (part.LinkNum == 1) +/// { // Root prim of linkset +// partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); +// } +// else +// { // single or child prim partIRot = Quaternion.Inverse(part.GetWorldRotation()); - } +// } float offZ = collisionPoint.Z - m_initialSitTarget.Z; Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index c27c420..688be83 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -2673,7 +2673,7 @@ Console.WriteLine(" JointCreateFixed"); m_lastposition = _position; m_lastorientation = _orientation; - + l_position.X = vec.X; l_position.Y = vec.Y; l_position.Z = vec.Z; @@ -2681,6 +2681,10 @@ Console.WriteLine(" JointCreateFixed"); l_orientation.Y = ori.Y; l_orientation.Z = ori.Z; l_orientation.W = ori.W; + +// if(l_position.Y != m_lastposition.Y){ +// Console.WriteLine("UP&V {0} {1}", m_primName, l_position); +// } if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f) { -- cgit v1.1