Пример #1
0
        /// <summary>
        /// Gather all the asset uuids associated with a given object.
        /// </summary>
        ///
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        ///
        /// <param name="sceneObject">The scene object for which to gather assets</param>
        /// <param name="assetUuids">The assets gathered</param>
        public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary <UUID, int> assetUuids)
        {
//            m_log.DebugFormat(
//                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
                //m_log.DebugFormat(
                //    "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);

                try
                {
                    Primitive.TextureEntry textureEntry = part.Shape.Textures;

                    // Get the prim's default texture.  This will be used for faces which don't have their own texture
                    assetUuids[textureEntry.DefaultTexture.TextureID] = 1;

                    // XXX: Not a great way to iterate through face textures, but there's no
                    // other method available to tell how many faces there actually are
                    //int i = 0;
                    foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
                    {
                        if (texture != null)
                        {
                            //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
                            assetUuids[texture.TextureID] = 1;
                        }
                    }

                    // If the prim is a sculpt then preserve this information too
                    if (part.Shape.SculptTexture != UUID.Zero)
                    {
                        assetUuids[part.Shape.SculptTexture] = 1;
                    }

                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();

                    // Now analyze this prim's inventory items to preserve all the uuids that they reference
                    foreach (TaskInventoryItem tii in taskDictionary.Values)
                    {
                        //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);

                        if (!assetUuids.ContainsKey(tii.AssetID))
                        {
                            GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
                    m_log.DebugFormat(
                        "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
                        part.Shape.TextureEntry.Length);
                }
            }
        }
Пример #2
0
 private static void ResetGroupAfterDeserialization(UUID itemId, SceneObjectGroup grp)
 {
     grp.ResetInstance(true, false, UUID.Zero);
     foreach (var part in grp.GetParts())
     {
         part.DoPostDeserializationCleanups(itemId);
         part.TrimPermissions();
     }
 }
Пример #3
0
        private SceneObjectGroup RezSingleObjectToWorld(IClientAPI remoteClient, UUID itemID, 
            SceneObjectGroup group, Vector3 RayEnd, Vector3 RayStart,
            UUID RayTargetID, byte BypassRayCast, byte bRayEndIsIntersection,
            bool RezSelected, bool attachment, Vector3 pos, string name,
            string description, IInventoryItem item, ItemPermissionBlock itemPermissions,
            int? startParam, UUID? newAvatarGroupId, UUID? rezzedByObjectUUID)
        {
            bool ownerChanged = false;  // record this for the CHANGED_OWNER changed event

            if (IsBadUserLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("You are currently not allowed to rez objects in this region.", false);
                return null;   // already reported above
            }
            if (IsBlacklistedLoad(group))
            {
                if (remoteClient != null)
                    remoteClient.SendAgentAlertMessage("Cannot rez blacklisted object '" + group.Name + "'.", false);
                return null;   // already reported above
            }

            //set the group here so that positioning in world will enable/disable the
            //script correctly based on the group the use is currently in

            // Initialize the server weight (LI)
            group.RecalcPrimWeights();

            group.RezzedFromFolderId = item.Folder;
            //group.FromAssetId = item.AssetID; //not needed yet

            if (newAvatarGroupId.HasValue)
            {
                //set the object's land group
                group.SetGroup(newAvatarGroupId.Value, null);
            }

            if (attachment)
            {
                group.SetFromItemID(itemID);
            }
            else
            {
                group.RootPart.SetGroupPositionDirect(pos);

                if (RezSelected)
                {
                    //also tell the client there is a new object being rezzed
                    foreach (SceneObjectPart part in group.GetParts())
                    {
                        part.AddFlag(PrimFlags.CreateSelected);
                    }
                }
            }

            SceneObjectPart rootPart = group.GetChildPart(group.UUID);
            if (rootPart == null) {
                string what = "object ";
                if (attachment)
                    what = " attachment ";
                m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + what + " root part not found.");
                return null;
            }

            // Since renaming the item in the inventory does not affect the name stored
            // in the serialization, transfer the correct name from the inventory to the
            // object itself before we rez.
            rootPart.Name = name;
            rootPart.Description = description;

            var partList = group.GetParts();

            foreach (SceneObjectPart part in partList)
            {
                /// This fixes inconsistencies between this part and the root part.
                /// In the past, there was a bug in Link operations that did not force 
                /// these permissions on child prims when linking.
                part.SyncChildPermsWithRoot();
            }

            if (rootPart.OwnerID != item.Owner)
            {
                if (Permissions.PropagatePermissions())
                {
                    if ((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0)
                    {    // enforce slam bit, apply item perms to the group parts
                        foreach (SceneObjectPart part in partList)
                        {
                            part.EveryoneMask = item.EveryOnePermissions;
                            part.NextOwnerMask = item.NextPermissions;
                            part.GroupMask = 0; // DO NOT propagate here
                        }
                    }
                    group.ApplyNextOwnerPermissions();
                }
            }

            ownerChanged |= group.Rationalize(item.Owner, false);

            foreach (SceneObjectPart part in partList)
            {
                if (part.OwnerID != item.Owner)
                {
                    part.LastOwnerID = part.OwnerID;
                    part.OwnerID = item.Owner;
                    part.Inventory.ChangeInventoryOwner(item.Owner);
                    ownerChanged = true;
                }
                else if (((itemPermissions.CurrentPermissions & ScenePermBits.SLAM) != 0) && (!attachment)) // Slam!
                {
                    part.EveryoneMask = itemPermissions.EveryOnePermissions;
                    part.NextOwnerMask = itemPermissions.NextPermissions;

                    part.GroupMask = 0; // DO NOT propagate here
                }
            }

            rootPart.TrimPermissions();

            if (!attachment)
            {
                if (group.RootPart.IsPrim)
                {
                    group.ClearPartAttachmentData();
                }
            }

            if (this.AddObjectToSceneIfPermitted(group, remoteClient, pos, attachment, rezzedByObjectUUID))
            {
                if (ownerChanged)
                {
                    foreach (SceneObjectPart part in partList)
                        part.TriggerScriptChangedEvent(Changed.OWNER);
                }

                if (!attachment)
                {
                    // Fire on_rez
                    group.CreateScriptInstances(startParam, ScriptStartFlags.PostOnRez, DefaultScriptEngine, (int)ScriptStateSource.PrimData, null);

                    rootPart.ScheduleFullUpdate(PrimUpdateFlags.ForcedFullUpdate);
                }

            } 
            else 
            {
                // The viewer automatically removes no-copy items from inventory on a rez attempt.
                // Since this one did not rez, it's still in inventory so let's "put it back".
                if (remoteClient != null)
                {
                    InventoryItemBase ib = item as InventoryItemBase;

                    if (item != null)
                    {
                        //this is a folder item, not a task item. update the user
                        remoteClient.SendInventoryItemCreateUpdate(ib, 0);
                    }
                }
                return null;
            }

            return rootPart.ParentGroup;
        }
Пример #4
0
        /// <summary>
        /// Gather all the asset uuids associated with a given object.
        /// </summary>
        /// 
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// 
        /// <param name="sceneObject">The scene object for which to gather assets</param>
        /// <param name="assetUuids">The assets gathered</param>
        public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids)
        {
//            m_log.DebugFormat(
//                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
                //m_log.DebugFormat(
                //    "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);

                try
                {
                    Primitive.TextureEntry textureEntry = part.Shape.Textures;

                    // Get the prim's default texture.  This will be used for faces which don't have their own texture
                    assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
                    
                    // XXX: Not a great way to iterate through face textures, but there's no
                    // other method available to tell how many faces there actually are
                    //int i = 0;
                    foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
                    {
                        if (texture != null)
                        {
                            //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
                            assetUuids[texture.TextureID] = 1;
                        }
                    }
                    
                    // If the prim is a sculpt then preserve this information too
                    if (part.Shape.SculptTexture != UUID.Zero)
                        assetUuids[part.Shape.SculptTexture] = 1;
                    
                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
                    
                    // Now analyze this prim's inventory items to preserve all the uuids that they reference
                    foreach (TaskInventoryItem tii in taskDictionary.Values)
                    {
                        //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);

                        if (!assetUuids.ContainsKey(tii.AssetID))
                            GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
                    }
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
                    m_log.DebugFormat(
                        "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)", 
                        part.Shape.TextureEntry.Length);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Gather all the asset uuids associated with a given object.
        /// </summary>
        /// 
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// 
        /// <param name="sceneObject">The scene object for which to gather assets</param>
        /// <param name="assetUuids">The assets gathered</param>
        public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
        {
//            m_log.DebugFormat(
//                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
//                m_log.DebugFormat(
//                    "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);

                try
                {
                    Primitive.TextureEntry textureEntry = part.Shape.Textures;
                    if (textureEntry != null)
                    {
                        // Get the prim's default texture.  This will be used for faces which don't have their own texture
                        if (textureEntry.DefaultTexture != null)
                            assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;

                        if (textureEntry.FaceTextures != null)
                        {
                            // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
                            foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
                            {
                                if (texture != null)
                                    assetUuids[texture.TextureID] = AssetType.Texture;
                            }
                        }
                    }
                    
                    // If the prim is a sculpt then preserve this information too
                    if (part.Shape.SculptTexture != UUID.Zero)
                        assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
                    
                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
                    
                    // Now analyze this prim's inventory items to preserve all the uuids that they reference
                    foreach (TaskInventoryItem tii in taskDictionary.Values)
                    {
//                        m_log.DebugFormat(
//                            "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}", 
//                            tii.Name, tii.Type, part.Name, part.UUID);

                        if (!assetUuids.ContainsKey(tii.AssetID))
                            GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
                    }
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
                    m_log.DebugFormat(
                        "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)", 
                        part.Shape.TextureEntry.Length);
                }
            }
        }
        private void OnObjectRemoved(SceneObjectGroup obj)
        {
            lock (m_knownMaterials)
            {
                foreach (SceneObjectPart part in obj.GetParts())
                {
                    // scan through the rendermaterials of this part for any textures used as materials
                    if ((part.Shape.TextureEntry == null) || (part.Shape.RenderMaterials == null))
                        continue;

                    var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
                    if (te == null)
                        continue;

                    var matIds = getMaterialIDsFromTextureEntry(te);

                    m_log.DebugFormat("[MaterialsModule]: OnObjectRemoved for SOP {0}:  {1}", part.LocalId, DebugMaterialsListToString(matIds));

                    foreach (var key in matIds)
                    {
                        if (m_knownMaterials.ContainsKey(key))
                        {
                            var entry = m_knownMaterials[key];
                            entry.partIds.Remove(part.LocalId);
                            if (entry.partIds.Count <= 0)
                            {
                                m_knownMaterials.Remove(key);
                                m_log.DebugFormat("[MaterialsModule]: OnObjectRemoved Material {0} not referenced. Removed from cache.", key);
                            }
                        }
                    }
                }
            }
        }
        private void OnObjectAdded(SceneObjectGroup obj)
        {
            lock (m_knownMaterials)
            {
                foreach (SceneObjectPart part in obj.GetParts())
                {
                    // scan through the rendermaterials of this part for any textures used as materials
                    if ((part.Shape.TextureEntry == null) || (part.Shape.RenderMaterials == null))
                        continue;

                    var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
                    if (te == null)
                        continue;

                    var matIds = getMaterialIDsFromTextureEntry(te);

                    foreach (var key in matIds)
                    {
                        if (m_knownMaterials.ContainsKey(key))
                        {
                            var entry = m_knownMaterials[key];
                            if (entry.partIds.Contains(part.LocalId) == false)
                                entry.partIds.Add(part.LocalId);

                            m_log.DebugFormat("[MaterialsModule]: KNOWN Material {0} for SOP {1}", key, part.LocalId);
                        }
                        else if (part.Shape.RenderMaterials.ContainsMaterial(key))
                        {
                            RenderMaterial mat = part.Shape.RenderMaterials.GetMaterial(key);
                            m_knownMaterials.Add(key, new RenderMaterialEntry(mat, part.LocalId));
                            m_log.DebugFormat("[MaterialsModule]: NEW Material {0} for SOP {1} ", key, part.LocalId);
                        }
                        else
                        {
                            m_log.ErrorFormat("[MaterialsModule]: ORPHANED Material {0} for SOP {1}!", key, part.LocalId);
                        }
                    }
                }
            }
        }
Пример #8
0
        protected internal void RemoveFromUpdateList(SceneObjectGroup obj)
        {
            //done here so that it happens outside the lock
            SceneObjectPart[] objParts = obj.GetParts();

            lock (m_updateList)
            {
                foreach (var part in objParts)
                {
                    m_updateList.Remove(part.LocalId);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Creates a new snapshot from the given group
        /// </summary>
        /// <param name="sog"></param>
        /// <returns></returns>
        public static SceneObjectGroupSnapshot FromSceneObjectGroup(SceneObjectGroup sog, SerializationFlags flags)
        {
            SceneObjectGroupSnapshot snapshot = new SceneObjectGroupSnapshot
            {
                RootPart = SceneObjectPartSnapshot.FromSceneObjectPart(sog.RootPart, flags)
            };

            var parts = sog.GetParts();
            SceneObjectPartSnapshot[] partsSnap;

            //do we have more than just the root?
            if (parts.Count > 1)
            {
                List<SceneObjectPartSnapshot> partsCollect = new List<SceneObjectPartSnapshot>();

                foreach (SceneObjectPart part in parts)
                {
                    if (!part.IsRootPart())
                    {
                        partsCollect.Add(SceneObjectPartSnapshot.FromSceneObjectPart(part, flags));
                    }
                }

                partsSnap = partsCollect.ToArray();
            }
            else
            {
                //nope, just the root
                partsSnap = new SceneObjectPartSnapshot[0];
            }

            snapshot.ChildParts = partsSnap;

            if (sog.IsAttachment && sog.HasGroupChanged)
            {
                snapshot.TaintedAttachment = true;
            }
            else
            {
                snapshot.TaintedAttachment = false;
            }

            if (sog.IsAttachment && sog.IsTempAttachment)
            {
                snapshot.TempAttachment = true;
            }
            else
            {
                snapshot.TempAttachment = false;
            }


            return snapshot;
        }
Пример #10
0
        public void CacheJ2kDecode(int threads)
        {
            if (threads < 1)
            {
                threads = 1;
            }

            IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface <IJ2KDecoder>();

            List <UUID> assetRequestList = new List <UUID>();

            #region AssetGathering!
            foreach (Scene scene in m_localScenes)
            {
                List <EntityBase> entitles = scene.GetEntities();
                foreach (EntityBase entity in entitles)
                {
                    if (entity is SceneObjectGroup)
                    {
                        SceneObjectGroup sog = (SceneObjectGroup)entity;
                        foreach (SceneObjectPart part in sog.GetParts())
                        {
                            if (part.Shape != null)
                            {
                                OpenMetaverse.Primitive.TextureEntry te = part.Shape.Textures;
                                if (te.DefaultTexture != null) // this has been null for some reason...
                                {
                                    if (te.DefaultTexture.TextureID != UUID.Zero)
                                    {
                                        assetRequestList.Add(te.DefaultTexture.TextureID);
                                    }
                                }
                                for (int i = 0; i < te.FaceTextures.Length; i++)
                                {
                                    if (te.FaceTextures[i] != null)
                                    {
                                        if (te.FaceTextures[i].TextureID != UUID.Zero)
                                        {
                                            assetRequestList.Add(te.FaceTextures[i].TextureID);
                                        }
                                    }
                                }
                                if (part.Shape.SculptTexture != UUID.Zero)
                                {
                                    assetRequestList.Add(part.Shape.SculptTexture);
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            int entries_per_thread = (assetRequestList.Count / threads) + 1;

            UUID[] arrAssetRequestList = assetRequestList.ToArray();

            List <UUID[]> arrvalus = new List <UUID[]>();

            //split into separate arrays
            for (int j = 0; j < threads; j++)
            {
                List <UUID> val = new List <UUID>();

                for (int k = j * entries_per_thread; k < ((j + 1) * entries_per_thread); k++)
                {
                    if (k < arrAssetRequestList.Length)
                    {
                        val.Add(arrAssetRequestList[k]);
                    }
                }
                arrvalus.Add(val.ToArray());
            }

            for (int l = 0; l < arrvalus.Count; l++)
            {
                DecodeThreadContents threadworkItem = new DecodeThreadContents();
                threadworkItem.sn        = m_localScenes[0];
                threadworkItem.j2kdecode = m_decoder;
                threadworkItem.arrassets = arrvalus[l];

                System.Threading.Thread decodethread =
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run));

                threadworkItem.SetThread(decodethread);

                decodethread.Priority = System.Threading.ThreadPriority.Lowest;
                decodethread.Name     = "J2kCacheDecodeThread_" + l + 1;
                ThreadTracker.Add(decodethread);
                decodethread.Start();
            }
        }
Пример #11
0
        /// <summary>
        /// Add an object to the scene.  This will both update the scene, and send information about the
        /// new object to all clients interested in the scene.
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <param name="attachToBackup">
        /// If true, the object is made persistent into the scene.
        /// If false, the object will not persist over server restarts
        /// </param>
        /// <returns>true if the object was added, false if an object with the same uuid was already in the scene
        /// </returns>
        public bool AddGroupToSceneGraph(SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool fromStorage,
            bool fromCrossing)
        {
            if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
            {
                m_log.ErrorFormat("[SceneGraph]: {0} AddGroupToSceneGraph failed, invalid or null object.", m_parentScene.RegionInfo.RegionName);
                return false;
            }

            // Prime (cache) the owner's group list.
            m_parentScene.UserGroupsGet(sceneObject.OwnerID);

            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
                Vector3 scale = part.Shape.Scale;
                if (scale.X < SceneObjectPart.MIN_PART_SCALE)
                {
                    scale.X = SceneObjectPart.MIN_PART_SCALE;
                    sceneObject.HasGroupChanged = true;
                }
                if (scale.Y < SceneObjectPart.MIN_PART_SCALE)
                {
                    scale.Y = SceneObjectPart.MIN_PART_SCALE;
                    sceneObject.HasGroupChanged = true;
                }
                if (scale.Z < SceneObjectPart.MIN_PART_SCALE)
                {
                    scale.Z = SceneObjectPart.MIN_PART_SCALE;
                    sceneObject.HasGroupChanged = true;
                }

                if (m_parentScene.m_clampPrimSize)
                {
                    if (scale.X > m_parentScene.m_maxNonphys)
                        scale.X = m_parentScene.m_maxNonphys;
                    if (scale.Y > m_parentScene.m_maxNonphys)
                        scale.Y = m_parentScene.m_maxNonphys;
                    if (scale.Z > m_parentScene.m_maxNonphys)
                        scale.Z = m_parentScene.m_maxNonphys;
                }
                part.Shape.Scale = scale;
            }

            // if physical, make sure we're above the ground by at least 10 cm
            if ((sceneObject.RootPart.Flags & PrimFlags.Physics) != 0)
            {
                OpenSim.Framework.Geom.Box bbox = sceneObject.BoundingBox();
                float groundHeight = m_parentScene.Heightmap.CalculateHeightAt(sceneObject.AbsolutePosition.X, sceneObject.AbsolutePosition.Y);
                if (sceneObject.AbsolutePosition.Z + bbox.Size.Z <= groundHeight)
                {
                    Vector3 newPos = sceneObject.AbsolutePosition;
                    newPos.Z = (bbox.Size.Z / 2.0f) + groundHeight + 0.1f;

                    sceneObject.RootPart.SetGroupPositionDirect(newPos);
                }

                AddPhysicalObject();
            }

            // rationalize the group: fix any inconsistency in locked bits, and 
            // clear the default touch action of BUY for any objects not actually for sale, etc
            sceneObject.Rationalize(sceneObject.OwnerID, fromCrossing);

            sceneObject.AttachToScene(m_parentScene, fromStorage); // allocates the localIds for the prims
            if (!alreadyPersisted)
            {
                sceneObject.HasGroupChanged = true;
            }

            sceneObject.IsPersisted = alreadyPersisted;

            lock (sceneObject)
            {
                bool entityAdded = false;
                lock (m_dictionary_lock)
                {
                    if (!Entities.ContainsKey(sceneObject.LocalId))
                    {
                        Entities.Add(sceneObject);
                        foreach (SceneObjectPart part in sceneObject.GetParts())
                        {
                            SceneObjectPartsByFullID[part.UUID] = part;
                            SceneObjectPartsByLocalID[part.LocalId] = part;
                        }

                        entityAdded = true;
                    }
                }

                if (entityAdded)
                {
                    m_numPrim += sceneObject.PrimCount;
                    m_parentScene.EventManager.TriggerParcelPrimCountTainted();

                    if (attachToBackup)
                    {
                        sceneObject.AttachToBackup();
                        //this gets the new object on the taint list
                        if (!alreadyPersisted)
                        {
                            sceneObject.HasGroupChanged = true;
                        }

                        m_parentScene.InspectForAutoReturn(sceneObject);
                    }

                    //This property doesn't work on rezzing, only on crossings or restarts
                    if ((fromStorage || fromCrossing) && sceneObject.RootPart.KeyframeAnimation != null)
                    {
                        if (sceneObject.RootPart.KeyframeAnimation.CurrentCommand == KeyframeAnimation.Commands.Play)
                        {
                            if (!fromStorage)
                            {
                                //Offset the initial position so that it is in the new region's coordinates
                                // (only if we are actually crossing from a different region)
                                Vector3 regionOffset = sceneObject.AbsolutePosition - sceneObject.OriginalEnteringScenePosition;
                                sceneObject.RootPart.KeyframeAnimation.InitialPosition += regionOffset;
                            }

                            sceneObject.AddKeyframedMotion(null, KeyframeAnimation.Commands.Play);
                        }
                    }

                    if (OnObjectCreate != null)
                        OnObjectCreate(sceneObject);

                    return true;
                }

            }

            return false;
        }
Пример #12
0
        /// <summary>
        /// Serialize a scene object to the 'xml2' format.
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <returns></returns>          
        public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer, StopScriptReason stopScriptReason, bool saveScriptState)
        {
            //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name);
            //int time = System.Environment.TickCount;

            writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
            sceneObject.RootPart.ToXml(writer);
            writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
            
            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
                if (part.UUID != sceneObject.RootPart.UUID)
                {
                    part.ToXml(writer);
                }
            }

            writer.WriteEndElement(); // End of OtherParts
            if (saveScriptState)
            {
                sceneObject.SaveScriptedState(writer, stopScriptReason);
            }
            writer.WriteEndElement(); // End of SceneObjectGroup

            //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time);
        }   
Пример #13
0
        private void OnObjectRemoved(SceneObjectGroup obj)
        {
            lock (m_knownMaterials)
            {
                foreach (SceneObjectPart part in obj.GetParts())
                {
                    // scan through the rendermaterials of this part for any textures used as materials
                    if ((part.Shape.Textures == null) || (part.Shape.RenderMaterials == null))
                        continue;

                    var matIds = part.Shape.GetMaterialIDs();

                    foreach (var key in matIds)
                    {
                        if (m_knownMaterials.ContainsKey(key))
                        {
                            var entry = m_knownMaterials[key];
                            entry.partIds.Remove(part.LocalId);
                            if (entry.partIds.Count <= 0)
                            {
                                m_knownMaterials.Remove(key);
                                m_log.DebugFormat("[MaterialsModule]: OnObjectRemoved Material {0} not referenced. Removed from cache.", key);
                            }
                        }
                    }
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Gather all the asset uuids associated with a given object.
        /// </summary>
        ///
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        ///
        /// <param name="sceneObject">The scene object for which to gather assets</param>
        /// <param name="assetUuids">The assets gathered</param>
        public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary <UUID, AssetType> assetUuids)
        {
//            m_log.DebugFormat(
//                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            foreach (SceneObjectPart part in sceneObject.GetParts())
            {
//                m_log.DebugFormat(
//                    "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);

                try
                {
                    Primitive.TextureEntry textureEntry = part.Shape.Textures;
                    if (textureEntry != null)
                    {
                        // Get the prim's default texture.  This will be used for faces which don't have their own texture
                        if (textureEntry.DefaultTexture != null)
                        {
                            assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
                        }

                        if (textureEntry.FaceTextures != null)
                        {
                            // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
                            foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
                            {
                                if (texture != null)
                                {
                                    assetUuids[texture.TextureID] = AssetType.Texture;
                                }
                            }
                        }
                    }

                    // If the prim is a sculpt then preserve this information too
                    if (part.Shape.SculptTexture != UUID.Zero)
                    {
                        assetUuids[part.Shape.SculptTexture] = AssetType.Texture;
                    }

                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();

                    // Now analyze this prim's inventory items to preserve all the uuids that they reference
                    foreach (TaskInventoryItem tii in taskDictionary.Values)
                    {
//                        m_log.DebugFormat(
//                            "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
//                            tii.Name, tii.Type, part.Name, part.UUID);

                        if (!assetUuids.ContainsKey(tii.AssetID))
                        {
                            GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
                    m_log.DebugFormat(
                        "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
                        part.Shape.TextureEntry.Length);
                }
            }
        }