aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
diff options
context:
space:
mode:
authordiva2009-05-23 17:51:13 +0000
committerdiva2009-05-23 17:51:13 +0000
commitfb6d314d4db0a157799a1d49a5f467f1c051ec9b (patch)
tree3a5f7c8d3f91722d6a32ee85b7031dfb4c2de6b0 /OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
parentAdded one missing config var for HG standalones. (diff)
downloadopensim-SC-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.zip
opensim-SC-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.gz
opensim-SC-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.bz2
opensim-SC-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.xz
This should make HG asset transfers work much better. It now uses HGUuidGatherer, which is a subclass of UuidGatherer. Hence, on-line HG asset transfers use exactly the same UUID collection code as save oar/xml. If it doesn't work, it's Justin's fault :D
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs122
1 files changed, 23 insertions, 99 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 720a09b..1d4bc9c 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
97 return false; 97 return false;
98 } 98 }
99 99
100 private AssetBase FetchAsset(string url, UUID assetID, bool isTexture) 100 public AssetBase FetchAsset(string url, UUID assetID)
101 { 101 {
102 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); 102 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
103 103
@@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
109 return null; 109 return null;
110 } 110 }
111 111
112 private bool PostAsset(string url, AssetBase asset) 112 public bool PostAsset(string url, AssetBase asset)
113 { 113 {
114 if (asset != null) 114 if (asset != null)
115 { 115 {
@@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 } 129 }
130 catch 130 catch
131 { 131 {
132 m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons"); 132 m_log.Warn("[HGScene]: Oops.");
133 } 133 }
134 134
135 m_scene.AssetService.Store(asset1); 135 m_scene.AssetService.Store(asset1);
@@ -155,86 +155,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
155 155
156 } 156 }
157 157
158 private void _guardedAdd(Dictionary<UUID, bool> lst, UUID obj, bool val)
159 {
160 if (!lst.ContainsKey(obj))
161 lst.Add(obj, val);
162 }
163
164 private void SniffTextureUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
165 {
166 try
167 {
168 _guardedAdd(uuids, sog.RootPart.Shape.Textures.DefaultTexture.TextureID, true);
169 }
170 catch (Exception) { }
171
172 foreach (Primitive.TextureEntryFace tface in sog.RootPart.Shape.Textures.FaceTextures)
173 {
174 try
175 {
176 _guardedAdd(uuids, tface.TextureID, true);
177 }
178 catch (Exception) { }
179 }
180
181 foreach (SceneObjectPart sop in sog.Children.Values)
182 {
183 try
184 {
185 _guardedAdd(uuids, sop.Shape.Textures.DefaultTexture.TextureID, true);
186 }
187 catch (Exception) { }
188 foreach (Primitive.TextureEntryFace tface in sop.Shape.Textures.FaceTextures)
189 {
190 try
191 {
192 _guardedAdd(uuids, tface.TextureID, true);
193 }
194 catch (Exception) { }
195 }
196 }
197 }
198
199 private void SniffTaskInventoryUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
200 {
201 TaskInventoryDictionary tinv = sog.RootPart.TaskInventory;
202
203 lock (tinv)
204 {
205 foreach (TaskInventoryItem titem in tinv.Values)
206 {
207 uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture);
208 }
209 }
210 }
211
212 private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset)
213 {
214 Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
215 if ((asset != null) && ((AssetType)asset.Type == AssetType.Object))
216 {
217 string ass_str = Utils.BytesToString(asset.Data);
218 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(ass_str);
219
220 SniffTextureUUIDs(uuids, sog);
221
222 // We need to sniff further...
223 SniffTaskInventoryUUIDs(uuids, sog);
224 }
225
226 return uuids;
227 }
228
229 private Dictionary<UUID, bool> SniffUUIDs(UUID assetID)
230 {
231 //Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
232
233 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
234
235 return SniffUUIDs(asset);
236 }
237
238 private void Dump(Dictionary<UUID, bool> lst) 158 private void Dump(Dictionary<UUID, bool> lst)
239 { 159 {
240 m_log.Debug("XXX -------- UUID DUMP ------- XXX"); 160 m_log.Debug("XXX -------- UUID DUMP ------- XXX");
@@ -259,16 +179,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
259 if (userAssetURL != null) 179 if (userAssetURL != null)
260 { 180 {
261 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 181 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
262 AssetBase asset = FetchAsset(userAssetURL, assetID, false); 182 AssetBase asset = FetchAsset(userAssetURL, assetID);
263 183
264 if (asset != null) 184 if (asset != null)
265 { 185 {
266 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); 186 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
187
267 // OK, now fetch the inside. 188 // OK, now fetch the inside.
268 Dictionary<UUID, bool> ids = SniffUUIDs(asset); 189 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
269 Dump(ids); 190 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
270 foreach (KeyValuePair<UUID, bool> kvp in ids) 191 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
271 FetchAsset(userAssetURL, kvp.Key, kvp.Value); 192 foreach (UUID uuid in ids.Keys)
193 FetchAsset(userAssetURL, uuid);
272 } 194 }
273 else 195 else
274 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); 196 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
@@ -315,21 +237,23 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
315 if (userAssetURL != null) 237 if (userAssetURL != null)
316 { 238 {
317 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 239 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
318 AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString()); 240 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
319 if (ass1 != null) 241 if (asset != null)
320 { 242 {
321 bool success = PostAsset(userAssetURL, ass1); 243 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
322 244 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
323 // Now the inside 245 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
324 Dictionary<UUID, bool> ids = SniffUUIDs(assetID); 246 foreach (UUID uuid in ids.Keys)
325 Dump(ids);
326 foreach (KeyValuePair<UUID, bool> kvp in ids)
327 { 247 {
328 ass1 = m_scene.AssetService.Get(kvp.Key.ToString()); 248 asset = m_scene.AssetService.Get(uuid.ToString());
329 PostAsset(userAssetURL, ass1); 249 if (asset != null)
250 m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
251 else
252 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
253 PostAsset(userAssetURL, asset);
330 } 254 }
331 255
332 if (success) 256 if (ids.Count > 0) // maybe it succeeded...
333 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); 257 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL);
334 else 258 else
335 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); 259 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);