diff options
author | Melanie | 2010-03-06 12:37:24 +0000 |
---|---|---|
committer | Melanie | 2010-03-06 12:37:24 +0000 |
commit | 8180c72cbc9cafff247d614ac14db29499fc32a9 (patch) | |
tree | fd92204394e657b805e094a237ffecaf50066df6 /OpenSim/Region/Framework/Scenes/SceneGraph.cs | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.zip opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.gz opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.bz2 opensim-SC-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 133 |
1 files changed, 5 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index cac768e..4e41b07 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -476,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
476 | if (group != null) | 476 | if (group != null) |
477 | { | 477 | { |
478 | //group.DetachToGround(); | 478 | //group.DetachToGround(); |
479 | m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); | 479 | m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
@@ -528,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
528 | return; | 528 | return; |
529 | 529 | ||
530 | // Calls attach with a Zero position | 530 | // Calls attach with a Zero position |
531 | if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) | 531 | if (m_parentScene.AttachmentsModule.AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) |
532 | { | 532 | { |
533 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 533 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
534 | 534 | ||
@@ -571,8 +571,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
571 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) | 571 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) |
572 | tainted = true; | 572 | tainted = true; |
573 | 573 | ||
574 | AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); | 574 | m_parentScene.AttachmentsModule.AttachObject( |
575 | remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); | ||
575 | //objatt.ScheduleGroupForFullUpdate(); | 576 | //objatt.ScheduleGroupForFullUpdate(); |
577 | |||
576 | if (tainted) | 578 | if (tainted) |
577 | objatt.HasGroupChanged = true; | 579 | objatt.HasGroupChanged = true; |
578 | 580 | ||
@@ -596,131 +598,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
596 | return null; | 598 | return null; |
597 | } | 599 | } |
598 | 600 | ||
599 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | ||
600 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | ||
601 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
602 | { | ||
603 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | ||
604 | return; | ||
605 | |||
606 | // We can NOT use the dictionries here, as we are looking | ||
607 | // for an entity by the fromAssetID, which is NOT the prim UUID | ||
608 | // | ||
609 | List<EntityBase> detachEntities = GetEntities(); | ||
610 | SceneObjectGroup group; | ||
611 | |||
612 | foreach (EntityBase entity in detachEntities) | ||
613 | { | ||
614 | if (entity is SceneObjectGroup) | ||
615 | { | ||
616 | group = (SceneObjectGroup)entity; | ||
617 | if (group.GetFromItemID() == itemID) | ||
618 | { | ||
619 | m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero); | ||
620 | bool hasScripts = false; | ||
621 | foreach (SceneObjectPart part in group.Children.Values) | ||
622 | { | ||
623 | if (part.Inventory.ContainsScripts()) | ||
624 | { | ||
625 | hasScripts = true; | ||
626 | break; | ||
627 | } | ||
628 | } | ||
629 | |||
630 | if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event | ||
631 | System.Threading.Thread.Sleep(100); | ||
632 | group.DetachToInventoryPrep(); | ||
633 | m_log.Debug("[DETACH]: Saving attachpoint: " + | ||
634 | ((uint)group.GetAttachmentPoint()).ToString()); | ||
635 | m_parentScene.UpdateKnownItem(remoteClient, group, | ||
636 | group.GetFromItemID(), group.OwnerID); | ||
637 | m_parentScene.DeleteSceneObject(group, false); | ||
638 | return; | ||
639 | } | ||
640 | } | ||
641 | } | ||
642 | } | ||
643 | |||
644 | /// <summary> | ||
645 | /// Attach a scene object to an avatar. | ||
646 | /// </summary> | ||
647 | /// <param name="remoteClient"></param> | ||
648 | /// <param name="objectLocalID"></param> | ||
649 | /// <param name="AttachmentPt"></param> | ||
650 | /// <param name="rot"></param> | ||
651 | /// <param name="attachPos"></param> | ||
652 | /// <param name="silent"></param> | ||
653 | /// <returns>true if the attachment was successful, false otherwise</returns> | ||
654 | protected internal bool AttachObject( | ||
655 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) | ||
656 | { | ||
657 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | ||
658 | if (group != null) | ||
659 | { | ||
660 | if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) | ||
661 | { | ||
662 | // If the attachment point isn't the same as the one previously used | ||
663 | // set it's offset position = 0 so that it appears on the attachment point | ||
664 | // and not in a weird location somewhere unknown. | ||
665 | if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) | ||
666 | { | ||
667 | attachPos = Vector3.Zero; | ||
668 | } | ||
669 | |||
670 | // AttachmentPt 0 means the client chose to 'wear' the attachment. | ||
671 | if (AttachmentPt == 0) | ||
672 | { | ||
673 | // Check object for stored attachment point | ||
674 | AttachmentPt = (uint)group.GetAttachmentPoint(); | ||
675 | } | ||
676 | |||
677 | // if we still didn't find a suitable attachment point....... | ||
678 | if (AttachmentPt == 0) | ||
679 | { | ||
680 | // Stick it on left hand with Zero Offset from the attachment point. | ||
681 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | ||
682 | attachPos = Vector3.Zero; | ||
683 | } | ||
684 | |||
685 | group.SetAttachmentPoint((byte)AttachmentPt); | ||
686 | group.AbsolutePosition = attachPos; | ||
687 | |||
688 | // Saves and gets itemID | ||
689 | UUID itemId; | ||
690 | |||
691 | if (group.GetFromItemID() == UUID.Zero) | ||
692 | { | ||
693 | m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); | ||
694 | } | ||
695 | else | ||
696 | { | ||
697 | itemId = group.GetFromItemID(); | ||
698 | } | ||
699 | |||
700 | m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); | ||
701 | |||
702 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); | ||
703 | // In case it is later dropped again, don't let | ||
704 | // it get cleaned up | ||
705 | // | ||
706 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
707 | group.HasGroupChanged = false; | ||
708 | } | ||
709 | else | ||
710 | { | ||
711 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); | ||
712 | return false; | ||
713 | } | ||
714 | } | ||
715 | else | ||
716 | { | ||
717 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); | ||
718 | return false; | ||
719 | } | ||
720 | |||
721 | return true; | ||
722 | } | ||
723 | |||
724 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) | 601 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |
725 | { | 602 | { |
726 | ScenePresence newAvatar = null; | 603 | ScenePresence newAvatar = null; |