Trigger OnScenePresenceUpdated when the avatar's animations change.

cpu-performance
Robert Adams 2013-05-30 19:15:14 -07:00
parent 48a175eff7
commit 4d32ca19bf
2 changed files with 21 additions and 4 deletions

View File

@ -92,8 +92,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
GetAnimName(animID), animID, m_scenePresence.Name); GetAnimName(animID), animID, m_scenePresence.Name);
if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
{
SendAnimPack(); SendAnimPack();
} }
}
// Called from scripts // Called from scripts
public void AddAnimation(string name, UUID objectID) public void AddAnimation(string name, UUID objectID)
@ -131,8 +133,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
GetAnimName(animID), animID, m_scenePresence.Name); GetAnimName(animID), animID, m_scenePresence.Name);
if (m_animations.Remove(animID, allowNoDefault)) if (m_animations.Remove(animID, allowNoDefault))
{
SendAnimPack(); SendAnimPack();
} }
}
// Called from scripts // Called from scripts
public void RemoveAnimation(string name) public void RemoveAnimation(string name)
@ -163,8 +167,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// The movement animation is reserved for "main" animations /// The movement animation is reserved for "main" animations
/// that are mutually exclusive, e.g. flying and sitting. /// that are mutually exclusive, e.g. flying and sitting.
/// </summary> /// </summary>
public void TrySetMovementAnimation(string anim) /// <returns>'true' if the animation was updated</returns>
public bool TrySetMovementAnimation(string anim)
{ {
bool ret = false;
if (!m_scenePresence.IsChildAgent) if (!m_scenePresence.IsChildAgent)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -181,6 +187,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// 16384 is CHANGED_ANIMATION // 16384 is CHANGED_ANIMATION
m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION});
SendAnimPack(); SendAnimPack();
ret = true;
} }
} }
else else
@ -189,6 +196,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
"[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}",
anim, m_scenePresence.Name); anim, m_scenePresence.Name);
} }
return ret;
} }
/// <summary> /// <summary>
@ -422,8 +430,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// <summary> /// <summary>
/// Update the movement animation of this avatar according to its current state /// Update the movement animation of this avatar according to its current state
/// </summary> /// </summary>
public void UpdateMovementAnimations() /// <returns>'true' if the animation was changed</returns>
public bool UpdateMovementAnimations()
{ {
bool ret = false;
lock (m_animations) lock (m_animations)
{ {
string newMovementAnimation = DetermineMovementAnimation(); string newMovementAnimation = DetermineMovementAnimation();
@ -437,9 +447,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// Only set it if it's actually changed, give a script // Only set it if it's actually changed, give a script
// a chance to stop a default animation // a chance to stop a default animation
TrySetMovementAnimation(CurrentMovementAnimation); ret = TrySetMovementAnimation(CurrentMovementAnimation);
} }
} }
return ret;
} }
public UUID[] GetAnimationArray() public UUID[] GetAnimationArray()

View File

@ -2039,6 +2039,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
Animator.TrySetMovementAnimation("STAND"); Animator.TrySetMovementAnimation("STAND");
TriggerScenePresenceUpdated();
} }
private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) private SceneObjectPart FindNextAvailableSitTarget(UUID targetID)
@ -2432,6 +2433,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
Animator.TrySetMovementAnimation(sitAnimation); Animator.TrySetMovementAnimation(sitAnimation);
SendAvatarDataToAllAgents(); SendAvatarDataToAllAgents();
TriggerScenePresenceUpdated();
} }
} }
@ -2440,6 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes
// m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick..
m_AngularVelocity = Vector3.Zero; m_AngularVelocity = Vector3.Zero;
Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
TriggerScenePresenceUpdated();
SitGround = true; SitGround = true;
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
} }
@ -2456,11 +2459,13 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleStartAnim(IClientAPI remoteClient, UUID animID) public void HandleStartAnim(IClientAPI remoteClient, UUID animID)
{ {
Animator.AddAnimation(animID, UUID.Zero); Animator.AddAnimation(animID, UUID.Zero);
TriggerScenePresenceUpdated();
} }
public void HandleStopAnim(IClientAPI remoteClient, UUID animID) public void HandleStopAnim(IClientAPI remoteClient, UUID animID)
{ {
Animator.RemoveAnimation(animID, false); Animator.RemoveAnimation(animID, false);
TriggerScenePresenceUpdated();
} }
/// <summary> /// <summary>
@ -3465,7 +3470,8 @@ namespace OpenSim.Region.Framework.Scenes
// if (m_updateCount > 0) // if (m_updateCount > 0)
// { // {
Animator.UpdateMovementAnimations(); if (Animator.UpdateMovementAnimations())
TriggerScenePresenceUpdated();
// m_updateCount--; // m_updateCount--;
// } // }