From 1c2a0c78d9a7feb96dd1366755d588d03b92fd36 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 4 Nov 2008 16:39:28 +0000 Subject: [PATCH] Added a (xmlIgnored) SitAnimation property to SceneObjectPart. That allows the setting of the name of the animation to be used when a avatar sits on that object. At some point in the future this should be persisted. So basically simplifies what a lsl script that detects a avatar sitting on a prim, then stopping the sit animation and playing a custom animation, does. Also added another ScenePresence.HandleAgentRequestSit() method , that accepts the name of the sit animation. So that modules can override the animation used, when they are doing a server controlled sit. Started some work on making the stand pose be played as soon as a user logs into a region. Rather than them starting with their arms stretched. This still needs more work --- .../Environment/Scenes/SceneObjectPart.cs | 8 +++ .../Environment/Scenes/ScenePresence.cs | 60 ++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 6c76d54f85..be37352bd9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -160,6 +160,7 @@ namespace OpenSim.Region.Environment.Scenes private string m_sitName = String.Empty; private Quaternion m_sitTargetOrientation = Quaternion.Identity; private Vector3 m_sitTargetPosition = Vector3.Zero; + private string m_sitAnimation = "SIT"; private string m_text = String.Empty; private string m_touchName = String.Empty; private readonly UndoStack m_undo = new UndoStack(5); @@ -1017,6 +1018,13 @@ if (m_shape != null) { set { _parentUUID = value; } } + [XmlIgnore] + public string SitAnimation + { + get { return m_sitAnimation; } + set { m_sitAnimation = value; } + } + #endregion Public Properties with only Get diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index d75d8a9352..14667786f4 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -97,6 +97,8 @@ namespace OpenSim.Region.Environment.Scenes private uint m_requestedSitTargetID = 0; private UUID m_requestedSitTargetUUID = UUID.Zero; + private bool m_startAnimationSet = false; + private Vector3 m_requestedSitOffset = new Vector3(); private Vector3 m_LastFinitePos = new Vector3(); @@ -172,6 +174,8 @@ namespace OpenSim.Region.Environment.Scenes private Vector3 m_autoPilotTarget = Vector3.Zero; private bool m_sitAtAutoTarget = false; + private string m_nextSitAnimation = String.Empty; + // Agent's Draw distance. protected float m_DrawDistance = 0f; @@ -1323,16 +1327,51 @@ namespace OpenSim.Region.Environment.Scenes { StandUp(); } + m_nextSitAnimation = "SIT"; //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); - SceneObjectPart part = FindNextAvailableSitTarget(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); if (part != null) { + if (!String.IsNullOrEmpty(part.SitAnimation)) + { + m_nextSitAnimation = part.SitAnimation; + } m_requestedSitTargetID = part.LocalId; m_requestedSitOffset = offset; } else + { + + m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); + } + SendSitResponse(remoteClient, targetID, offset); + } + + public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) + { + if (m_parentID != 0) + { + StandUp(); + } + if (!String.IsNullOrEmpty(sitAnimation)) + { + m_nextSitAnimation = sitAnimation; + } + else + { + m_nextSitAnimation = "SIT"; + } + + //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + SceneObjectPart part = FindNextAvailableSitTarget(targetID); + if (part != null) + { + m_requestedSitTargetID = part.LocalId; + m_requestedSitOffset = offset; + } + else { m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); } @@ -1340,6 +1379,18 @@ namespace OpenSim.Region.Environment.Scenes } public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) + { + if (!String.IsNullOrEmpty(m_nextSitAnimation)) + { + HandleAgentSit(remoteClient, agentID, m_nextSitAnimation); + } + else + { + HandleAgentSit(remoteClient, agentID, "SIT"); + } + } + + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); @@ -1381,7 +1432,7 @@ namespace OpenSim.Region.Environment.Scenes Velocity = new Vector3(0, 0, 0); RemoveFromPhysicalScene(); - TrySetMovementAnimation("SIT"); + TrySetMovementAnimation(sitAnimation); SendFullUpdateToAllClients(); // This may seem stupid, but Our Full updates don't send avatar rotation :P // So we're also sending a terse update (which has avatar rotation) @@ -1897,6 +1948,11 @@ namespace OpenSim.Region.Environment.Scenes SendAppearanceToAllOtherAgents(); SendWearables(); + if (!m_startAnimationSet) + { + UpdateMovementAnimations(); + m_startAnimationSet = true; + } } public void SetWearable(int wearableId, AvatarWearable wearable)