aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorJeff Ames2007-12-11 18:03:25 +0000
committerJeff Ames2007-12-11 18:03:25 +0000
commit77841fe35eab3948bc893ed3c7806f65b4895812 (patch)
treedbd5025d6016fadd78f9b578c9385184c3b13e75 /OpenSim/Region/Environment/Scenes
parentA few minor changes/additions/fixes. (diff)
downloadopensim-SC-77841fe35eab3948bc893ed3c7806f65b4895812.zip
opensim-SC-77841fe35eab3948bc893ed3c7806f65b4895812.tar.gz
opensim-SC-77841fe35eab3948bc893ed3c7806f65b4895812.tar.bz2
opensim-SC-77841fe35eab3948bc893ed3c7806f65b4895812.tar.xz
Minor cleanup/refactoring of ScenePresence.
Changes flying animation to hover when not moving (as per Teravus's suggestion).
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs123
1 files changed, 47 insertions, 76 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 201a547..c82d066 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Region.Environment.Scenes
98 /// </summary> 98 /// </summary>
99 private enum Dir_ControlFlags 99 private enum Dir_ControlFlags
100 { 100 {
101 DIR_CONTROL_FLAG_FOWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, 101 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
102 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, 102 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
103 DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, 103 DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS,
104 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, 104 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
@@ -293,83 +293,49 @@ namespace OpenSim.Region.Environment.Scenes
293 293
294 #region Constructor(s) 294 #region Constructor(s)
295 295
296 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 296 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
297 AvatarWearable[] wearables)
298 { 297 {
299 //couldn't move the following into SetInitialValues as they are readonly
300 m_regionHandle = reginfo.RegionHandle; 298 m_regionHandle = reginfo.RegionHandle;
301 m_controllingClient = client; 299 m_controllingClient = client;
302 m_firstname = m_controllingClient.FirstName; 300 m_firstname = m_controllingClient.FirstName;
303 m_lastname = m_controllingClient.LastName; 301 m_lastname = m_controllingClient.LastName;
304 302
305 SetInitialValues(client, world, reginfo); 303 m_scene = world;
304 m_uuid = client.AgentId;
305 m_regionInfo = reginfo;
306 m_localId = m_scene.NextLocalId;
306 307
307 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 308 AbsolutePosition = m_controllingClient.StartPos;
308 309
309 Animations = new AvatarAnimations(); 310 Animations = new AvatarAnimations();
310 Animations.LoadAnims(); 311 Animations.LoadAnims();
311 312
313 // TODO: m_animations and m_animationSeqs should always be of the same length.
314 // Move them into an object to (hopefully) avoid threading issues.
312 m_animations.Add(Animations.AnimsLLUUID["STAND"]); 315 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
313 m_animationSeqs.Add(1); 316 m_animationSeqs.Add(1);
314 317
315 RegisterToEvents(); 318 RegisterToEvents();
316
317 SetDirectionVectors(); 319 SetDirectionVectors();
318 320
319 //m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length);
320
321 // m_textureEntry = GetDefaultTextureEntry();
322 //temporary until we move some code into the body classes
323
324 if (m_newAvatar)
325 {
326 //do we need to use newAvatar? not sure so have added this to kill the compile warning
327 }
328
329 m_scene.LandManager.sendLandUpdate(this); 321 m_scene.LandManager.sendLandUpdate(this);
330 } 322 }
331 323
332 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 324 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
325 AvatarWearable[] wearables)
326 : this(client, world, reginfo)
333 { 327 {
334 //couldn't move the following into SetInitialValues as they are readonly 328 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
335 m_regionHandle = reginfo.RegionHandle;
336 m_controllingClient = client;
337 m_firstname = m_controllingClient.FirstName;
338 m_lastname = m_controllingClient.LastName;
339
340 SetInitialValues(client, world, reginfo);
341
342 m_appearance = appearance;
343
344 Animations = new AvatarAnimations();
345 Animations.LoadAnims();
346
347 m_animations.Add(Animations.AnimsLLUUID["STAND"]);
348 m_animationSeqs.Add(1);
349
350 RegisterToEvents();
351 SetDirectionVectors();
352
353 if (m_newAvatar)
354 {
355 //do we need to use newAvatar? not sure so have added this to kill the compile warning
356 }
357
358 m_scene.LandManager.sendLandUpdate(this);
359 } 329 }
360 330
361 private void SetInitialValues(IClientAPI client, Scene world, RegionInfo reginfo) 331 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
332 : this(client, world, reginfo)
362 { 333 {
363 m_scene = world; 334 m_appearance = appearance;
364 m_uuid = client.AgentId;
365 m_regionInfo = reginfo;
366 m_localId = m_scene.NextLocalId;
367 AbsolutePosition = m_controllingClient.StartPos;
368 } 335 }
369 336
370 private void RegisterToEvents() 337 private void RegisterToEvents()
371 { 338 {
372 //register for events
373 m_controllingClient.OnRequestWearables += SendOwnAppearance; 339 m_controllingClient.OnRequestWearables += SendOwnAppearance;
374 m_controllingClient.OnSetAppearance += SetAppearance; 340 m_controllingClient.OnSetAppearance += SetAppearance;
375 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 341 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
@@ -382,12 +348,12 @@ namespace OpenSim.Region.Environment.Scenes
382 m_controllingClient.OnStopAnim += HandleStopAnim; 348 m_controllingClient.OnStopAnim += HandleStopAnim;
383 349
384 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 350 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
385 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 351 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
386 } 352 }
387 353
388 private void SetDirectionVectors() 354 private void SetDirectionVectors()
389 { 355 {
390 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD 356 Dir_Vectors[0] = new Vector3(1, 0, 0); //FORWARD
391 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK 357 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
392 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT 358 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
393 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT 359 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
@@ -406,10 +372,12 @@ namespace OpenSim.Region.Environment.Scenes
406 } 372 }
407 // } 373 // }
408 } 374 }
375
409 public uint GenerateClientFlags(LLUUID ObjectID) 376 public uint GenerateClientFlags(LLUUID ObjectID)
410 { 377 {
411 return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID); 378 return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID);
412 } 379 }
380
413 public void SendPrimUpdates() 381 public void SendPrimUpdates()
414 { 382 {
415 // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode) 383 // if (m_scene.QuadTree.GetNodeID(this.AbsolutePosition.X, this.AbsolutePosition.Y) != m_currentQuadNode)
@@ -441,8 +409,6 @@ namespace OpenSim.Region.Environment.Scenes
441 // could have been sent in the last update - we still need to send the 409 // could have been sent in the last update - we still need to send the
442 // second here. 410 // second here.
443 411
444
445
446 if (update.LastFullUpdateTime < part.TimeStampFull) 412 if (update.LastFullUpdateTime < part.TimeStampFull)
447 { 413 {
448 //need to do a full update 414 //need to do a full update
@@ -458,8 +424,6 @@ namespace OpenSim.Region.Environment.Scenes
458 } 424 }
459 else if (update.LastTerseUpdateTime <= part.TimeStampTerse) 425 else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
460 { 426 {
461
462
463 part.SendTerseUpdate(ControllingClient); 427 part.SendTerseUpdate(ControllingClient);
464 428
465 update.LastTerseUpdateTime = part.TimeStampTerse; 429 update.LastTerseUpdateTime = part.TimeStampTerse;
@@ -493,7 +457,6 @@ namespace OpenSim.Region.Environment.Scenes
493 /// </summary> 457 /// </summary>
494 public void MakeRootAgent(LLVector3 pos, bool isFlying) 458 public void MakeRootAgent(LLVector3 pos, bool isFlying)
495 { 459 {
496
497 m_newAvatar = true; 460 m_newAvatar = true;
498 m_isChildAgent = false; 461 m_isChildAgent = false;
499 462
@@ -508,8 +471,8 @@ namespace OpenSim.Region.Environment.Scenes
508 //m_scene.SendAllSceneObjectsToClient(this); 471 //m_scene.SendAllSceneObjectsToClient(this);
509 //m_gotAllObjectsInScene = true; 472 //m_gotAllObjectsInScene = true;
510 //} 473 //}
511
512 } 474 }
475
513 /// <summary> 476 /// <summary>
514 /// This turns a root agent into a child agent 477 /// This turns a root agent into a child agent
515 /// when an agent departs this region for a neighbor, this gets called. 478 /// when an agent departs this region for a neighbor, this gets called.
@@ -610,6 +573,7 @@ namespace OpenSim.Region.Environment.Scenes
610 MakeRootAgent(AbsolutePosition, false); 573 MakeRootAgent(AbsolutePosition, false);
611 } 574 }
612 } 575 }
576
613 /// <summary> 577 /// <summary>
614 /// This is the event handler for client movement. If a client is moving, this event is triggering. 578 /// This is the event handler for client movement. If a client is moving, this event is triggering.
615 /// </summary> 579 /// </summary>
@@ -734,7 +698,7 @@ namespace OpenSim.Region.Environment.Scenes
734 SendFullUpdateToAllClients(); 698 SendFullUpdateToAllClients();
735 } 699 }
736 700
737 UpdateMovementAnimations(true); 701 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1);
738 } 702 }
739 703
740 private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset) 704 private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset)
@@ -777,13 +741,13 @@ namespace OpenSim.Region.Environment.Scenes
777 741
778 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) 742 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset)
779 { 743 {
780 SendSitResponse(remoteClient, targetID, offset);
781
782 if (m_parentID != 0) 744 if (m_parentID != 0)
783 { 745 {
784 StandUp(); 746 StandUp();
785 } 747 }
786 748
749 SendSitResponse(remoteClient, targetID, offset);
750
787 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 751 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
788 752
789 if (part != null) 753 if (part != null)
@@ -815,6 +779,7 @@ namespace OpenSim.Region.Environment.Scenes
815 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); 779 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1);
816 SendFullUpdateToAllClients(); 780 SendFullUpdateToAllClients();
817 } 781 }
782
818 /// <summary> 783 /// <summary>
819 /// Event handler for the 'Always run' setting on the client 784 /// Event handler for the 'Always run' setting on the client
820 /// Tells the physics plugin to increase speed of movement. 785 /// Tells the physics plugin to increase speed of movement.
@@ -878,6 +843,7 @@ namespace OpenSim.Region.Environment.Scenes
878 SendAnimPack(); 843 SendAnimPack();
879 } 844 }
880 } 845 }
846
881 /// <summary> 847 /// <summary>
882 /// This method handles agent movement related animations 848 /// This method handles agent movement related animations
883 /// </summary> 849 /// </summary>
@@ -889,9 +855,10 @@ namespace OpenSim.Region.Environment.Scenes
889 if (m_movementflag != 0) 855 if (m_movementflag != 0)
890 { 856 {
891 // We are moving 857 // We are moving
892 // Are we flying 858
893 if (m_physicsActor.Flying) 859 if (m_physicsActor.Flying)
894 { 860 {
861 // We are flying
895 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); 862 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
896 } 863 }
897 else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && 864 else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) &&
@@ -907,7 +874,7 @@ namespace OpenSim.Region.Environment.Scenes
907 } 874 }
908 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 875 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
909 { 876 {
910 // client is moving, and colliding and pressing the page up button but isn't flying 877 // Client is moving, and colliding and pressing the page up button but isn't flying
911 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); 878 SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1);
912 } 879 }
913 else if (m_setAlwaysRun) 880 else if (m_setAlwaysRun)
@@ -916,7 +883,10 @@ namespace OpenSim.Region.Environment.Scenes
916 SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1); 883 SetMovementAnimation(Animations.AnimsLLUUID["RUN"], 1);
917 } 884 }
918 else 885 else
886 {
887 // We're moving, but we're not doing anything else.. so play the stand animation
919 SetMovementAnimation(Animations.AnimsLLUUID["WALK"], 1); 888 SetMovementAnimation(Animations.AnimsLLUUID["WALK"], 1);
889 }
920 } 890 }
921 else 891 else
922 { 892 {
@@ -930,7 +900,7 @@ namespace OpenSim.Region.Environment.Scenes
930 } 900 }
931 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) 901 else if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying)
932 { 902 {
933 // Not colliding, and we're not flying and we're falling at a speed of 6m per unit 903 // Not colliding and not flying, and we're falling at high speed
934 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); 904 SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1);
935 } 905 }
936 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) 906 else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0)
@@ -940,13 +910,14 @@ namespace OpenSim.Region.Environment.Scenes
940 } 910 }
941 else if (m_physicsActor.Flying) 911 else if (m_physicsActor.Flying)
942 { 912 {
943 // This should probably be HOVER and not Fly 913 // We're flying but not moving
944 // We're not moving and flying 914 SetMovementAnimation(Animations.AnimsLLUUID["HOVER"], 1);
945 SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1);
946 } 915 }
947 else 916 else
917 {
918 // We're not moving.. and we're not doing anything.. so play the stand animation
948 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1); 919 SetMovementAnimation(Animations.AnimsLLUUID["STAND"], 1);
949 // We're not moving.. and we're not doing anything.. so play the stand animation 920 }
950 } 921 }
951 } 922 }
952 } 923 }
@@ -991,6 +962,7 @@ namespace OpenSim.Region.Environment.Scenes
991 newVelocity.Z = direc.z; 962 newVelocity.Z = direc.z;
992 m_forcesList.Add(newVelocity); 963 m_forcesList.Add(newVelocity);
993 } 964 }
965
994 /// <summary> 966 /// <summary>
995 /// Sets whether or not the agent is typing. 967 /// Sets whether or not the agent is typing.
996 /// </summary> 968 /// </summary>
@@ -1059,8 +1031,8 @@ namespace OpenSim.Region.Environment.Scenes
1059 /// <summary> 1031 /// <summary>
1060 /// Sends a location update to the client connected to this scenePresence 1032 /// Sends a location update to the client connected to this scenePresence
1061 /// </summary> 1033 /// </summary>
1062 /// <param name="RemoteClient"></param> 1034 /// <param name="remoteClient"></param>
1063 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 1035 public void SendTerseUpdateToClient(IClientAPI remoteClient)
1064 { 1036 {
1065 LLVector3 pos = m_pos; 1037 LLVector3 pos = m_pos;
1066 LLVector3 vel = Velocity; 1038 LLVector3 vel = Velocity;
@@ -1069,7 +1041,7 @@ namespace OpenSim.Region.Environment.Scenes
1069 rot.Y = m_bodyRot.y; 1041 rot.Y = m_bodyRot.y;
1070 rot.Z = m_bodyRot.z; 1042 rot.Z = m_bodyRot.z;
1071 rot.W = m_bodyRot.w; 1043 rot.W = m_bodyRot.w;
1072 RemoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), 1044 remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z),
1073 new LLVector3(vel.X, vel.Y, vel.Z), rot); 1045 new LLVector3(vel.X, vel.Y, vel.Z), rot);
1074 } 1046 }
1075 1047
@@ -1110,6 +1082,7 @@ namespace OpenSim.Region.Environment.Scenes
1110 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, 1082 remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid,
1111 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); 1083 LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID);
1112 } 1084 }
1085
1113 /// <summary> 1086 /// <summary>
1114 /// Tell *ALL* agents about this agent 1087 /// Tell *ALL* agents about this agent
1115 /// </summary> 1088 /// </summary>
@@ -1191,7 +1164,6 @@ namespace OpenSim.Region.Environment.Scenes
1191 m_appearance.SetWearable(ControllingClient, wearableId, wearable); 1164 m_appearance.SetWearable(ControllingClient, wearableId, wearable);
1192 } 1165 }
1193 1166
1194
1195 /// <summary> 1167 /// <summary>
1196 /// 1168 ///
1197 /// </summary> 1169 /// </summary>
@@ -1336,6 +1308,7 @@ namespace OpenSim.Region.Environment.Scenes
1336 respondPacket.AgentData = adb; 1308 respondPacket.AgentData = adb;
1337 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task); 1309 ControllingClient.OutPacket(respondPacket, ThrottleOutPacketType.Task);
1338 } 1310 }
1311
1339 /// <summary> 1312 /// <summary>
1340 /// This updates important decision making data about a child agent 1313 /// This updates important decision making data about a child agent
1341 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region 1314 /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region
@@ -1351,9 +1324,8 @@ namespace OpenSim.Region.Environment.Scenes
1351 //cAgentData.AVHeight; 1324 //cAgentData.AVHeight;
1352 //cAgentData.regionHandle; 1325 //cAgentData.regionHandle;
1353 //m_velocity = cAgentData.Velocity; 1326 //m_velocity = cAgentData.Velocity;
1354
1355
1356 } 1327 }
1328
1357 /// <summary> 1329 /// <summary>
1358 /// 1330 ///
1359 /// </summary> 1331 /// </summary>
@@ -1362,7 +1334,7 @@ namespace OpenSim.Region.Environment.Scenes
1362 } 1334 }
1363 1335
1364 /// <summary> 1336 /// <summary>
1365 /// handles part of the PID controller function for moving an avatar. 1337 /// Handles part of the PID controller function for moving an avatar.
1366 /// </summary> 1338 /// </summary>
1367 public override void UpdateMovement() 1339 public override void UpdateMovement()
1368 { 1340 {
@@ -1450,6 +1422,5 @@ namespace OpenSim.Region.Environment.Scenes
1450 { 1422 {
1451 RemoveFromPhysicalScene(); 1423 RemoveFromPhysicalScene();
1452 } 1424 }
1453
1454 } 1425 }
1455} 1426}