From 0785210e29c75b09084321dca0569c9e4b73f858 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 27 Nov 2013 02:08:22 +0000 Subject: [PATCH] Fix stand positions rather than having the stand jump to the root prim. --- .../ClientStack/Linden/UDP/LLClientView.cs | 10 ++++ .../Region/Framework/Scenes/ScenePresence.cs | 56 ++++++++++++++++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 1ac9d7f10d..c1aae3f4db 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 a73d140a10..f9b598f168 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();