aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorKittoFlora2009-11-16 01:40:15 +0100
committerKittoFlora2009-11-16 01:40:15 +0100
commit873c9098d8627972e80a1688e85a4cda45e1e7fe (patch)
treea0edc24aef11d5ad6928493d8985386f48dd2607 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentMerge branch 'vehicles' into tests (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-873c9098d8627972e80a1688e85a4cda45e1e7fe.zip
opensim-SC_OLD-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.gz
opensim-SC_OLD-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.bz2
opensim-SC_OLD-873c9098d8627972e80a1688e85a4cda45e1e7fe.tar.xz
Merge branch 'careminster' into tests
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs171
1 files changed, 79 insertions, 92 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 7d889ee..bf2f3d3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -243,7 +243,7 @@ namespace OpenSim.Region.Framework.Scenes
243 protected SceneObjectGroup m_parentGroup; 243 protected SceneObjectGroup m_parentGroup;
244 protected byte[] m_particleSystem = Utils.EmptyBytes; 244 protected byte[] m_particleSystem = Utils.EmptyBytes;
245 protected ulong m_regionHandle; 245 protected ulong m_regionHandle;
246 protected Quaternion m_rotationOffset; 246 protected Quaternion m_rotationOffset = Quaternion.Identity;
247 protected PrimitiveBaseShape m_shape; 247 protected PrimitiveBaseShape m_shape;
248 protected UUID m_uuid; 248 protected UUID m_uuid;
249 protected Vector3 m_velocity; 249 protected Vector3 m_velocity;
@@ -253,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes
253 protected Vector3 m_lastVelocity; 253 protected Vector3 m_lastVelocity;
254 protected Vector3 m_lastAcceleration; 254 protected Vector3 m_lastAcceleration;
255 protected Vector3 m_lastAngularVelocity; 255 protected Vector3 m_lastAngularVelocity;
256 protected int m_lastTerseSent;
256 257
257 // TODO: Those have to be changed into persistent properties at some later point, 258 // TODO: Those have to be changed into persistent properties at some later point,
258 // or sit-camera on vehicles will break on sim-crossing. 259 // or sit-camera on vehicles will break on sim-crossing.
@@ -506,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes
506 get 507 get
507 { 508 {
508 // If this is a linkset, we don't want the physics engine mucking up our group position here. 509 // If this is a linkset, we don't want the physics engine mucking up our group position here.
509 if (PhysActor != null && _parentID == 0) 510 PhysicsActor actor = PhysActor;
511 if (actor != null && _parentID == 0)
510 { 512 {
511 m_groupPosition.X = PhysActor.Position.X; 513 m_groupPosition = actor.Position;
512 m_groupPosition.Y = PhysActor.Position.Y;
513 m_groupPosition.Z = PhysActor.Position.Z;
514 } 514 }
515 515
516 if (IsAttachment) 516 if (IsAttachment)
517 { 517 {
518 ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); 518 ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
519 if (sp != null) 519 if (sp != null)
520 {
521 return sp.AbsolutePosition; 520 return sp.AbsolutePosition;
522 }
523 } 521 }
524 522
525 return m_groupPosition; 523 return m_groupPosition;
@@ -530,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes
530 528
531 m_groupPosition = value; 529 m_groupPosition = value;
532 530
533 if (PhysActor != null) 531 PhysicsActor actor = PhysActor;
532 if (actor != null)
534 { 533 {
535 try 534 try
536 { 535 {
537 // Root prim actually goes at Position 536 // Root prim actually goes at Position
538 if (_parentID == 0) 537 if (_parentID == 0)
539 { 538 {
540 PhysActor.Position = value; 539 actor.Position = value;
541 } 540 }
542 else 541 else
543 { 542 {
544 // To move the child prim in respect to the group position and rotation we have to calculate 543 // To move the child prim in respect to the group position and rotation we have to calculate
545 Vector3 resultingposition = GetWorldPosition(); 544 actor.Position = GetWorldPosition();
546 PhysActor.Position = resultingposition; 545 actor.Orientation = GetWorldRotation();
547 Quaternion resultingrot = GetWorldRotation();
548 PhysActor.Orientation = resultingrot;
549 } 546 }
550 547
551 // Tell the physics engines that this prim changed. 548 // Tell the physics engines that this prim changed.
552 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 549 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
553 } 550 }
554 catch (Exception e) 551 catch (Exception e)
555 { 552 {
@@ -582,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes
582 579
583 if (ParentGroup != null && !ParentGroup.IsDeleted) 580 if (ParentGroup != null && !ParentGroup.IsDeleted)
584 { 581 {
585 if (_parentID != 0 && PhysActor != null) 582 PhysicsActor actor = PhysActor;
583 if (_parentID != 0 && actor != null)
586 { 584 {
587 Vector3 resultingposition = GetWorldPosition(); 585 actor.Position = GetWorldPosition();
588 PhysActor.Position = resultingposition; 586 actor.Orientation = GetWorldRotation();
589 Quaternion resultingrot = GetWorldRotation();
590 PhysActor.Orientation = resultingrot;
591 587
592 // Tell the physics engines that this prim changed. 588 // Tell the physics engines that this prim changed.
593 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 589 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
594 } 590 }
595 } 591 }
596 } 592 }
@@ -601,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes
601 get 597 get
602 { 598 {
603 // We don't want the physics engine mucking up the rotations in a linkset 599 // We don't want the physics engine mucking up the rotations in a linkset
604 if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) 600 PhysicsActor actor = PhysActor;
601 if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
605 { 602 {
606 if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 603 if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
607 || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) 604 || actor.Orientation.Z != 0f || actor.Orientation.W != 0f)
608 { 605 {
609 m_rotationOffset = PhysActor.Orientation; 606 m_rotationOffset = actor.Orientation;
610 } 607 }
611 } 608 }
612 609
@@ -618,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes
618 StoreUndoState(); 615 StoreUndoState();
619 m_rotationOffset = value; 616 m_rotationOffset = value;
620 617
621 if (PhysActor != null) 618 PhysicsActor actor = PhysActor;
619 if (actor != null)
622 { 620 {
623 try 621 try
624 { 622 {
625 // Root prim gets value directly 623 // Root prim gets value directly
626 if (_parentID == 0) 624 if (_parentID == 0)
627 { 625 {
628 PhysActor.Orientation = value; 626 actor.Orientation = value;
629 //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); 627 //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString());
630 } 628 }
631 else 629 else
632 { 630 {
633 // Child prim we have to calculate it's world rotationwel 631 // Child prim we have to calculate it's world rotationwel
634 Quaternion resultingrotation = GetWorldRotation(); 632 Quaternion resultingrotation = GetWorldRotation();
635 PhysActor.Orientation = resultingrotation; 633 actor.Orientation = resultingrotation;
636 //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); 634 //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString());
637 } 635 }
638 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 636 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
639 //} 637 //}
640 } 638 }
641 catch (Exception ex) 639 catch (Exception ex)
@@ -652,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes
652 { 650 {
653 get 651 get
654 { 652 {
655 //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 653 PhysicsActor actor = PhysActor;
656 //|| PhysActor.Velocity.Z != 0) 654 if (actor != null)
657 //{
658 if (PhysActor != null)
659 { 655 {
660 if (PhysActor.IsPhysical) 656 if (actor.IsPhysical)
661 { 657 {
662 m_velocity.X = PhysActor.Velocity.X; 658 m_velocity = actor.Velocity;
663 m_velocity.Y = PhysActor.Velocity.Y;
664 m_velocity.Z = PhysActor.Velocity.Z;
665 } 659 }
666 } 660 }
667 661
@@ -671,31 +665,28 @@ namespace OpenSim.Region.Framework.Scenes
671 set 665 set
672 { 666 {
673 m_velocity = value; 667 m_velocity = value;
674 if (PhysActor != null) 668
669 PhysicsActor actor = PhysActor;
670 if (actor != null)
675 { 671 {
676 if (PhysActor.IsPhysical) 672 if (actor.IsPhysical)
677 { 673 {
678 PhysActor.Velocity = value; 674 actor.Velocity = value;
679 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 675 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
680 } 676 }
681 } 677 }
682 } 678 }
683 } 679 }
684 680
685 public Vector3 RotationalVelocity
686 {
687 get { return AngularVelocity; }
688 set { AngularVelocity = value; }
689 }
690
691 /// <summary></summary> 681 /// <summary></summary>
692 public Vector3 AngularVelocity 682 public Vector3 AngularVelocity
693 { 683 {
694 get 684 get
695 { 685 {
696 if ((PhysActor != null) && PhysActor.IsPhysical) 686 PhysicsActor actor = PhysActor;
687 if ((actor != null) && actor.IsPhysical)
697 { 688 {
698 m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); 689 m_angularVelocity = actor.RotationalVelocity;
699 } 690 }
700 return m_angularVelocity; 691 return m_angularVelocity;
701 } 692 }
@@ -715,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes
715 set 706 set
716 { 707 {
717 m_description = value; 708 m_description = value;
718 if (PhysActor != null) 709 PhysicsActor actor = PhysActor;
710 if (actor != null)
719 { 711 {
720 PhysActor.SOPDescription = value; 712 actor.SOPDescription = value;
721 } 713 }
722 } 714 }
723 } 715 }
@@ -808,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes
808 set 800 set
809 { 801 {
810 StoreUndoState(); 802 StoreUndoState();
811if (m_shape != null) { 803 if (m_shape != null)
812 m_shape.Scale = value;
813
814 if (PhysActor != null && m_parentGroup != null)
815 { 804 {
816 if (m_parentGroup.Scene != null) 805 m_shape.Scale = value;
806
807 PhysicsActor actor = PhysActor;
808 if (actor != null && m_parentGroup != null)
817 { 809 {
818 if (m_parentGroup.Scene.PhysicsScene != null) 810 if (m_parentGroup.Scene != null)
819 { 811 {
820 PhysActor.Size = m_shape.Scale; 812 if (m_parentGroup.Scene.PhysicsScene != null)
821 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 813 {
814 actor.Size = m_shape.Scale;
815 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
816 }
822 } 817 }
823 } 818 }
824 } 819 }
825}
826 TriggerScriptChangedEvent(Changed.SCALE); 820 TriggerScriptChangedEvent(Changed.SCALE);
827 } 821 }
828 } 822 }
@@ -1056,8 +1050,6 @@ if (m_shape != null) {
1056 1050
1057 #endregion Public Properties with only Get 1051 #endregion Public Properties with only Get
1058 1052
1059
1060
1061 #region Private Methods 1053 #region Private Methods
1062 1054
1063 private uint ApplyMask(uint val, bool set, uint mask) 1055 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1072,14 +1064,6 @@ if (m_shape != null) {
1072 } 1064 }
1073 } 1065 }
1074 1066
1075 /// <summary>
1076 /// Clear all pending updates of parts to clients
1077 /// </summary>
1078 private void ClearUpdateSchedule()
1079 {
1080 m_updateFlag = 0;
1081 }
1082
1083 private void SendObjectPropertiesToClient(UUID AgentID) 1067 private void SendObjectPropertiesToClient(UUID AgentID)
1084 { 1068 {
1085 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1069 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
@@ -1551,9 +1535,9 @@ if (m_shape != null) {
1551 m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? 1535 m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed?
1552 1536
1553 // make sure client isn't interpolating the joint proxy object 1537 // make sure client isn't interpolating the joint proxy object
1554 Velocity = new Vector3(0, 0, 0); 1538 Velocity = Vector3.Zero;
1555 RotationalVelocity = new Vector3(0, 0, 0); 1539 AngularVelocity = Vector3.Zero;
1556 Acceleration = new Vector3(0, 0, 0); 1540 Acceleration = Vector3.Zero;
1557 } 1541 }
1558 } 1542 }
1559 } 1543 }
@@ -1816,7 +1800,7 @@ if (m_shape != null) {
1816 } 1800 }
1817 1801
1818 CollisionEventUpdate a = (CollisionEventUpdate)e; 1802 CollisionEventUpdate a = (CollisionEventUpdate)e;
1819 Dictionary<uint, float> collissionswith = a.m_objCollisionList; 1803 Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
1820 List<uint> thisHitColliders = new List<uint>(); 1804 List<uint> thisHitColliders = new List<uint>();
1821 List<uint> endedColliders = new List<uint>(); 1805 List<uint> endedColliders = new List<uint>();
1822 List<uint> startedColliders = new List<uint>(); 1806 List<uint> startedColliders = new List<uint>();
@@ -2387,8 +2371,8 @@ if (m_shape != null) {
2387 //isattachment = ParentGroup.RootPart.IsAttachment; 2371 //isattachment = ParentGroup.RootPart.IsAttachment;
2388 2372
2389 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; 2373 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2390 remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, 2374 remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape,
2391 lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, 2375 lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID,
2392 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, 2376 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
2393 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); 2377 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
2394 } 2378 }
@@ -2398,20 +2382,23 @@ if (m_shape != null) {
2398 /// </summary> 2382 /// </summary>
2399 public void SendScheduledUpdates() 2383 public void SendScheduledUpdates()
2400 { 2384 {
2401 const float VELOCITY_TOLERANCE = 0.01f; 2385 const float ROTATION_TOLERANCE = 0.01f;
2402 const float POSITION_TOLERANCE = 0.1f; 2386 const float VELOCITY_TOLERANCE = 0.001f;
2387 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2388 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2403 2389
2404 if (m_updateFlag == 1) 2390 if (m_updateFlag == 1)
2405 { 2391 {
2406 // Throw away duplicate or insignificant updates 2392 // Throw away duplicate or insignificant updates
2407 if (RotationOffset != m_lastRotation || 2393 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2408 Acceleration != m_lastAcceleration || 2394 !Acceleration.Equals(m_lastAcceleration) ||
2409 (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || 2395 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2410 (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || 2396 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
2411 (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) 2397 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
2398 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
2412 { 2399 {
2413 AddTerseUpdateToAllAvatars(); 2400 AddTerseUpdateToAllAvatars();
2414 ClearUpdateSchedule(); 2401
2415 2402
2416 // This causes the Scene to 'poll' physical objects every couple of frames 2403 // This causes the Scene to 'poll' physical objects every couple of frames
2417 // bad, so it's been replaced by an event driven method. 2404 // bad, so it's been replaced by an event driven method.
@@ -2426,15 +2413,18 @@ if (m_shape != null) {
2426 m_lastRotation = RotationOffset; 2413 m_lastRotation = RotationOffset;
2427 m_lastVelocity = Velocity; 2414 m_lastVelocity = Velocity;
2428 m_lastAcceleration = Acceleration; 2415 m_lastAcceleration = Acceleration;
2429 m_lastAngularVelocity = RotationalVelocity; 2416 m_lastAngularVelocity = AngularVelocity;
2417 m_lastTerseSent = Environment.TickCount;
2430 } 2418 }
2419 //Moved this outside of the if clause so updates don't get blocked.. *sigh*
2420 m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams*
2431 } 2421 }
2432 else 2422 else
2433 { 2423 {
2434 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes 2424 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
2435 { 2425 {
2436 AddFullUpdateToAllAvatars(); 2426 AddFullUpdateToAllAvatars();
2437 ClearUpdateSchedule(); 2427 m_updateFlag = 0; //Same here
2438 } 2428 }
2439 } 2429 }
2440 } 2430 }
@@ -3774,14 +3764,12 @@ if (m_shape != null) {
3774 3764
3775 Vector3 lPos = OffsetPosition; 3765 Vector3 lPos = OffsetPosition;
3776 3766
3777 byte state = Shape.State;
3778 if (IsAttachment) 3767 if (IsAttachment)
3779 { 3768 {
3780 if (ParentGroup.RootPart != this) 3769 if (ParentGroup.RootPart != this)
3781 return; 3770 return;
3782 3771
3783 lPos = ParentGroup.RootPart.AttachedPos; 3772 lPos = ParentGroup.RootPart.AttachedPos;
3784 state = (byte)AttachmentPoint;
3785 } 3773 }
3786 else 3774 else
3787 { 3775 {
@@ -3792,10 +3780,9 @@ if (m_shape != null) {
3792 // Causes this thread to dig into the Client Thread Data. 3780 // Causes this thread to dig into the Client Thread Data.
3793 // Remember your locking here! 3781 // Remember your locking here!
3794 remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, 3782 remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle,
3795 (ushort)(m_parentGroup.GetTimeDilation() * 3783 m_parentGroup.GetTimeDilation(), LocalId, lPos,
3796 (float)ushort.MaxValue), LocalId, lPos,
3797 RotationOffset, Velocity, Acceleration, 3784 RotationOffset, Velocity, Acceleration,
3798 RotationalVelocity, state, FromItemID, 3785 AngularVelocity, FromItemID,
3799 OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); 3786 OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient)));
3800 } 3787 }
3801 3788