aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs153
1 files changed, 74 insertions, 79 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 9b11582..2bc7f66 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -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)
@@ -1551,9 +1543,9 @@ if (m_shape != null) {
1551 m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? 1543 m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed?
1552 1544
1553 // make sure client isn't interpolating the joint proxy object 1545 // make sure client isn't interpolating the joint proxy object
1554 Velocity = new Vector3(0, 0, 0); 1546 Velocity = Vector3.Zero;
1555 RotationalVelocity = new Vector3(0, 0, 0); 1547 AngularVelocity = Vector3.Zero;
1556 Acceleration = new Vector3(0, 0, 0); 1548 Acceleration = Vector3.Zero;
1557 } 1549 }
1558 } 1550 }
1559 } 1551 }
@@ -1816,7 +1808,7 @@ if (m_shape != null) {
1816 } 1808 }
1817 1809
1818 CollisionEventUpdate a = (CollisionEventUpdate)e; 1810 CollisionEventUpdate a = (CollisionEventUpdate)e;
1819 Dictionary<uint, float> collissionswith = a.m_objCollisionList; 1811 Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
1820 List<uint> thisHitColliders = new List<uint>(); 1812 List<uint> thisHitColliders = new List<uint>();
1821 List<uint> endedColliders = new List<uint>(); 1813 List<uint> endedColliders = new List<uint>();
1822 List<uint> startedColliders = new List<uint>(); 1814 List<uint> startedColliders = new List<uint>();
@@ -2382,8 +2374,8 @@ if (m_shape != null) {
2382 //isattachment = ParentGroup.RootPart.IsAttachment; 2374 //isattachment = ParentGroup.RootPart.IsAttachment;
2383 2375
2384 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; 2376 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2385 remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, 2377 remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape,
2386 lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, 2378 lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID,
2387 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, 2379 m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
2388 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); 2380 AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
2389 } 2381 }
@@ -2393,17 +2385,20 @@ if (m_shape != null) {
2393 /// </summary> 2385 /// </summary>
2394 public void SendScheduledUpdates() 2386 public void SendScheduledUpdates()
2395 { 2387 {
2396 const float VELOCITY_TOLERANCE = 0.01f; 2388 const float ROTATION_TOLERANCE = 0.01f;
2397 const float POSITION_TOLERANCE = 0.1f; 2389 const float VELOCITY_TOLERANCE = 0.001f;
2390 const float POSITION_TOLERANCE = 0.05f;
2391 const int TIME_MS_TOLERANCE = 3000;
2398 2392
2399 if (m_updateFlag == 1) 2393 if (m_updateFlag == 1)
2400 { 2394 {
2401 // Throw away duplicate or insignificant updates 2395 // Throw away duplicate or insignificant updates
2402 if (RotationOffset != m_lastRotation || 2396 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2403 Acceleration != m_lastAcceleration || 2397 !Acceleration.Equals(m_lastAcceleration) ||
2404 (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || 2398 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2405 (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || 2399 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
2406 (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) 2400 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
2401 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
2407 { 2402 {
2408 AddTerseUpdateToAllAvatars(); 2403 AddTerseUpdateToAllAvatars();
2409 ClearUpdateSchedule(); 2404 ClearUpdateSchedule();
@@ -2421,7 +2416,8 @@ if (m_shape != null) {
2421 m_lastRotation = RotationOffset; 2416 m_lastRotation = RotationOffset;
2422 m_lastVelocity = Velocity; 2417 m_lastVelocity = Velocity;
2423 m_lastAcceleration = Acceleration; 2418 m_lastAcceleration = Acceleration;
2424 m_lastAngularVelocity = RotationalVelocity; 2419 m_lastAngularVelocity = AngularVelocity;
2420 m_lastTerseSent = Environment.TickCount;
2425 } 2421 }
2426 } 2422 }
2427 else 2423 else
@@ -3780,10 +3776,9 @@ if (m_shape != null) {
3780 // Causes this thread to dig into the Client Thread Data. 3776 // Causes this thread to dig into the Client Thread Data.
3781 // Remember your locking here! 3777 // Remember your locking here!
3782 remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, 3778 remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle,
3783 (ushort)(m_parentGroup.GetTimeDilation() * 3779 m_parentGroup.GetTimeDilation(), LocalId, lPos,
3784 (float)ushort.MaxValue), LocalId, lPos,
3785 RotationOffset, Velocity, Acceleration, 3780 RotationOffset, Velocity, Acceleration,
3786 RotationalVelocity, state, FromItemID, 3781 AngularVelocity, state, FromItemID,
3787 OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); 3782 OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient)));
3788 } 3783 }
3789 3784