OpenSim.Region.Framework.Scenes.UuidGatherer.GatherAssetUuids C# (CSharp) Method

GatherAssetUuids() public method

Gather all the asset uuids associated with a given object.
public GatherAssetUuids ( SceneObjectGroup sceneObject, AssetType>.IDictionary assetUuids ) : void
sceneObject SceneObjectGroup The scene object for which to gather assets
assetUuids AssetType>.IDictionary The assets gathered
return void
        public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids)
        {
//            m_log.DebugFormat(
//                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            SceneObjectPart[] parts = sceneObject.Parts;
            for (int i = 0; i < parts.Length; i++)
            {
                SceneObjectPart part = parts[i];

//                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);
                }
            }
        }
        

Same methods

UuidGatherer::GatherAssetUuids ( UUID assetUuid, AssetType assetType, AssetType>.IDictionary assetUuids ) : void

Usage Example

Example #1
0
            public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
            {
                m_isArchiving = true;

                m_log.Info("[Archive]: Writing parcels to archive");

                writer.WriteDir("parcels");

                IParcelManagementModule module = scene.RequestModuleInterface<IParcelManagementModule>();
                if (module != null)
                {
                    List<ILandObject> landObject = module.AllParcels();
                    foreach (ILandObject parcel in landObject)
                    {
                        OSDMap parcelMap = parcel.LandData.ToOSD();
                        writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), OSDParser.SerializeLLSDBinary(parcelMap));
                    }
                }

                m_log.Info("[Archive]: Finished writing parcels to archive");
                m_log.Info("[Archive]: Writing terrain to archive");

                writer.WriteDir("terrain");

                ITerrainModule tModule = scene.RequestModuleInterface<ITerrainModule>();
                if (tModule != null)
                {
                    MemoryStream s = new MemoryStream();
                    tModule.SaveToStream(scene.RegionInfo.RegionID.ToString() + ".r32", s);
                    writer.WriteFile("terrain/" + scene.RegionInfo.RegionID.ToString() + ".r32", s.ToArray());
                    s.Close();
                }

                m_log.Info("[Archive]: Finished writing terrain to archive");
                m_log.Info("[Archive]: Writing entities to archive");
                ISceneEntity[] entities = scene.Entities.GetEntities();
                //Get all entities, then start writing them to the database
                writer.WriteDir("entities");

                IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
                UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);

                foreach (ISceneEntity entity in entities)
                {
                    //Write all entities
                    writer.WriteFile("entities/" + entity.UUID.ToString(), ((ISceneObject)entity).ToXml2());
                    //Get all the assets too
                    assetGatherer.GatherAssetUuids(entity, assets, scene);
                }

                m_log.Info("[Archive]: Finished writing entities to archive");
                m_log.Info("[Archive]: Writing assets for entities to archive");

                bool foundAllAssets = true;
                foreach (UUID assetID in new List<UUID>(assets.Keys))
                {
                    AssetBase asset = m_scene.AssetService.GetCached(assetID.ToString());
                    if (asset != null)
                        WriteAsset(asset, writer); //Write it syncronously since we havn't 
                    else
                    {
                        foundAllAssets = false; //Not all are cached
                        m_missingAssets.Add(assetID);
                        m_scene.AssetService.Get(assetID.ToString(), writer, RetrievedAsset);
                    }
                }
                if (foundAllAssets)
                    m_isArchiving = false; //We're done if all the assets were found

                m_log.Info("[Archive]: Finished writing assets for entities to archive");
            }
All Usage Examples Of OpenSim.Region.Framework.Scenes.UuidGatherer::GatherAssetUuids