back to sits and stands

master
UbitUmarov 2020-01-22 00:15:23 +00:00
parent 8cc02916ab
commit 8db60ba3aa
1 changed files with 73 additions and 105 deletions

View File

@ -291,7 +291,7 @@ namespace OpenSim.Region.Framework.Scenes
private Quaternion m_lastRotation; private Quaternion m_lastRotation;
private Vector3 m_lastVelocity; private Vector3 m_lastVelocity;
private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f);
private int NeedInitialData = -1; private int NeedInitialData = 1;
private int m_userFlags; private int m_userFlags;
public int UserFlags public int UserFlags
@ -3251,24 +3251,18 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// part.ParentGroup.DeleteAvatar(UUID);
Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset;
Vector3 sitWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation;
ControllingClient.SendClearFollowCamProperties(part.ParentUUID); ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
ParentID = 0; ParentID = 0;
ParentPart = null; ParentPart = null;
if (part.SitTargetAvatar == UUID) Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset;
standRotation = standRotation * part.SitTargetOrientation; Vector3 sitWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation;
else
standRotation = standRotation * m_bodyRot;
standRotation = standRotation * m_bodyRot;
m_bodyRot = standRotation; m_bodyRot = standRotation;
Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W); Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W);
float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
if (t > 0) if (t > 0)
{ {
@ -3282,15 +3276,11 @@ namespace OpenSim.Region.Framework.Scenes
standRotationZ.Z = 0f; standRotationZ.Z = 0f;
} }
Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ; Vector3 adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ;
Vector3 standPos = sitWorldPosition + adjustmentForSitPose;
m_pos = standPos;
m_pos = sitWorldPosition + adjustmentForSitPose;
} }
// We need to wait until we have calculated proper stand positions before sitting up the physical
// avatar to avoid race conditions.
if (PhysicsActor == null) if (PhysicsActor == null)
AddToPhysicalScene(false); AddToPhysicalScene(false);
@ -3299,7 +3289,7 @@ namespace OpenSim.Region.Framework.Scenes
m_requestedSitTargetID = 0; m_requestedSitTargetID = 0;
part.RemoveSittingAvatar(this); part.RemoveSittingAvatar(this);
part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
SendAvatarDataToAllAgents(); SendAvatarDataToAllAgents();
m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
} }
@ -3359,14 +3349,10 @@ namespace OpenSim.Region.Framework.Scenes
if (PhysicsActor != null) if (PhysicsActor != null)
m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
bool canSit = false;
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
{ {
offset = part.SitTargetPosition; offset = part.SitTargetPosition;
sitOrientation = part.SitTargetOrientation; sitOrientation = part.SitTargetOrientation;
canSit = true;
} }
else else
{ {
@ -3374,67 +3360,59 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
Vector3 pos = part.AbsolutePosition + offset; Vector3 pos = part.AbsolutePosition + offset;
if (Vector3.DistanceSquared(AbsolutePosition, pos) > 100)
if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) return;
{ AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
canSit = true;
}
} }
if (canSit) if (PhysicsActor != null)
RemoveFromPhysicalScene();
if (m_movingToTarget)
ResetMoveToTarget();
Velocity = Vector3.Zero;
m_AngularVelocity = Vector3.Zero;
part.AddSittingAvatar(this);
cameraAtOffset = part.GetCameraAtOffset();
cameraEyeOffset = part.GetCameraEyeOffset();
forceMouselook = part.GetForceMouselook();
if (!part.IsRoot)
{ {
if (PhysicsActor != null) sitOrientation = part.RotationOffset * sitOrientation;
offset = offset * part.RotationOffset;
offset += part.OffsetPosition;
if (cameraAtOffset == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
{ {
// We can remove the physicsActor until they stand up. cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
RemoveFromPhysicalScene(); cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
} }
else
if (m_movingToTarget)
ResetMoveToTarget();
Velocity = Vector3.Zero;
m_AngularVelocity = Vector3.Zero;
part.AddSittingAvatar(this);
cameraAtOffset = part.GetCameraAtOffset();
cameraEyeOffset = part.GetCameraEyeOffset();
forceMouselook = part.GetForceMouselook();
if (!part.IsRoot)
{ {
sitOrientation = part.RotationOffset * sitOrientation; cameraAtOffset = cameraAtOffset * part.RotationOffset;
offset = offset * part.RotationOffset; cameraAtOffset += part.OffsetPosition;
offset += part.OffsetPosition; cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
cameraEyeOffset += part.OffsetPosition;
if (cameraAtOffset == Vector3.Zero && cameraEyeOffset == Vector3.Zero)
{
cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
}
else
{
cameraAtOffset = cameraAtOffset * part.RotationOffset;
cameraAtOffset += part.OffsetPosition;
cameraEyeOffset = cameraEyeOffset * part.RotationOffset;
cameraEyeOffset += part.OffsetPosition;
}
} }
ControllingClient.SendSitResponse(
part.ParentGroup.UUID, offset, sitOrientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = part.UUID;
HandleAgentSit(ControllingClient, UUID);
// Moved here to avoid a race with default sit anim
// The script event needs to be raised after the default sit anim is set.
//part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
//m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
} }
ControllingClient.SendSitResponse(
part.ParentGroup.UUID, offset, sitOrientation * part.ParentGroup.RootPart.RotationOffset,
true, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = part.UUID;
HandleAgentSit(ControllingClient, UUID);
// Moved here to avoid a race with default sit anim
// The script event needs to be raised after the default sit anim is set.
//part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
//m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
} }
public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
@ -3480,10 +3458,10 @@ namespace OpenSim.Region.Framework.Scenes
//if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) //if (part.PhysicsShapeType == (byte)PhysicsShapeType.None)
ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot.");
//else //else
{ // non physical phantom TODO //{ // non physical phantom TODO
// ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); //ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot.");
// return false; // return false;
} //}
return true; return true;
} }
@ -3546,7 +3524,6 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 cameraAtOffset = part.GetCameraAtOffset(); Vector3 cameraAtOffset = part.GetCameraAtOffset();
Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
bool forceMouselook = part.GetForceMouselook();
if (!part.IsRoot) if (!part.IsRoot)
{ {
@ -3571,8 +3548,10 @@ namespace OpenSim.Region.Framework.Scenes
m_bodyRot = Orientation; m_bodyRot = Orientation;
m_pos = offset; m_pos = offset;
Orientation *= part.ParentGroup.RootPart.RotationOffset;
ControllingClient.SendSitResponse( ControllingClient.SendSitResponse(
part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook); part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, part.GetForceMouselook());
SendAvatarDataToAllAgents(); SendAvatarDataToAllAgents();
@ -3607,6 +3586,8 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
} }
RemoveFromPhysicalScene();
if (part.SitTargetAvatar == UUID) if (part.SitTargetAvatar == UUID)
{ {
Vector3 sitTargetPos = part.SitTargetPosition; Vector3 sitTargetPos = part.SitTargetPosition;
@ -3621,6 +3602,7 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion r = sitTargetOrient; Quaternion r = sitTargetOrient;
Vector3 newPos; Vector3 newPos;
Quaternion newRot;
if (LegacySitOffsets) if (LegacySitOffsets)
{ {
@ -3687,8 +3669,6 @@ namespace OpenSim.Region.Framework.Scenes
newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
} }
Quaternion newRot;
if (part.IsRoot) if (part.IsRoot)
{ {
newRot = sitTargetOrient; newRot = sitTargetOrient;
@ -3700,30 +3680,22 @@ namespace OpenSim.Region.Framework.Scenes
} }
newPos += part.OffsetPosition; newPos += part.OffsetPosition;
m_pos = newPos; m_pos = newPos;
Rotation = newRot; Rotation = newRot;
// ParentPosition = part.AbsolutePosition; // ParentPosition = part.AbsolutePosition;
} }
else else
{ {
// An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is
// being sat upon. // being sat upon.
m_pos -= part.GroupPosition; m_pos -= part.GroupPosition;
// ParentPosition = part.AbsolutePosition;
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target",
// Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId);
} }
part.AddSittingAvatar(this); part.AddSittingAvatar(this);
ParentPart = part; ParentPart = part;
ParentID = m_requestedSitTargetID; ParentID = m_requestedSitTargetID;
RemoveFromPhysicalScene();
m_AngularVelocity = Vector3.Zero; m_AngularVelocity = Vector3.Zero;
Velocity = Vector3.Zero; Velocity = Vector3.Zero;
@ -3731,12 +3703,11 @@ namespace OpenSim.Region.Framework.Scenes
SendAvatarDataToAllAgents(); SendAvatarDataToAllAgents();
sitAnimation = "SIT"; if (String.IsNullOrEmpty(part.SitAnimation))
if (!String.IsNullOrEmpty(part.SitAnimation)) sitAnimation = "SIT";
{ else
sitAnimation = part.SitAnimation; sitAnimation = part.SitAnimation;
}
// Animator.TrySetMovementAnimation(sitAnimation);
Animator.SetMovementAnimations("SIT"); Animator.SetMovementAnimations("SIT");
// TriggerScenePresenceUpdated(); // TriggerScenePresenceUpdated();
part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
@ -4065,25 +4036,22 @@ namespace OpenSim.Region.Framework.Scenes
if(m_gotRegionHandShake) if(m_gotRegionHandShake)
return; return;
m_gotRegionHandShake = true; m_gotRegionHandShake = true;
NeedInitialData = 1; NeedInitialData = 2;
} }
} }
private void SendInitialData() private void SendInitialData()
{ {
uint flags = ControllingClient.GetViewerCaps(); uint flags = ControllingClient.GetViewerCaps();
if((flags & 0x1000) == 0) // wait for seeds sending if ((flags & 0x1000) == 0) // wait for seeds sending
return; return;
// lock (m_completeMovementLock) if (NeedInitialData < 2)
{ return;
if(NeedInitialData < 0)
return;
// give some extra time to make sure viewers did process seeds // give some extra time to make sure viewers did process seeds
if(++NeedInitialData < 4) // needs fix if update rate changes on heartbeat if (++NeedInitialData < 6) // needs fix if update rate changes on heartbeat
return; return;
}
NeedInitialData = -1; NeedInitialData = -1;