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 Vector3 m_lastVelocity;
private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f);
private int NeedInitialData = -1;
private int NeedInitialData = 1;
private int m_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);
ParentID = 0;
ParentPart = null;
if (part.SitTargetAvatar == UUID)
standRotation = standRotation * part.SitTargetOrientation;
else
standRotation = standRotation * m_bodyRot;
Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset;
Vector3 sitWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation;
standRotation = standRotation * m_bodyRot;
m_bodyRot = standRotation;
Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W);
float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
if (t > 0)
{
@ -3282,15 +3276,11 @@ namespace OpenSim.Region.Framework.Scenes
standRotationZ.Z = 0f;
}
Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ;
Vector3 standPos = sitWorldPosition + adjustmentForSitPose;
m_pos = standPos;
Vector3 adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ;
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)
AddToPhysicalScene(false);
@ -3359,14 +3349,10 @@ namespace OpenSim.Region.Framework.Scenes
if (PhysicsActor != null)
m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
bool canSit = false;
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
{
offset = part.SitTargetPosition;
sitOrientation = part.SitTargetOrientation;
canSit = true;
}
else
{
@ -3374,67 +3360,59 @@ namespace OpenSim.Region.Framework.Scenes
return;
Vector3 pos = part.AbsolutePosition + offset;
if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
{
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
canSit = true;
}
if (Vector3.DistanceSquared(AbsolutePosition, pos) > 100)
return;
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
}
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.
RemoveFromPhysicalScene();
cameraAtOffset = part.ParentGroup.RootPart.GetCameraAtOffset();
cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset();
}
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)
else
{
sitOrientation = part.RotationOffset * sitOrientation;
offset = offset * part.RotationOffset;
offset += 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;
}
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)
@ -3480,10 +3458,10 @@ namespace OpenSim.Region.Framework.Scenes
//if (part.PhysicsShapeType == (byte)PhysicsShapeType.None)
ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot.");
//else
{ // non physical phantom TODO
// ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot.");
//{ // non physical phantom TODO
//ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot.");
// return false;
}
//}
return true;
}
@ -3546,7 +3524,6 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 cameraAtOffset = part.GetCameraAtOffset();
Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
bool forceMouselook = part.GetForceMouselook();
if (!part.IsRoot)
{
@ -3571,8 +3548,10 @@ namespace OpenSim.Region.Framework.Scenes
m_bodyRot = Orientation;
m_pos = offset;
Orientation *= part.ParentGroup.RootPart.RotationOffset;
ControllingClient.SendSitResponse(
part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook);
part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, part.GetForceMouselook());
SendAvatarDataToAllAgents();
@ -3607,6 +3586,8 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
RemoveFromPhysicalScene();
if (part.SitTargetAvatar == UUID)
{
Vector3 sitTargetPos = part.SitTargetPosition;
@ -3621,6 +3602,7 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion r = sitTargetOrient;
Vector3 newPos;
Quaternion newRot;
if (LegacySitOffsets)
{
@ -3687,8 +3669,6 @@ namespace OpenSim.Region.Framework.Scenes
newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
}
Quaternion newRot;
if (part.IsRoot)
{
newRot = sitTargetOrient;
@ -3700,30 +3680,22 @@ namespace OpenSim.Region.Framework.Scenes
}
newPos += part.OffsetPosition;
m_pos = newPos;
Rotation = newRot;
// ParentPosition = part.AbsolutePosition;
// ParentPosition = part.AbsolutePosition;
}
else
{
// An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is
// being sat upon.
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);
ParentPart = part;
ParentID = m_requestedSitTargetID;
RemoveFromPhysicalScene();
m_AngularVelocity = Vector3.Zero;
Velocity = Vector3.Zero;
@ -3731,12 +3703,11 @@ namespace OpenSim.Region.Framework.Scenes
SendAvatarDataToAllAgents();
sitAnimation = "SIT";
if (!String.IsNullOrEmpty(part.SitAnimation))
{
if (String.IsNullOrEmpty(part.SitAnimation))
sitAnimation = "SIT";
else
sitAnimation = part.SitAnimation;
}
// Animator.TrySetMovementAnimation(sitAnimation);
Animator.SetMovementAnimations("SIT");
// TriggerScenePresenceUpdated();
part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
@ -4065,25 +4036,22 @@ namespace OpenSim.Region.Framework.Scenes
if(m_gotRegionHandShake)
return;
m_gotRegionHandShake = true;
NeedInitialData = 1;
NeedInitialData = 2;
}
}
private void SendInitialData()
{
uint flags = ControllingClient.GetViewerCaps();
if((flags & 0x1000) == 0) // wait for seeds sending
if ((flags & 0x1000) == 0) // wait for seeds sending
return;
// lock (m_completeMovementLock)
{
if(NeedInitialData < 0)
return;
if (NeedInitialData < 2)
return;
// give some extra time to make sure viewers did process seeds
if(++NeedInitialData < 4) // needs fix if update rate changes on heartbeat
return;
}
// give some extra time to make sure viewers did process seeds
if (++NeedInitialData < 6) // needs fix if update rate changes on heartbeat
return;
NeedInitialData = -1;