diff options
author | UbitUmarov | 2017-04-25 17:59:53 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-25 17:59:53 +0100 |
commit | a680d8b8d700f78beb1a9eea98b52d59118efe2e (patch) | |
tree | dd084e74fb61400c704a14dcfa8689670acb9ec2 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | Merge branch 'master' into httptests (diff) | |
parent | move mesh pbs creation code out of mesh upload code into to PrimitiveBaseShap... (diff) | |
download | opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.zip opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.gz opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.bz2 opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.xz |
fix merge
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 645 |
1 files changed, 477 insertions, 168 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5928764..e73795e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -117,9 +117,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | NOT_STATUS_ROTATE_Z = 0xF7 | 117 | NOT_STATUS_ROTATE_Z = 0xF7 |
118 | } | 118 | } |
119 | 119 | ||
120 | // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm | ||
121 | public static readonly uint SLAM = 16; | ||
122 | |||
123 | // private PrimCountTaintedDelegate handlerPrimCountTainted = null; | 120 | // private PrimCountTaintedDelegate handlerPrimCountTainted = null; |
124 | 121 | ||
125 | /// <summary> | 122 | /// <summary> |
@@ -156,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | timeLastChanged = DateTime.UtcNow.Ticks; | 153 | timeLastChanged = DateTime.UtcNow.Ticks; |
157 | if (!m_hasGroupChanged) | 154 | if (!m_hasGroupChanged) |
158 | timeFirstChanged = DateTime.UtcNow.Ticks; | 155 | timeFirstChanged = DateTime.UtcNow.Ticks; |
159 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | 156 | if (m_rootPart != null && m_scene != null) |
160 | { | 157 | { |
161 | /* | 158 | /* |
162 | if (m_rand == null) | 159 | if (m_rand == null) |
@@ -379,6 +376,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
379 | public bool m_dupeInProgress = false; | 376 | public bool m_dupeInProgress = false; |
380 | internal Dictionary<UUID, string> m_savedScriptState; | 377 | internal Dictionary<UUID, string> m_savedScriptState; |
381 | 378 | ||
379 | public UUID MonitoringObject { get; set; } | ||
380 | |||
382 | #region Properties | 381 | #region Properties |
383 | 382 | ||
384 | /// <summary> | 383 | /// <summary> |
@@ -539,7 +538,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
539 | 538 | ||
540 | 539 | ||
541 | public bool inTransit = false; | 540 | public bool inTransit = false; |
542 | public delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos); | 541 | private delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos, TeleportObjectData tpData); |
543 | 542 | ||
544 | /// <summary> | 543 | /// <summary> |
545 | /// The absolute position of this scene object in the scene | 544 | /// The absolute position of this scene object in the scene |
@@ -561,7 +560,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
561 | { | 560 | { |
562 | inTransit = true; | 561 | inTransit = true; |
563 | SOGCrossDelegate d = CrossAsync; | 562 | SOGCrossDelegate d = CrossAsync; |
564 | d.BeginInvoke(this, val, CrossAsyncCompleted, d); | 563 | d.BeginInvoke(this, val, null, CrossAsyncCompleted, d); |
565 | } | 564 | } |
566 | return; | 565 | return; |
567 | } | 566 | } |
@@ -602,7 +601,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
602 | av.sitSOGmoved(); | 601 | av.sitSOGmoved(); |
603 | } | 602 | } |
604 | 603 | ||
605 | |||
606 | // now that position is changed tell it to scripts | 604 | // now that position is changed tell it to scripts |
607 | if (triggerScriptEvent) | 605 | if (triggerScriptEvent) |
608 | { | 606 | { |
@@ -618,64 +616,75 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | } | 616 | } |
619 | } | 617 | } |
620 | 618 | ||
621 | public SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val) | 619 | private SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val, TeleportObjectData tpdata) |
622 | { | 620 | { |
623 | Scene sogScene = sog.m_scene; | 621 | Scene sogScene = sog.m_scene; |
624 | IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>(); | 622 | SceneObjectPart root = sog.RootPart; |
625 | 623 | ||
626 | Vector3 newpos = Vector3.Zero; | 624 | bool isTeleport = tpdata != null; |
627 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
628 | 625 | ||
629 | if (sog.RootPart.DIE_AT_EDGE) | 626 | if(!isTeleport) |
630 | { | 627 | { |
631 | try | 628 | if (root.DIE_AT_EDGE) |
632 | { | ||
633 | sogScene.DeleteSceneObject(sog, false); | ||
634 | } | ||
635 | catch (Exception) | ||
636 | { | 629 | { |
637 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); | 630 | try |
631 | { | ||
632 | sogScene.DeleteSceneObject(sog, false); | ||
633 | } | ||
634 | catch (Exception) | ||
635 | { | ||
636 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); | ||
637 | } | ||
638 | return sog; | ||
638 | } | 639 | } |
639 | return sog; | ||
640 | } | ||
641 | 640 | ||
642 | if (sog.RootPart.RETURN_AT_EDGE) | 641 | if (root.RETURN_AT_EDGE) |
643 | { | ||
644 | // We remove the object here | ||
645 | try | ||
646 | { | ||
647 | List<uint> localIDs = new List<uint>(); | ||
648 | localIDs.Add(sog.RootPart.LocalId); | ||
649 | sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition, | ||
650 | "Returned at region cross"); | ||
651 | sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero); | ||
652 | } | ||
653 | catch (Exception) | ||
654 | { | 642 | { |
655 | m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); | 643 | // We remove the object here |
644 | try | ||
645 | { | ||
646 | List<uint> localIDs = new List<uint>(); | ||
647 | localIDs.Add(root.LocalId); | ||
648 | sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition, | ||
649 | "Returned at region cross"); | ||
650 | sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero, false); | ||
651 | } | ||
652 | catch (Exception) | ||
653 | { | ||
654 | m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); | ||
655 | } | ||
656 | return sog; | ||
656 | } | 657 | } |
657 | return sog; | ||
658 | } | 658 | } |
659 | 659 | ||
660 | if (sog.m_rootPart.KeyframeMotion != null) | 660 | if (root.KeyframeMotion != null) |
661 | sog.m_rootPart.KeyframeMotion.StartCrossingCheck(); | 661 | root.KeyframeMotion.StartCrossingCheck(); |
662 | |||
663 | if(root.PhysActor != null) | ||
664 | root.PhysActor.CrossingStart(); | ||
665 | |||
666 | IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>(); | ||
662 | 667 | ||
663 | if (entityTransfer == null) | 668 | if (entityTransfer == null) |
664 | return sog; | 669 | return sog; |
665 | 670 | ||
671 | Vector3 newpos = Vector3.Zero; | ||
672 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
673 | |||
666 | destination = entityTransfer.GetObjectDestination(sog, val, out newpos); | 674 | destination = entityTransfer.GetObjectDestination(sog, val, out newpos); |
667 | if (destination == null) | 675 | if (destination == null) |
668 | return sog; | 676 | return sog; |
669 | 677 | ||
670 | if (sog.m_sittingAvatars.Count == 0) | 678 | if (sog.m_sittingAvatars.Count == 0) |
671 | { | 679 | { |
672 | entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, true); | 680 | entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, !isTeleport, true); |
673 | return sog; | 681 | return sog; |
674 | } | 682 | } |
675 | 683 | ||
676 | string reason = String.Empty; | 684 | string reason = String.Empty; |
677 | EntityTransferContext ctx = new EntityTransferContext(); | 685 | EntityTransferContext ctx = new EntityTransferContext(); |
678 | 686 | ||
687 | Vector3 curPos = root.GroupPosition; | ||
679 | foreach (ScenePresence av in sog.m_sittingAvatars) | 688 | foreach (ScenePresence av in sog.m_sittingAvatars) |
680 | { | 689 | { |
681 | // We need to cross these agents. First, let's find | 690 | // We need to cross these agents. First, let's find |
@@ -686,10 +695,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | 695 | ||
687 | // We set the avatar position as being the object | 696 | // We set the avatar position as being the object |
688 | // position to get the region to send to | 697 | // position to get the region to send to |
698 | if(av.IsNPC) | ||
699 | continue; | ||
700 | |||
701 | if(av.IsInTransit) | ||
702 | return sog; | ||
703 | |||
689 | if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason)) | 704 | if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason)) |
690 | { | ||
691 | return sog; | 705 | return sog; |
692 | } | 706 | |
693 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | 707 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); |
694 | } | 708 | } |
695 | 709 | ||
@@ -697,8 +711,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | // be made to stand up | 711 | // be made to stand up |
698 | 712 | ||
699 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | 713 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); |
700 | 714 | List<ScenePresence> avsToCrossFar = new List<ScenePresence>(); | |
701 | foreach (ScenePresence av in sog.m_sittingAvatars) | 715 | ulong destHandle = destination.RegionHandle; |
716 | List<ScenePresence> sittingAvatars = GetSittingAvatars(); | ||
717 | foreach (ScenePresence av in sittingAvatars) | ||
702 | { | 718 | { |
703 | byte cflags = 1; | 719 | byte cflags = 1; |
704 | 720 | ||
@@ -712,68 +728,175 @@ namespace OpenSim.Region.Framework.Scenes | |||
712 | else | 728 | else |
713 | cflags = 3; | 729 | cflags = 3; |
714 | } | 730 | } |
731 | if(!av.knowsNeighbourRegion(destHandle)) | ||
732 | cflags |= 8; | ||
715 | 733 | ||
716 | // 1 is crossing | 734 | // 1 is crossing |
717 | // 2 is sitting | 735 | // 2 is sitting |
718 | // 4 is sitting at sittarget | 736 | // 4 is sitting at sittarget |
719 | av.crossingFlags = cflags; | 737 | // 8 far crossing |
720 | 738 | ||
721 | avinfo.av = av; | 739 | avinfo.av = av; |
722 | avinfo.ParentID = av.ParentID; | 740 | avinfo.ParentID = av.ParentID; |
723 | avsToCross.Add(avinfo); | 741 | avsToCross.Add(avinfo); |
724 | 742 | ||
743 | if(!av.knowsNeighbourRegion(destHandle)) | ||
744 | { | ||
745 | cflags |= 8; | ||
746 | avsToCrossFar.Add(av); | ||
747 | } | ||
748 | |||
749 | if(av.IsNPC) | ||
750 | av.crossingFlags = 0; | ||
751 | else | ||
752 | av.crossingFlags = cflags; | ||
753 | |||
725 | av.PrevSitOffset = av.OffsetPosition; | 754 | av.PrevSitOffset = av.OffsetPosition; |
726 | av.ParentID = 0; | 755 | av.ParentID = 0; |
727 | } | 756 | } |
728 | 757 | ||
758 | Vector3 vel = root.Velocity; | ||
759 | Vector3 avel = root.AngularVelocity; | ||
760 | Vector3 acc = root.Acceleration; | ||
761 | Quaternion ori = root.RotationOffset; | ||
762 | |||
763 | if(isTeleport) | ||
764 | { | ||
765 | root.Stop(); | ||
766 | sogScene.ForEachScenePresence(delegate(ScenePresence av) | ||
767 | { | ||
768 | av.ControllingClient.SendEntityUpdate(root,PrimUpdateFlags.SendInTransit); | ||
769 | av.ControllingClient.SendEntityTerseUpdateImmediate(root); | ||
770 | }); | ||
771 | |||
772 | root.Velocity = tpdata.vel; | ||
773 | root.AngularVelocity = tpdata.avel; | ||
774 | root.Acceleration = tpdata.acc; | ||
775 | root.RotationOffset = tpdata.ori; | ||
776 | } | ||
777 | |||
729 | if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false)) | 778 | if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false)) |
730 | { | 779 | { |
780 | if(isTeleport) | ||
781 | { | ||
782 | sogScene.ForEachScenePresence(delegate(ScenePresence oav) | ||
783 | { | ||
784 | if(sittingAvatars.Contains(oav)) | ||
785 | return; | ||
786 | if(oav.knowsNeighbourRegion(destHandle)) | ||
787 | return; | ||
788 | oav.ControllingClient.SendEntityUpdate(root, PrimUpdateFlags.Kill); | ||
789 | foreach (ScenePresence sav in sittingAvatars) | ||
790 | { | ||
791 | sav.SendKillTo(oav); | ||
792 | } | ||
793 | }); | ||
794 | } | ||
795 | bool crossedfar = false; | ||
796 | foreach (ScenePresence av in avsToCrossFar) | ||
797 | { | ||
798 | if(entityTransfer.CrossAgentCreateFarChild(av,destination, newpos, ctx)) | ||
799 | crossedfar = true; | ||
800 | else | ||
801 | av.crossingFlags = 0; | ||
802 | } | ||
803 | |||
804 | if(crossedfar) | ||
805 | Thread.Sleep(1000); | ||
806 | |||
731 | foreach (avtocrossInfo avinfo in avsToCross) | 807 | foreach (avtocrossInfo avinfo in avsToCross) |
732 | { | 808 | { |
733 | ScenePresence av = avinfo.av; | 809 | ScenePresence av = avinfo.av; |
734 | if (!av.IsInTransit) // just in case... | 810 | av.IsInTransit = true; |
735 | { | 811 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); |
736 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
737 | 812 | ||
738 | av.IsInTransit = true; | 813 | if(av.crossingFlags > 0) |
814 | entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, false, ctx); | ||
739 | 815 | ||
740 | // CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | 816 | if (av.IsChildAgent) |
741 | // d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | 817 | { |
742 | entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, ctx); | 818 | // avatar crossed do some extra cleanup |
743 | if (av.IsChildAgent) | 819 | if (av.ParentUUID != UUID.Zero) |
744 | { | ||
745 | // avatar crossed do some extra cleanup | ||
746 | if (av.ParentUUID != UUID.Zero) | ||
747 | { | ||
748 | av.ClearControls(); | ||
749 | av.ParentPart = null; | ||
750 | } | ||
751 | } | ||
752 | else | ||
753 | { | 820 | { |
754 | // avatar cross failed we need do dedicated standUp | 821 | av.ClearControls(); |
755 | // part of it was done at CrossAgentToNewRegionAsync | 822 | av.ParentPart = null; |
756 | // so for now just remove the sog controls | ||
757 | // this may need extra care | ||
758 | av.UnRegisterSeatControls(sog.UUID); | ||
759 | } | 823 | } |
760 | |||
761 | av.ParentUUID = UUID.Zero; | 824 | av.ParentUUID = UUID.Zero; |
825 | av.ParentPart = null; | ||
762 | // In any case | 826 | // In any case |
763 | av.IsInTransit = false; | 827 | av.IsInTransit = false; |
764 | av.crossingFlags = 0; | 828 | av.crossingFlags = 0; |
765 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname); | 829 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname); |
766 | } | 830 | } |
767 | else | 831 | else |
768 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val); | 832 | { |
833 | // avatar cross failed we need do dedicated standUp | ||
834 | // part of it was done at CrossAgentToNewRegionAsync | ||
835 | // so for now just remove the sog controls | ||
836 | // this may need extra care | ||
837 | av.UnRegisterSeatControls(sog.UUID); | ||
838 | av.ParentUUID = UUID.Zero; | ||
839 | av.ParentPart = null; | ||
840 | Vector3 oldp = curPos; | ||
841 | oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); | ||
842 | oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); | ||
843 | av.AbsolutePosition = oldp; | ||
844 | av.crossingFlags = 0; | ||
845 | av.sitAnimation = "SIT"; | ||
846 | av.IsInTransit = false; | ||
847 | if(av.Animator!= null) | ||
848 | av.Animator.SetMovementAnimations("STAND"); | ||
849 | av.AddToPhysicalScene(false); | ||
850 | sogScene.ForEachScenePresence(delegate(ScenePresence oav) | ||
851 | { | ||
852 | if(sittingAvatars.Contains(oav)) | ||
853 | return; | ||
854 | if(oav.knowsNeighbourRegion(destHandle)) | ||
855 | av.SendAvatarDataToAgent(oav); | ||
856 | else | ||
857 | { | ||
858 | av.SendAvatarDataToAgent(oav); | ||
859 | av.SendAppearanceToAgent(oav); | ||
860 | if (av.Animator != null) | ||
861 | av.Animator.SendAnimPackToClient(oav.ControllingClient); | ||
862 | av.SendAttachmentsToAgentNF(oav); // not ok | ||
863 | } | ||
864 | }); | ||
865 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} failed.", av.Firstname, av.Lastname); | ||
866 | } | ||
769 | } | 867 | } |
868 | |||
869 | if(crossedfar) | ||
870 | { | ||
871 | Thread.Sleep(10000); | ||
872 | foreach (ScenePresence av in avsToCrossFar) | ||
873 | { | ||
874 | if(av.IsChildAgent) | ||
875 | { | ||
876 | av.Scene.CloseAgent(av.UUID, false); | ||
877 | } | ||
878 | else | ||
879 | av.RemoveNeighbourRegion(destHandle); | ||
880 | } | ||
881 | } | ||
882 | avsToCrossFar.Clear(); | ||
770 | avsToCross.Clear(); | 883 | avsToCross.Clear(); |
771 | sog.RemoveScriptInstances(true); | 884 | sog.RemoveScriptInstances(true); |
772 | sog.Clear(); | 885 | sog.Clear(); |
773 | return sog; | 886 | return sog; |
774 | } | 887 | } |
775 | else // cross failed, put avas back ?? | 888 | else |
776 | { | 889 | { |
890 | if(isTeleport) | ||
891 | { | ||
892 | if((tpdata.flags & OSTPOBJ_STOPONFAIL) == 0) | ||
893 | { | ||
894 | root.Velocity = vel; | ||
895 | root.AngularVelocity = avel; | ||
896 | root.Acceleration = acc; | ||
897 | } | ||
898 | root.RotationOffset = ori; | ||
899 | } | ||
777 | foreach (avtocrossInfo avinfo in avsToCross) | 900 | foreach (avtocrossInfo avinfo in avsToCross) |
778 | { | 901 | { |
779 | ScenePresence av = avinfo.av; | 902 | ScenePresence av = avinfo.av; |
@@ -783,7 +906,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
783 | } | 906 | } |
784 | } | 907 | } |
785 | avsToCross.Clear(); | 908 | avsToCross.Clear(); |
786 | |||
787 | return sog; | 909 | return sog; |
788 | } | 910 | } |
789 | 911 | ||
@@ -795,11 +917,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
795 | if (!sog.IsDeleted) | 917 | if (!sog.IsDeleted) |
796 | { | 918 | { |
797 | SceneObjectPart rootp = sog.m_rootPart; | 919 | SceneObjectPart rootp = sog.m_rootPart; |
920 | |||
798 | Vector3 oldp = rootp.GroupPosition; | 921 | Vector3 oldp = rootp.GroupPosition; |
799 | oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); | 922 | oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); |
800 | oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); | 923 | oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); |
801 | rootp.GroupPosition = oldp; | 924 | rootp.GroupPosition = oldp; |
802 | 925 | ||
926 | rootp.Stop(); | ||
927 | |||
803 | SceneObjectPart[] parts = sog.m_parts.GetArray(); | 928 | SceneObjectPart[] parts = sog.m_parts.GetArray(); |
804 | 929 | ||
805 | foreach (SceneObjectPart part in parts) | 930 | foreach (SceneObjectPart part in parts) |
@@ -813,47 +938,150 @@ namespace OpenSim.Region.Framework.Scenes | |||
813 | av.sitSOGmoved(); | 938 | av.sitSOGmoved(); |
814 | } | 939 | } |
815 | 940 | ||
816 | sog.Velocity = Vector3.Zero; | ||
817 | |||
818 | if (sog.m_rootPart.KeyframeMotion != null) | 941 | if (sog.m_rootPart.KeyframeMotion != null) |
819 | sog.m_rootPart.KeyframeMotion.CrossingFailure(); | 942 | sog.m_rootPart.KeyframeMotion.CrossingFailure(); |
820 | 943 | ||
821 | if (sog.RootPart.PhysActor != null) | 944 | if (sog.RootPart.PhysActor != null) |
822 | { | ||
823 | sog.RootPart.PhysActor.CrossingFailure(); | 945 | sog.RootPart.PhysActor.CrossingFailure(); |
824 | } | ||
825 | 946 | ||
826 | sog.inTransit = false; | 947 | sog.inTransit = false; |
948 | AttachToBackup(); | ||
827 | sog.ScheduleGroupForFullUpdate(); | 949 | sog.ScheduleGroupForFullUpdate(); |
828 | } | 950 | } |
829 | } | 951 | } |
830 | 952 | ||
831 | /* outdated | 953 | private class TeleportObjectData |
832 | private void CrossAgentToNewRegionCompleted(ScenePresence agent) | ||
833 | { | 954 | { |
834 | //// If the cross was successful, this agent is a child agent | 955 | public int flags; |
835 | if (agent.IsChildAgent) | 956 | public Vector3 vel; |
957 | public Vector3 avel; | ||
958 | public Vector3 acc; | ||
959 | public Quaternion ori; | ||
960 | public UUID sourceID; | ||
961 | } | ||
962 | |||
963 | // copy from LSL_constants.cs | ||
964 | const int OSTPOBJ_STOPATTARGET = 0x1; // stops at destination | ||
965 | const int OSTPOBJ_STOPONFAIL = 0x2; // stops at start if tp fails | ||
966 | const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation | ||
967 | |||
968 | public int TeleportObject(UUID sourceID, Vector3 targetPosition, Quaternion rotation, int flags) | ||
969 | { | ||
970 | if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null) | ||
971 | return -1; | ||
972 | |||
973 | inTransit = true; | ||
974 | |||
975 | PhysicsActor pa = RootPart.PhysActor; | ||
976 | if(pa == null || RootPart.KeyframeMotion != null /*|| m_sittingAvatars.Count == 0*/) | ||
836 | { | 977 | { |
837 | if (agent.ParentUUID != UUID.Zero) | 978 | inTransit = false; |
979 | return -1; | ||
980 | } | ||
981 | |||
982 | bool stop = (flags & OSTPOBJ_STOPATTARGET) != 0; | ||
983 | bool setrot = (flags & OSTPOBJ_SETROT) != 0; | ||
984 | |||
985 | rotation.Normalize(); | ||
986 | |||
987 | Quaternion currentRot = RootPart.RotationOffset; | ||
988 | if(setrot) | ||
989 | rotation = Quaternion.Conjugate(currentRot) * rotation; | ||
990 | |||
991 | bool dorot = setrot | (Math.Abs(rotation.W) < 0.99999); | ||
992 | |||
993 | Vector3 vel = Vector3.Zero; | ||
994 | Vector3 avel = Vector3.Zero; | ||
995 | Vector3 acc = Vector3.Zero; | ||
996 | |||
997 | if(!stop) | ||
998 | { | ||
999 | vel = RootPart.Velocity; | ||
1000 | avel = RootPart.AngularVelocity; | ||
1001 | acc = RootPart.Acceleration; | ||
1002 | } | ||
1003 | Quaternion ori = RootPart.RotationOffset; | ||
1004 | |||
1005 | if(dorot) | ||
1006 | { | ||
1007 | if(!stop) | ||
838 | { | 1008 | { |
839 | agent.HandleForceReleaseControls(agent.ControllingClient,agent.UUID); | 1009 | vel *= rotation; |
840 | agent.ParentPart = null; | 1010 | avel *= rotation; |
841 | // agent.ParentPosition = Vector3.Zero; | 1011 | acc *= rotation; |
842 | // agent.ParentUUID = UUID.Zero; | ||
843 | } | 1012 | } |
1013 | ori *= rotation; | ||
844 | } | 1014 | } |
845 | 1015 | ||
846 | agent.ParentUUID = UUID.Zero; | 1016 | if(Scene.PositionIsInCurrentRegion(targetPosition)) |
847 | // agent.Reset(); | 1017 | { |
848 | // else // Not successful | 1018 | if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 1.0)) |
849 | // agent.RestoreInCurrentScene(); | 1019 | { |
1020 | inTransit = false; | ||
1021 | return -2; | ||
1022 | } | ||
850 | 1023 | ||
851 | // In any case | 1024 | Vector3 curPos = AbsolutePosition; |
852 | agent.IsInTransit = false; | 1025 | ILandObject curLand = Scene.LandChannel.GetLandObject(curPos.X, curPos.Y); |
1026 | float posX = targetPosition.X; | ||
1027 | float posY = targetPosition.Y; | ||
1028 | ILandObject land = Scene.LandChannel.GetLandObject(posX, posY); | ||
1029 | if(land != null && land != curLand) | ||
1030 | { | ||
1031 | if(!Scene.Permissions.CanObjectEnterWithScripts(this, land)) | ||
1032 | { | ||
1033 | inTransit = false; | ||
1034 | return -3; | ||
1035 | } | ||
1036 | |||
1037 | UUID agentID; | ||
1038 | foreach (ScenePresence av in m_sittingAvatars) | ||
1039 | { | ||
1040 | agentID = av.UUID; | ||
1041 | if(land.IsRestrictedFromLand(agentID) || land.IsBannedFromLand(agentID)) | ||
1042 | { | ||
1043 | inTransit = false; | ||
1044 | return -4; | ||
1045 | } | ||
1046 | } | ||
1047 | } | ||
1048 | |||
1049 | RootPart.Velocity = vel; | ||
1050 | RootPart.AngularVelocity = avel; | ||
1051 | RootPart.Acceleration = acc; | ||
1052 | RootPart.RotationOffset = ori; | ||
1053 | |||
1054 | Vector3 s = RootPart.Scale * RootPart.RotationOffset; | ||
1055 | float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; | ||
1056 | if(targetPosition.Z < h) | ||
1057 | targetPosition.Z = h; | ||
1058 | |||
1059 | inTransit = false; | ||
1060 | AbsolutePosition = targetPosition; | ||
1061 | RootPart.ScheduleTerseUpdate(); | ||
1062 | return 1; | ||
1063 | } | ||
1064 | |||
1065 | if(Scene.InTeleportTargetsCoolDown(UUID, sourceID, 20.0)) | ||
1066 | { | ||
1067 | inTransit = false; | ||
1068 | return -1; | ||
1069 | } | ||
853 | 1070 | ||
854 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | 1071 | TeleportObjectData tdata = new TeleportObjectData(); |
1072 | tdata.flags = flags; | ||
1073 | tdata.vel = vel; | ||
1074 | tdata.avel = avel; | ||
1075 | tdata.acc = acc; | ||
1076 | tdata.ori = ori; | ||
1077 | tdata.sourceID = sourceID; | ||
1078 | |||
1079 | |||
1080 | SOGCrossDelegate d = CrossAsync; | ||
1081 | d.BeginInvoke(this, targetPosition, tdata, CrossAsyncCompleted, d); | ||
1082 | return 0; | ||
855 | } | 1083 | } |
856 | */ | 1084 | |
857 | public override Vector3 Velocity | 1085 | public override Vector3 Velocity |
858 | { | 1086 | { |
859 | get { return RootPart.Velocity; } | 1087 | get { return RootPart.Velocity; } |
@@ -1786,63 +2014,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1786 | } | 2014 | } |
1787 | } | 2015 | } |
1788 | 2016 | ||
1789 | /// <summary> | ||
1790 | /// Attach this scene object to the given avatar. | ||
1791 | /// </summary> | ||
1792 | /// <param name="agentID"></param> | ||
1793 | /// <param name="attachmentpoint"></param> | ||
1794 | /// <param name="AttachOffset"></param> | ||
1795 | private void AttachToAgent( | ||
1796 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1797 | { | ||
1798 | if (avatar != null) | ||
1799 | { | ||
1800 | // don't attach attachments to child agents | ||
1801 | if (avatar.IsChildAgent) return; | ||
1802 | |||
1803 | // Remove from database and parcel prim count | ||
1804 | m_scene.DeleteFromStorage(so.UUID); | ||
1805 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1806 | |||
1807 | so.AttachedAvatar = avatar.UUID; | ||
1808 | |||
1809 | if (so.RootPart.PhysActor != null) | ||
1810 | { | ||
1811 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1812 | so.RootPart.PhysActor = null; | ||
1813 | } | ||
1814 | |||
1815 | so.AbsolutePosition = attachOffset; | ||
1816 | so.RootPart.AttachedPos = attachOffset; | ||
1817 | so.IsAttachment = true; | ||
1818 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1819 | so.AttachmentPoint = attachmentpoint; | ||
1820 | |||
1821 | avatar.AddAttachment(this); | ||
1822 | |||
1823 | if (!silent) | ||
1824 | { | ||
1825 | // Killing it here will cause the client to deselect it | ||
1826 | // It then reappears on the avatar, deselected | ||
1827 | // through the full update below | ||
1828 | // | ||
1829 | if (IsSelected) | ||
1830 | { | ||
1831 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1832 | } | ||
1833 | |||
1834 | IsSelected = false; // fudge.... | ||
1835 | ScheduleGroupForFullUpdate(); | ||
1836 | } | ||
1837 | } | ||
1838 | else | ||
1839 | { | ||
1840 | m_log.WarnFormat( | ||
1841 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1842 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1843 | } | ||
1844 | } | ||
1845 | |||
1846 | public byte GetAttachmentPoint() | 2017 | public byte GetAttachmentPoint() |
1847 | { | 2018 | { |
1848 | return m_rootPart.Shape.State; | 2019 | return m_rootPart.Shape.State; |
@@ -1957,6 +2128,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1957 | 2128 | ||
1958 | if (part.LinkNum == 2) | 2129 | if (part.LinkNum == 2) |
1959 | RootPart.LinkNum = 1; | 2130 | RootPart.LinkNum = 1; |
2131 | InvalidatePartsLinkMaps(); | ||
1960 | } | 2132 | } |
1961 | 2133 | ||
1962 | /// <summary> | 2134 | /// <summary> |
@@ -2233,7 +2405,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2233 | { | 2405 | { |
2234 | if (part.OwnerID != userId) | 2406 | if (part.OwnerID != userId) |
2235 | { | 2407 | { |
2236 | part.LastOwnerID = part.OwnerID; | 2408 | if(part.GroupID != part.OwnerID) |
2409 | part.LastOwnerID = part.OwnerID; | ||
2237 | part.OwnerID = userId; | 2410 | part.OwnerID = userId; |
2238 | } | 2411 | } |
2239 | }); | 2412 | }); |
@@ -2313,7 +2486,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2313 | RootPart.UUID); | 2486 | RootPart.UUID); |
2314 | m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn"); | 2487 | m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn"); |
2315 | m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, | 2488 | m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, |
2316 | DeRezAction.Return, UUID.Zero); | 2489 | DeRezAction.Return, UUID.Zero, false); |
2317 | 2490 | ||
2318 | return; | 2491 | return; |
2319 | } | 2492 | } |
@@ -2443,17 +2616,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2443 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2616 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
2444 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2617 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2445 | 2618 | ||
2446 | |||
2447 | if (userExposed) | 2619 | if (userExposed) |
2448 | dupe.m_rootPart.TrimPermissions(); | 2620 | dupe.m_rootPart.TrimPermissions(); |
2449 | 2621 | ||
2450 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2622 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
2451 | 2623 | ||
2452 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2624 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
2453 | { | 2625 | { |
2454 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2626 | return p1.LinkNum.CompareTo(p2.LinkNum); |
2455 | } | 2627 | } |
2456 | ); | 2628 | ); |
2457 | 2629 | ||
2458 | foreach (SceneObjectPart part in partList) | 2630 | foreach (SceneObjectPart part in partList) |
2459 | { | 2631 | { |
@@ -2505,12 +2677,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2505 | if (dupe.m_rootPart.PhysActor != null) | 2677 | if (dupe.m_rootPart.PhysActor != null) |
2506 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | 2678 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building |
2507 | 2679 | ||
2680 | dupe.AggregateDeepPerms(); | ||
2681 | |||
2508 | dupe.HasGroupChanged = true; | 2682 | dupe.HasGroupChanged = true; |
2509 | dupe.AttachToBackup(); | 2683 | dupe.AttachToBackup(); |
2510 | 2684 | ||
2511 | ScheduleGroupForFullUpdate(); | 2685 | dupe.ScheduleGroupForFullUpdate(); |
2512 | } | 2686 | } |
2513 | 2687 | ||
2688 | dupe.InvalidatePartsLinkMaps(); | ||
2514 | m_dupeInProgress = false; | 2689 | m_dupeInProgress = false; |
2515 | return dupe; | 2690 | return dupe; |
2516 | } | 2691 | } |
@@ -2746,25 +2921,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2746 | } | 2921 | } |
2747 | 2922 | ||
2748 | /// <summary> | 2923 | /// <summary> |
2749 | /// Set the owner of the root part. | 2924 | /// Set the owner of all linkset. |
2750 | /// </summary> | 2925 | /// </summary> |
2751 | /// <param name="part"></param> | ||
2752 | /// <param name="cAgentID"></param> | 2926 | /// <param name="cAgentID"></param> |
2753 | /// <param name="cGroupID"></param> | 2927 | /// <param name="cGroupID"></param> |
2754 | public void SetRootPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) | 2928 | public void SetOwner(UUID cAgentID, UUID cGroupID) |
2755 | { | 2929 | { |
2756 | part.LastOwnerID = part.OwnerID; | 2930 | SceneObjectPart rpart = RootPart; |
2757 | part.OwnerID = cAgentID; | 2931 | UUID oldowner = rpart.OwnerID; |
2758 | part.GroupID = cGroupID; | 2932 | ForEachPart(delegate(SceneObjectPart part) |
2933 | { | ||
2934 | if(part.GroupID != part.OwnerID) | ||
2935 | part.LastOwnerID = part.OwnerID; | ||
2936 | part.OwnerID = cAgentID; | ||
2937 | part.GroupID = cGroupID; | ||
2938 | }); | ||
2759 | 2939 | ||
2760 | if (part.OwnerID != cAgentID) | 2940 | if (oldowner != cAgentID) |
2761 | { | 2941 | { |
2762 | // Apply Next Owner Permissions if we're not bypassing permissions | 2942 | // Apply Next Owner Permissions if we're not bypassing permissions |
2763 | if (!m_scene.Permissions.BypassPermissions()) | 2943 | if (!m_scene.Permissions.BypassPermissions()) |
2944 | { | ||
2764 | ApplyNextOwnerPermissions(); | 2945 | ApplyNextOwnerPermissions(); |
2946 | AggregatePerms(); | ||
2947 | } | ||
2765 | } | 2948 | } |
2766 | 2949 | ||
2767 | part.ScheduleFullUpdate(); | 2950 | rpart.ScheduleFullUpdate(); |
2768 | } | 2951 | } |
2769 | 2952 | ||
2770 | /// <summary> | 2953 | /// <summary> |
@@ -3264,6 +3447,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3264 | ResetChildPrimPhysicsPositions(); | 3447 | ResetChildPrimPhysicsPositions(); |
3265 | 3448 | ||
3266 | InvalidBoundsRadius(); | 3449 | InvalidBoundsRadius(); |
3450 | InvalidatePartsLinkMaps(); | ||
3267 | 3451 | ||
3268 | if (m_rootPart.PhysActor != null) | 3452 | if (m_rootPart.PhysActor != null) |
3269 | m_rootPart.PhysActor.Building = false; | 3453 | m_rootPart.PhysActor.Building = false; |
@@ -3420,6 +3604,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3420 | objectGroup.HasGroupChangedDueToDelink = true; | 3604 | objectGroup.HasGroupChangedDueToDelink = true; |
3421 | 3605 | ||
3422 | InvalidBoundsRadius(); | 3606 | InvalidBoundsRadius(); |
3607 | InvalidatePartsLinkMaps(); | ||
3608 | objectGroup.AggregatePerms(); | ||
3423 | 3609 | ||
3424 | if (sendEvents) | 3610 | if (sendEvents) |
3425 | linkPart.TriggerScriptChangedEvent(Changed.LINK); | 3611 | linkPart.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3958,8 +4144,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3958 | 4144 | ||
3959 | public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive) | 4145 | public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive) |
3960 | { | 4146 | { |
3961 | uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff8; // Mask folded bits | 4147 | uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff0; // Mask folded bits |
3962 | uint foldedPerms = RootPart.OwnerMask & 3; | 4148 | uint foldedPerms = RootPart.OwnerMask & (uint)PermissionMask.FoldedMask; |
3963 | 4149 | ||
3964 | ForEachPart(part => | 4150 | ForEachPart(part => |
3965 | { | 4151 | { |
@@ -3970,14 +4156,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3970 | part.Inventory.ApplyGodPermissions(part.BaseMask); | 4156 | part.Inventory.ApplyGodPermissions(part.BaseMask); |
3971 | }); | 4157 | }); |
3972 | 4158 | ||
3973 | uint lockMask = ~(uint)(PermissionMask.Move | PermissionMask.Modify); | 4159 | uint lockMask = ~(uint)(PermissionMask.Move); |
3974 | uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move | PermissionMask.Modify); | 4160 | uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move); |
3975 | RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); | 4161 | RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); |
3976 | 4162 | ||
3977 | // m_log.DebugFormat( | 4163 | // m_log.DebugFormat( |
3978 | // "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}", | 4164 | // "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}", |
3979 | // (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name); | 4165 | // (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name); |
3980 | 4166 | AggregatePerms(); | |
3981 | RootPart.ScheduleFullUpdate(); | 4167 | RootPart.ScheduleFullUpdate(); |
3982 | } | 4168 | } |
3983 | 4169 | ||
@@ -4002,6 +4188,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4002 | { | 4188 | { |
4003 | foreach (SceneObjectPart part in Parts) | 4189 | foreach (SceneObjectPart part in Parts) |
4004 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | 4190 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); |
4191 | AggregatePerms(); | ||
4005 | } | 4192 | } |
4006 | 4193 | ||
4007 | HasGroupChanged = true; | 4194 | HasGroupChanged = true; |
@@ -4647,7 +4834,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4647 | } | 4834 | } |
4648 | if ((change & ObjectChangeType.Position) != 0) | 4835 | if ((change & ObjectChangeType.Position) != 0) |
4649 | { | 4836 | { |
4650 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | 4837 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group, false, data.position)) |
4651 | UpdateGroupPosition(data.position); | 4838 | UpdateGroupPosition(data.position); |
4652 | updateType = updatetype.groupterse; | 4839 | updateType = updatetype.groupterse; |
4653 | } | 4840 | } |
@@ -5056,6 +5243,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
5056 | return Ptot; | 5243 | return Ptot; |
5057 | } | 5244 | } |
5058 | 5245 | ||
5246 | public void GetInertiaData(out float TotalMass, out Vector3 CenterOfMass, out Vector3 Inertia, out Vector4 aux ) | ||
5247 | { | ||
5248 | PhysicsActor pa = RootPart.PhysActor; | ||
5249 | |||
5250 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
5251 | { | ||
5252 | PhysicsInertiaData inertia; | ||
5253 | |||
5254 | inertia = pa.GetInertiaData(); | ||
5255 | |||
5256 | TotalMass = inertia.TotalMass; | ||
5257 | CenterOfMass = inertia.CenterOfMass; | ||
5258 | Inertia = inertia.Inertia; | ||
5259 | aux = inertia.InertiaRotation; | ||
5260 | |||
5261 | return; | ||
5262 | } | ||
5263 | |||
5264 | TotalMass = GetMass(); | ||
5265 | CenterOfMass = GetCenterOfMass() - AbsolutePosition; | ||
5266 | CenterOfMass *= Quaternion.Conjugate(RootPart.RotationOffset); | ||
5267 | Inertia = Vector3.Zero; | ||
5268 | aux = Vector4.Zero; | ||
5269 | } | ||
5270 | |||
5271 | public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux ) | ||
5272 | { | ||
5273 | PhysicsInertiaData inertia = new PhysicsInertiaData(); | ||
5274 | inertia.TotalMass = TotalMass; | ||
5275 | inertia.CenterOfMass = CenterOfMass; | ||
5276 | inertia.Inertia = Inertia; | ||
5277 | inertia.InertiaRotation = aux; | ||
5278 | |||
5279 | if(TotalMass < 0) | ||
5280 | RootPart.PhysicsInertia = null; | ||
5281 | else | ||
5282 | RootPart.PhysicsInertia = new PhysicsInertiaData(inertia); | ||
5283 | |||
5284 | PhysicsActor pa = RootPart.PhysActor; | ||
5285 | if(pa !=null) | ||
5286 | pa.SetInertiaData(inertia); | ||
5287 | } | ||
5288 | |||
5059 | /// <summary> | 5289 | /// <summary> |
5060 | /// Set the user group to which this scene object belongs. | 5290 | /// Set the user group to which this scene object belongs. |
5061 | /// </summary> | 5291 | /// </summary> |
@@ -5217,6 +5447,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5217 | { | 5447 | { |
5218 | part.ResetOwnerChangeFlag(); | 5448 | part.ResetOwnerChangeFlag(); |
5219 | }); | 5449 | }); |
5450 | AggregatePerms(); | ||
5220 | } | 5451 | } |
5221 | 5452 | ||
5222 | // clear some references to easy cg | 5453 | // clear some references to easy cg |
@@ -5230,6 +5461,84 @@ namespace OpenSim.Region.Framework.Scenes | |||
5230 | m_PlaySoundSlavePrims.Clear(); | 5461 | m_PlaySoundSlavePrims.Clear(); |
5231 | m_LoopSoundMasterPrim = null; | 5462 | m_LoopSoundMasterPrim = null; |
5232 | m_targets.Clear(); | 5463 | m_targets.Clear(); |
5464 | m_partsNameToLinkMap.Clear(); | ||
5465 | } | ||
5466 | |||
5467 | private Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>(); | ||
5468 | private string GetLinkNumber_lastname; | ||
5469 | private int GetLinkNumber_lastnumber; | ||
5470 | |||
5471 | // this scales bad but so does GetLinkNumPart | ||
5472 | public int GetLinkNumber(string name) | ||
5473 | { | ||
5474 | if(String.IsNullOrEmpty(name) || name == "Object") | ||
5475 | return -1; | ||
5476 | |||
5477 | lock(m_partsNameToLinkMap) | ||
5478 | { | ||
5479 | if(m_partsNameToLinkMap.Count == 0) | ||
5480 | { | ||
5481 | GetLinkNumber_lastname = String.Empty; | ||
5482 | GetLinkNumber_lastnumber = -1; | ||
5483 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
5484 | for (int i = 0; i < parts.Length; i++) | ||
5485 | { | ||
5486 | string s = parts[i].Name; | ||
5487 | if(String.IsNullOrEmpty(s) || s == "Object" || s == "Primitive") | ||
5488 | continue; | ||
5489 | |||
5490 | if(m_partsNameToLinkMap.ContainsKey(s)) | ||
5491 | { | ||
5492 | int ol = parts[i].LinkNum; | ||
5493 | if(ol < m_partsNameToLinkMap[s]) | ||
5494 | m_partsNameToLinkMap[s] = ol; | ||
5495 | } | ||
5496 | else | ||
5497 | m_partsNameToLinkMap[s] = parts[i].LinkNum; | ||
5498 | } | ||
5499 | } | ||
5500 | |||
5501 | if(name == GetLinkNumber_lastname) | ||
5502 | return GetLinkNumber_lastnumber; | ||
5503 | |||
5504 | if(m_partsNameToLinkMap.ContainsKey(name)) | ||
5505 | { | ||
5506 | lock(m_partsNameToLinkMap) | ||
5507 | { | ||
5508 | GetLinkNumber_lastname = name; | ||
5509 | GetLinkNumber_lastnumber = m_partsNameToLinkMap[name]; | ||
5510 | return GetLinkNumber_lastnumber; | ||
5511 | } | ||
5512 | } | ||
5513 | } | ||
5514 | |||
5515 | if(m_sittingAvatars.Count > 0) | ||
5516 | { | ||
5517 | int j = m_parts.Count + 1; | ||
5518 | |||
5519 | ScenePresence[] avs = m_sittingAvatars.ToArray(); | ||
5520 | for (int i = 0; i < avs.Length; i++, j++) | ||
5521 | { | ||
5522 | if (avs[i].Name == name) | ||
5523 | { | ||
5524 | GetLinkNumber_lastname = name; | ||
5525 | GetLinkNumber_lastnumber = j; | ||
5526 | return j; | ||
5527 | } | ||
5528 | } | ||
5529 | } | ||
5530 | |||
5531 | return -1; | ||
5532 | } | ||
5533 | |||
5534 | public void InvalidatePartsLinkMaps() | ||
5535 | { | ||
5536 | lock(m_partsNameToLinkMap) | ||
5537 | { | ||
5538 | m_partsNameToLinkMap.Clear(); | ||
5539 | GetLinkNumber_lastname = String.Empty; | ||
5540 | GetLinkNumber_lastnumber = -1; | ||
5541 | } | ||
5233 | } | 5542 | } |
5234 | 5543 | ||
5235 | #endregion | 5544 | #endregion |