diff options
author | Jeff Ames | 2007-12-10 15:08:44 +0000 |
---|---|---|
committer | Jeff Ames | 2007-12-10 15:08:44 +0000 |
commit | 40fd37f95af68a213b0c3a465858c27fa7c8cfdf (patch) | |
tree | 27424718d3b777adee5088deecd813573223bc33 /OpenSim/Region/Environment/Scenes/ScenePresence.cs | |
parent | more work on texture downloading. (diff) | |
download | opensim-SC-40fd37f95af68a213b0c3a465858c27fa7c8cfdf.zip opensim-SC-40fd37f95af68a213b0c3a465858c27fa7c8cfdf.tar.gz opensim-SC-40fd37f95af68a213b0c3a465858c27fa7c8cfdf.tar.bz2 opensim-SC-40fd37f95af68a213b0c3a465858c27fa7c8cfdf.tar.xz |
Refactored animation handling in ScenePresence. Now maintains a list of current animations.
* Fixes weirdness when typing and sitting at the same time
* Should fix bug #32 (getting stuck in edit appearance pose)
* Crouchwalk and possibly jump may need more looking into
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 179 |
1 files changed, 101 insertions, 78 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 21c0f3f..c277011 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -43,8 +43,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
43 | public static AvatarAnimations Animations; | 43 | public static AvatarAnimations Animations; |
44 | public static byte[] DefaultTexture; | 44 | public static byte[] DefaultTexture; |
45 | 45 | ||
46 | public LLUUID CurrentAnimation; | 46 | private List<LLUUID> m_animations = new List<LLUUID>(); |
47 | public int AnimationSeq; | 47 | private List<int> m_animationSeqs = new List<int>(); |
48 | 48 | ||
49 | private bool m_updateflag = false; | 49 | private bool m_updateflag = false; |
50 | private byte m_movementflag = 0; | 50 | private byte m_movementflag = 0; |
@@ -55,7 +55,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
55 | private float m_sitAvatarHeight = 2.0f; | 55 | private float m_sitAvatarHeight = 2.0f; |
56 | private float m_godlevel = 0; | 56 | private float m_godlevel = 0; |
57 | 57 | ||
58 | private bool m_isTyping = false; | ||
59 | private bool m_setAlwaysRun = false; | 58 | private bool m_setAlwaysRun = false; |
60 | 59 | ||
61 | private Quaternion m_bodyRot; | 60 | private Quaternion m_bodyRot; |
@@ -74,7 +73,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
74 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 73 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; |
75 | private LLVector3 lastPhysPos = new LLVector3(); | 74 | private LLVector3 lastPhysPos = new LLVector3(); |
76 | 75 | ||
77 | |||
78 | // Position of agent's camera in world | 76 | // Position of agent's camera in world |
79 | protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); | 77 | protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); |
80 | 78 | ||
@@ -286,6 +284,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
286 | Animations = new AvatarAnimations(); | 284 | Animations = new AvatarAnimations(); |
287 | Animations.LoadAnims(); | 285 | Animations.LoadAnims(); |
288 | 286 | ||
287 | m_animations.Add(Animations.AnimsLLUUID["STAND"]); | ||
288 | m_animationSeqs.Add(1); | ||
289 | |||
289 | RegisterToEvents(); | 290 | RegisterToEvents(); |
290 | 291 | ||
291 | SetDirectionVectors(); | 292 | SetDirectionVectors(); |
@@ -303,7 +304,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
303 | m_scene.LandManager.sendLandUpdate(this); | 304 | m_scene.LandManager.sendLandUpdate(this); |
304 | } | 305 | } |
305 | 306 | ||
306 | |||
307 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) | 307 | public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) |
308 | { | 308 | { |
309 | //couldn't move the following into SetInitialValues as they are readonly | 309 | //couldn't move the following into SetInitialValues as they are readonly |
@@ -319,6 +319,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
319 | Animations = new AvatarAnimations(); | 319 | Animations = new AvatarAnimations(); |
320 | Animations.LoadAnims(); | 320 | Animations.LoadAnims(); |
321 | 321 | ||
322 | m_animations.Add(Animations.AnimsLLUUID["STAND"]); | ||
323 | m_animationSeqs.Add(1); | ||
324 | |||
322 | RegisterToEvents(); | 325 | RegisterToEvents(); |
323 | SetDirectionVectors(); | 326 | SetDirectionVectors(); |
324 | 327 | ||
@@ -350,8 +353,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
350 | m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; | 353 | m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; |
351 | m_controllingClient.OnAgentSit += HandleAgentSit; | 354 | m_controllingClient.OnAgentSit += HandleAgentSit; |
352 | m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 355 | m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
356 | m_controllingClient.OnStartAnim += HandleStartAnim; | ||
357 | m_controllingClient.OnStopAnim += HandleStopAnim; | ||
353 | 358 | ||
354 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); | ||
355 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 359 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
356 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 360 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
357 | } | 361 | } |
@@ -786,7 +790,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
786 | Velocity = new LLVector3(0, 0, 0); | 790 | Velocity = new LLVector3(0, 0, 0); |
787 | RemoveFromPhysicalScene(); | 791 | RemoveFromPhysicalScene(); |
788 | 792 | ||
789 | SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); | 793 | SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); |
790 | SendFullUpdateToAllClients(); | 794 | SendFullUpdateToAllClients(); |
791 | } | 795 | } |
792 | 796 | ||
@@ -799,6 +803,57 @@ namespace OpenSim.Region.Environment.Scenes | |||
799 | } | 803 | } |
800 | } | 804 | } |
801 | 805 | ||
806 | public void AddAnimation(LLUUID animID, int seq) | ||
807 | { | ||
808 | if (!m_animations.Contains(animID)) | ||
809 | { | ||
810 | m_animations.Add(animID); | ||
811 | m_animationSeqs.Add(seq); | ||
812 | SendAnimPack(); | ||
813 | } | ||
814 | } | ||
815 | |||
816 | public void RemoveAnimation(LLUUID animID) | ||
817 | { | ||
818 | if (m_animations.Contains(animID)) | ||
819 | { | ||
820 | if (m_animations[0] == animID) | ||
821 | { | ||
822 | SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); | ||
823 | } | ||
824 | else | ||
825 | { | ||
826 | m_animations.Remove(animID); | ||
827 | SendAnimPack(); | ||
828 | } | ||
829 | } | ||
830 | } | ||
831 | |||
832 | public void HandleStartAnim(IClientAPI remoteClient, LLUUID animID, int seq) | ||
833 | { | ||
834 | AddAnimation(animID, seq); | ||
835 | } | ||
836 | |||
837 | public void HandleStopAnim(IClientAPI remoteClient, LLUUID animID) | ||
838 | { | ||
839 | RemoveAnimation(animID); | ||
840 | } | ||
841 | |||
842 | /// <summary> | ||
843 | /// The movement animation is the first element of the animation list, | ||
844 | /// reserved for "main" animations that are mutually exclusive, | ||
845 | /// like flying and sitting, for example. | ||
846 | /// </summary> | ||
847 | protected void SetMovementAnimation(LLUUID anim, int seq) | ||
848 | { | ||
849 | if (m_animations[0] != anim) | ||
850 | { | ||
851 | m_animations[0] = anim; | ||
852 | m_animationSeqs[0] = seq; | ||
853 | SendAnimPack(); | ||
854 | } | ||
855 | } | ||
856 | |||
802 | protected void UpdateMovementAnimations(bool update_movementflag) | 857 | protected void UpdateMovementAnimations(bool update_movementflag) |
803 | { | 858 | { |
804 | if (update_movementflag) | 859 | if (update_movementflag) |
@@ -807,81 +862,49 @@ namespace OpenSim.Region.Environment.Scenes | |||
807 | { | 862 | { |
808 | if (m_physicsActor.Flying) | 863 | if (m_physicsActor.Flying) |
809 | { | 864 | { |
810 | SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); | 865 | SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); |
811 | } | 866 | } |
812 | else | 867 | else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && |
868 | PhysicsActor.IsColliding) | ||
813 | { | 869 | { |
814 | if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && | 870 | SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1); |
815 | PhysicsActor.IsColliding) | ||
816 | { | ||
817 | SendAnimPack(Animations.AnimsLLUUID["CROUCHWALK"], 1); | ||
818 | } | ||
819 | else | ||
820 | { | ||
821 | if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) | ||
822 | { | ||
823 | SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); | ||
824 | } | ||
825 | else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | ||
826 | { | ||
827 | SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); | ||
828 | } | ||
829 | else | ||
830 | { | ||
831 | if (!m_setAlwaysRun) | ||
832 | { | ||
833 | SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); | ||
834 | } | ||
835 | else | ||
836 | { | ||
837 | SendAnimPack(Animations.AnimsLLUUID["RUN"], 1); | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | } | 871 | } |
842 | } | 872 | else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) |
843 | else if (m_parentID != 0) | ||
844 | { | ||
845 | if (m_isTyping) | ||
846 | { | 873 | { |
847 | SendAnimPack(Animations.AnimsLLUUID["TYPE"], 1); | 874 | SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); |
848 | } | 875 | } |
849 | else | 876 | else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) |
850 | { | 877 | { |
851 | // TODO: stop the typing animation, continue sitting | 878 | SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); |
852 | SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); | ||
853 | } | 879 | } |
880 | else if (m_setAlwaysRun) | ||
881 | { | ||
882 | SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1); | ||
883 | } | ||
884 | else | ||
885 | SetMovementAnimation(Animations.AnimsLLUUID["WALK"], 1); | ||
854 | } | 886 | } |
855 | else | 887 | else |
856 | { | 888 | { |
857 | if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && | 889 | if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && |
858 | PhysicsActor.IsColliding) | 890 | PhysicsActor.IsColliding) |
859 | { | 891 | { |
860 | SendAnimPack(Animations.AnimsLLUUID["CROUCH"], 1); | 892 | SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1); |
861 | } | 893 | } |
862 | else if (m_isTyping) | 894 | else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) |
863 | { | 895 | { |
864 | SendAnimPack(Animations.AnimsLLUUID["TYPE"], 1); | 896 | SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); |
865 | } | 897 | } |
866 | else | 898 | else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) |
867 | { | 899 | { |
868 | if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) | 900 | SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); |
869 | { | 901 | } |
870 | SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); | 902 | else if (m_physicsActor.Flying) |
871 | } | 903 | { |
872 | else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 904 | SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); |
873 | { | ||
874 | SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); | ||
875 | } | ||
876 | else | ||
877 | { | ||
878 | if (!m_physicsActor.Flying) | ||
879 | { | ||
880 | SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); | ||
881 | } | ||
882 | } | ||
883 | |||
884 | } | 905 | } |
906 | else | ||
907 | SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); | ||
885 | } | 908 | } |
886 | } | 909 | } |
887 | } | 910 | } |
@@ -912,8 +935,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
912 | { | 935 | { |
913 | direc.z *= 3; | 936 | direc.z *= 3; |
914 | //System.Console.WriteLine("Jump"); | 937 | //System.Console.WriteLine("Jump"); |
915 | SendAnimPack(Animations.AnimsLLUUID["PREJUMP"], 1); | 938 | SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1); |
916 | SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); | 939 | SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); |
917 | } | 940 | } |
918 | } | 941 | } |
919 | } | 942 | } |
@@ -932,9 +955,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
932 | return; | 955 | return; |
933 | } | 956 | } |
934 | 957 | ||
935 | m_isTyping = typing; | 958 | if (typing) |
936 | 959 | AddAnimation(Animations.AnimsLLUUID["TYPE"], 1); | |
937 | UpdateMovementAnimations(true); | 960 | else |
961 | RemoveAnimation(Animations.AnimsLLUUID["TYPE"]); | ||
938 | } | 962 | } |
939 | 963 | ||
940 | #endregion | 964 | #endregion |
@@ -1122,15 +1146,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
1122 | /// <summary> | 1146 | /// <summary> |
1123 | /// | 1147 | /// |
1124 | /// </summary> | 1148 | /// </summary> |
1125 | /// <param name="animID"></param> | 1149 | /// <param name="animations"></param> |
1126 | /// <param name="seq"></param> | 1150 | /// <param name="seqs"></param> |
1127 | public void SendAnimPack(LLUUID animID, int seq) | 1151 | public void SendAnimPack(LLUUID[] animations, int[] seqs) |
1128 | { | 1152 | { |
1129 | CurrentAnimation = animID; | 1153 | m_scene.Broadcast(delegate(IClientAPI client) |
1130 | AnimationSeq = seq; | 1154 | { |
1131 | LLUUID sourceAgentId = m_controllingClient.AgentId; | 1155 | client.SendAnimations(animations, seqs, m_controllingClient.AgentId); |
1132 | 1156 | }); | |
1133 | m_scene.Broadcast(delegate(IClientAPI client) { client.SendAnimation(animID, seq, sourceAgentId); }); | ||
1134 | } | 1157 | } |
1135 | 1158 | ||
1136 | /// <summary> | 1159 | /// <summary> |
@@ -1138,7 +1161,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1138 | /// </summary> | 1161 | /// </summary> |
1139 | public void SendAnimPack() | 1162 | public void SendAnimPack() |
1140 | { | 1163 | { |
1141 | SendAnimPack(CurrentAnimation, AnimationSeq); | 1164 | SendAnimPack(m_animations.ToArray(), m_animationSeqs.ToArray()); |
1142 | } | 1165 | } |
1143 | 1166 | ||
1144 | #endregion | 1167 | #endregion |