aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs116
1 files changed, 63 insertions, 53 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 1a38244..23e1035 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types; 35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities; 36using OpenSim.Framework.Utilities;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Environment.Regions;
38 39
39namespace OpenSim.Region.Environment.Scenes 40namespace OpenSim.Region.Environment.Scenes
40{ 41{
@@ -42,33 +43,34 @@ namespace OpenSim.Region.Environment.Scenes
42 { 43 {
43 public static AvatarAnimations Animations; 44 public static AvatarAnimations Animations;
44 public static byte[] DefaultTexture; 45 public static byte[] DefaultTexture;
45 public LLUUID current_anim; 46
46 public int anim_seq; 47 public LLUUID CurrentAnimation;
47 private bool updateflag = false; 48 public int AnimationSeq;
48 private byte movementflag = 0; 49
49 private List<NewForce> forcesList = new List<NewForce>(); 50 private bool m_updateflag = false;
50 private short _updateCount = 0; 51 private byte m_movementflag = 0;
52 private readonly List<NewForce> m_forcesList = new List<NewForce>();
53 private short m_updateCount = 0;
51 54
52 private Quaternion bodyRot; 55 private Quaternion bodyRot;
53 private byte[] visualParams; 56 private byte[] visualParams;
54 private AvatarWearable[] Wearables; 57 private AvatarWearable[] Wearables;
55 private LLObject.TextureEntry m_textureEntry; 58 private LLObject.TextureEntry m_textureEntry;
56 59
57 public bool childAgent = true;
58 public bool IsRestrictedToRegion = false; 60 public bool IsRestrictedToRegion = false;
59 61
60 private bool newForce = false; 62 private bool m_newForce = false;
61 private bool newAvatar = false; 63 private bool newAvatar = false;
62 private bool newCoarseLocations = true; 64 private bool newCoarseLocations = true;
63 65
64 protected RegionInfo m_regionInfo; 66 protected RegionInfo m_regionInfo;
65 protected ulong crossingFromRegion = 0; 67 protected ulong crossingFromRegion = 0;
66 68
67 private IScenePresenceBody m_body; 69 private readonly Vector3[] Dir_Vectors = new Vector3[6];
68
69 private Vector3[] Dir_Vectors = new Vector3[6];
70 private LLVector3 lastPhysPos = new LLVector3(); 70 private LLVector3 lastPhysPos = new LLVector3();
71 71
72 private RegionPresence m_regionPresence;
73
72 private enum Dir_ControlFlags 74 private enum Dir_ControlFlags
73 { 75 {
74 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, 76 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
@@ -93,8 +95,8 @@ namespace OpenSim.Region.Environment.Scenes
93 // private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>(); 95 // private Queue<SceneObjectGroup> m_fullGroupUpdates = new Queue<SceneObjectGroup>();
94 // private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>(); 96 // private Queue<SceneObjectGroup> m_terseGroupUpdates = new Queue<SceneObjectGroup>();
95 97
96 private Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>(); 98 private readonly Queue<SceneObjectPart> m_fullPartUpdates = new Queue<SceneObjectPart>();
97 private Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>(); 99 private readonly Queue<SceneObjectPart> m_tersePartUpdates = new Queue<SceneObjectPart>();
98 100
99 #region Properties 101 #region Properties
100 102
@@ -109,8 +111,8 @@ namespace OpenSim.Region.Environment.Scenes
109 111
110 public bool Updated 112 public bool Updated
111 { 113 {
112 set { updateflag = value; } 114 set { m_updateflag = value; }
113 get { return updateflag; } 115 get { return m_updateflag; }
114 } 116 }
115 117
116 private readonly ulong m_regionHandle; 118 private readonly ulong m_regionHandle;
@@ -134,7 +136,7 @@ namespace OpenSim.Region.Environment.Scenes
134 private readonly IClientAPI m_controllingClient; 136 private readonly IClientAPI m_controllingClient;
135 protected PhysicsActor m_physicsActor; 137 protected PhysicsActor m_physicsActor;
136 138
137 public IClientAPI _ControllingClient 139 public IClientAPI ControllingClient
138 { 140 {
139 get { return m_controllingClient; } 141 get { return m_controllingClient; }
140 } 142 }
@@ -207,6 +209,13 @@ namespace OpenSim.Region.Environment.Scenes
207 } 209 }
208 } 210 }
209 211
212 private bool m_isChildAgent = true;
213 public bool IsChildAgent
214 {
215 get { return m_isChildAgent; }
216 set { m_isChildAgent = value; }
217 }
218
210 #endregion 219 #endregion
211 220
212 #region Constructor(s) 221 #region Constructor(s)
@@ -220,6 +229,8 @@ namespace OpenSim.Region.Environment.Scenes
220 /// <param name="regionDat"></param> 229 /// <param name="regionDat"></param>
221 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) 230 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo)
222 { 231 {
232 m_regionPresence = new RegionPresence( client );
233
223 m_scene = world; 234 m_scene = world;
224 m_uuid = client.AgentId; 235 m_uuid = client.AgentId;
225 236
@@ -262,7 +273,6 @@ namespace OpenSim.Region.Environment.Scenes
262 m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length); 273 m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length);
263 274
264 //temporary until we move some code into the body classes 275 //temporary until we move some code into the body classes
265 m_body = new ChildAgent();
266 276
267 if (newAvatar) 277 if (newAvatar)
268 { 278 {
@@ -327,9 +337,9 @@ namespace OpenSim.Region.Environment.Scenes
327 /// <param name="status"></param> 337 /// <param name="status"></param>
328 public void ChildStatusChange(bool status) 338 public void ChildStatusChange(bool status)
329 { 339 {
330 childAgent = status; 340 m_isChildAgent = status;
331 341
332 if (childAgent == true) 342 if (m_isChildAgent == true)
333 { 343 {
334 Velocity = new LLVector3(0, 0, 0); 344 Velocity = new LLVector3(0, 0, 0);
335 AbsolutePosition = new LLVector3(128, 128, 70); 345 AbsolutePosition = new LLVector3(128, 128, 70);
@@ -339,7 +349,7 @@ namespace OpenSim.Region.Environment.Scenes
339 public void MakeAvatarPhysical(LLVector3 pos, bool isFlying) 349 public void MakeAvatarPhysical(LLVector3 pos, bool isFlying)
340 { 350 {
341 newAvatar = true; 351 newAvatar = true;
342 childAgent = false; 352 m_isChildAgent = false;
343 353
344 AbsolutePosition = pos; 354 AbsolutePosition = pos;
345 355
@@ -353,7 +363,7 @@ namespace OpenSim.Region.Environment.Scenes
353 protected void MakeChildAgent() 363 protected void MakeChildAgent()
354 { 364 {
355 Velocity = new LLVector3(0, 0, 0); 365 Velocity = new LLVector3(0, 0, 0);
356 childAgent = true; 366 m_isChildAgent = true;
357 367
358 RemoveFromPhysicalScene(); 368 RemoveFromPhysicalScene();
359 369
@@ -416,9 +426,9 @@ namespace OpenSim.Region.Environment.Scenes
416 look = new LLVector3(0.99f, 0.042f, 0); 426 look = new LLVector3(0.99f, 0.042f, 0);
417 } 427 }
418 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 428 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
419 if (childAgent) 429 if (m_isChildAgent)
420 { 430 {
421 childAgent = false; 431 m_isChildAgent = false;
422 432
423 //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); 433 //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient);
424 } 434 }
@@ -430,7 +440,7 @@ namespace OpenSim.Region.Environment.Scenes
430 /// <param name="pack"></param> 440 /// <param name="pack"></param>
431 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 441 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
432 { 442 {
433 if (childAgent) 443 if (m_isChildAgent)
434 { 444 {
435 Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); 445 Console.WriteLine("DEBUG: HandleAgentUpdate: child agent");
436 return; 446 return;
@@ -463,17 +473,17 @@ namespace OpenSim.Region.Environment.Scenes
463 { 473 {
464 DCFlagKeyPressed = true; 474 DCFlagKeyPressed = true;
465 agent_control_v3 += Dir_Vectors[i]; 475 agent_control_v3 += Dir_Vectors[i];
466 if ((movementflag & (uint) DCF) == 0) 476 if ((m_movementflag & (uint) DCF) == 0)
467 { 477 {
468 movementflag += (byte) (uint) DCF; 478 m_movementflag += (byte) (uint) DCF;
469 update_movementflag = true; 479 update_movementflag = true;
470 } 480 }
471 } 481 }
472 else 482 else
473 { 483 {
474 if ((movementflag & (uint) DCF) != 0) 484 if ((m_movementflag & (uint) DCF) != 0)
475 { 485 {
476 movementflag -= (byte) (uint) DCF; 486 m_movementflag -= (byte) (uint) DCF;
477 update_movementflag = true; 487 update_movementflag = true;
478 } 488 }
479 } 489 }
@@ -490,7 +500,7 @@ namespace OpenSim.Region.Environment.Scenes
490 { 500 {
491 if (update_movementflag) 501 if (update_movementflag)
492 { 502 {
493 if (movementflag != 0) 503 if (m_movementflag != 0)
494 { 504 {
495 if (m_physicsActor.Flying) 505 if (m_physicsActor.Flying)
496 { 506 {
@@ -511,7 +521,7 @@ namespace OpenSim.Region.Environment.Scenes
511 521
512 protected void AddNewMovement(Vector3 vec, Quaternion rotation) 522 protected void AddNewMovement(Vector3 vec, Quaternion rotation)
513 { 523 {
514 if (childAgent) 524 if (m_isChildAgent)
515 { 525 {
516 Console.WriteLine("DEBUG: AddNewMovement: child agent"); 526 Console.WriteLine("DEBUG: AddNewMovement: child agent");
517 return; 527 return;
@@ -527,7 +537,7 @@ namespace OpenSim.Region.Environment.Scenes
527 newVelocity.X = direc.x; 537 newVelocity.X = direc.x;
528 newVelocity.Y = direc.y; 538 newVelocity.Y = direc.y;
529 newVelocity.Z = direc.z; 539 newVelocity.Z = direc.z;
530 forcesList.Add(newVelocity); 540 m_forcesList.Add(newVelocity);
531 } 541 }
532 542
533 #endregion 543 #endregion
@@ -554,23 +564,23 @@ namespace OpenSim.Region.Environment.Scenes
554 newCoarseLocations = false; 564 newCoarseLocations = false;
555 } 565 }
556 566
557 if (childAgent == false) 567 if (m_isChildAgent == false)
558 { 568 {
559 /// check for user movement 'forces' (ie commands to move) 569 /// check for user movement 'forces' (ie commands to move)
560 if (newForce) 570 if (m_newForce)
561 { 571 {
562 SendTerseUpdateToAllClients(); 572 SendTerseUpdateToAllClients();
563 _updateCount = 0; 573 m_updateCount = 0;
564 } 574 }
565 575
566 /// check for scripted movement (?) 576 /// check for scripted movement (?)
567 else if (movementflag != 0) 577 else if (m_movementflag != 0)
568 { 578 {
569 _updateCount++; 579 m_updateCount++;
570 if (_updateCount > 3) 580 if (m_updateCount > 3)
571 { 581 {
572 SendTerseUpdateToAllClients(); 582 SendTerseUpdateToAllClients();
573 _updateCount = 0; 583 m_updateCount = 0;
574 } 584 }
575 } 585 }
576 586
@@ -578,7 +588,7 @@ namespace OpenSim.Region.Environment.Scenes
578 else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02) 588 else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02)
579 { 589 {
580 SendTerseUpdateToAllClients(); 590 SendTerseUpdateToAllClients();
581 _updateCount = 0; 591 m_updateCount = 0;
582 lastPhysPos = AbsolutePosition; 592 lastPhysPos = AbsolutePosition;
583 } 593 }
584 CheckForSignificantMovement(); 594 CheckForSignificantMovement();
@@ -669,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes
669 SendFullUpdateToOtherClient(avatar); 679 SendFullUpdateToOtherClient(avatar);
670 if (avatar.LocalId != LocalId) 680 if (avatar.LocalId != LocalId)
671 { 681 {
672 if (!avatar.childAgent) 682 if (!avatar.m_isChildAgent)
673 { 683 {
674 avatar.SendFullUpdateToOtherClient(this); 684 avatar.SendFullUpdateToOtherClient(this);
675 avatar.SendAppearanceToOtherAgent(this); 685 avatar.SendAppearanceToOtherAgent(this);
@@ -685,7 +695,7 @@ namespace OpenSim.Region.Environment.Scenes
685 { 695 {
686 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, 696 m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId,
687 AbsolutePosition, m_textureEntry.ToBytes()); 697 AbsolutePosition, m_textureEntry.ToBytes());
688 if (!childAgent) 698 if (!m_isChildAgent)
689 { 699 {
690 m_scene.InformClientOfNeighbours(m_controllingClient); 700 m_scene.InformClientOfNeighbours(m_controllingClient);
691 newAvatar = false; 701 newAvatar = false;
@@ -748,8 +758,8 @@ namespace OpenSim.Region.Environment.Scenes
748 /// <param name="seq"></param> 758 /// <param name="seq"></param>
749 public void SendAnimPack(LLUUID animID, int seq) 759 public void SendAnimPack(LLUUID animID, int seq)
750 { 760 {
751 current_anim = animID; 761 CurrentAnimation = animID;
752 anim_seq = seq; 762 AnimationSeq = seq;
753 763
754 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 764 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
755 { 765 {
@@ -763,7 +773,7 @@ namespace OpenSim.Region.Environment.Scenes
763 /// </summary> 773 /// </summary>
764 public void SendAnimPack() 774 public void SendAnimPack()
765 { 775 {
766 SendAnimPack(current_anim, anim_seq); 776 SendAnimPack(CurrentAnimation, AnimationSeq);
767 } 777 }
768 778
769 #endregion 779 #endregion
@@ -878,22 +888,22 @@ namespace OpenSim.Region.Environment.Scenes
878 /// </summary> 888 /// </summary>
879 public override void UpdateMovement() 889 public override void UpdateMovement()
880 { 890 {
881 newForce = false; 891 m_newForce = false;
882 lock (forcesList) 892 lock (m_forcesList)
883 { 893 {
884 if (forcesList.Count > 0) 894 if (m_forcesList.Count > 0)
885 { 895 {
886 for (int i = 0; i < forcesList.Count; i++) 896 for (int i = 0; i < m_forcesList.Count; i++)
887 { 897 {
888 NewForce force = forcesList[i]; 898 NewForce force = m_forcesList[i];
889 899
890 updateflag = true; 900 m_updateflag = true;
891 Velocity = new LLVector3(force.X, force.Y, force.Z); 901 Velocity = new LLVector3(force.X, force.Y, force.Z);
892 newForce = true; 902 m_newForce = true;
893 } 903 }
894 for (int i = 0; i < forcesList.Count; i++) 904 for (int i = 0; i < m_forcesList.Count; i++)
895 { 905 {
896 forcesList.RemoveAt(0); 906 m_forcesList.RemoveAt(0);
897 } 907 }
898 } 908 }
899 } 909 }