aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-23 11:52:25 +0000
committerAdam Frisby2008-04-23 11:52:25 +0000
commitbca7ab7e363e9c9874a9ab137b60a042b9d1139c (patch)
tree52150bf5c1514fdad8ff086c84af8e6ae67cbb17 /OpenSim/Region/Environment/Scenes/ScenePresence.cs
parent* Fix mantis #842 - folders which are created but left named "New Folder" in ... (diff)
downloadopensim-SC_OLD-bca7ab7e363e9c9874a9ab137b60a042b9d1139c.zip
opensim-SC_OLD-bca7ab7e363e9c9874a9ab137b60a042b9d1139c.tar.gz
opensim-SC_OLD-bca7ab7e363e9c9874a9ab137b60a042b9d1139c.tar.bz2
opensim-SC_OLD-bca7ab7e363e9c9874a9ab137b60a042b9d1139c.tar.xz
* Applying Mantis #1020 (Animations) - Thanks Melanie.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs138
1 files changed, 91 insertions, 47 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index d85eea6..3f70108 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -359,17 +359,15 @@ namespace OpenSim.Region.Environment.Scenes
359 359
360 AbsolutePosition = m_controllingClient.StartPos; 360 AbsolutePosition = m_controllingClient.StartPos;
361 361
362 // TODO: m_animations and m_animationSeqs should always be of the same length.
363 // Move them into an object to (hopefully) avoid threading issues. 362 // Move them into an object to (hopefully) avoid threading issues.
364 try 363 try
365 { 364 {
366 m_animations.Add(Animations.AnimsLLUUID["STAND"]); 365 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
367 } 366 }
368 catch (KeyNotFoundException) 367 catch (KeyNotFoundException)
369 { 368 {
370 m_log.Warn("[AVATAR]: KeyNotFound Exception playing avatar stand animation"); 369 m_log.Warn("[AVATAR]: KeyNotFound Exception playing avatar stand animation");
371 } 370 }
372 m_animationSeqs.Add(1);
373 371
374 RegisterToEvents(); 372 RegisterToEvents();
375 SetDirectionVectors(); 373 SetDirectionVectors();
@@ -549,6 +547,7 @@ namespace OpenSim.Region.Environment.Scenes
549 547
550 AddToPhysicalScene(); 548 AddToPhysicalScene();
551 m_physicsActor.Flying = isFlying; 549 m_physicsActor.Flying = isFlying;
550 SendAnimPack();
552 551
553 m_scene.SwapRootAgentCount(false); 552 m_scene.SwapRootAgentCount(false);
554 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid); 553 m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid);
@@ -571,6 +570,15 @@ namespace OpenSim.Region.Environment.Scenes
571 /// </summary> 570 /// </summary>
572 public void MakeChildAgent() 571 public void MakeChildAgent()
573 { 572 {
573 if(m_animations.Count > 0)
574 {
575 LLUUID movement=m_animations[0];
576
577 m_animations.Clear();
578 m_animationSeqs.Clear();
579
580 SetMovementAnimation(movement);
581 }
574// m_log.DebugFormat( 582// m_log.DebugFormat(
575// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}", 583// "[SCENEPRESENCE]: Downgrading child agent {0}, {1} to a root agent in {2}",
576// Name, UUID, m_scene.RegionInfo.RegionName); 584// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -634,7 +642,7 @@ namespace OpenSim.Region.Environment.Scenes
634 { 642 {
635 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (1.56f / 6)); 643 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (1.56f / 6));
636 } 644 }
637 SetMovementAnimation(Animations.AnimsLLUUID["LAND"], 2); 645 SetMovementAnimation(Animations.AnimsLLUUID["LAND"]);
638 SendFullUpdateToAllClients(); 646 SendFullUpdateToAllClients();
639 } 647 }
640 648
@@ -754,7 +762,7 @@ namespace OpenSim.Region.Environment.Scenes
754 { 762 {
755 // TODO: This doesn't quite work yet -- probably a parent ID problem 763 // TODO: This doesn't quite work yet -- probably a parent ID problem
756 // m_parentID = (what should this be?) 764 // m_parentID = (what should this be?)
757 SetMovementAnimation(Animations.AnimsLLUUID["SIT_GROUND"], 1); 765 SetMovementAnimation(Animations.AnimsLLUUID["SIT_GROUND"]);
758 } 766 }
759 // In the future, these values might need to go global. 767 // In the future, these values might need to go global.
760 // Here's where you get them. 768 // Here's where you get them.
@@ -891,7 +899,7 @@ namespace OpenSim.Region.Environment.Scenes
891 } 899 }
892 } 900 }
893 901
894 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); 902 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
895 } 903 }
896 904
897 private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset) 905 private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset)
@@ -1025,7 +1033,7 @@ namespace OpenSim.Region.Environment.Scenes
1025 Velocity = new LLVector3(0, 0, 0); 1033 Velocity = new LLVector3(0, 0, 0);
1026 RemoveFromPhysicalScene(); 1034 RemoveFromPhysicalScene();
1027 1035
1028 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); 1036 SetMovementAnimation(Animations.AnimsLLUUID["SIT"]);
1029 SendFullUpdateToAllClients(); 1037 SendFullUpdateToAllClients();
1030 // This may seem stupid, but Our Full updates don't send avatar rotation :P 1038 // This may seem stupid, but Our Full updates don't send avatar rotation :P
1031 // So we're also sending a terse update (which has avatar rotation) 1039 // So we're also sending a terse update (which has avatar rotation)
@@ -1045,35 +1053,58 @@ namespace OpenSim.Region.Environment.Scenes
1045 } 1053 }
1046 } 1054 }
1047 1055
1048 public void AddAnimation(LLUUID animID, int seq) 1056 public void AddAnimation(LLUUID animID)
1049 { 1057 {
1058 if(m_isChildAgent)
1059 return;
1060
1061 // Don't let this animation become the movement animation
1062 if(m_animations.Count < 1)
1063 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1064
1050 if (!m_animations.Contains(animID)) 1065 if (!m_animations.Contains(animID))
1051 { 1066 {
1052 m_animations.Add(animID); 1067 m_animations.Add(animID);
1053 m_animationSeqs.Add(seq); 1068 m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber);
1054 SendAnimPack(); 1069 SendAnimPack();
1055 } 1070 }
1056 } 1071 }
1057 1072
1058 public void RemoveAnimation(LLUUID animID) 1073 public void RemoveAnimation(LLUUID animID)
1059 { 1074 {
1075 if(m_isChildAgent)
1076 return;
1077
1060 if (m_animations.Contains(animID)) 1078 if (m_animations.Contains(animID))
1061 { 1079 {
1062 if (m_animations[0] == animID) 1080 if (m_animations[0] == animID)
1063 { 1081 {
1064 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); 1082 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1065 } 1083 }
1066 else 1084 else
1067 { 1085 {
1068 m_animations.Remove(animID); 1086 // What a HACK!! Anim list really needs to be an object!
1069 SendAnimPack(); 1087 int idx;
1088
1089 for(idx=0;idx < m_animations.Count;idx++)
1090 {
1091 if(m_animations[idx] == animID)
1092 {
1093 int seq=m_animationSeqs[idx];
1094
1095 m_animations.Remove(animID);
1096 m_animationSeqs.Remove(seq);
1097 SendAnimPack();
1098 break;
1099 }
1100 }
1070 } 1101 }
1071 } 1102 }
1072 } 1103 }
1073 1104
1074 public void HandleStartAnim(IClientAPI remoteClient, LLUUID animID, int seq) 1105 public void HandleStartAnim(IClientAPI remoteClient, LLUUID animID)
1075 { 1106 {
1076 AddAnimation(animID, seq); 1107 AddAnimation(animID);
1077 } 1108 }
1078 1109
1079 public void HandleStopAnim(IClientAPI remoteClient, LLUUID animID) 1110 public void HandleStopAnim(IClientAPI remoteClient, LLUUID animID)
@@ -1086,25 +1117,35 @@ namespace OpenSim.Region.Environment.Scenes
1086 /// reserved for "main" animations that are mutually exclusive, 1117 /// reserved for "main" animations that are mutually exclusive,
1087 /// like flying and sitting, for example. 1118 /// like flying and sitting, for example.
1088 /// </summary> 1119 /// </summary>
1089 protected void SetMovementAnimation(LLUUID anim, int seq) 1120 protected void SetMovementAnimation(LLUUID anim)
1090 { 1121 {
1091 try 1122 if(m_animations.Count < 1)
1092 { 1123 {
1093 if (m_animations[0] != anim) 1124 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
1094 { 1125 m_animationSeqs.Add(1);
1095 m_animations[0] = anim; 1126
1096 m_animationSeqs[0] = seq; 1127 SendAnimPack();
1097 SendAnimPack(); 1128 }
1098 } 1129 else
1099 } 1130 {
1100 catch 1131 try
1101 { 1132 {
1102 m_log.Warn("[AVATAR]: SetMovementAnimation for avatar failed. Attempting recovery..."); 1133 if (m_animations[0] != anim)
1103 m_animations[0] = anim; 1134 {
1104 m_animationSeqs[0] = seq; 1135 m_animations[0] = anim;
1105 SendAnimPack(); 1136 m_animationSeqs[0] = m_controllingClient.NextAnimationSequenceNumber;
1106 } 1137 }
1107 } 1138 SendAnimPack();
1139 }
1140 catch
1141 {
1142 m_log.Warn("[AVATAR]: SetMovementAnimation for avatar failed. Attempting recovery...");
1143 m_animations[0] = anim;
1144 m_animationSeqs[0] = m_controllingClient.NextAnimationSequenceNumber;
1145 SendAnimPack();
1146 }
1147 }
1148 }
1108 1149
1109 /// <summary> 1150 /// <summary>
1110 /// This method handles agent movement related animations 1151 /// This method handles agent movement related animations
@@ -1123,18 +1164,18 @@ namespace OpenSim.Region.Environment.Scenes
1123 if (m_physicsActor.Flying) 1164 if (m_physicsActor.Flying)
1124 { 1165 {
1125 // We are flying 1166 // We are flying
1126 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); 1167 SetMovementAnimation(Animations.AnimsLLUUID["FLY"]);
1127 } 1168 }
1128 else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 1169 else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
1129 PhysicsActor.IsColliding) 1170 PhysicsActor.IsColliding)
1130 { 1171 {
1131 // Client is pressing the page down button and moving and is colliding with something 1172 // Client is pressing the page down button and moving and is colliding with something
1132 SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"], 1); 1173 SetMovementAnimation(Animations.AnimsLLUUID["CROUCHWALK"]);
1133 } 1174 }
1134 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) 1175 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6)
1135 { 1176 {
1136 // Client is moving and falling at a velocity greater then 6 meters per unit 1177 // Client is moving and falling at a velocity greater then 6 meters per unit
1137 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 1178 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"]);
1138 } 1179 }
1139 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && 1180 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 &&
1140 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 1181 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
@@ -1142,7 +1183,7 @@ namespace OpenSim.Region.Environment.Scenes
1142 // Client is moving, and colliding and pressing the page up button but isn't flying 1183 // Client is moving, and colliding and pressing the page up button but isn't flying
1143 try 1184 try
1144 { 1185 {
1145 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1186 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1146 } 1187 }
1147 catch (KeyNotFoundException) 1188 catch (KeyNotFoundException)
1148 { } 1189 { }
@@ -1152,7 +1193,7 @@ namespace OpenSim.Region.Environment.Scenes
1152 // We are running 1193 // We are running
1153 try 1194 try
1154 { 1195 {
1155 SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1); 1196 SetMovementAnimation(Animations.AnimsLLUUID["RUN"]);
1156 } 1197 }
1157 catch (KeyNotFoundException) 1198 catch (KeyNotFoundException)
1158 { } 1199 { }
@@ -1162,7 +1203,7 @@ namespace OpenSim.Region.Environment.Scenes
1162 // We're moving, but we're not doing anything else.. so play the stand animation 1203 // We're moving, but we're not doing anything else.. so play the stand animation
1163 try 1204 try
1164 { 1205 {
1165 SetMovementAnimation(Animations.AnimsLLUUID["WALK"], 1); 1206 SetMovementAnimation(Animations.AnimsLLUUID["WALK"]);
1166 } 1207 }
1167 catch (KeyNotFoundException) 1208 catch (KeyNotFoundException)
1168 { } 1209 { }
@@ -1177,23 +1218,23 @@ namespace OpenSim.Region.Environment.Scenes
1177 PhysicsActor.IsColliding) 1218 PhysicsActor.IsColliding)
1178 { 1219 {
1179 // Client pressing the page down button 1220 // Client pressing the page down button
1180 SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"], 1); 1221 SetMovementAnimation(Animations.AnimsLLUUID["CROUCH"]);
1181 } 1222 }
1182 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) 1223 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying)
1183 { 1224 {
1184 // Not colliding and not flying, and we're falling at high speed 1225 // Not colliding and not flying, and we're falling at high speed
1185 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 1226 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"]);
1186 } 1227 }
1187 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && 1228 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying &&
1188 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 1229 (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
1189 { 1230 {
1190 // This is the standing jump 1231 // This is the standing jump
1191 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1232 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1192 } 1233 }
1193 else if (m_physicsActor.Flying) 1234 else if (m_physicsActor.Flying)
1194 { 1235 {
1195 // We're flying but not moving 1236 // We're flying but not moving
1196 SetMovementAnimation(Animations.AnimsLLUUID["HOVER"], 1); 1237 SetMovementAnimation(Animations.AnimsLLUUID["HOVER"]);
1197 } 1238 }
1198 else 1239 else
1199 { 1240 {
@@ -1201,7 +1242,7 @@ namespace OpenSim.Region.Environment.Scenes
1201 try 1242 try
1202 { 1243 {
1203 1244
1204 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); 1245 SetMovementAnimation(Animations.AnimsLLUUID["STAND"]);
1205 } 1246 }
1206 catch (KeyNotFoundException) 1247 catch (KeyNotFoundException)
1207 { } 1248 { }
@@ -1257,8 +1298,8 @@ namespace OpenSim.Region.Environment.Scenes
1257 // PreJump and jump happen too quickly. Many times prejump gets ignored. 1298 // PreJump and jump happen too quickly. Many times prejump gets ignored.
1258 try 1299 try
1259 { 1300 {
1260 SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"], 1); 1301 SetMovementAnimation(Animations.AnimsLLUUID["PREJUMP"]);
1261 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 1302 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"]);
1262 } 1303 }
1263 catch (KeyNotFoundException) 1304 catch (KeyNotFoundException)
1264 { } 1305 { }
@@ -1495,6 +1536,9 @@ namespace OpenSim.Region.Environment.Scenes
1495 /// <param name="seqs"></param> 1536 /// <param name="seqs"></param>
1496 public void SendAnimPack(LLUUID[] animations, int[] seqs) 1537 public void SendAnimPack(LLUUID[] animations, int[] seqs)
1497 { 1538 {
1539 if(m_isChildAgent)
1540 return;
1541
1498 m_scene.Broadcast( 1542 m_scene.Broadcast(
1499 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); }); 1543 delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); });
1500 } 1544 }
@@ -1915,7 +1959,7 @@ namespace OpenSim.Region.Environment.Scenes
1915 1959
1916 m_animations = new List<LLUUID>(); 1960 m_animations = new List<LLUUID>();
1917 m_animations.Add(Animations.AnimsLLUUID["STAND"]); 1961 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
1918 m_animationSeqs.Add(1); 1962 m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber);
1919 1963
1920 SetDirectionVectors(); 1964 SetDirectionVectors();
1921 */ 1965 */