dont let ignored AgentUpdates change their throttles. Apply respective movement to physics on the handling thread, not heartbeat, avoiding missing transitions that should get into physics. Make some usefull sp state flags visible everywhere

melanie
UbitUmarov 2016-10-05 13:17:23 +01:00
parent f3e7603c37
commit 8a3958ad04
3 changed files with 79 additions and 60 deletions

View File

@ -55,6 +55,9 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
bool IsChildAgent { get; } bool IsChildAgent { get; }
bool IsInTransit { get; }
bool isNPC { get;}
bool Invulnerable { get; set; } bool Invulnerable { get; set; }
/// <summary> /// <summary>
/// Avatar appearance data. /// Avatar appearance data.

View File

@ -909,7 +909,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{ {
m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue; m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue; // m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
m_thisAgentUpdateArgs.ControlFlags = 0;
AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
mov.SimData.ChannelVersion = m_channelVersion; mov.SimData.ChannelVersion = m_channelVersion;
@ -6196,27 +6197,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param> /// <param name='x'></param>
private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{ {
float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation)); if(
//qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
bool movementSignificant =
(x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
|| (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands || ((x.ControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0 &&
(x.ControlFlags & 0x3f8dfff) != 0) // we need to rotate the av on fly
|| (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
|| (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
|| (qdelta1 < QDELTABody) // significant if body rotation above(below cos) threshold
// Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
// || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold
|| (Math.Abs(x.Far - m_thisAgentUpdateArgs.Far) >= 32) // significant if far distance changed || (Math.Abs(x.Far - m_thisAgentUpdateArgs.Far) >= 32) // significant if far distance changed
; )
//if (movementSignificant) return true;
//{
//m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
// qdelta1, qdelta2); //qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
//m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
// x.ControlFlags, x.Flags, x.Far, x.State); if(
//} qdelta1 < QDELTABody // significant if body rotation above(below cos) threshold
return movementSignificant; // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
// || qdelta2 < QDELTAHead // significant if head rotation above(below cos) threshold
)
return true;
return false;
} }
/// <summary> /// <summary>
@ -6227,33 +6228,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name='x'></param> /// <param name='x'></param>
private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
{ {
float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); float vdelta = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); if((vdelta > VDELTA))
float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); return true;
float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
bool cameraSignificant = vdelta = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
(vdelta1 > VDELTA) || if((vdelta > VDELTA))
(vdelta2 > VDELTA) || return true;
(vdelta3 > VDELTA) ||
(vdelta4 > VDELTA)
;
//if (cameraSignificant) vdelta = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
//{ if((vdelta > VDELTA))
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", return true;
// x.CameraAtAxis, x.CameraCenter);
//m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
// x.CameraLeftAxis, x.CameraUpAxis);
//}
return cameraSignificant; vdelta = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
if((vdelta > VDELTA))
return true;
return false;
} }
private bool HandleAgentUpdate(IClientAPI sender, Packet packet) private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
{ {
// We got here, which means that something in agent update was significant
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
@ -6264,10 +6259,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
TotalAgentUpdates++; TotalAgentUpdates++;
// dont let ignored updates pollute this throttles
if(SceneAgent == null || SceneAgent.IsChildAgent || SceneAgent.IsInTransit)
{
// throttle reset is done at MoveAgentIntoRegion()
// called by scenepresence on completemovement
PacketPool.Instance.ReturnPacket(packet);
return true;
}
bool movement = CheckAgentMovementUpdateSignificance(x); bool movement = CheckAgentMovementUpdateSignificance(x);
bool camera = CheckAgentCameraUpdateSignificance(x); bool camera = CheckAgentCameraUpdateSignificance(x);
// Was there a significant movement/state change? // Was there a significant movement/state change?
if (movement) if (movement)
{ {
@ -6276,7 +6279,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_thisAgentUpdateArgs.Far = x.Far; m_thisAgentUpdateArgs.Far = x.Far;
m_thisAgentUpdateArgs.Flags = x.Flags; m_thisAgentUpdateArgs.Flags = x.Flags;
m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
// m_thisAgentUpdateArgs.SessionID = x.SessionID;
m_thisAgentUpdateArgs.State = x.State; m_thisAgentUpdateArgs.State = x.State;
UpdateAgent handlerAgentUpdate = OnAgentUpdate; UpdateAgent handlerAgentUpdate = OnAgentUpdate;
@ -6287,9 +6289,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (handlerAgentUpdate != null) if (handlerAgentUpdate != null)
OnAgentUpdate(this, m_thisAgentUpdateArgs); OnAgentUpdate(this, m_thisAgentUpdateArgs);
handlerAgentUpdate = null;
handlerPreAgentUpdate = null;
} }
// Was there a significant camera(s) change? // Was there a significant camera(s) change?
@ -6305,7 +6305,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (handlerAgentCameraUpdate != null) if (handlerAgentCameraUpdate != null)
handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs); handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
handlerAgentCameraUpdate = null;
} }
PacketPool.Instance.ReturnPacket(packet); PacketPool.Instance.ReturnPacket(packet);

View File

@ -281,7 +281,9 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_followCamAuto = false; private bool m_followCamAuto = false;
private Vector3? m_forceToApply; // private object m_forceToApplyLock = new object();
// private bool m_forceToApplyValid;
// private Vector3 m_forceToApply;
private int m_userFlags; private int m_userFlags;
public int UserFlags public int UserFlags
{ {
@ -582,11 +584,11 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get get
{ {
return m_drawDistance; return m_drawDistance;
} }
set set
{ {
m_drawDistance = Util.Clamp(value, 32f, m_scene.MaxDrawDistance); m_drawDistance = Util.Clamp(value, 32f, m_scene.MaxDrawDistance);
} }
} }
@ -594,7 +596,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get get
{ {
return Util.Clamp(m_drawDistance, 32f, m_scene.MaxRegionViewDistance); return Util.Clamp(m_drawDistance, 32f, m_scene.MaxRegionViewDistance);
} }
} }
@ -2120,6 +2122,7 @@ namespace OpenSim.Region.Framework.Scenes
if (haveAnims) if (haveAnims)
SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); SendAnimPackToAgent(this, animIDs, animseqs, animsobjs);
// we should be able to receive updates, etc // we should be able to receive updates, etc
// so release them // so release them
m_inTransit = false; m_inTransit = false;
@ -2238,6 +2241,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
finally finally
{ {
haveGroupInformation = false;
gotCrossUpdate = false;
crossingFlags = 0;
m_inTransit = false; m_inTransit = false;
} }
// if hide force a check // if hide force a check
@ -2247,9 +2253,6 @@ namespace OpenSim.Region.Framework.Scenes
// m_currentParcelHide = newhide; // m_currentParcelHide = newhide;
// } // }
haveGroupInformation = false;
gotCrossUpdate = false;
crossingFlags = 0;
m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
@ -3006,7 +3009,8 @@ namespace OpenSim.Region.Framework.Scenes
MovingToTarget = false; MovingToTarget = false;
// MoveToPositionTarget = Vector3.Zero; // MoveToPositionTarget = Vector3.Zero;
m_forceToApply = null; // cancel possible last action // lock(m_forceToApplyLock)
// m_forceToApplyValid = false; // cancel possible last action
// We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct
// resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag.
@ -3638,8 +3642,14 @@ namespace OpenSim.Region.Framework.Scenes
} }
// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
/*
m_forceToApply = direc; lock(m_forceToApplyLock)
{
m_forceToApply = direc;
m_forceToApplyValid = true;
}
*/
Velocity = direc;
Animator.UpdateMovementAnimations(); Animator.UpdateMovementAnimations();
} }
@ -4734,17 +4744,21 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public void UpdateMovement() public void UpdateMovement()
{ {
/*
if (IsInTransit) if (IsInTransit)
return; return;
if (m_forceToApply.HasValue)
lock(m_forceToApplyLock)
{ {
Vector3 force = m_forceToApply.Value; if (m_forceToApplyValid)
{
Velocity = m_forceToApply;
Velocity = force; m_forceToApplyValid = false;
TriggerScenePresenceUpdated();
m_forceToApply = null; }
TriggerScenePresenceUpdated();
} }
*/
} }
/// <summary> /// <summary>
@ -4767,6 +4781,9 @@ namespace OpenSim.Region.Framework.Scenes
// Appearance.SetHeight(); // Appearance.SetHeight();
Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f));
// lock(m_forceToApplyLock)
// m_forceToApplyValid = false;
PhysicsScene scene = m_scene.PhysicsScene; PhysicsScene scene = m_scene.PhysicsScene;
Vector3 pVec = AbsolutePosition; Vector3 pVec = AbsolutePosition;