diff options
author | John Hurliman | 2009-11-02 11:40:57 -0800 |
---|---|---|
committer | John Hurliman | 2009-11-02 11:40:57 -0800 |
commit | 0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b (patch) | |
tree | d94f9d1f0217315eb0e66719ac4899dee2300087 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Removing duplicate SceneObjectPart.RotationalVelocity property (diff) | |
download | opensim-SC-0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b.zip opensim-SC-0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b.tar.gz opensim-SC-0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b.tar.bz2 opensim-SC-0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b.tar.xz |
Fixing race conditions in the SceneObjectPart properties
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 474ffdd..2bc7f66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -507,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
507 | get | 507 | get |
508 | { | 508 | { |
509 | // 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. |
510 | if (PhysActor != null && _parentID == 0) | 510 | PhysicsActor actor = PhysActor; |
511 | if (actor != null && _parentID == 0) | ||
511 | { | 512 | { |
512 | m_groupPosition.X = PhysActor.Position.X; | 513 | m_groupPosition = actor.Position; |
513 | m_groupPosition.Y = PhysActor.Position.Y; | ||
514 | m_groupPosition.Z = PhysActor.Position.Z; | ||
515 | } | 514 | } |
516 | 515 | ||
517 | if (IsAttachment) | 516 | if (IsAttachment) |
518 | { | 517 | { |
519 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); | 518 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); |
520 | if (sp != null) | 519 | if (sp != null) |
521 | { | ||
522 | return sp.AbsolutePosition; | 520 | return sp.AbsolutePosition; |
523 | } | ||
524 | } | 521 | } |
525 | 522 | ||
526 | return m_groupPosition; | 523 | return m_groupPosition; |
@@ -531,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
531 | 528 | ||
532 | m_groupPosition = value; | 529 | m_groupPosition = value; |
533 | 530 | ||
534 | if (PhysActor != null) | 531 | PhysicsActor actor = PhysActor; |
532 | if (actor != null) | ||
535 | { | 533 | { |
536 | try | 534 | try |
537 | { | 535 | { |
538 | // Root prim actually goes at Position | 536 | // Root prim actually goes at Position |
539 | if (_parentID == 0) | 537 | if (_parentID == 0) |
540 | { | 538 | { |
541 | PhysActor.Position = value; | 539 | actor.Position = value; |
542 | } | 540 | } |
543 | else | 541 | else |
544 | { | 542 | { |
545 | // 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 |
546 | Vector3 resultingposition = GetWorldPosition(); | 544 | actor.Position = GetWorldPosition(); |
547 | PhysActor.Position = resultingposition; | 545 | actor.Orientation = GetWorldRotation(); |
548 | Quaternion resultingrot = GetWorldRotation(); | ||
549 | PhysActor.Orientation = resultingrot; | ||
550 | } | 546 | } |
551 | 547 | ||
552 | // Tell the physics engines that this prim changed. | 548 | // Tell the physics engines that this prim changed. |
553 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 549 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
554 | } | 550 | } |
555 | catch (Exception e) | 551 | catch (Exception e) |
556 | { | 552 | { |
@@ -583,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
583 | 579 | ||
584 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 580 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
585 | { | 581 | { |
586 | if (_parentID != 0 && PhysActor != null) | 582 | PhysicsActor actor = PhysActor; |
583 | if (_parentID != 0 && actor != null) | ||
587 | { | 584 | { |
588 | Vector3 resultingposition = GetWorldPosition(); | 585 | actor.Position = GetWorldPosition(); |
589 | PhysActor.Position = resultingposition; | 586 | actor.Orientation = GetWorldRotation(); |
590 | Quaternion resultingrot = GetWorldRotation(); | ||
591 | PhysActor.Orientation = resultingrot; | ||
592 | 587 | ||
593 | // Tell the physics engines that this prim changed. | 588 | // Tell the physics engines that this prim changed. |
594 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 589 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
595 | } | 590 | } |
596 | } | 591 | } |
597 | } | 592 | } |
@@ -602,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
602 | get | 597 | get |
603 | { | 598 | { |
604 | // 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 |
605 | 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) | ||
606 | { | 602 | { |
607 | if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 | 603 | if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f |
608 | || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) | 604 | || actor.Orientation.Z != 0f || actor.Orientation.W != 0f) |
609 | { | 605 | { |
610 | m_rotationOffset = PhysActor.Orientation; | 606 | m_rotationOffset = actor.Orientation; |
611 | } | 607 | } |
612 | } | 608 | } |
613 | 609 | ||
@@ -619,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
619 | StoreUndoState(); | 615 | StoreUndoState(); |
620 | m_rotationOffset = value; | 616 | m_rotationOffset = value; |
621 | 617 | ||
622 | if (PhysActor != null) | 618 | PhysicsActor actor = PhysActor; |
619 | if (actor != null) | ||
623 | { | 620 | { |
624 | try | 621 | try |
625 | { | 622 | { |
626 | // Root prim gets value directly | 623 | // Root prim gets value directly |
627 | if (_parentID == 0) | 624 | if (_parentID == 0) |
628 | { | 625 | { |
629 | PhysActor.Orientation = value; | 626 | actor.Orientation = value; |
630 | //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); | 627 | //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); |
631 | } | 628 | } |
632 | else | 629 | else |
633 | { | 630 | { |
634 | // Child prim we have to calculate it's world rotationwel | 631 | // Child prim we have to calculate it's world rotationwel |
635 | Quaternion resultingrotation = GetWorldRotation(); | 632 | Quaternion resultingrotation = GetWorldRotation(); |
636 | PhysActor.Orientation = resultingrotation; | 633 | actor.Orientation = resultingrotation; |
637 | //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); | 634 | //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString()); |
638 | } | 635 | } |
639 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 636 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
640 | //} | 637 | //} |
641 | } | 638 | } |
642 | catch (Exception ex) | 639 | catch (Exception ex) |
@@ -653,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
653 | { | 650 | { |
654 | get | 651 | get |
655 | { | 652 | { |
656 | //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 | 653 | PhysicsActor actor = PhysActor; |
657 | //|| PhysActor.Velocity.Z != 0) | 654 | if (actor != null) |
658 | //{ | ||
659 | if (PhysActor != null) | ||
660 | { | 655 | { |
661 | if (PhysActor.IsPhysical) | 656 | if (actor.IsPhysical) |
662 | { | 657 | { |
663 | m_velocity.X = PhysActor.Velocity.X; | 658 | m_velocity = actor.Velocity; |
664 | m_velocity.Y = PhysActor.Velocity.Y; | ||
665 | m_velocity.Z = PhysActor.Velocity.Z; | ||
666 | } | 659 | } |
667 | } | 660 | } |
668 | 661 | ||
@@ -672,12 +665,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
672 | set | 665 | set |
673 | { | 666 | { |
674 | m_velocity = value; | 667 | m_velocity = value; |
675 | if (PhysActor != null) | 668 | |
669 | PhysicsActor actor = PhysActor; | ||
670 | if (actor != null) | ||
676 | { | 671 | { |
677 | if (PhysActor.IsPhysical) | 672 | if (actor.IsPhysical) |
678 | { | 673 | { |
679 | PhysActor.Velocity = value; | 674 | actor.Velocity = value; |
680 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 675 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
681 | } | 676 | } |
682 | } | 677 | } |
683 | } | 678 | } |
@@ -688,9 +683,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
688 | { | 683 | { |
689 | get | 684 | get |
690 | { | 685 | { |
691 | if ((PhysActor != null) && PhysActor.IsPhysical) | 686 | PhysicsActor actor = PhysActor; |
687 | if ((actor != null) && actor.IsPhysical) | ||
692 | { | 688 | { |
693 | m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); | 689 | m_angularVelocity = actor.RotationalVelocity; |
694 | } | 690 | } |
695 | return m_angularVelocity; | 691 | return m_angularVelocity; |
696 | } | 692 | } |
@@ -710,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
710 | set | 706 | set |
711 | { | 707 | { |
712 | m_description = value; | 708 | m_description = value; |
713 | if (PhysActor != null) | 709 | PhysicsActor actor = PhysActor; |
710 | if (actor != null) | ||
714 | { | 711 | { |
715 | PhysActor.SOPDescription = value; | 712 | actor.SOPDescription = value; |
716 | } | 713 | } |
717 | } | 714 | } |
718 | } | 715 | } |
@@ -803,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
803 | set | 800 | set |
804 | { | 801 | { |
805 | StoreUndoState(); | 802 | StoreUndoState(); |
806 | if (m_shape != null) { | 803 | if (m_shape != null) |
807 | m_shape.Scale = value; | ||
808 | |||
809 | if (PhysActor != null && m_parentGroup != null) | ||
810 | { | 804 | { |
811 | if (m_parentGroup.Scene != null) | 805 | m_shape.Scale = value; |
806 | |||
807 | PhysicsActor actor = PhysActor; | ||
808 | if (actor != null && m_parentGroup != null) | ||
812 | { | 809 | { |
813 | if (m_parentGroup.Scene.PhysicsScene != null) | 810 | if (m_parentGroup.Scene != null) |
814 | { | 811 | { |
815 | PhysActor.Size = m_shape.Scale; | 812 | if (m_parentGroup.Scene.PhysicsScene != null) |
816 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 813 | { |
814 | actor.Size = m_shape.Scale; | ||
815 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | ||
816 | } | ||
817 | } | 817 | } |
818 | } | 818 | } |
819 | } | 819 | } |
820 | } | ||
821 | TriggerScriptChangedEvent(Changed.SCALE); | 820 | TriggerScriptChangedEvent(Changed.SCALE); |
822 | } | 821 | } |
823 | } | 822 | } |
@@ -1051,8 +1050,6 @@ if (m_shape != null) { | |||
1051 | 1050 | ||
1052 | #endregion Public Properties with only Get | 1051 | #endregion Public Properties with only Get |
1053 | 1052 | ||
1054 | |||
1055 | |||
1056 | #region Private Methods | 1053 | #region Private Methods |
1057 | 1054 | ||
1058 | private uint ApplyMask(uint val, bool set, uint mask) | 1055 | private uint ApplyMask(uint val, bool set, uint mask) |