aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/AvatarFactory
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/AvatarFactory')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs119
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs4
2 files changed, 94 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index ce79f07..cfc7e7e 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -140,9 +140,24 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
140 /// <param name="sp"></param> 140 /// <param name="sp"></param>
141 /// <param name="texture"></param> 141 /// <param name="texture"></param>
142 /// <param name="visualParam"></param> 142 /// <param name="visualParam"></param>
143 public void SetAppearance(IScenePresence sp, AvatarAppearance appearance) 143 public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems)
144 { 144 {
145 SetAppearance(sp, appearance.Texture, appearance.VisualParams); 145 SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems);
146 }
147
148
149 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
150 {
151 float oldoff = sp.Appearance.AvatarFeetOffset;
152 Vector3 oldbox = sp.Appearance.AvatarBoxSize;
153
154 SetAppearance(sp, textureEntry, visualParams, cacheItems);
155 sp.Appearance.SetSize(avSize);
156
157 float off = sp.Appearance.AvatarFeetOffset;
158 Vector3 box = sp.Appearance.AvatarBoxSize;
159 if (oldoff != off || oldbox != box)
160 ((ScenePresence)sp).SetSize(box, off);
146 } 161 }
147 162
148 /// <summary> 163 /// <summary>
@@ -151,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
151 /// <param name="sp"></param> 166 /// <param name="sp"></param>
152 /// <param name="texture"></param> 167 /// <param name="texture"></param>
153 /// <param name="visualParam"></param> 168 /// <param name="visualParam"></param>
154 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) 169 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems)
155 { 170 {
156// m_log.DebugFormat( 171// m_log.DebugFormat(
157// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", 172// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}",
@@ -174,18 +189,27 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
174 // m_log.DebugFormat( 189 // m_log.DebugFormat(
175 // "[AVFACTORY]: Setting visual params for {0} to {1}", 190 // "[AVFACTORY]: Setting visual params for {0} to {1}",
176 // client.Name, string.Join(", ", visualParamsStrings)); 191 // client.Name, string.Join(", ", visualParamsStrings));
177 192/*
178 float oldHeight = sp.Appearance.AvatarHeight; 193 float oldHeight = sp.Appearance.AvatarHeight;
179 changed = sp.Appearance.SetVisualParams(visualParams); 194 changed = sp.Appearance.SetVisualParams(visualParams);
180 195
181 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) 196 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
182 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); 197 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
183 } 198 */
199// float oldoff = sp.Appearance.AvatarFeetOffset;
200// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
201 changed = sp.Appearance.SetVisualParams(visualParams);
202// float off = sp.Appearance.AvatarFeetOffset;
203// Vector3 box = sp.Appearance.AvatarBoxSize;
204// if(oldoff != off || oldbox != box)
205// ((ScenePresence)sp).SetSize(box,off);
184 206
207 }
208
185 // Process the baked texture array 209 // Process the baked texture array
186 if (textureEntry != null) 210 if (textureEntry != null)
187 { 211 {
188// m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); 212 m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID);
189 213
190// WriteBakedTexturesReport(sp, m_log.DebugFormat); 214// WriteBakedTexturesReport(sp, m_log.DebugFormat);
191 215
@@ -254,6 +278,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
254 return GetBakedTextureFaces(sp); 278 return GetBakedTextureFaces(sp);
255 } 279 }
256 280
281 public WearableCacheItem[] GetCachedItems(UUID agentId)
282 {
283 ScenePresence sp = m_scene.GetScenePresence(agentId);
284 WearableCacheItem[] items = sp.Appearance.WearableCacheItems;
285 //foreach (WearableCacheItem item in items)
286 //{
287
288 //}
289 return items;
290 }
291
257 public bool SaveBakedTextures(UUID agentId) 292 public bool SaveBakedTextures(UUID agentId)
258 { 293 {
259 ScenePresence sp = m_scene.GetScenePresence(agentId); 294 ScenePresence sp = m_scene.GetScenePresence(agentId);
@@ -340,6 +375,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
340 public bool ValidateBakedTextureCache(IScenePresence sp) 375 public bool ValidateBakedTextureCache(IScenePresence sp)
341 { 376 {
342 bool defonly = true; // are we only using default textures 377 bool defonly = true; // are we only using default textures
378 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
343 379
344 // Process the texture entry 380 // Process the texture entry
345 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 381 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
@@ -364,8 +400,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
364 400
365 defonly = false; // found a non-default texture reference 401 defonly = false; // found a non-default texture reference
366 402
367 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 403 if (cache != null)
368 return false; 404 {
405 if (!cache.Check(face.TextureID.ToString()))
406 return false;
407 }
408 else
409 {
410 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
411 return false;
412 }
369 } 413 }
370 414
371// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 415// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
@@ -377,6 +421,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
377 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 421 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
378 { 422 {
379 int texturesRebaked = 0; 423 int texturesRebaked = 0;
424 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
380 425
381 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 426 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
382 { 427 {
@@ -400,21 +445,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
400 445
401 if (missingTexturesOnly) 446 if (missingTexturesOnly)
402 { 447 {
403 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) 448 if (cache != null)
404 { 449 {
405 continue; 450 if (cache.Check(face.TextureID.ToString()))
451 continue;
452 else
453 {
454 m_log.DebugFormat(
455 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
456 face.TextureID, idx, sp.Name);
457 }
406 } 458 }
407 else 459 else
408 { 460 {
409 // On inter-simulator teleports, this occurs if baked textures are not being stored by the 461 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
410 // grid asset service (which means that they are not available to the new region and so have 462 {
411 // to be re-requested from the client). 463 continue;
412 // 464 }
413 // The only available core OpenSimulator behaviour right now 465
414 // is not to store these textures, temporarily or otherwise. 466 else
415 m_log.DebugFormat( 467 {
416 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", 468 // On inter-simulator teleports, this occurs if baked textures are not being stored by the
417 face.TextureID, idx, sp.Name); 469 // grid asset service (which means that they are not available to the new region and so have
470 // to be re-requested from the client).
471 //
472 // The only available core OpenSimulator behaviour right now
473 // is not to store these textures, temporarily or otherwise.
474 m_log.DebugFormat(
475 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
476 face.TextureID, idx, sp.Name);
477 }
418 } 478 }
419 } 479 }
420 else 480 else
@@ -595,12 +655,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
595 /// <param name="client"></param> 655 /// <param name="client"></param>
596 private void Client_OnRequestWearables(IClientAPI client) 656 private void Client_OnRequestWearables(IClientAPI client)
597 { 657 {
598 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); 658 Util.FireAndForget(delegate(object x)
599 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 659 {
600 if (sp != null) 660 Thread.Sleep(4000);
601 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); 661
602 else 662 // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId);
603 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); 663 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
664 if (sp != null)
665 client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++);
666 else
667 m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId);
668 });
604 } 669 }
605 670
606 /// <summary> 671 /// <summary>
@@ -609,12 +674,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
609 /// <param name="client"></param> 674 /// <param name="client"></param>
610 /// <param name="texture"></param> 675 /// <param name="texture"></param>
611 /// <param name="visualParam"></param> 676 /// <param name="visualParam"></param>
612 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) 677 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
613 { 678 {
614 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); 679 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId);
615 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 680 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
616 if (sp != null) 681 if (sp != null)
617 SetAppearance(sp, textureEntry, visualParams); 682 SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems);
618 else 683 else
619 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); 684 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId);
620 } 685 }
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
index 1830d41..f090e15 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
61 for (byte i = 0; i < visualParams.Length; i++) 61 for (byte i = 0; i < visualParams.Length; i++)
62 visualParams[i] = i; 62 visualParams[i] = i;
63 63
64 afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); 64 afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]);
65 65
66 // TODO: Check baked texture 66 // TODO: Check baked texture
67 Assert.AreEqual(visualParams, sp.Appearance.VisualParams); 67 Assert.AreEqual(visualParams, sp.Appearance.VisualParams);
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
102 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 102 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
103 eyesFace.TextureID = eyesTextureId; 103 eyesFace.TextureID = eyesTextureId;
104 104
105 afm.SetAppearance(sp, bakedTextureEntry, visualParams); 105 afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]);
106 afm.SaveBakedTextures(userId); 106 afm.SaveBakedTextures(userId);
107// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); 107// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
108 108