Fix stand positions rather than having the stand jump to the root prim.

link-sitting
Justin Clark-Casey (justincc) 2013-11-27 02:08:22 +00:00
parent a3c72dafe6
commit 0785210e29
2 changed files with 59 additions and 7 deletions

View File

@ -5076,6 +5076,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
ScenePresence presence = (ScenePresence)entity; 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; attachPoint = presence.State;
collisionPlane = presence.CollisionPlane; collisionPlane = presence.CollisionPlane;
position = presence.OffsetPosition; position = presence.OffsetPosition;
@ -5195,6 +5198,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data) 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]; byte[] objectData = new byte[76];
data.CollisionPlane.ToBytes(objectData, 0); data.CollisionPlane.ToBytes(objectData, 0);
@ -12646,6 +12652,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
if (p is ScenePresence) 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 // 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 // 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 // velocity, collision plane and avatar height

View File

@ -499,6 +499,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
else 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. // Obtain the correct position of a seated avatar.
// In addition to providing the correct position while // In addition to providing the correct position while
// the avatar is seated, this value will also // the avatar is seated, this value will also
@ -515,14 +516,14 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart sitPart = ParentPart; SceneObjectPart sitPart = ParentPart;
if (sitPart != null) if (sitPart != null)
return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); return sitPart.AbsolutePosition;
} }
return m_pos; return m_pos;
} }
set 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(); // Util.PrintCallStack();
if (PhysicsActor != null) if (PhysicsActor != null)
@ -2174,8 +2175,6 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name);
SitGround = false; SitGround = false;
if (PhysicsActor == null)
AddToPhysicalScene(false);
if (ParentID != 0) if (ParentID != 0)
{ {
@ -2198,11 +2197,53 @@ namespace OpenSim.Region.Framework.Scenes
ParentPosition = part.GetWorldPosition(); ParentPosition = part.GetWorldPosition();
ControllingClient.SendClearFollowCamProperties(part.ParentUUID); ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
ParentPosition = Vector3.Zero;
ParentID = 0; ParentID = 0;
ParentPart = null; 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(); SendAvatarDataToAllAgents();
m_requestedSitTargetID = 0; m_requestedSitTargetID = 0;
@ -2859,6 +2900,7 @@ namespace OpenSim.Region.Framework.Scenes
lastTerseUpdateToAllClientsTick = currentTick; lastTerseUpdateToAllClientsTick = currentTick;
lastPositionSentToAllClients = OffsetPosition; lastPositionSentToAllClients = OffsetPosition;
// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
m_scene.ForEachClient(SendTerseUpdateToClient); m_scene.ForEachClient(SendTerseUpdateToClient);
} }
TriggerScenePresenceUpdated(); TriggerScenePresenceUpdated();