diff --git a/OpenSim/Framework/General/IClientAPI.cs b/OpenSim/Framework/General/IClientAPI.cs index c7ec5143a1..ec7a69e687 100644 --- a/OpenSim/Framework/General/IClientAPI.cs +++ b/OpenSim/Framework/General/IClientAPI.cs @@ -226,7 +226,7 @@ namespace OpenSim.Framework public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); - public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID); + public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset); public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID); diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 7dcf1e8b0e..bf2a678669 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -835,19 +835,6 @@ namespace OpenSim.Region.ClientStack OutPacket(avatarReply); } - public void SendSitResponse(LLUUID targetID, LLVector3 offset) - { - AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); - - avatarSitResponse.SitObject.ID = targetID; - - avatarSitResponse.SitTransform.AutoPilot = true; - avatarSitResponse.SitTransform.SitPosition = offset; - avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f); - - OutPacket(avatarSitResponse); - } - #endregion #region Appearance/ Wearables Methods diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index dd2562ca3d..7d1780c99f 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -200,12 +200,11 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.AgentRequestSit: - AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket) Pack; - SendSitResponse(agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); if (OnAgentRequestSit != null) { + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, - agentRequestSit.TargetObject.TargetID); + agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); } break; case PacketType.AgentSit: diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 527eb226f3..5155b41e57 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -50,6 +50,8 @@ namespace OpenSim.Region.Environment.Scenes private readonly List m_forcesList = new List(); private short m_updateCount = 0; private uint m_requestedSitTargetID = 0; + private LLVector3 m_requestedSitOffset = new LLVector3(); + private float m_sitAvatarHeight = 2.0f; private Quaternion bodyRot; private byte[] m_visualParams; @@ -448,6 +450,14 @@ namespace OpenSim.Region.Environment.Scenes // return; //} + // Must check for standing up even when PhysicsActor is null, + // since sitting currently removes avatar from physical scene + if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + { + StandUp(); + UpdateMovementAnimations(true); + } + if (PhysicsActor == null) { // Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!"); @@ -467,12 +477,6 @@ namespace OpenSim.Region.Environment.Scenes update_movementflag = true; } - if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) - { - StandUp(); - update_movementflag = true; - } - if (q != bodyRot) { bodyRot = q; @@ -517,15 +521,56 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentID != 0) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + LLVector3 pos = new LLVector3(); if (part != null) - AbsolutePosition = part.AbsolutePosition; + pos = part.AbsolutePosition + m_requestedSitOffset + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + MakeRootAgent(pos, false); m_parentID = 0; SendFullUpdateToAllClients(); } } - public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID) + private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset) { + AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); + + avatarSitResponse.SitObject.ID = targetID; + + bool autopilot = true; + LLVector3 pos = new LLVector3(); + + SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + if (part != null) + { + pos = part.AbsolutePosition + offset; + + double dist = AbsolutePosition.GetDistanceTo(pos); + + if (m_physicsActor != null) + { + m_sitAvatarHeight = m_physicsActor.Size.Z; + } + +// this doesn't seem to quite work yet.... +// // if we're close, set the avatar position to the target position and forgo autopilot +// if (dist < 2.5) +// { +// autopilot = false; +// AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); +// } + } + + avatarSitResponse.SitTransform.AutoPilot = autopilot; + avatarSitResponse.SitTransform.SitPosition = offset; + avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f); + + remoteClient.OutPacket(avatarSitResponse); + } + + public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) + { + SendSitResponse(remoteClient, targetID, offset); + if (m_parentID != 0) { StandUp(); @@ -537,6 +582,7 @@ namespace OpenSim.Region.Environment.Scenes if (part != null) { m_requestedSitTargetID = part.LocalID; + m_requestedSitOffset = offset; } else { @@ -546,8 +592,11 @@ namespace OpenSim.Region.Environment.Scenes public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID) { - AbsolutePosition = new LLVector3(0F, 0F, 0F); + // these magic numbers come mostly from experimenting with ODE, + // and seeing what looks right + AbsolutePosition = m_requestedSitOffset + new LLVector3(m_physicsActor.Size.X / 2.7f, 0f, m_physicsActor.Size.Z / 1.45f); m_parentID = m_requestedSitTargetID; + MakeChildAgent(); SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); SendFullUpdateToAllClients(); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index c9af6dd19a..27c3a6a004 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -503,7 +503,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Size { - get { return new PhysicsVector(0, 0, 0); } + get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } set { } }