diff options
author | Justin Clarke Casey | 2008-06-16 21:59:39 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-06-16 21:59:39 +0000 |
commit | 4c2171ec827aa426375ccecf4bd2d7e009719d74 (patch) | |
tree | b26d9a8b2ab90a01b3118c1d0cfd9493ba331242 /OpenSim | |
parent | I really didn't expect that one to work out of the box, but just managed (diff) | |
download | opensim-SC_OLD-4c2171ec827aa426375ccecf4bd2d7e009719d74.zip opensim-SC_OLD-4c2171ec827aa426375ccecf4bd2d7e009719d74.tar.gz opensim-SC_OLD-4c2171ec827aa426375ccecf4bd2d7e009719d74.tar.bz2 opensim-SC_OLD-4c2171ec827aa426375ccecf4bd2d7e009719d74.tar.xz |
* Allow archiver to save and load objects within other objects to arbitrary levels
* This currently has various bugs which are more to do with the way its been hacked together than the feature itself (e.g. on save-oar, ghost prims will appear of the saved
contained items). These will be found and eliminated in subsequent patches.
* Not yet ready for use
Diffstat (limited to 'OpenSim')
3 files changed, 100 insertions, 55 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index dd9015b..a1d9c73 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -270,7 +270,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
270 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); | 270 | // m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); |
271 | #endif | 271 | #endif |
272 | 272 | ||
273 | |||
274 | NewAssetRequest req = new NewAssetRequest(assetId, callback); | 273 | NewAssetRequest req = new NewAssetRequest(assetId, callback); |
275 | AssetRequestsList requestList; | 274 | AssetRequestsList requestList; |
276 | 275 | ||
@@ -291,28 +290,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
291 | m_assetServer.RequestAsset(assetId, isTexture); | 290 | m_assetServer.RequestAsset(assetId, isTexture); |
292 | } | 291 | } |
293 | } | 292 | } |
294 | |||
295 | |||
296 | /* Old code doesn't handle duplicate requests right | ||
297 | NewAssetRequest req = new NewAssetRequest(assetId, callback); | ||
298 | |||
299 | // Make sure we always have a request list to which to add the asset | ||
300 | AssetRequestsList requestList; | ||
301 | lock (RequestLists) | ||
302 | { | ||
303 | // m_log.Info("AssetCache: Lock taken on requestLists (GetAsset)"); | ||
304 | if (!RequestLists.TryGetValue(assetId, out requestList)) | ||
305 | { | ||
306 | requestList = new AssetRequestsList(assetId); | ||
307 | RequestLists.Add(assetId, requestList); | ||
308 | } | ||
309 | } | ||
310 | // m_log.Info("AssetCache: Lock released on requestLists (GetAsset)"); | ||
311 | |||
312 | requestList.Requests.Add(req); | ||
313 | |||
314 | m_assetServer.RequestAsset(assetId, isTexture); | ||
315 | */ | ||
316 | } | 293 | } |
317 | } | 294 | } |
318 | 295 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs index a93e58d..1b78f4c 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -47,64 +47,132 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | protected Scene m_scene; | 49 | protected Scene m_scene; |
50 | protected string m_savePath; | 50 | protected string m_savePath; |
51 | |||
52 | /// <summary> | ||
53 | /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate | ||
54 | /// asset was found by the asset service. | ||
55 | /// </summary> | ||
56 | protected AssetBase m_requestedObjectAsset; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Signal whether we are currently waiting for the asset service to deliver an asset. | ||
60 | /// </summary> | ||
61 | protected bool m_waitingForObjectAsset; | ||
51 | 62 | ||
63 | /// <summary> | ||
64 | /// Constructor | ||
65 | /// </summary> | ||
52 | public ArchiveWriteRequestPreparation(Scene scene, string savePath) | 66 | public ArchiveWriteRequestPreparation(Scene scene, string savePath) |
53 | { | 67 | { |
54 | m_scene = scene; | 68 | m_scene = scene; |
55 | m_savePath = savePath; | 69 | m_savePath = savePath; |
56 | } | 70 | } |
57 | 71 | ||
58 | public void ArchiveRegion() | 72 | /// <summary> |
73 | /// The callback made when we request the asset for an object from the asset service. | ||
74 | /// </summary> | ||
75 | public void AssetRequestCallback(LLUUID assetID, AssetBase asset) | ||
59 | { | 76 | { |
60 | Dictionary<LLUUID, int> assetUuids = new Dictionary<LLUUID, int>(); | 77 | lock (this) |
61 | |||
62 | List<EntityBase> entities = m_scene.GetEntities(); | ||
63 | |||
64 | foreach (EntityBase entity in entities) | ||
65 | { | 78 | { |
66 | if (entity is SceneObjectGroup) | 79 | m_requestedObjectAsset = asset; |
80 | m_waitingForObjectAsset = false; | ||
81 | Monitor.Pulse(this); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Get all the asset uuids associated with a given object. This includes both those directly associated with | ||
87 | /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained | ||
88 | /// within this object). | ||
89 | /// </summary> | ||
90 | /// <param name="sceneObject"></param> | ||
91 | /// <param name="assetUuids"></param> | ||
92 | protected void GetSceneObjectAssetUuids(SceneObjectGroup sceneObject, IDictionary<LLUUID, int> assetUuids) | ||
93 | { | ||
94 | m_log.DebugFormat( | ||
95 | "[ARCHIVER]: Getting assets for object {0}, {1}", sceneObject.RootPart.Name, sceneObject.UUID); | ||
96 | |||
97 | foreach (SceneObjectPart part in sceneObject.GetParts()) | ||
98 | { | ||
99 | m_log.DebugFormat( | ||
100 | "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID); | ||
101 | |||
102 | // XXX: Not a great way to iterate through face textures, but there's no | ||
103 | // other way to tell how many faces there actually are | ||
104 | int i = 0; | ||
105 | foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures) | ||
67 | { | 106 | { |
68 | SceneObjectGroup sceneObject = (SceneObjectGroup)entity; | 107 | if (texture != null) |
108 | { | ||
109 | m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); | ||
110 | assetUuids[texture.TextureID] = 1; | ||
111 | } | ||
112 | } | ||
69 | 113 | ||
70 | foreach (SceneObjectPart part in sceneObject.GetParts()) | 114 | foreach (TaskInventoryItem tii in part.TaskInventory.Values) |
115 | { | ||
116 | if (!assetUuids.ContainsKey(tii.AssetID)) | ||
71 | { | 117 | { |
72 | // XXX: Not a great way to iterate through face textures, but there's no | 118 | assetUuids[tii.AssetID] = 1; |
73 | // other way to tell how many faces there actually are | 119 | |
74 | //int i = 0; | 120 | if (tii.Type != (int)InventoryType.Object) |
75 | foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures) | ||
76 | { | 121 | { |
77 | if (texture != null) | 122 | m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tii.AssetID, part.UUID); |
78 | { | ||
79 | //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); | ||
80 | assetUuids[texture.TextureID] = 1; | ||
81 | } | ||
82 | } | 123 | } |
83 | 124 | else | |
84 | foreach (TaskInventoryItem tit in part.TaskInventory.Values) | ||
85 | { | 125 | { |
86 | if (tit.Type != (int)InventoryType.Object) | 126 | m_waitingForObjectAsset = true; |
127 | m_scene.AssetCache.GetAsset(tii.AssetID, AssetRequestCallback, true); | ||
128 | |||
129 | // The asset cache callback can either | ||
130 | // | ||
131 | // 1. Complete on the same thread (if the asset is already in the cache) or | ||
132 | // 2. Come in via a different thread (if we need to go fetch it). | ||
133 | // | ||
134 | // The code below handles both these alternatives. | ||
135 | lock (this) | ||
87 | { | 136 | { |
88 | m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tit.AssetID, part.UUID); | 137 | if (m_waitingForObjectAsset) |
89 | assetUuids[tit.AssetID] = 1; | 138 | { |
139 | Monitor.Wait(this); | ||
140 | m_waitingForObjectAsset = false; | ||
141 | } | ||
90 | } | 142 | } |
91 | else | 143 | |
144 | if (null != m_requestedObjectAsset) | ||
92 | { | 145 | { |
93 | // TODO: Need to unpack every tit and go through its textures & items, recursively | 146 | string xml = Helpers.FieldToUTF8String(m_requestedObjectAsset.Data); |
94 | // this will mean going through the 'assets' received multiple times so that we can | 147 | SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml); |
95 | // unpack objects within objects before recursively requesting the inner assets | 148 | GetSceneObjectAssetUuids(sog, assetUuids); |
96 | } | 149 | } |
97 | } | 150 | } |
98 | } | 151 | } |
99 | } | 152 | } |
100 | } | 153 | } |
154 | } | ||
155 | |||
156 | public void ArchiveRegion() | ||
157 | { | ||
158 | Dictionary<LLUUID, int> assetUuids = new Dictionary<LLUUID, int>(); | ||
159 | |||
160 | List<EntityBase> entities = m_scene.GetEntities(); | ||
161 | |||
162 | foreach (EntityBase entity in entities) | ||
163 | { | ||
164 | if (entity is SceneObjectGroup) | ||
165 | { | ||
166 | GetSceneObjectAssetUuids((SceneObjectGroup)entity, assetUuids); | ||
167 | } | ||
168 | } | ||
101 | 169 | ||
102 | string serializedEntities = SerializeObjects(entities); | 170 | string serializedEntities = SerializeObjects(entities); |
103 | 171 | ||
104 | if (serializedEntities != null && serializedEntities.Length > 0) | 172 | if (serializedEntities != null && serializedEntities.Length > 0) |
105 | { | 173 | { |
106 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); | 174 | m_log.DebugFormat("[ARCHIVER]: Successfully got serialization for {0} entities", entities.Count); |
107 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} textures", assetUuids.Count); | 175 | m_log.DebugFormat("[ARCHIVER]: Requiring save of {0} assets", assetUuids.Count); |
108 | 176 | ||
109 | // Asynchronously request all the assets required to perform this archive operation | 177 | // Asynchronously request all the assets required to perform this archive operation |
110 | ArchiveWriteRequestExecution awre = new ArchiveWriteRequestExecution(serializedEntities, m_savePath); | 178 | ArchiveWriteRequestExecution awre = new ArchiveWriteRequestExecution(serializedEntities, m_savePath); |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f6dc8a2..b6c59e3 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -1596,7 +1596,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | /// <summary> | 1598 | /// <summary> |
1599 | /// | 1599 | /// Do everything required once a client completes its movement into a region |
1600 | /// </summary> | 1600 | /// </summary> |
1601 | public void SendInitialData() | 1601 | public void SendInitialData() |
1602 | { | 1602 | { |