From 36d146bf272f33eb54de80579b163f27f2703fd4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Nov 2013 00:43:35 +0000 Subject: fix position changes when sitting on a prim with position and/or orientation explicitly specified --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 31 +++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a1017f..42a9b4d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2267,7 +2267,6 @@ namespace OpenSim.Region.Framework.Scenes m_sitAvatarHeight = PhysicsActor.Size.Z; bool canSit = false; - Vector3 pos = part.AbsolutePosition + offset; if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) { @@ -2277,10 +2276,24 @@ namespace OpenSim.Region.Framework.Scenes offset = part.SitTargetPosition; sitOrientation = part.SitTargetOrientation; + +// m_log.DebugFormat("Old sit orient {0}", sitOrientation); + if (part.IsRoot) + sitOrientation = sitOrientation; + else + sitOrientation = part.RotationOffset * sitOrientation; +// m_log.DebugFormat("New sit orient {0}", sitOrientation); + +// m_log.DebugFormat("Old sit offset {0}", offset); + offset = offset * sitOrientation; +// m_log.DebugFormat("New sit offset {0}", offset); + canSit = true; } else { + Vector3 pos = part.AbsolutePosition + offset; + if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) { // m_log.DebugFormat( @@ -2590,8 +2603,20 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; - Rotation = part.RotationOffset * sitTargetOrient; + Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + + if (part.IsRoot) + Rotation = sitTargetOrient; + else + Rotation = part.RotationOffset * sitTargetOrient; + +// m_log.DebugFormat("Old offset2 {0}", newPos); + newPos = newPos * Rotation; +// m_log.DebugFormat("New offset2 {0}", newPos); + + newPos += part.OffsetPosition; + + m_pos = newPos; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From a3c72dafe6459f20297a937bb4bca3dc00a24c9f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Nov 2013 01:40:55 +0000 Subject: Only translate linked prim specified offset pos by the link prim rotation, not any specified avatar rotation as well. Don't translate root prim position by avatar rotation. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 42a9b4d..a73d140 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2277,16 +2277,15 @@ namespace OpenSim.Region.Framework.Scenes offset = part.SitTargetPosition; sitOrientation = part.SitTargetOrientation; -// m_log.DebugFormat("Old sit orient {0}", sitOrientation); - if (part.IsRoot) - sitOrientation = sitOrientation; - else + if (!part.IsRoot) + { + // m_log.DebugFormat("Old sit orient {0}", sitOrientation); sitOrientation = part.RotationOffset * sitOrientation; -// m_log.DebugFormat("New sit orient {0}", sitOrientation); - + // m_log.DebugFormat("New sit orient {0}", sitOrientation); // m_log.DebugFormat("Old sit offset {0}", offset); - offset = offset * sitOrientation; + offset = offset * part.RotationOffset; // m_log.DebugFormat("New sit offset {0}", offset); + } canSit = true; } @@ -2604,19 +2603,22 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + Quaternion newRot; if (part.IsRoot) - Rotation = sitTargetOrient; + { + newRot = sitTargetOrient; + } else - Rotation = part.RotationOffset * sitTargetOrient; - -// m_log.DebugFormat("Old offset2 {0}", newPos); - newPos = newPos * Rotation; -// m_log.DebugFormat("New offset2 {0}", newPos); + { + newPos = newPos * part.RotationOffset; + newRot = part.RotationOffset * sitTargetOrient; + } newPos += part.OffsetPosition; m_pos = newPos; + Rotation = newRot; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From 0785210e29c75b09084321dca0569c9e4b73f858 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Nov 2013 02:08:22 +0000 Subject: Fix stand positions rather than having the stand jump to the root prim. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 10 ++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 56 +++++++++++++++++++--- 2 files changed, 59 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 1ac9d7f..c1aae3f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5076,6 +5076,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP { ScenePresence presence = (ScenePresence)entity; +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name); + attachPoint = presence.State; collisionPlane = presence.CollisionPlane; position = presence.OffsetPosition; @@ -5195,6 +5198,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data) { +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name); + byte[] objectData = new byte[76]; data.CollisionPlane.ToBytes(objectData, 0); @@ -12646,6 +12652,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (p is ScenePresence) { +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}", +// p.Name, Name, Scene.Name); + // It turns out to get the agent to stop flying, you have to feed it stop flying velocities // There's no explicit message to send the client to tell it to stop flying.. it relies on the // velocity, collision plane and avatar height diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a73d140..f9b598f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -499,6 +499,7 @@ namespace OpenSim.Region.Framework.Scenes } else { +// m_log.DebugFormat("[SCENE PRESENCE]: Fetching abs pos where PhysicsActor == null and parent part {0} for {1}", Name, Scene.Name); // Obtain the correct position of a seated avatar. // In addition to providing the correct position while // the avatar is seated, this value will also @@ -515,14 +516,14 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart sitPart = ParentPart; if (sitPart != null) - return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); + return sitPart.AbsolutePosition; } return m_pos; } set { -// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value); +// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} to {1} in {2}", Name, value, Scene.Name); // Util.PrintCallStack(); if (PhysicsActor != null) @@ -2174,8 +2175,6 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); SitGround = false; - if (PhysicsActor == null) - AddToPhysicalScene(false); if (ParentID != 0) { @@ -2198,11 +2197,53 @@ namespace OpenSim.Region.Framework.Scenes ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); - ParentPosition = Vector3.Zero; - ParentID = 0; ParentPart = null; + + Quaternion standRotation; + + if (part.SitTargetAvatar == UUID) + { + standRotation = part.GetWorldRotation(); + + if (!part.IsRoot) + standRotation = standRotation * part.SitTargetOrientation; +// standRotation = part.RotationOffset * part.SitTargetOrientation; +// else +// standRotation = part.SitTargetOrientation; + + } + else + { + standRotation = Rotation; + } + + //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + //Vector3 standPos = ParentPosition; + +// Vector3 standPositionAdjustment +// = part.SitTargetPosition + new Vector3(0.5f, 0f, m_sitAvatarHeight / 2f); + Vector3 adjustmentForSitPosition = part.SitTargetPosition * part.GetWorldRotation(); + + // XXX: This is based on the physics capsule sizes. Need to find a better way to read this rather than + // hardcoding here. + Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; + + Vector3 standPos = ParentPosition + adjustmentForSitPosition + adjustmentForSitPose; + + m_log.DebugFormat( + "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", + standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); + + Rotation = standRotation; + AbsolutePosition = standPos; + ParentPosition = Vector3.Zero; + + // We need to wait until we have calculated proper stand positions before sitting up the physical + // avatar to avoid race conditions. + if (PhysicsActor == null) + AddToPhysicalScene(false); + SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; @@ -2859,6 +2900,7 @@ namespace OpenSim.Region.Framework.Scenes lastTerseUpdateToAllClientsTick = currentTick; lastPositionSentToAllClients = OffsetPosition; +// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); m_scene.ForEachClient(SendTerseUpdateToClient); } TriggerScenePresenceUpdated(); -- cgit v1.1 From f9193e3c51f0de6047906549640c59dc05b7e9d5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 01:50:12 +0000 Subject: Restore SP.AbsolutePosition to properly return actual absolute position when sitting --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f9b598f..a52263b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -516,7 +516,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart sitPart = ParentPart; if (sitPart != null) - return sitPart.AbsolutePosition; + return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); } return m_pos; -- cgit v1.1 From 868c0c27469067d25add501569e5fb12f8a79c12 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 01:56:49 +0000 Subject: Fix regression where sitting on ground stopped working. This was due to the PhysicsActor no longer being recreated on stand from ground. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a52263b..0fb5477 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2174,11 +2174,12 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); + bool satOnObject = IsSatOnObject; + SceneObjectPart part = ParentPart; SitGround = false; - if (ParentID != 0) + if (satOnObject) { - SceneObjectPart part = ParentPart; TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { @@ -2238,19 +2239,21 @@ namespace OpenSim.Region.Framework.Scenes Rotation = standRotation; AbsolutePosition = standPos; ParentPosition = Vector3.Zero; + } - // We need to wait until we have calculated proper stand positions before sitting up the physical - // avatar to avoid race conditions. - if (PhysicsActor == null) - AddToPhysicalScene(false); + // We need to wait until we have calculated proper stand positions before sitting up the physical + // avatar to avoid race conditions. + if (PhysicsActor == null) + AddToPhysicalScene(false); + if (satOnObject) + { SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; part.RemoveSittingAvatar(UUID); - if (part != null) - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } Animator.TrySetMovementAnimation("STAND"); -- cgit v1.1