From 46a01d955068974c471c883700daace5e80d555a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 26 Oct 2010 12:22:09 -0700 Subject: [PATCH] Animations to multiple CMs (including idle anims) are working --- .../RegionSyncModule/RegionSyncAvatar.cs | 2 +- .../RegionSyncModule/RegionSyncClient.cs | 71 ++++++++++--------- .../RegionSyncModule/RegionSyncClientView.cs | 48 ++++++------- .../RegionSyncServerModule.cs | 4 +- .../Scenes/Animation/ScenePresenceAnimator.cs | 7 ++ 5 files changed, 73 insertions(+), 59 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs index 059229dc08..717e660306 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs @@ -496,7 +496,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (m_clientView != null) { - // m_log.Debug("[REGION SYNC AVATAR] SendAnimations"); + // m_log.DebugFormat("[REGION SYNC AVATAR] SendAnimations for {0}", m_agentID.ToString()); m_scene.RegionSyncServerModule.SendAnimations(m_agentID, animations, seqs, sourceAgentId, objectIDs); } } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index f078de56b0..79b4a31be1 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -747,7 +747,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } UUID agentID = data["agentID"].AsUUID(); - m_log.DebugFormat("{0} SendAnimations for {1}", LogHeader, agentID.ToString()); + // m_log.DebugFormat("{0} SendAnimations for {1}", LogHeader, agentID.ToString()); OSDArray animatA = (OSDArray)data["animations"]; UUID[] animIDs = new UUID[animatA.Count]; @@ -767,7 +767,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.TryGetScenePresence(agentID, out sp); if (sp != null) { - sp.ControllingClient.SendAnimations(animIDs, seqs, sourceAgentID, objectIDs); + if (agentID == sourceAgentID) + { + sp.Animator.SendAnimPack(animIDs, seqs, objectIDs); + } + else + { + sp.ControllingClient.SendAnimations(animIDs, seqs, sourceAgentID, objectIDs); + } } else { @@ -883,8 +890,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule client.OnAgentSit += HandleAgentSit; client.OnGrabObject += HandleGrabObject; client.OnGrabUpdate += HandleGrabUpdate; - client.OnDeGrabObject += HandleDeGrabObject; - client.OnStartAnim += HandleStartAnim; + client.OnDeGrabObject += HandleDeGrabObject; + client.OnStartAnim += HandleStartAnim; client.OnStopAnim += HandleStopAnim; } @@ -1025,34 +1032,34 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["pos"] = OSD.FromVector3(pos); data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs); Send(new RegionSyncMessage(RegionSyncMessage.MsgType.GrabUpdate, OSDParser.SerializeJsonString(data))); - } - - public void HandleDeGrabObject(uint localID, IClientAPI remoteClient, List surfaceArgs) - { - m_log.DebugFormat("[REGION SYNC CLIENT] HandleDeGrabObject for {0}", remoteClient.AgentId.ToString()); - OSDMap data = new OSDMap(3); - data["agentID"] = OSD.FromUUID(remoteClient.AgentId); - data["localID"] = OSD.FromUInteger(localID); - data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs); - Send(new RegionSyncMessage(RegionSyncMessage.MsgType.DeGrabObject, OSDParser.SerializeJsonString(data))); - } - - public void HandleStartAnim(IClientAPI remoteClient, UUID animID) - { - m_log.DebugFormat("[REGION SYNC CLIENT] HandleStartAnim for {0}", remoteClient.AgentId.ToString()); - OSDMap data = new OSDMap(3); - data["agentID"] = OSD.FromUUID(remoteClient.AgentId); - data["animID"] = OSD.FromUUID(animID); - Send(new RegionSyncMessage(RegionSyncMessage.MsgType.StartAnim, OSDParser.SerializeJsonString(data))); - } - - public void HandleStopAnim(IClientAPI remoteClient, UUID animID) - { - m_log.DebugFormat("[REGION SYNC CLIENT] HandleStopAnim for {0}", remoteClient.AgentId.ToString()); - OSDMap data = new OSDMap(3); - data["agentID"] = OSD.FromUUID(remoteClient.AgentId); - data["animID"] = OSD.FromUUID(animID); - Send(new RegionSyncMessage(RegionSyncMessage.MsgType.StopAnim, OSDParser.SerializeJsonString(data))); + } + + public void HandleDeGrabObject(uint localID, IClientAPI remoteClient, List surfaceArgs) + { + m_log.DebugFormat("[REGION SYNC CLIENT] HandleDeGrabObject for {0}", remoteClient.AgentId.ToString()); + OSDMap data = new OSDMap(3); + data["agentID"] = OSD.FromUUID(remoteClient.AgentId); + data["localID"] = OSD.FromUInteger(localID); + data["surfaceArgs"] = MakeSurfaceArgsArray(surfaceArgs); + Send(new RegionSyncMessage(RegionSyncMessage.MsgType.DeGrabObject, OSDParser.SerializeJsonString(data))); + } + + public void HandleStartAnim(IClientAPI remoteClient, UUID animID) + { + // m_log.DebugFormat("[REGION SYNC CLIENT] HandleStartAnim for {0}", remoteClient.AgentId.ToString()); + OSDMap data = new OSDMap(3); + data["agentID"] = OSD.FromUUID(remoteClient.AgentId); + data["id"] = OSD.FromUUID(animID); + Send(new RegionSyncMessage(RegionSyncMessage.MsgType.StartAnim, OSDParser.SerializeJsonString(data))); + } + + public void HandleStopAnim(IClientAPI remoteClient, UUID animID) + { + // m_log.DebugFormat("[REGION SYNC CLIENT] HandleStopAnim for {0}", remoteClient.AgentId.ToString()); + OSDMap data = new OSDMap(3); + data["agentID"] = OSD.FromUUID(remoteClient.AgentId); + data["id"] = OSD.FromUUID(animID); + Send(new RegionSyncMessage(RegionSyncMessage.MsgType.StopAnim, OSDParser.SerializeJsonString(data))); } /// diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs index 97bfdfadb6..509a29add1 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs @@ -587,39 +587,39 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data."); return; } - UUID agentID = data["agentID"].AsUUID(); + UUID agentID = data["agentID"].AsUUID(); UUID animID = data["id"].AsUUID(); - m_log.DebugFormat("{0} AnimStart for {1}", LogHeader, agentID.ToString()); + // m_log.DebugFormat("{0} AnimStart for {1}", LogHeader, agentID.ToString()); ScenePresence sp; m_scene.TryGetScenePresence(agentID, out sp); if (sp != null) { - sp.Animator.AddAnimation(animID, UUID.Zero); + sp.HandleStartAnim(sp.ControllingClient, animID); + } + return; + } + case RegionSyncMessage.MsgType.StopAnim: + { + OSDMap data = DeserializeMessage(msg); + if (data == null) + { + RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data."); + return; + } + UUID agentID = data["agentID"].AsUUID(); + UUID animID = data["id"].AsUUID(); + + // m_log.DebugFormat("{0} AnimStop for {1}", LogHeader, agentID.ToString()); + + ScenePresence sp; + m_scene.TryGetScenePresence(agentID, out sp); + if (sp != null) + { + sp.HandleStopAnim(sp.ControllingClient, animID); } return; - } - case RegionSyncMessage.MsgType.StopAnim: - { - OSDMap data = DeserializeMessage(msg); - if (data == null) - { - RegionSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data."); - return; - } - UUID agentID = data["agentID"].AsUUID(); - UUID animID = data["id"].AsUUID(); - - m_log.DebugFormat("{0} AnimStop for {1}", LogHeader, agentID.ToString()); - - ScenePresence sp; - m_scene.TryGetScenePresence(agentID, out sp); - if (sp != null) - { - sp.Animator.RemoveAnimation(animID); - } - return; } case RegionSyncMessage.MsgType.GrabObject: { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index 3e6fd56c1c..4f6899de58 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -366,8 +366,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["sourceAgentID"] = OSD.FromUUID(sourceAgentId); OSDArray obIDA = new OSDArray(); foreach (UUID ii in objectIDs) obIDA.Add(OSD.FromUUID(ii)); - data["objectIDs"] = obIDA; - m_log.DebugFormat("[REGION SYNC SERVER MODULE] Broadcast animations to {0}", agentID.ToString()); + data["objectIDs"] = obIDA; + // m_log.DebugFormat("[REGION SYNC SERVER MODULE] Broadcast animations for {0}", agentID.ToString()); RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.SendAnimations, OSDParser.SerializeJsonString(data)); m_server.Broadcast(rsm); // m_clientView.Send(rsm); diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 05c47edc51..061595b26c 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -407,6 +407,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation { if (m_scenePresence.IsChildAgent) return; + if (m_scenePresence.Scene.IsSyncedServer()) + { + m_scenePresence.Scene.RegionSyncServerModule.SendAnimations( + m_scenePresence.ControllingClient.AgentId, animations, seqs, + m_scenePresence.ControllingClient.AgentId, objectIDs); + return; + } m_scenePresence.Scene.ForEachClient( delegate(IClientAPI client)