aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs521
1 files changed, 266 insertions, 255 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 35f5566..882f4d4 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -103,16 +103,15 @@ namespace OpenSim.Region.Framework.Scenes
103 103
104 public UUID currentParcelUUID = UUID.Zero; 104 public UUID currentParcelUUID = UUID.Zero;
105 105
106 private ISceneViewer m_sceneViewer; 106 protected ScenePresenceAnimator m_animator;
107
108 /// <value> 107 /// <value>
109 /// The animator for this avatar 108 /// The animator for this avatar
110 /// </value> 109 /// </value>
111 public ScenePresenceAnimator Animator 110 public ScenePresenceAnimator Animator
112 { 111 {
113 get { return m_animator; } 112 get { return m_animator; }
113 private set { m_animator = value; }
114 } 114 }
115 protected ScenePresenceAnimator m_animator;
116 115
117 /// <summary> 116 /// <summary>
118 /// Attachments recorded on this avatar. 117 /// Attachments recorded on this avatar.
@@ -144,8 +143,6 @@ namespace OpenSim.Region.Framework.Scenes
144 private Vector3 m_lastVelocity; 143 private Vector3 m_lastVelocity;
145 //private int m_lastTerseSent; 144 //private int m_lastTerseSent;
146 145
147 private bool m_updateflag;
148 private byte m_movementflag;
149 private Vector3? m_forceToApply; 146 private Vector3? m_forceToApply;
150 private int m_userFlags; 147 private int m_userFlags;
151 public int UserFlags 148 public int UserFlags
@@ -171,26 +168,14 @@ namespace OpenSim.Region.Framework.Scenes
171 168
172 private float m_sitAvatarHeight = 2.0f; 169 private float m_sitAvatarHeight = 2.0f;
173 170
174 private int m_godLevel;
175 private int m_userLevel;
176
177 private bool m_invulnerable = true;
178
179 private Vector3 m_lastChildAgentUpdatePosition; 171 private Vector3 m_lastChildAgentUpdatePosition;
180 private Vector3 m_lastChildAgentUpdateCamPosition; 172 private Vector3 m_lastChildAgentUpdateCamPosition;
181 173
182 private int m_perfMonMS; 174 private int m_perfMonMS;
183 175
184 private bool m_setAlwaysRun;
185 private bool m_forceFly;
186 private bool m_flyDisabled;
187 private bool m_flyingOld; // add for fly velocity control 176 private bool m_flyingOld; // add for fly velocity control
188 public bool m_wasFlying; // add for fly velocity control 177 public bool m_wasFlying; // add for fly velocity control
189 178
190 private float m_speedModifier = 1.0f;
191
192 private Quaternion m_bodyRot = Quaternion.Identity;
193
194 private const int LAND_VELOCITYMAG_MAX = 12; 179 private const int LAND_VELOCITYMAG_MAX = 12;
195 180
196 public bool IsRestrictedToRegion; 181 public bool IsRestrictedToRegion;
@@ -204,22 +189,12 @@ namespace OpenSim.Region.Framework.Scenes
204 private readonly Vector3[] Dir_Vectors = new Vector3[11]; 189 private readonly Vector3[] Dir_Vectors = new Vector3[11];
205 private bool m_isNudging = false; 190 private bool m_isNudging = false;
206 191
207 // Position of agent's camera in world (region cordinates)
208 protected Vector3 m_CameraCenter;
209 protected Vector3 m_lastCameraCenter;
210 192
211 protected Timer m_reprioritization_timer; 193 protected Timer m_reprioritization_timer;
212 protected bool m_reprioritizing; 194 protected bool m_reprioritizing;
213 protected bool m_reprioritization_called; 195 protected bool m_reprioritization_called;
214 196
215 // Use these three vectors to figure out what the agent is looking at
216 // Convert it to a Matrix and/or Quaternion
217 protected Vector3 m_CameraAtAxis;
218 protected Vector3 m_CameraLeftAxis;
219 protected Vector3 m_CameraUpAxis;
220 private AgentManager.ControlFlags m_AgentControlFlags;
221 private Quaternion m_headrotation = Quaternion.Identity; 197 private Quaternion m_headrotation = Quaternion.Identity;
222 private byte m_state;
223 198
224 //Reuse the Vector3 instead of creating a new one on the UpdateMovement method 199 //Reuse the Vector3 instead of creating a new one on the UpdateMovement method
225// private Vector3 movementvector; 200// private Vector3 movementvector;
@@ -256,11 +231,19 @@ namespace OpenSim.Region.Framework.Scenes
256 //private int m_moveToPositionStateStatus; 231 //private int m_moveToPositionStateStatus;
257 //***************************************************** 232 //*****************************************************
258 233
259 // Agent's Draw distance.
260 protected float m_DrawDistance;
261
262 protected AvatarAppearance m_appearance; 234 protected AvatarAppearance m_appearance;
263 235
236 public AvatarAppearance Appearance
237 {
238 get { return m_appearance; }
239 set
240 {
241 m_appearance = value;
242// m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value);
243 }
244 }
245
246
264 // neighbouring regions we have enabled a child agent in 247 // neighbouring regions we have enabled a child agent in
265 // holds the seed cap for the child agent in that region 248 // holds the seed cap for the child agent in that region
266 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 249 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -272,6 +255,7 @@ namespace OpenSim.Region.Framework.Scenes
272 public List<string> InTransitScriptStates 255 public List<string> InTransitScriptStates
273 { 256 {
274 get { return m_InTransitScriptStates; } 257 get { return m_InTransitScriptStates; }
258 private set { m_InTransitScriptStates = value; }
275 } 259 }
276 private List<string> m_InTransitScriptStates = new List<string>(); 260 private List<string> m_InTransitScriptStates = new List<string>();
277 261
@@ -302,8 +286,6 @@ namespace OpenSim.Region.Framework.Scenes
302 string m_callbackURI; 286 string m_callbackURI;
303 UUID m_originRegionID; 287 UUID m_originRegionID;
304 288
305 ulong m_rootRegionHandle;
306
307 /// <value> 289 /// <value>
308 /// Script engines present in the scene 290 /// Script engines present in the scene
309 /// </value> 291 /// </value>
@@ -311,6 +293,8 @@ namespace OpenSim.Region.Framework.Scenes
311 293
312 #region Properties 294 #region Properties
313 295
296 protected PhysicsActor m_physicsActor;
297
314 /// <summary> 298 /// <summary>
315 /// Physical scene representation of this Avatar. 299 /// Physical scene representation of this Avatar.
316 /// </summary> 300 /// </summary>
@@ -320,69 +304,102 @@ namespace OpenSim.Region.Framework.Scenes
320 get { return m_physicsActor; } 304 get { return m_physicsActor; }
321 } 305 }
322 306
307 private byte m_movementflag;
308
323 public byte MovementFlag 309 public byte MovementFlag
324 { 310 {
325 set { m_movementflag = value; } 311 set { m_movementflag = value; }
326 get { return m_movementflag; } 312 get { return m_movementflag; }
327 } 313 }
328 314
315 private bool m_updateflag;
316
329 public bool Updated 317 public bool Updated
330 { 318 {
331 set { m_updateflag = value; } 319 set { m_updateflag = value; }
332 get { return m_updateflag; } 320 get { return m_updateflag; }
333 } 321 }
334 322
323 private bool m_invulnerable = true;
324
335 public bool Invulnerable 325 public bool Invulnerable
336 { 326 {
337 set { m_invulnerable = value; } 327 set { m_invulnerable = value; }
338 get { return m_invulnerable; } 328 get { return m_invulnerable; }
339 } 329 }
340 330
331 private int m_userLevel;
332
341 public int UserLevel 333 public int UserLevel
342 { 334 {
343 get { return m_userLevel; } 335 get { return m_userLevel; }
336 private set { m_userLevel = value; }
344 } 337 }
345 338
339 private int m_godLevel;
340
346 public int GodLevel 341 public int GodLevel
347 { 342 {
348 get { return m_godLevel; } 343 get { return m_godLevel; }
344 private set { m_godLevel = value; }
349 } 345 }
350 346
347 private ulong m_rootRegionHandle;
348
351 public ulong RegionHandle 349 public ulong RegionHandle
352 { 350 {
353 get { return m_rootRegionHandle; } 351 get { return m_rootRegionHandle; }
352 private set { m_rootRegionHandle = value; }
354 } 353 }
355 354
355 #region Client Camera
356 // Position of agent's camera in world (region cordinates)
357 protected Vector3 m_lastCameraPosition;
358
359 protected Vector3 m_CameraPosition;
360
356 public Vector3 CameraPosition 361 public Vector3 CameraPosition
357 { 362 {
358 get { return m_CameraCenter; } 363 get { return m_CameraPosition; }
364 private set { m_CameraPosition = value; }
359 } 365 }
360 366
361 public Quaternion CameraRotation 367 public Quaternion CameraRotation
362 { 368 {
363 get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } 369 get { return Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); }
364 } 370 }
365 371
372 // Use these three vectors to figure out what the agent is looking at
373 // Convert it to a Matrix and/or Quaternion
374 //
375 protected Vector3 m_CameraAtAxis;
376 protected Vector3 m_CameraLeftAxis;
377 protected Vector3 m_CameraUpAxis;
378
366 public Vector3 CameraAtAxis 379 public Vector3 CameraAtAxis
367 { 380 {
368 get { return m_CameraAtAxis; } 381 get { return m_CameraAtAxis; }
382 private set { m_CameraAtAxis = value; }
369 } 383 }
370 384
385
371 public Vector3 CameraLeftAxis 386 public Vector3 CameraLeftAxis
372 { 387 {
373 get { return m_CameraLeftAxis; } 388 get { return m_CameraLeftAxis; }
389 private set { m_CameraLeftAxis = value; }
374 } 390 }
375 391
376 public Vector3 CameraUpAxis 392 public Vector3 CameraUpAxis
377 { 393 {
378 get { return m_CameraUpAxis; } 394 get { return m_CameraUpAxis; }
395 private set { m_CameraUpAxis = value; }
379 } 396 }
380 397
381 public Vector3 Lookat 398 public Vector3 Lookat
382 { 399 {
383 get 400 get
384 { 401 {
385 Vector3 a = new Vector3(m_CameraAtAxis.X, m_CameraAtAxis.Y, 0); 402 Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0);
386 403
387 if (a == Vector3.Zero) 404 if (a == Vector3.Zero)
388 return a; 405 return a;
@@ -390,20 +407,10 @@ namespace OpenSim.Region.Framework.Scenes
390 return Util.GetNormalizedVector(a); 407 return Util.GetNormalizedVector(a);
391 } 408 }
392 } 409 }
410 #endregion
393 411
394 private readonly string m_firstname; 412 public readonly string Firstname;
395 413 public readonly string Lastname;
396 public string Firstname
397 {
398 get { return m_firstname; }
399 }
400
401 private readonly string m_lastname;
402
403 public string Lastname
404 {
405 get { return m_lastname; }
406 }
407 414
408 private string m_grouptitle; 415 private string m_grouptitle;
409 416
@@ -413,9 +420,13 @@ namespace OpenSim.Region.Framework.Scenes
413 set { m_grouptitle = value; } 420 set { m_grouptitle = value; }
414 } 421 }
415 422
423 // Agent's Draw distance.
424 protected float m_DrawDistance;
425
416 public float DrawDistance 426 public float DrawDistance
417 { 427 {
418 get { return m_DrawDistance; } 428 get { return m_DrawDistance; }
429 private set { m_DrawDistance = value; }
419 } 430 }
420 431
421 protected bool m_allowMovement = true; 432 protected bool m_allowMovement = true;
@@ -426,6 +437,8 @@ namespace OpenSim.Region.Framework.Scenes
426 set { m_allowMovement = value; } 437 set { m_allowMovement = value; }
427 } 438 }
428 439
440 private bool m_setAlwaysRun;
441
429 public bool SetAlwaysRun 442 public bool SetAlwaysRun
430 { 443 {
431 get 444 get
@@ -449,12 +462,16 @@ namespace OpenSim.Region.Framework.Scenes
449 } 462 }
450 } 463 }
451 464
465 private byte m_state;
466
452 public byte State 467 public byte State
453 { 468 {
454 get { return m_state; } 469 get { return m_state; }
455 set { m_state = value; } 470 set { m_state = value; }
456 } 471 }
457 472
473 private AgentManager.ControlFlags m_AgentControlFlags;
474
458 public uint AgentControlFlags 475 public uint AgentControlFlags
459 { 476 {
460 get { return (uint)m_AgentControlFlags; } 477 get { return (uint)m_AgentControlFlags; }
@@ -466,11 +483,10 @@ namespace OpenSim.Region.Framework.Scenes
466 /// </summary> 483 /// </summary>
467 private IClientAPI m_controllingClient; 484 private IClientAPI m_controllingClient;
468 485
469 protected PhysicsActor m_physicsActor;
470
471 public IClientAPI ControllingClient 486 public IClientAPI ControllingClient
472 { 487 {
473 get { return m_controllingClient; } 488 get { return m_controllingClient; }
489 private set { m_controllingClient = value; }
474 } 490 }
475 491
476 public IClientCore ClientView 492 public IClientCore ClientView
@@ -479,6 +495,7 @@ namespace OpenSim.Region.Framework.Scenes
479 } 495 }
480 496
481 protected Vector3 m_parentPosition; 497 protected Vector3 m_parentPosition;
498
482 public Vector3 ParentPosition 499 public Vector3 ParentPosition
483 { 500 {
484 get { return m_parentPosition; } 501 get { return m_parentPosition; }
@@ -509,7 +526,7 @@ namespace OpenSim.Region.Framework.Scenes
509 // the avatar is seated, this value will also 526 // the avatar is seated, this value will also
510 // be used as the location to unsit to. 527 // be used as the location to unsit to.
511 // 528 //
512 // If m_parentID is not 0, assume we are a seated avatar 529 // If ParentID is not 0, assume we are a seated avatar
513 // and we should return the position based on the sittarget 530 // and we should return the position based on the sittarget
514 // offset and rotation of the prim we are seated on. 531 // offset and rotation of the prim we are seated on.
515 // 532 //
@@ -517,16 +534,16 @@ namespace OpenSim.Region.Framework.Scenes
517 // in the sim unless the avatar is on a sit target. While 534 // in the sim unless the avatar is on a sit target. While
518 // on a sit target, m_pos will contain the desired offset 535 // on a sit target, m_pos will contain the desired offset
519 // without the parent rotation applied. 536 // without the parent rotation applied.
520 if (m_parentID != 0) 537 if (ParentID != 0)
521 { 538 {
522 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); 539 SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID);
523 if (part != null) 540 if (part != null)
524 { 541 {
525 return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); 542 return part.AbsolutePosition + (m_pos * part.GetWorldRotation());
526 } 543 }
527 else 544 else
528 { 545 {
529 return m_parentPosition + m_pos; 546 return ParentPosition + m_pos;
530 } 547 }
531 } 548 }
532 } 549 }
@@ -535,13 +552,12 @@ namespace OpenSim.Region.Framework.Scenes
535 } 552 }
536 set 553 set
537 { 554 {
538 PhysicsActor actor = m_physicsActor; 555 if (PhysicsActor != null)
539 if (actor != null)
540 { 556 {
541 try 557 try
542 { 558 {
543 lock (m_scene.SyncRoot) 559 lock (m_scene.SyncRoot)
544 m_physicsActor.Position = value; 560 PhysicsActor.Position = value;
545 } 561 }
546 catch (Exception e) 562 catch (Exception e)
547 { 563 {
@@ -576,10 +592,9 @@ namespace OpenSim.Region.Framework.Scenes
576 { 592 {
577 get 593 get
578 { 594 {
579 PhysicsActor actor = m_physicsActor; 595 if (PhysicsActor != null)
580 if (actor != null)
581 { 596 {
582 m_velocity = actor.Velocity; 597 m_velocity = PhysicsActor.Velocity;
583 598
584// m_log.DebugFormat( 599// m_log.DebugFormat(
585// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", 600// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
@@ -590,13 +605,12 @@ namespace OpenSim.Region.Framework.Scenes
590 } 605 }
591 set 606 set
592 { 607 {
593 PhysicsActor actor = m_physicsActor; 608 if (PhysicsActor != null)
594 if (actor != null)
595 { 609 {
596 try 610 try
597 { 611 {
598 lock (m_scene.SyncRoot) 612 lock (m_scene.SyncRoot)
599 actor.Velocity = value; 613 PhysicsActor.Velocity = value;
600 } 614 }
601 catch (Exception e) 615 catch (Exception e)
602 { 616 {
@@ -617,6 +631,7 @@ namespace OpenSim.Region.Framework.Scenes
617 get { return m_offsetRotation; } 631 get { return m_offsetRotation; }
618 set { m_offsetRotation = value; } 632 set { m_offsetRotation = value; }
619 } 633 }
634 private Quaternion m_bodyRot = Quaternion.Identity;
620 635
621 public Quaternion Rotation 636 public Quaternion Rotation
622 { 637 {
@@ -707,9 +722,12 @@ namespace OpenSim.Region.Framework.Scenes
707 } 722 }
708 } 723 }
709 724
725 private ISceneViewer m_sceneViewer;
726
710 public ISceneViewer SceneViewer 727 public ISceneViewer SceneViewer
711 { 728 {
712 get { return m_sceneViewer; } 729 get { return m_sceneViewer; }
730 private set { m_sceneViewer = value; }
713 } 731 }
714 732
715 public void AdjustKnownSeeds() 733 public void AdjustKnownSeeds()
@@ -756,28 +774,35 @@ namespace OpenSim.Region.Framework.Scenes
756 } 774 }
757 } 775 }
758 776
759 private bool m_inTransit;
760 private bool m_mouseLook; 777 private bool m_mouseLook;
761 private bool m_leftButtonDown; 778 private bool m_leftButtonDown;
762 779
780 private bool m_inTransit;
781
763 public bool IsInTransit 782 public bool IsInTransit
764 { 783 {
765 get { return m_inTransit; } 784 get { return m_inTransit; }
766 set { m_inTransit = value; } 785 private set { m_inTransit = value; }
767 } 786 }
768 787
788 private float m_speedModifier = 1.0f;
789
769 public float SpeedModifier 790 public float SpeedModifier
770 { 791 {
771 get { return m_speedModifier; } 792 get { return m_speedModifier; }
772 set { m_speedModifier = value; } 793 set { m_speedModifier = value; }
773 } 794 }
774 795
796 private bool m_forceFly;
797
775 public bool ForceFly 798 public bool ForceFly
776 { 799 {
777 get { return m_forceFly; } 800 get { return m_forceFly; }
778 set { m_forceFly = value; } 801 set { m_forceFly = value; }
779 } 802 }
780 803
804 private bool m_flyDisabled;
805
781 public bool FlyDisabled 806 public bool FlyDisabled
782 { 807 {
783 get { return m_flyDisabled; } 808 get { return m_flyDisabled; }
@@ -799,15 +824,15 @@ namespace OpenSim.Region.Framework.Scenes
799 AttachmentsSyncLock = new Object(); 824 AttachmentsSyncLock = new Object();
800 825
801 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 826 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
802 m_sceneViewer = new SceneViewer(this); 827 SceneViewer = new SceneViewer(this);
803 m_animator = new ScenePresenceAnimator(this); 828 Animator = new ScenePresenceAnimator(this);
804 PresenceType = type; 829 PresenceType = type;
805 m_DrawDistance = world.DefaultDrawDistance; 830 DrawDistance = world.DefaultDrawDistance;
806 m_rootRegionHandle = world.RegionInfo.RegionHandle; 831 RegionHandle = world.RegionInfo.RegionHandle;
807 m_controllingClient = client; 832 ControllingClient = client;
808 m_firstname = m_controllingClient.FirstName; 833 Firstname = ControllingClient.FirstName;
809 m_lastname = m_controllingClient.LastName; 834 Lastname = ControllingClient.LastName;
810 m_name = String.Format("{0} {1}", m_firstname, m_lastname); 835 m_name = String.Format("{0} {1}", Firstname, Lastname);
811 m_scene = world; 836 m_scene = world;
812 m_uuid = client.AgentId; 837 m_uuid = client.AgentId;
813 m_localId = m_scene.AllocateLocalId(); 838 m_localId = m_scene.AllocateLocalId();
@@ -816,16 +841,16 @@ namespace OpenSim.Region.Framework.Scenes
816 m_userFlags = account.UserFlags; 841 m_userFlags = account.UserFlags;
817 842
818 if (account != null) 843 if (account != null)
819 m_userLevel = account.UserLevel; 844 UserLevel = account.UserLevel;
820 845
821 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 846 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
822 if (gm != null) 847 if (gm != null)
823 m_grouptitle = gm.GetGroupTitle(m_uuid); 848 Grouptitle = gm.GetGroupTitle(m_uuid);
824 849
825 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); 850 m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>();
826 851
827 AbsolutePosition = posLastSignificantMove = m_CameraCenter = 852 AbsolutePosition = posLastSignificantMove = CameraPosition =
828 m_lastCameraCenter = m_controllingClient.StartPos; 853 m_lastCameraPosition = ControllingClient.StartPos;
829 854
830 m_reprioritization_timer = new Timer(world.ReprioritizationInterval); 855 m_reprioritization_timer = new Timer(world.ReprioritizationInterval);
831 m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); 856 m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize);
@@ -845,21 +870,21 @@ namespace OpenSim.Region.Framework.Scenes
845 RegisterToEvents(); 870 RegisterToEvents();
846 SetDirectionVectors(); 871 SetDirectionVectors();
847 872
848 m_appearance = appearance; 873 Appearance = appearance;
849 } 874 }
850 875
851 public void RegisterToEvents() 876 public void RegisterToEvents()
852 { 877 {
853 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 878 ControllingClient.OnCompleteMovementToRegion += CompleteMovement;
854 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; 879 //ControllingClient.OnCompleteMovementToRegion += SendInitialData;
855 m_controllingClient.OnAgentUpdate += HandleAgentUpdate; 880 ControllingClient.OnAgentUpdate += HandleAgentUpdate;
856 m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; 881 ControllingClient.OnAgentRequestSit += HandleAgentRequestSit;
857 m_controllingClient.OnAgentSit += HandleAgentSit; 882 ControllingClient.OnAgentSit += HandleAgentSit;
858 m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; 883 ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun;
859 m_controllingClient.OnStartAnim += HandleStartAnim; 884 ControllingClient.OnStartAnim += HandleStartAnim;
860 m_controllingClient.OnStopAnim += HandleStopAnim; 885 ControllingClient.OnStopAnim += HandleStopAnim;
861 m_controllingClient.OnForceReleaseControls += HandleForceReleaseControls; 886 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
862 m_controllingClient.OnAutoPilotGo += MoveToTarget; 887 ControllingClient.OnAutoPilotGo += MoveToTarget;
863 888
864 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 889 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
865 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 890 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -930,6 +955,10 @@ namespace OpenSim.Region.Framework.Scenes
930 public void SendPrimUpdates() 955 public void SendPrimUpdates()
931 { 956 {
932 m_sceneViewer.SendPrimUpdates(); 957 m_sceneViewer.SendPrimUpdates();
958 m_perfMonMS = Util.EnvironmentTickCount();
959
960 SceneViewer.SendPrimUpdates();
961
933 } 962 }
934 963
935 #region Status Methods 964 #region Status Methods
@@ -947,21 +976,21 @@ namespace OpenSim.Region.Framework.Scenes
947 976
948 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 977 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
949 978
950 bool wasChild = m_isChildAgent; 979 bool wasChild = IsChildAgent;
951 m_isChildAgent = false; 980 IsChildAgent = false;
952 981
953 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 982 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
954 if (gm != null) 983 if (gm != null)
955 m_grouptitle = gm.GetGroupTitle(m_uuid); 984 Grouptitle = gm.GetGroupTitle(m_uuid);
956 985
957 m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; 986 RegionHandle = m_scene.RegionInfo.RegionHandle;
958 987
959 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 988 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
960 989
961 // Moved this from SendInitialData to ensure that m_appearance is initialized 990 // Moved this from SendInitialData to ensure that Appearance is initialized
962 // before the inventory is processed in MakeRootAgent. This fixes a race condition 991 // before the inventory is processed in MakeRootAgent. This fixes a race condition
963 // related to the handling of attachments 992 // related to the handling of attachments
964 //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 993 //m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
965 if (m_scene.TestBorderCross(pos, Cardinals.E)) 994 if (m_scene.TestBorderCross(pos, Cardinals.E))
966 { 995 {
967 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 996 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
@@ -1042,8 +1071,8 @@ namespace OpenSim.Region.Framework.Scenes
1042 } 1071 }
1043 1072
1044 float localAVHeight = 1.56f; 1073 float localAVHeight = 1.56f;
1045 if (m_appearance.AvatarHeight > 0) 1074 if (Appearance.AvatarHeight > 0)
1046 localAVHeight = m_appearance.AvatarHeight; 1075 localAVHeight = Appearance.AvatarHeight;
1047 1076
1048 float posZLimit = 0; 1077 float posZLimit = 0;
1049 1078
@@ -1059,13 +1088,13 @@ namespace OpenSim.Region.Framework.Scenes
1059 1088
1060 AddToPhysicalScene(isFlying); 1089 AddToPhysicalScene(isFlying);
1061 1090
1062 if (m_forceFly) 1091 if (ForceFly)
1063 { 1092 {
1064 m_physicsActor.Flying = true; 1093 PhysicsActor.Flying = true;
1065 } 1094 }
1066 else if (m_flyDisabled) 1095 else if (FlyDisabled)
1067 { 1096 {
1068 m_physicsActor.Flying = false; 1097 PhysicsActor.Flying = false;
1069 } 1098 }
1070 1099
1071 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 1100 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
@@ -1103,7 +1132,7 @@ namespace OpenSim.Region.Framework.Scenes
1103 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1132 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
1104 // stall on the border crossing since the existing child agent will still have the last movement 1133 // stall on the border crossing since the existing child agent will still have the last movement
1105 // recorded, which stops the input from being processed. 1134 // recorded, which stops the input from being processed.
1106 m_movementflag = 0; 1135 MovementFlag = 0;
1107 1136
1108 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1137 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1109 } 1138 }
@@ -1133,12 +1162,12 @@ namespace OpenSim.Region.Framework.Scenes
1133 { 1162 {
1134 // Reset these so that teleporting in and walking out isn't seen 1163 // Reset these so that teleporting in and walking out isn't seen
1135 // as teleporting back 1164 // as teleporting back
1136 m_teleportFlags = TeleportFlags.Default; 1165 TeleportFlags = TeleportFlags.Default;
1137 1166
1138 // It looks like m_animator is set to null somewhere, and MakeChild 1167 // It looks like Animator is set to null somewhere, and MakeChild
1139 // is called after that. Probably in aborted teleports. 1168 // is called after that. Probably in aborted teleports.
1140 if (m_animator == null) 1169 if (Animator == null)
1141 m_animator = new ScenePresenceAnimator(this); 1170 Animator = new ScenePresenceAnimator(this);
1142 else 1171 else
1143 Animator.ResetAnimations(); 1172 Animator.ResetAnimations();
1144 1173
@@ -1150,11 +1179,11 @@ namespace OpenSim.Region.Framework.Scenes
1150 // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated. 1179 // depending on the exact timing. This shouldn't matter anyway since child agent positions are not updated.
1151 //Velocity = new Vector3(0, 0, 0); 1180 //Velocity = new Vector3(0, 0, 0);
1152 1181
1153 m_isChildAgent = true; 1182 IsChildAgent = true;
1154 m_scene.SwapRootAgentCount(true); 1183 m_scene.SwapRootAgentCount(true);
1155 RemoveFromPhysicalScene(); 1184 RemoveFromPhysicalScene();
1156 1185
1157 // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into 1186 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
1158 1187
1159 m_scene.EventManager.TriggerOnMakeChildAgent(this); 1188 m_scene.EventManager.TriggerOnMakeChildAgent(this);
1160 } 1189 }
@@ -1187,10 +1216,9 @@ namespace OpenSim.Region.Framework.Scenes
1187 public void Teleport(Vector3 pos) 1216 public void Teleport(Vector3 pos)
1188 { 1217 {
1189 bool isFlying = false; 1218 bool isFlying = false;
1219 if (PhysicsActor != null)
1220 isFlying = PhysicsActor.Flying;
1190 1221
1191 if (m_physicsActor != null)
1192 isFlying = m_physicsActor.Flying;
1193
1194 RemoveFromPhysicalScene(); 1222 RemoveFromPhysicalScene();
1195 Velocity = Vector3.Zero; 1223 Velocity = Vector3.Zero;
1196 CheckLandingPoint(ref pos); 1224 CheckLandingPoint(ref pos);
@@ -1204,8 +1232,8 @@ namespace OpenSim.Region.Framework.Scenes
1204 public void TeleportWithMomentum(Vector3 pos) 1232 public void TeleportWithMomentum(Vector3 pos)
1205 { 1233 {
1206 bool isFlying = false; 1234 bool isFlying = false;
1207 if (m_physicsActor != null) 1235 if (PhysicsActor != null)
1208 isFlying = m_physicsActor.Flying; 1236 isFlying = PhysicsActor.Flying;
1209 1237
1210 RemoveFromPhysicalScene(); 1238 RemoveFromPhysicalScene();
1211 CheckLandingPoint(ref pos); 1239 CheckLandingPoint(ref pos);
@@ -1321,11 +1349,11 @@ namespace OpenSim.Region.Framework.Scenes
1321 1349
1322 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1350 //m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1323 1351
1324 m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1352 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1325 SendInitialData(); 1353 SendInitialData();
1326 1354
1327 // Create child agents in neighbouring regions 1355 // Create child agents in neighbouring regions
1328 if (openChildAgents && !m_isChildAgent) 1356 if (openChildAgents && !IsChildAgent)
1329 { 1357 {
1330 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1358 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1331 if (m_agentTransfer != null) 1359 if (m_agentTransfer != null)
@@ -1369,7 +1397,7 @@ namespace OpenSim.Region.Framework.Scenes
1369 { 1397 {
1370 if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1398 if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1371 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 1399 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
1372 !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1400 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
1373 { 1401 {
1374 if (CameraConstraintActive) 1402 if (CameraConstraintActive)
1375 { 1403 {
@@ -1391,7 +1419,7 @@ namespace OpenSim.Region.Framework.Scenes
1391 { 1419 {
1392 // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); 1420 // m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name);
1393 1421
1394 //if (m_isChildAgent) 1422 //if (IsChildAgent)
1395 //{ 1423 //{
1396 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); 1424 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
1397 // return; 1425 // return;
@@ -1435,28 +1463,28 @@ namespace OpenSim.Region.Framework.Scenes
1435 1463
1436 // Camera location in world. We'll need to raytrace 1464 // Camera location in world. We'll need to raytrace
1437 // from this location from time to time. 1465 // from this location from time to time.
1438 m_CameraCenter = agentData.CameraCenter; 1466 CameraPosition = agentData.CameraCenter;
1439 if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance) 1467 if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance)
1440 { 1468 {
1441 ReprioritizeUpdates(); 1469 ReprioritizeUpdates();
1442 m_lastCameraCenter = m_CameraCenter; 1470 m_lastCameraPosition = CameraPosition;
1443 } 1471 }
1444 1472
1445 // Use these three vectors to figure out what the agent is looking at 1473 // Use these three vectors to figure out what the agent is looking at
1446 // Convert it to a Matrix and/or Quaternion 1474 // Convert it to a Matrix and/or Quaternion
1447 m_CameraAtAxis = agentData.CameraAtAxis; 1475 CameraAtAxis = agentData.CameraAtAxis;
1448 m_CameraLeftAxis = agentData.CameraLeftAxis; 1476 CameraLeftAxis = agentData.CameraLeftAxis;
1449 m_CameraUpAxis = agentData.CameraUpAxis; 1477 m_CameraUpAxis = agentData.CameraUpAxis;
1450 1478
1451 // The Agent's Draw distance setting 1479 // The Agent's Draw distance setting
1452 // When we get to the point of re-computing neighbors everytime this 1480 // When we get to the point of re-computing neighbors everytime this
1453 // changes, then start using the agent's drawdistance rather than the 1481 // changes, then start using the agent's drawdistance rather than the
1454 // region's draw distance. 1482 // region's draw distance.
1455 // m_DrawDistance = agentData.Far; 1483 // DrawDistance = agentData.Far;
1456 m_DrawDistance = Scene.DefaultDrawDistance; 1484 DrawDistance = Scene.DefaultDrawDistance;
1457 1485
1458 // Check if Client has camera in 'follow cam' or 'build' mode. 1486 // Check if Client has camera in 'follow cam' or 'build' mode.
1459 Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); 1487 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1460 1488
1461 m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) 1489 m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
1462 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; 1490 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
@@ -1478,7 +1506,7 @@ namespace OpenSim.Region.Framework.Scenes
1478 if (m_followCamAuto) 1506 if (m_followCamAuto)
1479 { 1507 {
1480 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1508 Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
1481 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); 1509 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback);
1482 } 1510 }
1483 } 1511 }
1484 1512
@@ -1507,7 +1535,7 @@ namespace OpenSim.Region.Framework.Scenes
1507 // Here's where you get them. 1535 // Here's where you get them.
1508 m_AgentControlFlags = flags; 1536 m_AgentControlFlags = flags;
1509 m_headrotation = agentData.HeadRotation; 1537 m_headrotation = agentData.HeadRotation;
1510 m_state = agentData.State; 1538 State = agentData.State;
1511 1539
1512 PhysicsActor actor = PhysicsActor; 1540 PhysicsActor actor = PhysicsActor;
1513 if (actor == null) 1541 if (actor == null)
@@ -1515,12 +1543,12 @@ namespace OpenSim.Region.Framework.Scenes
1515 return; 1543 return;
1516 } 1544 }
1517 1545
1518 if (m_allowMovement && !SitGround) 1546 if (AllowMovement && !SitGround)
1519 { 1547 {
1520 Quaternion bodyRotation = agentData.BodyRotation; 1548 Quaternion bodyRotation = agentData.BodyRotation;
1521 bool update_rotation = false; 1549 bool update_rotation = false;
1522 1550
1523 if (bodyRotation != m_bodyRot) 1551 if (bodyRotation != Rotation)
1524 { 1552 {
1525 Rotation = bodyRotation; 1553 Rotation = bodyRotation;
1526 update_rotation = true; 1554 update_rotation = true;
@@ -1540,9 +1568,9 @@ namespace OpenSim.Region.Framework.Scenes
1540 1568
1541 bool oldflying = PhysicsActor.Flying; 1569 bool oldflying = PhysicsActor.Flying;
1542 1570
1543 if (m_forceFly) 1571 if (ForceFly)
1544 actor.Flying = true; 1572 actor.Flying = true;
1545 else if (m_flyDisabled) 1573 else if (FlyDisabled)
1546 actor.Flying = false; 1574 actor.Flying = false;
1547 else 1575 else
1548 actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1576 actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
@@ -1550,7 +1578,7 @@ namespace OpenSim.Region.Framework.Scenes
1550 if (actor.Flying != oldflying) 1578 if (actor.Flying != oldflying)
1551 update_movementflag = true; 1579 update_movementflag = true;
1552 1580
1553 if (m_parentID == 0) 1581 if (ParentID == 0)
1554 { 1582 {
1555 bool bAllowUpdateMoveToPosition = false; 1583 bool bAllowUpdateMoveToPosition = false;
1556 1584
@@ -1558,12 +1586,12 @@ namespace OpenSim.Region.Framework.Scenes
1558 1586
1559 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying 1587 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
1560 // this prevents 'jumping' in inappropriate situations. 1588 // this prevents 'jumping' in inappropriate situations.
1561 if ((m_mouseLook && !m_physicsActor.Flying) || (m_leftButtonDown && !m_physicsActor.Flying)) 1589 if ((m_mouseLook && !PhysicsActor.Flying) || (m_leftButtonDown && !PhysicsActor.Flying))
1562 dirVectors = GetWalkDirectionVectors(); 1590 dirVectors = GetWalkDirectionVectors();
1563 else 1591 else
1564 dirVectors = Dir_Vectors; 1592 dirVectors = Dir_Vectors;
1565 1593
1566 // The fact that m_movementflag is a byte needs to be fixed 1594 // The fact that MovementFlag is a byte needs to be fixed
1567 // it really should be a uint 1595 // it really should be a uint
1568 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 1596 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
1569 uint nudgehack = 250; 1597 uint nudgehack = 250;
@@ -1583,15 +1611,15 @@ namespace OpenSim.Region.Framework.Scenes
1583 // Why did I get this? 1611 // Why did I get this?
1584 } 1612 }
1585 1613
1586 if ((m_movementflag & (byte)(uint)DCF) == 0) 1614 if ((MovementFlag & (byte)(uint)DCF) == 0)
1587 { 1615 {
1588 if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE) 1616 if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACK_NUDGE)
1589 { 1617 {
1590 m_movementflag |= (byte)nudgehack; 1618 MovementFlag |= (byte)nudgehack;
1591 } 1619 }
1592 1620
1593 // m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); 1621// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1594 m_movementflag += (byte)(uint)DCF; 1622 MovementFlag += (byte)(uint)DCF;
1595 update_movementflag = true; 1623 update_movementflag = true;
1596 } 1624 }
1597 } 1625 }
@@ -1608,7 +1636,7 @@ namespace OpenSim.Region.Framework.Scenes
1608 1636
1609 /* 1637 /*
1610 if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) 1638 if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
1611 && ((m_movementflag & (byte)nudgehack) == nudgehack)) 1639 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1612 { 1640 {
1613 m_log.Debug("Removed Hack flag"); 1641 m_log.Debug("Removed Hack flag");
1614 } 1642 }
@@ -1643,7 +1671,7 @@ namespace OpenSim.Region.Framework.Scenes
1643 // with something with the down arrow pressed. 1671 // with something with the down arrow pressed.
1644 1672
1645 // Only do this if we're flying 1673 // Only do this if we're flying
1646 if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) 1674 if (PhysicsActor != null && PhysicsActor.Flying && !ForceFly)
1647 { 1675 {
1648 // Landing detection code 1676 // Landing detection code
1649 1677
@@ -1651,10 +1679,7 @@ namespace OpenSim.Region.Framework.Scenes
1651 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1679 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1652 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1680 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1653 1681
1654 // Are the collision requirements fulfilled? 1682 if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland)
1655 bool colliding = (m_physicsActor.IsColliding == true);
1656
1657 if (m_physicsActor.Flying && colliding && controlland)
1658 { 1683 {
1659 // nesting this check because LengthSquared() is expensive and we don't 1684 // nesting this check because LengthSquared() is expensive and we don't
1660 // want to do it every step when flying. 1685 // want to do it every step when flying.
@@ -1683,7 +1708,7 @@ namespace OpenSim.Region.Framework.Scenes
1683 // } 1708 // }
1684 // } 1709 // }
1685 1710
1686 if (update_movementflag && m_parentID == 0) 1711 if (update_movementflag && ParentID == 0)
1687 Animator.UpdateMovementAnimations(); 1712 Animator.UpdateMovementAnimations();
1688 } 1713 }
1689 1714
@@ -1765,26 +1790,26 @@ namespace OpenSim.Region.Framework.Scenes
1765 // one of left/right/back/forward. 1790 // one of left/right/back/forward.
1766 if (LocalVectorToTarget3D.X < 0) //MoveBack 1791 if (LocalVectorToTarget3D.X < 0) //MoveBack
1767 { 1792 {
1768 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 1793 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
1769 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 1794 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
1770 updated = true; 1795 updated = true;
1771 } 1796 }
1772 else if (LocalVectorToTarget3D.X > 0) //Move Forward 1797 else if (LocalVectorToTarget3D.X > 0) //Move Forward
1773 { 1798 {
1774 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 1799 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
1775 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 1800 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
1776 updated = true; 1801 updated = true;
1777 } 1802 }
1778 1803
1779 if (LocalVectorToTarget3D.Y > 0) //MoveLeft 1804 if (LocalVectorToTarget3D.Y > 0) //MoveLeft
1780 { 1805 {
1781 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 1806 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
1782 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 1807 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
1783 updated = true; 1808 updated = true;
1784 } 1809 }
1785 else if (LocalVectorToTarget3D.Y < 0) //MoveRight 1810 else if (LocalVectorToTarget3D.Y < 0) //MoveRight
1786 { 1811 {
1787 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 1812 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
1788 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 1813 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
1789 updated = true; 1814 updated = true;
1790 } 1815 }
@@ -1793,14 +1818,14 @@ namespace OpenSim.Region.Framework.Scenes
1793 { 1818 {
1794 // Don't set these flags for up or down - doing so will make the avatar crouch or 1819 // Don't set these flags for up or down - doing so will make the avatar crouch or
1795 // keep trying to jump even if walking along level ground 1820 // keep trying to jump even if walking along level ground
1796 //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; 1821 //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
1797 //AgentControlFlags 1822 //AgentControlFlags
1798 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; 1823 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
1799 updated = true; 1824 updated = true;
1800 } 1825 }
1801 else if (LocalVectorToTarget3D.Z < 0) //Down 1826 else if (LocalVectorToTarget3D.Z < 0) //Down
1802 { 1827 {
1803 //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; 1828 //MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
1804 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; 1829 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
1805 updated = true; 1830 updated = true;
1806 } 1831 }
@@ -1963,7 +1988,7 @@ namespace OpenSim.Region.Framework.Scenes
1963 { 1988 {
1964 SitGround = false; 1989 SitGround = false;
1965 1990
1966 if (m_parentID != 0) 1991 if (ParentID != 0)
1967 { 1992 {
1968 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); 1993 SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
1969 if (part != null) 1994 if (part != null)
@@ -1986,7 +2011,7 @@ namespace OpenSim.Region.Framework.Scenes
1986 part.SitTargetAvatar = UUID.Zero; 2011 part.SitTargetAvatar = UUID.Zero;
1987 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 2012 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1988 2013
1989 m_parentPosition = part.GetWorldPosition(); 2014 ParentPosition = part.GetWorldPosition();
1990 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 2015 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1991 } 2016 }
1992 // part.GetWorldRotation() is the rotation of the object being sat on 2017 // part.GetWorldRotation() is the rotation of the object being sat on
@@ -2256,7 +2281,7 @@ namespace OpenSim.Region.Framework.Scenes
2256 // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation) 2281 // public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation)
2257 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) 2282 public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
2258 { 2283 {
2259 if (m_parentID != 0) 2284 if (ParentID != 0)
2260 { 2285 {
2261 StandUp(); 2286 StandUp();
2262 } 2287 }
@@ -2582,6 +2607,7 @@ namespace OpenSim.Region.Framework.Scenes
2582 return; 2607 return;
2583 } 2608 }
2584 } 2609 }
2610 ParentID = m_requestedSitTargetID;
2585 2611
2586 //We want our offsets to reference the root prim, not the child we may have sat on 2612 //We want our offsets to reference the root prim, not the child we may have sat on
2587 if (!part.IsRoot) 2613 if (!part.IsRoot)
@@ -2644,11 +2670,7 @@ namespace OpenSim.Region.Framework.Scenes
2644 /// </summary> 2670 /// </summary>
2645 public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) 2671 public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun)
2646 { 2672 {
2647 m_setAlwaysRun = pSetAlwaysRun; 2673 SetAlwaysRun = pSetAlwaysRun;
2648 if (PhysicsActor != null)
2649 {
2650 PhysicsActor.SetAlwaysRun = pSetAlwaysRun;
2651 }
2652 } 2674 }
2653 2675
2654 public void HandleStartAnim(IClientAPI remoteClient, UUID animID) 2676 public void HandleStartAnim(IClientAPI remoteClient, UUID animID)
@@ -2670,27 +2692,25 @@ namespace OpenSim.Region.Framework.Scenes
2670 Vector3 direc = vec * Rotation; 2692 Vector3 direc = vec * Rotation;
2671 direc.Normalize(); 2693 direc.Normalize();
2672 2694
2673 direc *= 0.03f * 128f * m_speedModifier; 2695 direc *= 0.03f * 128f * SpeedModifier;
2674 2696
2675 PhysicsActor actor = m_physicsActor; 2697 if (PhysicsActor != null)
2676 if (actor != null)
2677 { 2698 {
2678 if (actor.Flying) 2699 if (PhysicsActor.Flying)
2679 { 2700 {
2680 direc *= 4.0f; 2701 direc *= 4.0f;
2681 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 2702 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2682 //bool colliding = (m_physicsActor.IsColliding==true);
2683 //if (controlland) 2703 //if (controlland)
2684 // m_log.Info("[AGENT]: landCommand"); 2704 // m_log.Info("[AGENT]: landCommand");
2685 //if (colliding) 2705 //if (PhysicsActor.IsColliding)
2686 // m_log.Info("[AGENT]: colliding"); 2706 // m_log.Info("[AGENT]: colliding");
2687 //if (m_physicsActor.Flying && colliding && controlland) 2707 //if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland)
2688 //{ 2708 //{
2689 // StopFlying(); 2709 // StopFlying();
2690 // m_log.Info("[AGENT]: Stop FLying"); 2710 // m_log.Info("[AGENT]: Stop Flying");
2691 //} 2711 //}
2692 } 2712 }
2693 else if (!actor.Flying && actor.IsColliding) 2713 else if (!PhysicsActor.Flying && PhysicsActor.IsColliding)
2694 { 2714 {
2695 if (direc.Z > 2.0f) 2715 if (direc.Z > 2.0f)
2696 { 2716 {
@@ -2723,16 +2743,14 @@ namespace OpenSim.Region.Framework.Scenes
2723 if (!sendingPrims) 2743 if (!sendingPrims)
2724 Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; }); 2744 Util.FireAndForget(delegate { sendingPrims = true; SendPrimUpdates(); sendingPrims = false; });
2725 2745
2726 if (m_isChildAgent == false) 2746 if (IsChildAgent == false)
2727 { 2747 {
2728// PhysicsActor actor = m_physicsActor;
2729
2730 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 2748 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to
2731 // grab the latest PhysicsActor velocity, whereas m_velocity is often 2749 // grab the latest PhysicsActor velocity, whereas m_velocity is often
2732 // storing a requested force instead of an actual traveling velocity 2750 // storing a requested force instead of an actual traveling velocity
2733 2751
2734 // Throw away duplicate or insignificant updates 2752 // Throw away duplicate or insignificant updates
2735 if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || 2753 if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2736 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 2754 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2737 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) 2755 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
2738 //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) 2756 //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
@@ -2741,13 +2759,13 @@ namespace OpenSim.Region.Framework.Scenes
2741 2759
2742 // Update the "last" values 2760 // Update the "last" values
2743 m_lastPosition = m_pos; 2761 m_lastPosition = m_pos;
2744 m_lastRotation = m_bodyRot; 2762 m_lastRotation = Rotation;
2745 m_lastVelocity = Velocity; 2763 m_lastVelocity = Velocity;
2746 //m_lastTerseSent = Environment.TickCount; 2764 //m_lastTerseSent = Environment.TickCount;
2747 } 2765 }
2748 2766
2749 // followed suggestion from mic bowman. reversed the two lines below. 2767 // followed suggestion from mic bowman. reversed the two lines below.
2750 if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something 2768 if (ParentID == 0 && PhysicsActor != null || ParentID != 0) // Check that we have a physics actor or we're sitting on something
2751 CheckForBorderCrossing(); 2769 CheckForBorderCrossing();
2752 2770
2753 CheckForSignificantMovement(); // sends update to the modules. 2771 CheckForSignificantMovement(); // sends update to the modules.
@@ -2773,9 +2791,9 @@ namespace OpenSim.Region.Framework.Scenes
2773 if (remoteClient.IsActive) 2791 if (remoteClient.IsActive)
2774 { 2792 {
2775 Vector3 pos = m_pos; 2793 Vector3 pos = m_pos;
2776 pos.Z += m_appearance.HipOffset; 2794 pos.Z += Appearance.HipOffset;
2777 2795
2778 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); 2796 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
2779 2797
2780 remoteClient.SendPrimUpdate( 2798 remoteClient.SendPrimUpdate(
2781 this, 2799 this,
@@ -2847,7 +2865,8 @@ namespace OpenSim.Region.Framework.Scenes
2847 2865
2848 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2866 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
2849 { 2867 {
2850 m_controllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations); 2868 m_perfMonMS = Util.EnvironmentTickCount();
2869 ControllingClient.SendCoarseLocationUpdate(avatarUUIDs, coarseLocations);
2851 } 2870 }
2852 2871
2853 /// <summary> 2872 /// <summary>
@@ -2857,21 +2876,21 @@ namespace OpenSim.Region.Framework.Scenes
2857 private void SendInitialData() 2876 private void SendInitialData()
2858 { 2877 {
2859 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); 2878 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
2860 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2879 // Moved this into CompleteMovement to ensure that Appearance is initialized before
2861 // the inventory arrives 2880 // the inventory arrives
2862 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2881 // m_scene.GetAvatarAppearance(ControllingClient, out Appearance);
2863 2882
2864 bool cachedappearance = false; 2883 bool cachedappearance = false;
2865 2884
2866 // We have an appearance but we may not have the baked textures. Check the asset cache 2885 // We have an appearance but we may not have the baked textures. Check the asset cache
2867 // to see if all the baked textures are already here. 2886 // to see if all the baked textures are already here.
2868 if (m_scene.AvatarFactory != null) 2887 if (m_scene.AvatarFactory != null)
2869 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient); 2888 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(ControllingClient);
2870 2889
2871 // If we aren't using a cached appearance, then clear out the baked textures 2890 // If we aren't using a cached appearance, then clear out the baked textures
2872 if (!cachedappearance) 2891 if (!cachedappearance)
2873 { 2892 {
2874 m_appearance.ResetAppearance(); 2893 Appearance.ResetAppearance();
2875 if (m_scene.AvatarFactory != null) 2894 if (m_scene.AvatarFactory != null)
2876 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 2895 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2877 } 2896 }
@@ -3019,17 +3038,7 @@ namespace OpenSim.Region.Framework.Scenes
3019// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); 3038// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
3020 3039
3021 avatar.ControllingClient.SendAppearance( 3040 avatar.ControllingClient.SendAppearance(
3022 UUID, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 3041 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
3023 }
3024
3025 public AvatarAppearance Appearance
3026 {
3027 get { return m_appearance; }
3028 set
3029 {
3030 m_appearance = value;
3031// m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value);
3032 }
3033 } 3042 }
3034 3043
3035 #endregion 3044 #endregion
@@ -3057,14 +3066,13 @@ namespace OpenSim.Region.Framework.Scenes
3057 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); 3066 ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();
3058 cadu.ActiveGroupID = UUID.Zero.Guid; 3067 cadu.ActiveGroupID = UUID.Zero.Guid;
3059 cadu.AgentID = UUID.Guid; 3068 cadu.AgentID = UUID.Guid;
3060 cadu.alwaysrun = m_setAlwaysRun; 3069 cadu.alwaysrun = SetAlwaysRun;
3061 cadu.AVHeight = m_appearance.AvatarHeight; 3070 cadu.AVHeight = Appearance.AvatarHeight;
3062 Vector3 tempCameraCenter = m_CameraCenter; 3071 cadu.cameraPosition = CameraPosition;
3063 cadu.cameraPosition = tempCameraCenter; 3072 cadu.drawdistance = DrawDistance;
3064 cadu.drawdistance = m_DrawDistance;
3065 cadu.GroupAccess = 0; 3073 cadu.GroupAccess = 0;
3066 cadu.Position = AbsolutePosition; 3074 cadu.Position = AbsolutePosition;
3067 cadu.regionHandle = m_rootRegionHandle; 3075 cadu.regionHandle = RegionHandle;
3068 3076
3069 // Throttles 3077 // Throttles
3070 float multiplier = 1; 3078 float multiplier = 1;
@@ -3170,7 +3178,7 @@ namespace OpenSim.Region.Framework.Scenes
3170 { 3178 {
3171 if (m_requestedSitTargetUUID == UUID.Zero) 3179 if (m_requestedSitTargetUUID == UUID.Zero)
3172 { 3180 {
3173 bool isFlying = m_physicsActor.Flying; 3181 bool isFlying = PhysicsActor.Flying;
3174 RemoveFromPhysicalScene(); 3182 RemoveFromPhysicalScene();
3175 3183
3176 Vector3 pos = AbsolutePosition; 3184 Vector3 pos = AbsolutePosition;
@@ -3195,7 +3203,7 @@ namespace OpenSim.Region.Framework.Scenes
3195 { 3203 {
3196 if (m_requestedSitTargetUUID == UUID.Zero) 3204 if (m_requestedSitTargetUUID == UUID.Zero)
3197 { 3205 {
3198 bool isFlying = m_physicsActor.Flying; 3206 bool isFlying = PhysicsActor.Flying;
3199 RemoveFromPhysicalScene(); 3207 RemoveFromPhysicalScene();
3200 3208
3201 Vector3 pos = AbsolutePosition; 3209 Vector3 pos = AbsolutePosition;
@@ -3285,7 +3293,7 @@ namespace OpenSim.Region.Framework.Scenes
3285 { 3293 {
3286 try 3294 try
3287 { 3295 {
3288 return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); 3296 return m_scene.CrossAgentToNewRegion(this, PhysicsActor.Flying);
3289 } 3297 }
3290 catch 3298 catch
3291 { 3299 {
@@ -3295,9 +3303,9 @@ namespace OpenSim.Region.Framework.Scenes
3295 3303
3296 public void InTransit() 3304 public void InTransit()
3297 { 3305 {
3298 m_inTransit = true; 3306 IsInTransit = true;
3299 3307
3300 if ((m_physicsActor != null) && m_physicsActor.Flying) 3308 if ((PhysicsActor != null) && PhysicsActor.Flying)
3301 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; 3309 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY;
3302 else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) 3310 else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0)
3303 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; 3311 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY;
@@ -3305,7 +3313,7 @@ namespace OpenSim.Region.Framework.Scenes
3305 3313
3306 public void NotInTransit() 3314 public void NotInTransit()
3307 { 3315 {
3308 m_inTransit = false; 3316 IsInTransit = false;
3309 } 3317 }
3310 3318
3311 public void RestoreInCurrentScene() 3319 public void RestoreInCurrentScene()
@@ -3361,7 +3369,7 @@ namespace OpenSim.Region.Framework.Scenes
3361 if (byebyeRegions.Count > 0) 3369 if (byebyeRegions.Count > 0)
3362 { 3370 {
3363 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); 3371 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents");
3364 m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); 3372 m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions);
3365 } 3373 }
3366 3374
3367 foreach (ulong handle in byebyeRegions) 3375 foreach (ulong handle in byebyeRegions)
@@ -3387,17 +3395,17 @@ namespace OpenSim.Region.Framework.Scenes
3387 if (account != null) 3395 if (account != null)
3388 { 3396 {
3389 if (account.UserLevel > 0) 3397 if (account.UserLevel > 0)
3390 m_godLevel = account.UserLevel; 3398 GodLevel = account.UserLevel;
3391 else 3399 else
3392 m_godLevel = 200; 3400 GodLevel = 200;
3393 } 3401 }
3394 } 3402 }
3395 else 3403 else
3396 { 3404 {
3397 m_godLevel = 0; 3405 GodLevel = 0;
3398 } 3406 }
3399 3407
3400 ControllingClient.SendAdminResponse(token, (uint)m_godLevel); 3408 ControllingClient.SendAdminResponse(token, (uint)GodLevel);
3401 } 3409 }
3402 3410
3403 #region Child Agent Updates 3411 #region Child Agent Updates
@@ -3429,8 +3437,8 @@ namespace OpenSim.Region.Framework.Scenes
3429 // When we get to the point of re-computing neighbors everytime this 3437 // When we get to the point of re-computing neighbors everytime this
3430 // changes, then start using the agent's drawdistance rather than the 3438 // changes, then start using the agent's drawdistance rather than the
3431 // region's draw distance. 3439 // region's draw distance.
3432 // m_DrawDistance = cAgentData.Far; 3440 // DrawDistance = cAgentData.Far;
3433 m_DrawDistance = Scene.DefaultDrawDistance; 3441 DrawDistance = Scene.DefaultDrawDistance;
3434 3442
3435 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! 3443 if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!!
3436 m_pos = cAgentData.Position + offset; 3444 m_pos = cAgentData.Position + offset;
@@ -3441,7 +3449,7 @@ namespace OpenSim.Region.Framework.Scenes
3441 ReprioritizeUpdates(); 3449 ReprioritizeUpdates();
3442 } 3450 }
3443 3451
3444 m_CameraCenter = cAgentData.Center + offset; 3452 CameraPosition = cAgentData.Center + offset;
3445 3453
3446 //SetHeight(cAgentData.AVHeight); 3454 //SetHeight(cAgentData.AVHeight);
3447 3455
@@ -3449,7 +3457,7 @@ namespace OpenSim.Region.Framework.Scenes
3449 ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); 3457 ControllingClient.SetChildAgentThrottle(cAgentData.Throttles);
3450 3458
3451 //cAgentData.AVHeight; 3459 //cAgentData.AVHeight;
3452 m_rootRegionHandle = cAgentData.RegionHandle; 3460 RegionHandle = cAgentData.RegionHandle;
3453 //m_velocity = cAgentData.Velocity; 3461 //m_velocity = cAgentData.Velocity;
3454 } 3462 }
3455 3463
@@ -3462,12 +3470,12 @@ namespace OpenSim.Region.Framework.Scenes
3462 3470
3463 cAgent.Position = AbsolutePosition; 3471 cAgent.Position = AbsolutePosition;
3464 cAgent.Velocity = m_velocity; 3472 cAgent.Velocity = m_velocity;
3465 cAgent.Center = m_CameraCenter; 3473 cAgent.Center = CameraPosition;
3466 cAgent.AtAxis = m_CameraAtAxis; 3474 cAgent.AtAxis = CameraAtAxis;
3467 cAgent.LeftAxis = m_CameraLeftAxis; 3475 cAgent.LeftAxis = CameraLeftAxis;
3468 cAgent.UpAxis = m_CameraUpAxis; 3476 cAgent.UpAxis = m_CameraUpAxis;
3469 3477
3470 cAgent.Far = m_DrawDistance; 3478 cAgent.Far = DrawDistance;
3471 3479
3472 // Throttles 3480 // Throttles
3473 float multiplier = 1; 3481 float multiplier = 1;
@@ -3482,17 +3490,17 @@ namespace OpenSim.Region.Framework.Scenes
3482 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); 3490 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
3483 3491
3484 cAgent.HeadRotation = m_headrotation; 3492 cAgent.HeadRotation = m_headrotation;
3485 cAgent.BodyRotation = m_bodyRot; 3493 cAgent.BodyRotation = Rotation;
3486 cAgent.ControlFlags = (uint)m_AgentControlFlags; 3494 cAgent.ControlFlags = (uint)m_AgentControlFlags;
3487 3495
3488 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3496 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3489 cAgent.GodLevel = (byte)m_godLevel; 3497 cAgent.GodLevel = (byte)GodLevel;
3490 else 3498 else
3491 cAgent.GodLevel = (byte) 0; 3499 cAgent.GodLevel = (byte) 0;
3492 3500
3493 cAgent.AlwaysRun = m_setAlwaysRun; 3501 cAgent.AlwaysRun = SetAlwaysRun;
3494 3502
3495 cAgent.Appearance = new AvatarAppearance(m_appearance); 3503 cAgent.Appearance = new AvatarAppearance(Appearance);
3496 3504
3497 lock (scriptedcontrols) 3505 lock (scriptedcontrols)
3498 { 3506 {
@@ -3521,7 +3529,7 @@ namespace OpenSim.Region.Framework.Scenes
3521 cAgent.AttachmentObjects = new List<ISceneObject>(); 3529 cAgent.AttachmentObjects = new List<ISceneObject>();
3522 cAgent.AttachmentObjectStates = new List<string>(); 3530 cAgent.AttachmentObjectStates = new List<string>();
3523 // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); 3531 // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3524 m_InTransitScriptStates.Clear(); 3532 InTransitScriptStates.Clear();
3525 3533
3526 foreach (SceneObjectGroup sog in m_attachments) 3534 foreach (SceneObjectGroup sog in m_attachments)
3527 { 3535 {
@@ -3534,7 +3542,7 @@ namespace OpenSim.Region.Framework.Scenes
3534 cAgent.AttachmentObjects.Add(clone); 3542 cAgent.AttachmentObjects.Add(clone);
3535 string state = sog.GetStateSnapshot(); 3543 string state = sog.GetStateSnapshot();
3536 cAgent.AttachmentObjectStates.Add(state); 3544 cAgent.AttachmentObjectStates.Add(state);
3537 m_InTransitScriptStates.Add(state); 3545 InTransitScriptStates.Add(state);
3538 // Let's remove the scripts of the original object here 3546 // Let's remove the scripts of the original object here
3539 sog.RemoveScriptInstances(true); 3547 sog.RemoveScriptInstances(true);
3540 } 3548 }
@@ -3551,32 +3559,32 @@ namespace OpenSim.Region.Framework.Scenes
3551 m_pos = cAgent.Position; 3559 m_pos = cAgent.Position;
3552 3560
3553 m_velocity = cAgent.Velocity; 3561 m_velocity = cAgent.Velocity;
3554 m_CameraCenter = cAgent.Center; 3562 CameraPosition = cAgent.Center;
3555 m_CameraAtAxis = cAgent.AtAxis; 3563 CameraAtAxis = cAgent.AtAxis;
3556 m_CameraLeftAxis = cAgent.LeftAxis; 3564 CameraLeftAxis = cAgent.LeftAxis;
3557 m_CameraUpAxis = cAgent.UpAxis; 3565 m_CameraUpAxis = cAgent.UpAxis;
3558 3566
3559 // When we get to the point of re-computing neighbors everytime this 3567 // When we get to the point of re-computing neighbors everytime this
3560 // changes, then start using the agent's drawdistance rather than the 3568 // changes, then start using the agent's drawdistance rather than the
3561 // region's draw distance. 3569 // region's draw distance.
3562 // m_DrawDistance = cAgent.Far; 3570 // DrawDistance = cAgent.Far;
3563 m_DrawDistance = Scene.DefaultDrawDistance; 3571 DrawDistance = Scene.DefaultDrawDistance;
3564 3572
3565 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) 3573 if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
3566 ControllingClient.SetChildAgentThrottle(cAgent.Throttles); 3574 ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
3567 3575
3568 m_headrotation = cAgent.HeadRotation; 3576 m_headrotation = cAgent.HeadRotation;
3569 m_bodyRot = cAgent.BodyRotation; 3577 Rotation = cAgent.BodyRotation;
3570 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; 3578 m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
3571 3579
3572 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) 3580 if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
3573 m_godLevel = cAgent.GodLevel; 3581 GodLevel = cAgent.GodLevel;
3574 m_setAlwaysRun = cAgent.AlwaysRun; 3582 SetAlwaysRun = cAgent.AlwaysRun;
3575 3583
3576 m_appearance = new AvatarAppearance(cAgent.Appearance); 3584 Appearance = new AvatarAppearance(cAgent.Appearance);
3577 if (m_physicsActor != null) 3585 if (PhysicsActor != null)
3578 { 3586 {
3579 bool isFlying = m_physicsActor.Flying; 3587 bool isFlying = PhysicsActor.Flying;
3580 RemoveFromPhysicalScene(); 3588 RemoveFromPhysicalScene();
3581 AddToPhysicalScene(isFlying); 3589 AddToPhysicalScene(isFlying);
3582 } 3590 }
@@ -3642,7 +3650,7 @@ namespace OpenSim.Region.Framework.Scenes
3642 { 3650 {
3643 Vector3 force = m_forceToApply.Value; 3651 Vector3 force = m_forceToApply.Value;
3644 3652
3645 m_updateflag = true; 3653 Updated = true;
3646 3654
3647 Velocity = force; 3655 Velocity = force;
3648 3656
@@ -3659,28 +3667,30 @@ namespace OpenSim.Region.Framework.Scenes
3659// "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}", 3667// "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}",
3660// Name, isFlying, Scene.RegionInfo.RegionName); 3668// Name, isFlying, Scene.RegionInfo.RegionName);
3661 3669
3662 if (m_appearance.AvatarHeight == 0) 3670 if (Appearance.AvatarHeight == 0)
3663 m_appearance.SetHeight(); 3671 Appearance.SetHeight();
3664 3672
3665 PhysicsScene scene = m_scene.PhysicsScene; 3673 PhysicsScene scene = m_scene.PhysicsScene;
3666 3674
3667 Vector3 pVec = AbsolutePosition; 3675 Vector3 pVec = AbsolutePosition;
3668 3676
3669 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, 3677 // Old bug where the height was in centimeters instead of meters
3670 new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying); 3678 PhysicsActor = scene.AddAvatar(LocalId, Firstname + "." + Lastname, pVec,
3671 scene.AddPhysicsActorTaint(m_physicsActor); 3679 new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying);
3672 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3680
3673 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3681 scene.AddPhysicsActorTaint(PhysicsActor);
3674 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3682 //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
3675 m_physicsActor.SubscribeEvents(500); 3683 PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3676 m_physicsActor.LocalID = LocalId; 3684 PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3685 PhysicsActor.SubscribeEvents(500);
3686 PhysicsActor.LocalID = LocalId;
3677 3687
3678 SetHeight(m_appearance.AvatarHeight); 3688 SetHeight(Appearance.AvatarHeight);
3679 } 3689 }
3680 3690
3681 private void OutOfBoundsCall(Vector3 pos) 3691 private void OutOfBoundsCall(Vector3 pos)
3682 { 3692 {
3683 //bool flying = m_physicsActor.Flying; 3693 //bool flying = PhysicsActor.Flying;
3684 //RemoveFromPhysicalScene(); 3694 //RemoveFromPhysicalScene();
3685 3695
3686 //AddToPhysicalScene(flying); 3696 //AddToPhysicalScene(flying);
@@ -3693,8 +3703,9 @@ namespace OpenSim.Region.Framework.Scenes
3693 { 3703 {
3694 if (e == null) 3704 if (e == null)
3695 return; 3705 return;
3696 3706
3697 // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( 3707 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f))
3708 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
3698 // as of this comment the interval is set in AddToPhysicalScene 3709 // as of this comment the interval is set in AddToPhysicalScene
3699 if (Animator!=null) 3710 if (Animator!=null)
3700 { 3711 {
@@ -3887,7 +3898,7 @@ namespace OpenSim.Region.Framework.Scenes
3887 } 3898 }
3888 } 3899 }
3889 3900
3890 if (m_invulnerable) 3901 if (Invulnerable)
3891 return; 3902 return;
3892 3903
3893 float starthealth = Health; 3904 float starthealth = Health;
@@ -3912,13 +3923,13 @@ namespace OpenSim.Region.Framework.Scenes
3912 //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); 3923 //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString());
3913 } 3924 }
3914 //Health = 100; 3925 //Health = 100;
3915 if (!m_invulnerable) 3926 if (!Invulnerable)
3916 { 3927 {
3917 if (starthealth != Health) 3928 if (starthealth != Health)
3918 { 3929 {
3919 ControllingClient.SendHealth(Health); 3930 ControllingClient.SendHealth(Health);
3920 } 3931 }
3921 if (m_health <= 0) 3932 if (Health <= 0)
3922 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3933 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3923 } 3934 }
3924 } 3935 }
@@ -3949,11 +3960,11 @@ namespace OpenSim.Region.Framework.Scenes
3949 // unsetting the elapsed callback should be enough to allow for cleanup however. 3960 // unsetting the elapsed callback should be enough to allow for cleanup however.
3950 // m_reprioritizationTimer.Dispose(); 3961 // m_reprioritizationTimer.Dispose();
3951 3962
3952 m_sceneViewer.Close(); 3963 SceneViewer.Close();
3953 3964
3954 RemoveFromPhysicalScene(); 3965 RemoveFromPhysicalScene();
3955 m_animator.Close(); 3966 Animator.Close();
3956 m_animator = null; 3967 Animator = null;
3957 } 3968 }
3958 3969
3959 public void AddAttachment(SceneObjectGroup gobj) 3970 public void AddAttachment(SceneObjectGroup gobj)
@@ -4319,7 +4330,7 @@ namespace OpenSim.Region.Framework.Scenes
4319 4330
4320 private void Reprioritize(object sender, ElapsedEventArgs e) 4331 private void Reprioritize(object sender, ElapsedEventArgs e)
4321 { 4332 {
4322 m_controllingClient.ReprioritizeUpdates(); 4333 ControllingClient.ReprioritizeUpdates();
4323 4334
4324 lock (m_reprioritization_timer) 4335 lock (m_reprioritization_timer)
4325 { 4336 {