Make anims way more snappy. Decouple SP animation handling from physics frame

time.
avinationmerge
Melanie 2012-03-23 03:16:07 +01:00
parent dfd7068864
commit ade164667f
1 changed files with 29 additions and 14 deletions

View File

@ -233,6 +233,8 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_collisionEventFlag = false; private bool m_collisionEventFlag = false;
private object m_collisionEventLock = new Object(); private object m_collisionEventLock = new Object();
private int m_movementAnimationUpdateCounter = 0;
private Vector3 m_prevSitOffset; private Vector3 m_prevSitOffset;
protected AvatarAppearance m_appearance; protected AvatarAppearance m_appearance;
@ -741,6 +743,26 @@ namespace OpenSim.Region.Framework.Scenes
Appearance = appearance; Appearance = appearance;
} }
private void RegionHeartbeatEnd(Scene scene)
{
if (IsChildAgent)
return;
m_movementAnimationUpdateCounter ++;
if (m_movementAnimationUpdateCounter >= 2)
{
m_movementAnimationUpdateCounter = 0;
if (Animator != null)
{
Animator.UpdateMovementAnimations();
}
else
{
m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
}
}
}
public void RegisterToEvents() public void RegisterToEvents()
{ {
ControllingClient.OnCompleteMovementToRegion += CompleteMovement; ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
@ -952,6 +974,8 @@ namespace OpenSim.Region.Framework.Scenes
MovementFlag = 0; MovementFlag = 0;
m_scene.EventManager.TriggerOnMakeRootAgent(this); m_scene.EventManager.TriggerOnMakeRootAgent(this);
m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
} }
public int GetStateSource() public int GetStateSource()
@ -979,6 +1003,8 @@ namespace OpenSim.Region.Framework.Scenes
/// </remarks> /// </remarks>
public void MakeChildAgent() public void MakeChildAgent()
{ {
m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName);
// Reset these so that teleporting in and walking out isn't seen // Reset these so that teleporting in and walking out isn't seen
@ -2377,14 +2403,15 @@ namespace OpenSim.Region.Framework.Scenes
direc.Z *= 2.6f; direc.Z *= 2.6f;
// TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored.
Animator.TrySetMovementAnimation("PREJUMP"); // Animator.TrySetMovementAnimation("PREJUMP");
Animator.TrySetMovementAnimation("JUMP"); // Animator.TrySetMovementAnimation("JUMP");
} }
} }
} }
// TODO: Add the force instead of only setting it to support multiple forces per frame? // TODO: Add the force instead of only setting it to support multiple forces per frame?
m_forceToApply = direc; m_forceToApply = direc;
Animator.UpdateMovementAnimations();
} }
#endregion #endregion
@ -3334,18 +3361,6 @@ namespace OpenSim.Region.Framework.Scenes
if (IsChildAgent) if (IsChildAgent)
return; return;
//if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
// The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
// as of this comment the interval is set in AddToPhysicalScene
if (Animator != null)
{
// if (m_updateCount > 0)
// {
Animator.UpdateMovementAnimations();
// m_updateCount--;
// }
}
CollisionEventUpdate collisionData = (CollisionEventUpdate)e; CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;