コード例 #1
0
        public static CoalescedObjectSnapshot FromCoalescedObject(CoalescedObject csog, SerializationFlags flags)
        {
            List<Tuple<SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot>> snapGroups
                = new List<Tuple<SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot>>();

            foreach (var group in csog.Groups)
            {
                snapGroups.Add(
                    new Tuple<SceneObjectGroupSnapshot, ItemPermissionBlockSnapshot>(
                        SceneObjectGroupSnapshot.FromSceneObjectGroup(group, flags),
                        ItemPermissionBlockSnapshot.FromItemPermissionBlock(csog.FindPermissions(group.UUID)))
                    );
            }

            return new CoalescedObjectSnapshot { GroupsWithPermissions = snapGroups.ToArray() };
        }
コード例 #2
0
        private bool RezCoalescedObject(IClientAPI remoteClient, UUID itemID, 
            CoalescedObject obj, Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, 
            byte BypassRayCast, byte bRayEndIsIntersection, 
            bool RezSelected, bool rezAtRoot, Vector3 pos, 
            IInventoryItem item, int? startParam, UUID? newAvatarGroupId,
            UUID? rezzedByObjectUUID)
        {
            //determine the bounding box of the entire set
            Box coBoundingBox = obj.GetBoundingBox();
            Vector3 rezAtRootOffset = Vector3.Zero;

            pos = GetNewRezLocation(
                  RayStart, RayEnd, RayTargetID, Quaternion.Identity,
                  BypassRayCast, bRayEndIsIntersection, true, coBoundingBox.Size, false, 
                  remoteClient != null ? remoteClient.AgentId : UUID.Zero);

            Vector3 newPos = coBoundingBox.Center;
            if (rezAtRoot)
            {
                // Use the root prim position of the last object (matches SL).
                SceneObjectGroup lastGroup = null;
                foreach (SceneObjectGroup group in obj.Groups)
                    lastGroup = group;

                if (lastGroup != null)
                    rezAtRootOffset = (coBoundingBox.Center - lastGroup.RootPart.AbsolutePosition);
            }

            //reset the positions of all parts to be an offset from 0
            SceneObjectGroup.TranslateToNewCenterPosition(coBoundingBox.Center, pos, obj.Groups);
            
            //rez each group
            bool success = true;
            foreach (SceneObjectGroup group in obj.Groups)
            {
                group.ResetInstance(true, false, UUID.Zero);
                success = success &&
                (this.RezSingleObjectToWorld(remoteClient, itemID, group, RayEnd, RayStart, RayTargetID,
                    BypassRayCast, bRayEndIsIntersection, RezSelected, false, group.AbsolutePosition+rezAtRootOffset,
                    group.RootPart.Name, group.RootPart.Description, item, obj.FindPermissions(group.UUID),
                    startParam, newAvatarGroupId, rezzedByObjectUUID)) != null;
            }

            return success;
        }
コード例 #3
0
        private bool RestoreCoalescedObject(IClientAPI remoteClient, CachedUserInfo userInfo, CoalescedObject obj, UUID itemID, InventoryItemBase item, UUID groupId)
        {
            //determine the bounding box of the entire set
            Box coBoundingBox = obj.GetBoundingBox();
            Vector3 rezAtRootOffset = Vector3.Zero;

            Vector3 newPos = coBoundingBox.Center;

            //rez each group
            bool success = true;
            foreach (SceneObjectGroup group in obj.Groups)
            {
                group.ResetInstance(true, false, UUID.Zero);
                success &= RestoreObject(remoteClient, userInfo, itemID, item, group, groupId);
            }

            return success;
        }
コード例 #4
0
        private byte[] DoSerializeCoalesced(IList<SceneObjectGroup> items, List<ItemPermissionBlock> itemPermissions, SerializationFlags flags)
        {
            ISerializationEngine engine;
            if (ProviderRegistry.Instance.TryGet<ISerializationEngine>(out engine))
            {
                Dictionary<UUID, ItemPermissionBlock> perms = new Dictionary<UUID,ItemPermissionBlock>();
                for (int i = 0; i < items.Count; i++)
                {
                    perms.Add(items[i].UUID, itemPermissions[i]);
                }

                CoalescedObject csog = new CoalescedObject(items, perms);
                return engine.InventoryObjectSerializer.SerializeCoalescedObjToInventoryBytes(csog, flags);
            }
            else
            {
                StopScriptReason stopScriptReason = SerializationFlagsToStopReason(flags);
                return Utils.StringToBytes(CoalescedSceneObjectSerializer.ToXmlFormat(items, itemPermissions, stopScriptReason));
            }
        }
コード例 #5
0
ファイル: SerializerTests.cs プロジェクト: kf6kjg/halcyon
        public void TestCoalescedSerializationDeserialization()
        {
            var sop1 = Util.RandomSOP("Root", 1);
            var sop2 = Util.RandomSOP("Child1", 2);
            var sop3 = Util.RandomSOP("Child2", 3);

            SceneObjectGroup group = new SceneObjectGroup(sop1);
            group.AddPart(sop2);
            group.AddPart(sop3);


            var sop4 = Util.RandomSOP("Root2", 1);
            var sop5 = Util.RandomSOP("Child12", 2);
            var sop6 = Util.RandomSOP("Child22", 3);

            SceneObjectGroup group2 = new SceneObjectGroup(sop4);
            group2.AddPart(sop5);
            group2.AddPart(sop6);

            var gp1perms = group.GetNewItemPermissions(UUID.Random());
            var gp2perms = group2.GetNewItemPermissions(UUID.Random());

            var perms = new Dictionary<UUID, ItemPermissionBlock>();
            perms[group.UUID] = gp1perms;
            perms[group2.UUID] = gp2perms;

            CoalescedObject cobj = new CoalescedObject(
                new List<SceneObjectGroup> { group, group2 }, 
                perms
                );

            var colbytes = serEngine.CoalescedObjectSerializer.SerializeObjectToBytes(cobj, SerializationFlags.None);

            var deserColObj = serEngine.CoalescedObjectSerializer.DeserializeObjectFromBytes(colbytes);

            CompareObjects comp = new CompareObjects();
            comp.CompareStaticFields = false;
            comp.CompareStaticProperties = false;
            comp.ElementsToIgnore = PrimCompareIgnoreList;

            Assert.IsTrue(comp.Compare(cobj, deserColObj), comp.DifferencesString);
        }