aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-18 21:02:43 +0000
committerJustin Clarke Casey2009-02-18 21:02:43 +0000
commit89f2589f6c12e7cd265c25f7f83bd1b3f1e98d7e (patch)
treedc23461c298a5a1156a6b4141a216f938baae964 /OpenSim
parentFixes height on Basic Physics in local teleports. Plus some small refactoring. (diff)
downloadopensim-SC_OLD-89f2589f6c12e7cd265c25f7f83bd1b3f1e98d7e.zip
opensim-SC_OLD-89f2589f6c12e7cd265c25f7f83bd1b3f1e98d7e.tar.gz
opensim-SC_OLD-89f2589f6c12e7cd265c25f7f83bd1b3f1e98d7e.tar.bz2
opensim-SC_OLD-89f2589f6c12e7cd265c25f7f83bd1b3f1e98d7e.tar.xz
* Change AssetGatherer method access so that only methods which are worth calling from the outside are public
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/AssetGatherer.cs182
3 files changed, 101 insertions, 88 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 1152a1e..7f228e4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -37,6 +37,7 @@ using OpenSim.Framework;
37using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Region.CoreModules.World.Archiver; 39using OpenSim.Region.CoreModules.World.Archiver;
40using OpenSim.Region.Framework.Scenes;
40 41
41namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 42namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
42{ 43{
@@ -45,6 +46,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 47
47 protected TarArchiveWriter archive = new TarArchiveWriter(); 48 protected TarArchiveWriter archive = new TarArchiveWriter();
49 protected AssetGatherer m_assetGatherer;
48 protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>(); 50 protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
49 51
50 private InventoryArchiverModule m_module; 52 private InventoryArchiverModule m_module;
@@ -78,7 +80,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
78 m_module = module; 80 m_module = module;
79 m_userInfo = userInfo; 81 m_userInfo = userInfo;
80 m_invPath = invPath; 82 m_invPath = invPath;
81 m_saveStream = saveStream; 83 m_saveStream = saveStream;
84 m_assetGatherer = new AssetGatherer(m_module.CommsManager.AssetCache);
82 } 85 }
83 86
84 protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids) 87 protected void ReceivedAllAssets(IDictionary<UUID, AssetBase> assetsFound, ICollection<UUID> assetsNotFoundUuids)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index d78acdd..1edd2dc 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
100 100
101 foreach (SceneObjectGroup sceneObject in sceneObjects) 101 foreach (SceneObjectGroup sceneObject in sceneObjects)
102 { 102 {
103 assetGatherer.GetSceneObjectAssetUuids(sceneObject, assetUuids); 103 assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
104 } 104 }
105 105
106 m_log.DebugFormat( 106 m_log.DebugFormat(
diff --git a/OpenSim/Region/Framework/Scenes/AssetGatherer.cs b/OpenSim/Region/Framework/Scenes/AssetGatherer.cs
index 2726bd8..00a4398 100644
--- a/OpenSim/Region/Framework/Scenes/AssetGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/AssetGatherer.cs
@@ -67,12 +67,101 @@ namespace OpenSim.Region.Framework.Scenes
67 public AssetGatherer(IAssetCache assetCache) 67 public AssetGatherer(IAssetCache assetCache)
68 { 68 {
69 m_assetCache = assetCache; 69 m_assetCache = assetCache;
70 } 70 }
71
72 /// <summary>
73 /// Gather all the asset uuids associated with the asset referenced by a given uuid
74 /// </summary>
75 ///
76 /// This includes both those directly associated with
77 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
78 /// within this object).
79 ///
80 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
81 /// <param name="assetType">The type of the asset for the uuid given</param>
82 /// <param name="assetUuids">The assets gathered</param>
83 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, int> assetUuids)
84 {
85 assetUuids[assetUuid] = 1;
86
87 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
88 {
89 GetWearableAssetUuids(assetUuid, assetUuids);
90 }
91 else if (AssetType.LSLText == assetType)
92 {
93 GetScriptAssetUuids(assetUuid, assetUuids);
94 }
95 else if (AssetType.Object == assetType)
96 {
97 GetSceneObjectAssetUuids(assetUuid, assetUuids);
98 }
99 }
100
101 /// <summary>
102 /// Gather all the asset uuids associated with a given object.
103 /// </summary>
104 ///
105 /// This includes both those directly associated with
106 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
107 /// within this object).
108 ///
109 /// <param name="sceneObject">The scene object for which to gather assets</param>
110 /// <param name="assetUuids">The assets gathered</param>
111 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids)
112 {
113 m_log.DebugFormat(
114 "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
115
116 foreach (SceneObjectPart part in sceneObject.GetParts())
117 {
118 //m_log.DebugFormat(
119 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
120
121 try
122 {
123 Primitive.TextureEntry textureEntry = part.Shape.Textures;
124
125 // Get the prim's default texture. This will be used for faces which don't have their own texture
126 assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
127
128 // XXX: Not a great way to iterate through face textures, but there's no
129 // other method available to tell how many faces there actually are
130 //int i = 0;
131 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
132 {
133 if (texture != null)
134 {
135 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
136 assetUuids[texture.TextureID] = 1;
137 }
138 }
139
140 // If the prim is a sculpt then preserve this information too
141 if (part.Shape.SculptTexture != UUID.Zero)
142 assetUuids[part.Shape.SculptTexture] = 1;
143
144 // Now analyze this prim's inventory items to preserve all the uuids that they reference
145 foreach (TaskInventoryItem tii in part.TaskInventory.Values)
146 {
147 //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);
148
149 if (!assetUuids.ContainsKey(tii.AssetID))
150 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
151 }
152 }
153 catch (Exception e)
154 {
155 m_log.ErrorFormat("[ASSET GATHERER]: Failed to get part - {0}", e);
156 m_log.DebugFormat("[ASSET GATHERER]: Texture entry length for prim was {0} (min is 46)", part.Shape.TextureEntry.Length);
157 }
158 }
159 }
71 160
72 /// <summary> 161 /// <summary>
73 /// The callback made when we request the asset for an object from the asset service. 162 /// The callback made when we request the asset for an object from the asset service.
74 /// </summary> 163 /// </summary>
75 public void AssetRequestCallback(UUID assetID, AssetBase asset) 164 protected void AssetRequestCallback(UUID assetID, AssetBase asset)
76 { 165 {
77 lock (this) 166 lock (this)
78 { 167 {
@@ -116,7 +205,7 @@ namespace OpenSim.Region.Framework.Scenes
116 /// </summary> 205 /// </summary>
117 /// <param name="scriptUuid"></param> 206 /// <param name="scriptUuid"></param>
118 /// <param name="assetUuids">Dictionary in which to record the references</param> 207 /// <param name="assetUuids">Dictionary in which to record the references</param>
119 public void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, int> assetUuids) 208 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, int> assetUuids)
120 { 209 {
121 AssetBase scriptAsset = GetAsset(scriptUuid); 210 AssetBase scriptAsset = GetAsset(scriptUuid);
122 211
@@ -141,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
141 /// </summary> 230 /// </summary>
142 /// <param name="wearableAssetUuid"></param> 231 /// <param name="wearableAssetUuid"></param>
143 /// <param name="assetUuids">Dictionary in which to record the references</param> 232 /// <param name="assetUuids">Dictionary in which to record the references</param>
144 public void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, int> assetUuids) 233 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, int> assetUuids)
145 { 234 {
146 AssetBase assetBase = GetAsset(wearableAssetUuid); 235 AssetBase assetBase = GetAsset(wearableAssetUuid);
147 //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); 236 //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data));
@@ -165,7 +254,7 @@ namespace OpenSim.Region.Framework.Scenes
165 /// </summary> 254 /// </summary>
166 /// <param name="sceneObject"></param> 255 /// <param name="sceneObject"></param>
167 /// <param name="assetUuids"></param> 256 /// <param name="assetUuids"></param>
168 public void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, int> assetUuids) 257 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, int> assetUuids)
169 { 258 {
170 AssetBase objectAsset = GetAsset(sceneObjectUuid); 259 AssetBase objectAsset = GetAsset(sceneObjectUuid);
171 260
@@ -173,87 +262,8 @@ namespace OpenSim.Region.Framework.Scenes
173 { 262 {
174 string xml = Utils.BytesToString(objectAsset.Data); 263 string xml = Utils.BytesToString(objectAsset.Data);
175 SceneObjectGroup sog = new SceneObjectGroup(xml, true); 264 SceneObjectGroup sog = new SceneObjectGroup(xml, true);
176 GetSceneObjectAssetUuids(sog, assetUuids); 265 GatherAssetUuids(sog, assetUuids);
177 }
178 }
179
180 /// <summary>
181 /// Get all the asset uuids associated with a given object.
182 /// </summary>
183 ///
184 /// This includes both those directly associated with
185 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
186 /// within this object).
187 ///
188 /// <param name="sceneObject">The scene object for which to gather assets</param>
189 /// <param name="assetUuids">The assets gathered</param>
190 public void GetSceneObjectAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, int> assetUuids)
191 {
192 m_log.DebugFormat(
193 "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
194
195 foreach (SceneObjectPart part in sceneObject.GetParts())
196 {
197 //m_log.DebugFormat(
198 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
199
200 try
201 {
202 Primitive.TextureEntry textureEntry = part.Shape.Textures;
203
204 // Get the prim's default texture. This will be used for faces which don't have their own texture
205 assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
206
207 // XXX: Not a great way to iterate through face textures, but there's no
208 // other method available to tell how many faces there actually are
209 //int i = 0;
210 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
211 {
212 if (texture != null)
213 {
214 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
215 assetUuids[texture.TextureID] = 1;
216 }
217 }
218
219 // If the prim is a sculpt then preserve this information too
220 if (part.Shape.SculptTexture != UUID.Zero)
221 assetUuids[part.Shape.SculptTexture] = 1;
222
223 // Now analyze this prim's inventory items to preserve all the uuids that they reference
224 foreach (TaskInventoryItem tii in part.TaskInventory.Values)
225 {
226 //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);
227
228 if (!assetUuids.ContainsKey(tii.AssetID))
229 {
230 assetUuids[tii.AssetID] = 1;
231
232 if ((int)AssetType.Bodypart == tii.Type || ((int)AssetType.Clothing == tii.Type))
233 {
234 GetWearableAssetUuids(tii.AssetID, assetUuids);
235 }
236 else if ((int)AssetType.LSLText == tii.Type)
237 {
238 GetScriptAssetUuids(tii.AssetID, assetUuids);
239 }
240 else if ((int)AssetType.Object == tii.Type)
241 {
242 GetSceneObjectAssetUuids(tii.AssetID, assetUuids);
243 }
244 //else
245 //{
246 //m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tii.AssetID, part.UUID);
247 //}
248 }
249 }
250 }
251 catch (Exception e)
252 {
253 m_log.ErrorFormat("[ASSET GATHERER]: Failed to get part - {0}", e);
254 m_log.DebugFormat("[ASSET GATHERER]: Texture entry length for prim was {0} (min is 46)", part.Shape.TextureEntry.Length);
255 }
256 } 266 }
257 } 267 }
258 } 268 }
259} 269}