diff options
author | Mic Bowman | 2011-08-30 08:44:28 -0700 |
---|---|---|
committer | Mic Bowman | 2011-08-30 08:44:28 -0700 |
commit | 17dab7245fd3f132264fb4ae5e8e70ebdbde073b (patch) | |
tree | 4099256b83c94e9c568c316431ebc92a32a85241 /OpenSim/Region/CoreModules/Avatar/AvatarFactory | |
parent | Use GetMeshKey from PrimitiveBaseShape. (diff) | |
parent | Fix bug in persisting saved appearances for npcs (diff) | |
download | opensim-SC_OLD-17dab7245fd3f132264fb4ae5e8e70ebdbde073b.zip opensim-SC_OLD-17dab7245fd3f132264fb4ae5e8e70ebdbde073b.tar.gz opensim-SC_OLD-17dab7245fd3f132264fb4ae5e8e70ebdbde073b.tar.bz2 opensim-SC_OLD-17dab7245fd3f132264fb4ae5e8e70ebdbde073b.tar.xz |
Merge branch 'master' into bulletsim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 48 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | 51 |
2 files changed, 91 insertions, 8 deletions
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 |