Get NPCs to revert to the correct 'resting' animation (e.g. stand or hover) after finishing their movement. This also fixes judder after an avatar has finished "go here"/autopilot movement in a viewer.

This meant reseting the SP.AgentControlFlags since the Animator uses these to determine the correct default animation.
bulletsim
Justin Clark-Casey (justincc) 2011-08-11 01:56:42 +01:00
parent 951ffad81e
commit 4402851b08
5 changed files with 19 additions and 8 deletions

View File

@ -77,6 +77,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (m_scenePresence.IsChildAgent) if (m_scenePresence.IsChildAgent)
return; return;
// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", 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();
} }
@ -91,6 +93,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
if (animID == UUID.Zero) if (animID == UUID.Zero)
return; return;
// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name);
AddAnimation(animID, objectID); AddAnimation(animID, objectID);
} }
@ -127,13 +131,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// </summary> /// </summary>
public void TrySetMovementAnimation(string anim) public void TrySetMovementAnimation(string anim)
{ {
//m_log.DebugFormat("Updating movement animation to {0}", anim);
if (!m_scenePresence.IsChildAgent) if (!m_scenePresence.IsChildAgent)
{ {
if (m_animations.TrySetDefaultAnimation( if (m_animations.TrySetDefaultAnimation(
anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID))
{ {
// m_log.DebugFormat(
// "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}",
// anim, m_scenePresence.Name);
// 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();

View File

@ -1745,6 +1745,12 @@ namespace OpenSim.Region.Framework.Scenes
MovingToTarget = false; MovingToTarget = false;
MoveToPositionTarget = Vector3.Zero; MoveToPositionTarget = Vector3.Zero;
// 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.
// However, the line is here rather than in the NPC module since it also appears necessary to stop a
// viewer that uses "go here" from juddering on all subsequent avatar movements.
AgentControlFlags = (uint)AgentManager.ControlFlags.NONE;
} }
private void CheckAtSitTarget() private void CheckAtSitTarget()

View File

@ -95,11 +95,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// } // }
} }
// FIXME: This doesn't work // m_log.DebugFormat(
if (presence.PhysicsActor.Flying) // "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
presence.Animator.TrySetMovementAnimation("HOVER"); // presence.AgentControlFlags, presence.MovementFlag, presence.Name);
else
presence.Animator.TrySetMovementAnimation("STAND");
} }
else else
{ {

View File

@ -131,6 +131,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
// Try a second movement // Try a second movement
startPos = npc.AbsolutePosition; startPos = npc.AbsolutePosition;

View File

@ -870,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence target = (ScenePresence)World.Entities[avatarID]; ScenePresence target = (ScenePresence)World.Entities[avatarID];
if (target != null) if (target != null)
{ {
UUID animID=UUID.Zero; UUID animID = UUID.Zero;
lock (m_host.TaskInventory) lock (m_host.TaskInventory)
{ {
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)