diff options
author | Justin Clark-Casey (justincc) | 2011-08-30 01:58:32 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-30 01:58:32 +0100 |
commit | be357f8feeb438e3292292d163918a307d69c69a (patch) | |
tree | f1f45b0a5bb58262885065b7a3fa37dde0d3d03e /OpenSim/Region | |
parent | Move GetMeshKey from buried inside Meshmerizer to a public method on Primitiv... (diff) | |
download | opensim-SC_OLD-be357f8feeb438e3292292d163918a307d69c69a.zip opensim-SC_OLD-be357f8feeb438e3292292d163918a307d69c69a.tar.gz opensim-SC_OLD-be357f8feeb438e3292292d163918a307d69c69a.tar.bz2 opensim-SC_OLD-be357f8feeb438e3292292d163918a307d69c69a.tar.xz |
Fix bug in persisting saved appearances for npcs
Assets have to be marked non-local as well as non-temporary to persist. This is now done.
Hopefully addresses http://opensimulator.org/mantis/view.php?id=5660
Diffstat (limited to 'OpenSim/Region')
6 files changed, 131 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ff889ea..d1ce5df 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -136,7 +136,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
136 | TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; | 136 | TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; |
137 | CAPSFetchInventoryDescendents = m_Scene.HandleFetchInventoryDescendentsCAPS; | 137 | CAPSFetchInventoryDescendents = m_Scene.HandleFetchInventoryDescendentsCAPS; |
138 | GetClient = m_Scene.SceneContents.GetControllingClient; | 138 | GetClient = m_Scene.SceneContents.GetControllingClient; |
139 | |||
140 | } | 139 | } |
141 | 140 | ||
142 | /// <summary> | 141 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 4627701..f34b6d2 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -257,20 +257,27 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
257 | return true; | 257 | return true; |
258 | } | 258 | } |
259 | 259 | ||
260 | public bool SaveBakedTextures(UUID agentId) | 260 | public Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId) |
261 | { | 261 | { |
262 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 262 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
263 | 263 | ||
264 | if (sp == null || sp.IsChildAgent) | 264 | if (sp == null) |
265 | return false; | 265 | return new Dictionary<BakeType, Primitive.TextureEntryFace>(); |
266 | |||
267 | return GetBakedTextureFaces(sp); | ||
268 | } | ||
269 | |||
270 | private Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(ScenePresence sp) | ||
271 | { | ||
272 | if (sp.IsChildAgent) | ||
273 | return new Dictionary<BakeType, Primitive.TextureEntryFace>(); | ||
274 | |||
275 | Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures | ||
276 | = new Dictionary<BakeType, Primitive.TextureEntryFace>(); | ||
266 | 277 | ||
267 | AvatarAppearance appearance = sp.Appearance; | 278 | AvatarAppearance appearance = sp.Appearance; |
268 | Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures; | 279 | Primitive.TextureEntryFace[] faceTextures = appearance.Texture.FaceTextures; |
269 | 280 | ||
270 | m_log.DebugFormat( | ||
271 | "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", | ||
272 | sp.Name, m_scene.RegionInfo.RegionName); | ||
273 | |||
274 | foreach (int i in Enum.GetValues(typeof(BakeType))) | 281 | foreach (int i in Enum.GetValues(typeof(BakeType))) |
275 | { | 282 | { |
276 | BakeType bakeType = (BakeType)i; | 283 | BakeType bakeType = (BakeType)i; |
@@ -283,7 +290,31 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
283 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 290 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
284 | 291 | ||
285 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | 292 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); |
286 | Primitive.TextureEntryFace bakedTextureFace = faceTextures[ftIndex]; | 293 | bakedTextures[bakeType] = faceTextures[ftIndex]; |
294 | } | ||
295 | |||
296 | return bakedTextures; | ||
297 | } | ||
298 | |||
299 | public bool SaveBakedTextures(UUID agentId) | ||
300 | { | ||
301 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
302 | |||
303 | if (sp == null) | ||
304 | return false; | ||
305 | |||
306 | m_log.DebugFormat( | ||
307 | "[AV FACTORY]: Permanently saving baked textures for {0} in {1}", | ||
308 | sp.Name, m_scene.RegionInfo.RegionName); | ||
309 | |||
310 | Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp); | ||
311 | |||
312 | if (bakedTextures.Count == 0) | ||
313 | return false; | ||
314 | |||
315 | foreach (BakeType bakeType in bakedTextures.Keys) | ||
316 | { | ||
317 | Primitive.TextureEntryFace bakedTextureFace = bakedTextures[bakeType]; | ||
287 | 318 | ||
288 | if (bakedTextureFace == null) | 319 | if (bakedTextureFace == null) |
289 | { | 320 | { |
@@ -299,6 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
299 | if (asset != null) | 330 | if (asset != null) |
300 | { | 331 | { |
301 | asset.Temporary = false; | 332 | asset.Temporary = false; |
333 | asset.Local = false; | ||
302 | m_scene.AssetService.Store(asset); | 334 | m_scene.AssetService.Store(asset); |
303 | } | 335 | } |
304 | else | 336 | else |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index b831b31..7b2f14e 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -26,9 +26,12 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
29 | using NUnit.Framework; | 31 | using NUnit.Framework; |
30 | using OpenMetaverse; | 32 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.CoreModules.Asset; | ||
32 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
34 | using OpenSim.Tests.Common.Mock; | 37 | using OpenSim.Tests.Common.Mock; |
@@ -65,5 +68,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
65 | // TODO: Check baked texture | 68 | // TODO: Check baked texture |
66 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); | 69 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); |
67 | } | 70 | } |
71 | |||
72 | [Test] | ||
73 | public void TestSaveBakedTextures() | ||
74 | { | ||
75 | TestHelpers.InMethod(); | ||
76 | // log4net.Config.XmlConfigurator.Configure(); | ||
77 | |||
78 | UUID userId = TestHelpers.ParseTail(0x1); | ||
79 | UUID eyesTextureId = TestHelpers.ParseTail(0x2); | ||
80 | |||
81 | // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly | ||
82 | // to the AssetService, which will then store temporary and local assets permanently | ||
83 | CoreAssetCache assetCache = new CoreAssetCache(); | ||
84 | |||
85 | AvatarFactoryModule afm = new AvatarFactoryModule(); | ||
86 | TestScene scene = SceneHelpers.SetupScene(assetCache); | ||
87 | SceneHelpers.SetupSceneModules(scene, afm); | ||
88 | IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | ||
89 | |||
90 | // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules | ||
91 | AssetBase uploadedAsset; | ||
92 | uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString()); | ||
93 | uploadedAsset.Data = new byte[] { 2 }; | ||
94 | uploadedAsset.Temporary = true; | ||
95 | uploadedAsset.Local = true; // Local assets aren't persisted, non-local are | ||
96 | scene.AssetService.Store(uploadedAsset); | ||
97 | |||
98 | byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; | ||
99 | for (byte i = 0; i < visualParams.Length; i++) | ||
100 | visualParams[i] = i; | ||
101 | |||
102 | Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); | ||
103 | uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); | ||
104 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); | ||
105 | eyesFace.TextureID = eyesTextureId; | ||
106 | |||
107 | afm.SetAppearanceFromClient(tc, bakedTextureEntry, visualParams); | ||
108 | afm.SaveBakedTextures(userId); | ||
109 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); | ||
110 | |||
111 | // We should also inpsect the asset data store layer directly, but this is difficult to get at right now. | ||
112 | assetCache.Clear(); | ||
113 | |||
114 | AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString()); | ||
115 | Assert.That(eyesBake, Is.Not.Null); | ||
116 | Assert.That(eyesBake.Temporary, Is.False); | ||
117 | Assert.That(eyesBake.Local, Is.False); | ||
118 | } | ||
68 | } | 119 | } |
69 | } \ No newline at end of file | 120 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 51d1d59..cc5d061 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -129,15 +129,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
129 | m_Cache = null; | 129 | m_Cache = null; |
130 | } | 130 | } |
131 | 131 | ||
132 | m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName); | 132 | m_log.DebugFormat( |
133 | "[LOCAL ASSET SERVICES CONNECTOR]: Enabled connector for region {0}", scene.RegionInfo.RegionName); | ||
133 | 134 | ||
134 | if (m_Cache != null) | 135 | if (m_Cache != null) |
135 | { | 136 | { |
136 | m_log.InfoFormat("[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); | 137 | m_log.DebugFormat( |
138 | "[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}", | ||
139 | scene.RegionInfo.RegionName); | ||
137 | } | 140 | } |
138 | else | 141 | else |
139 | { | 142 | { |
140 | // Short-circuit directly to storage layer | 143 | // Short-circuit directly to storage layer. This ends up storing temporary and local assets. |
141 | // | 144 | // |
142 | scene.UnregisterModuleInterface<IAssetService>(this); | 145 | scene.UnregisterModuleInterface<IAssetService>(this); |
143 | scene.RegisterModuleInterface<IAssetService>(m_AssetService); | 146 | scene.RegisterModuleInterface<IAssetService>(m_AssetService); |
@@ -246,9 +249,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
246 | m_Cache.Cache(asset); | 249 | m_Cache.Cache(asset); |
247 | 250 | ||
248 | if (asset.Temporary || asset.Local) | 251 | if (asset.Temporary || asset.Local) |
252 | { | ||
253 | // m_log.DebugFormat( | ||
254 | // "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}", | ||
255 | // asset.Name, asset.ID, asset.Temporary, asset.Local); | ||
256 | |||
249 | return asset.ID; | 257 | return asset.ID; |
250 | 258 | } | |
251 | return m_AssetService.Store(asset); | 259 | else |
260 | { | ||
261 | // m_log.DebugFormat( | ||
262 | // "[LOCAL ASSET SERVICE CONNECTOR]: Passing {0} {1} on to asset service for storage, status Temporary = {2}, Local = {3}", | ||
263 | // asset.Name, asset.ID, asset.Temporary, asset.Local); | ||
264 | |||
265 | return m_AssetService.Store(asset); | ||
266 | } | ||
252 | } | 267 | } |
253 | 268 | ||
254 | public bool UpdateContent(string id, byte[] data) | 269 | public bool UpdateContent(string id, byte[] data) |
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs index 6817725..4dbddf4 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using OpenMetaverse; | 29 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
30 | 31 | ||
@@ -39,7 +40,23 @@ namespace OpenSim.Region.Framework.Interfaces | |||
39 | /// <returns></returns> | 40 | /// <returns></returns> |
40 | bool SendAppearance(UUID agentId); | 41 | bool SendAppearance(UUID agentId); |
41 | 42 | ||
43 | /// <summary> | ||
44 | /// Return the baked texture ids of the given agent. | ||
45 | /// </summary> | ||
46 | /// <param name="agentId"></param> | ||
47 | /// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns> | ||
48 | Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId); | ||
49 | |||
50 | /// <summary> | ||
51 | /// Save the baked textures for the given agent permanently in the asset database. | ||
52 | /// </summary> | ||
53 | /// <remarks> | ||
54 | /// This is used to preserve apperance textures for NPCs | ||
55 | /// </remarks> | ||
56 | /// <param name="agentId"></param> | ||
57 | /// <returns>true if a valid agent was found, false otherwise</returns> | ||
42 | bool SaveBakedTextures(UUID agentId); | 58 | bool SaveBakedTextures(UUID agentId); |
59 | |||
43 | bool ValidateBakedTextureCache(IClientAPI client); | 60 | bool ValidateBakedTextureCache(IClientAPI client); |
44 | void QueueAppearanceSend(UUID agentid); | 61 | void QueueAppearanceSend(UUID agentid); |
45 | void QueueAppearanceSave(UUID agentid); | 62 | void QueueAppearanceSave(UUID agentid); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4148d4b..4143d44 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1695,9 +1695,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1695 | /// </param> | 1695 | /// </param> |
1696 | public void MoveToTarget(Vector3 pos, bool noFly) | 1696 | public void MoveToTarget(Vector3 pos, bool noFly) |
1697 | { | 1697 | { |
1698 | // m_log.DebugFormat( | 1698 | m_log.DebugFormat( |
1699 | // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", | 1699 | "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", |
1700 | // Name, pos, m_scene.RegionInfo.RegionName); | 1700 | Name, pos, m_scene.RegionInfo.RegionName); |
1701 | 1701 | ||
1702 | if (pos.X < 0 || pos.X >= Constants.RegionSize | 1702 | if (pos.X < 0 || pos.X >= Constants.RegionSize |
1703 | || pos.Y < 0 || pos.Y >= Constants.RegionSize | 1703 | || pos.Y < 0 || pos.Y >= Constants.RegionSize |