aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2010-10-29 21:06:46 +0100
committerMelanie2010-10-29 21:06:46 +0100
commit934e53673856876762df27c7880df30df633ccd3 (patch)
treeb50129669f9d7f725cf63db1df60c600b8da9f0c /OpenSim/Framework
parentAdd my work on top of cmickeyb's (diff)
parentClean up some cruft from the last commit. Re-add the initial update (diff)
downloadopensim-SC-934e53673856876762df27c7880df30df633ccd3.zip
opensim-SC-934e53673856876762df27c7880df30df633ccd3.tar.gz
opensim-SC-934e53673856876762df27c7880df30df633ccd3.tar.bz2
opensim-SC-934e53673856876762df27c7880df30df633ccd3.tar.xz
Merge commit 'cmickeyb/dev-appearance'
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs66
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs186
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs14
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs98
4 files changed, 207 insertions, 157 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index be98380..640a646 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -206,16 +206,18 @@ namespace OpenSim.Framework
206 206
207 args["service_session_id"] = OSD.FromString(ServiceSessionID); 207 args["service_session_id"] = OSD.FromString(ServiceSessionID);
208 args["start_pos"] = OSD.FromString(startpos.ToString()); 208 args["start_pos"] = OSD.FromString(startpos.ToString());
209 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
210 args["client_ip"] = OSD.FromString(IPAddress); 209 args["client_ip"] = OSD.FromString(IPAddress);
211 args["viewer"] = OSD.FromString(Viewer); 210 args["viewer"] = OSD.FromString(Viewer);
212 args["channel"] = OSD.FromString(Channel); 211 args["channel"] = OSD.FromString(Channel);
213 args["mac"] = OSD.FromString(Mac); 212 args["mac"] = OSD.FromString(Mac);
214 args["id0"] = OSD.FromString(Id0); 213 args["id0"] = OSD.FromString(Id0);
215 214
216/* 215 // Eventually this code should be deprecated, use full appearance
216 // packing in packed_appearance
217 if (Appearance != null) 217 if (Appearance != null)
218 { 218 {
219 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
220
219 //System.Console.WriteLine("XXX Before packing Wearables"); 221 //System.Console.WriteLine("XXX Before packing Wearables");
220 if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) 222 if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
221 { 223 {
@@ -230,20 +232,19 @@ namespace OpenSim.Framework
230 } 232 }
231 233
232 //System.Console.WriteLine("XXX Before packing Attachments"); 234 //System.Console.WriteLine("XXX Before packing Attachments");
233 Dictionary<int, AvatarAttachment> attachments = Appearance.Attachments; 235 List<AvatarAttachment> attachments = Appearance.GetAttachments();
234 if ((attachments != null) && (attachments.Count > 0)) 236 if ((attachments != null) && (attachments.Count > 0))
235 { 237 {
236 OSDArray attachs = new OSDArray(attachments.Count); 238 OSDArray attachs = new OSDArray(attachments.Count);
237 foreach (KeyValuePair<int, AvatarAttachment> kvp in attachments) 239 foreach (AvatarAttachment attach in attachments)
238 { 240 {
239 AvatarAttachment adata = new AvatarAttachment(kvp.Value); 241 attachs.Add(attach.Pack());
240 attachs.Add(adata.Pack());
241 //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]); 242 //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]);
242 } 243 }
243 args["attachments"] = attachs; 244 args["attachments"] = attachs;
244 } 245 }
245 } 246 }
246*/ 247
247 if (Appearance != null) 248 if (Appearance != null)
248 { 249 {
249 OSDMap appmap = Appearance.Pack(); 250 OSDMap appmap = Appearance.Pack();
@@ -339,27 +340,9 @@ namespace OpenSim.Framework
339 try { 340 try {
340 // Unpack various appearance elements 341 // Unpack various appearance elements
341 Appearance = new AvatarAppearance(AgentID); 342 Appearance = new AvatarAppearance(AgentID);
342 if (args["packed_appearance"] != null) 343
343 { 344 // Eventually this code should be deprecated, use full appearance
344 if (args["packed_appearance"].Type == OSDType.Map) 345 // packing in packed_appearance
345 {
346 Appearance.Unpack((OSDMap)args["packed_appearance"]);
347 m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
348 }
349 else
350 m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString());
351 }
352// DEBUG ON
353 else
354 m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
355// DEBUG OFF
356 } catch (Exception e)
357 {
358 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
359 }
360
361
362/*
363 if (args["appearance_serial"] != null) 346 if (args["appearance_serial"] != null)
364 Appearance.Serial = args["appearance_serial"].AsInteger(); 347 Appearance.Serial = args["appearance_serial"].AsInteger();
365 348
@@ -368,26 +351,39 @@ namespace OpenSim.Framework
368 OSDArray wears = (OSDArray)(args["wearables"]); 351 OSDArray wears = (OSDArray)(args["wearables"]);
369 for (int i = 0; i < wears.Count / 2; i++) 352 for (int i = 0; i < wears.Count / 2; i++)
370 { 353 {
371 Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); 354 AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID());
372 Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); 355 Appearance.SetWearable(i,awear);
373 } 356 }
374 } 357 }
375 358
376 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 359 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
377 { 360 {
378 OSDArray attachs = (OSDArray)(args["attachments"]); 361 OSDArray attachs = (OSDArray)(args["attachments"]);
379 AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count];
380 int i = 0;
381 foreach (OSD o in attachs) 362 foreach (OSD o in attachs)
382 { 363 {
383 if (o.Type == OSDType.Map) 364 if (o.Type == OSDType.Map)
384 { 365 {
385 attachments[i++] = new AvatarAttachment((OSDMap)o); 366 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
386 } 367 }
387 } 368 }
388 Appearance.SetAttachments(attachments);
389 } 369 }
390*/ 370
371 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
372 {
373 Appearance.Unpack((OSDMap)args["packed_appearance"]);
374// DEBUG ON
375 m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
376// DEBUG OFF
377 }
378// DEBUG ON
379 else
380 m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
381// DEBUG OFF
382 } catch (Exception e)
383 {
384 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
385 }
386
391 ServiceURLs = new Dictionary<string, object>(); 387 ServiceURLs = new Dictionary<string, object>();
392 if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) 388 if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
393 { 389 {
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 4738d88..a4bb765 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -143,13 +143,14 @@ namespace OpenSim.Framework
143 public readonly static int VISUALPARAM_COUNT = 218; 143 public readonly static int VISUALPARAM_COUNT = 218;
144 144
145 public readonly static int TEXTURE_COUNT = 21; 145 public readonly static int TEXTURE_COUNT = 21;
146 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
146 147
147 protected UUID m_owner; 148 protected UUID m_owner;
148 protected int m_serial = 1; 149 protected int m_serial = 1;
149 protected byte[] m_visualparams; 150 protected byte[] m_visualparams;
150 protected Primitive.TextureEntry m_texture; 151 protected Primitive.TextureEntry m_texture;
151 protected AvatarWearable[] m_wearables; 152 protected AvatarWearable[] m_wearables;
152 protected Dictionary<int, AvatarAttachment> m_attachments; 153 protected Dictionary<int, List<AvatarAttachment>> m_attachments;
153 protected float m_avatarHeight = 0; 154 protected float m_avatarHeight = 0;
154 protected float m_hipOffset = 0; 155 protected float m_hipOffset = 0;
155 156
@@ -183,11 +184,6 @@ namespace OpenSim.Framework
183 set { m_wearables = value; } 184 set { m_wearables = value; }
184 } 185 }
185 186
186 public virtual Dictionary<int, AvatarAttachment> Attachments
187 {
188 get { return m_attachments; }
189 }
190
191 public virtual UUID BodyItem { 187 public virtual UUID BodyItem {
192 get { return m_wearables[AvatarWearable.BODY].ItemID; } 188 get { return m_wearables[AvatarWearable.BODY].ItemID; }
193 set { m_wearables[AvatarWearable.BODY].ItemID = value; } 189 set { m_wearables[AvatarWearable.BODY].ItemID = value; }
@@ -336,7 +332,7 @@ namespace OpenSim.Framework
336// DEBUG ON 332// DEBUG ON
337 m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner); 333 m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner);
338// DEBUG OFF 334// DEBUG OFF
339 m_serial = 0; 335 m_serial = 1;
340 m_owner = owner; 336 m_owner = owner;
341 337
342 SetDefaultWearables(); 338 SetDefaultWearables();
@@ -344,7 +340,7 @@ namespace OpenSim.Framework
344 SetDefaultParams(); 340 SetDefaultParams();
345 SetHeight(); 341 SetHeight();
346 342
347 m_attachments = new Dictionary<int, AvatarAttachment>(); 343 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
348 } 344 }
349 345
350 public AvatarAppearance(UUID avatarID, OSDMap map) 346 public AvatarAppearance(UUID avatarID, OSDMap map)
@@ -382,7 +378,7 @@ namespace OpenSim.Framework
382 378
383 SetHeight(); 379 SetHeight();
384 380
385 m_attachments = new Dictionary<int, AvatarAttachment>(); 381 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
386 } 382 }
387 383
388 public AvatarAppearance(AvatarAppearance appearance) 384 public AvatarAppearance(AvatarAppearance appearance)
@@ -392,7 +388,7 @@ namespace OpenSim.Framework
392// DEBUG OFF 388// DEBUG OFF
393 if (appearance == null) 389 if (appearance == null)
394 { 390 {
395 m_serial = 0; 391 m_serial = 1;
396 m_owner = UUID.Zero; 392 m_owner = UUID.Zero;
397 393
398 SetDefaultWearables(); 394 SetDefaultWearables();
@@ -400,7 +396,7 @@ namespace OpenSim.Framework
400 SetDefaultParams(); 396 SetDefaultParams();
401 SetHeight(); 397 SetHeight();
402 398
403 m_attachments = new Dictionary<int, AvatarAttachment>(); 399 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
404 400
405 return; 401 return;
406 } 402 }
@@ -427,9 +423,10 @@ namespace OpenSim.Framework
427 if (appearance.VisualParams != null) 423 if (appearance.VisualParams != null)
428 m_visualparams = (byte[])appearance.VisualParams.Clone(); 424 m_visualparams = (byte[])appearance.VisualParams.Clone();
429 425
430 m_attachments = new Dictionary<int, AvatarAttachment>(); 426 // Copy the attachment, force append mode since that ensures consistency
431 foreach (KeyValuePair<int, AvatarAttachment> kvp in appearance.Attachments) 427 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
432 m_attachments[kvp.Key] = new AvatarAttachment(kvp.Value); 428 foreach (AvatarAttachment attachment in appearance.GetAttachments())
429 AppendAttachment(new AvatarAttachment(attachment));
433 } 430 }
434 431
435 protected virtual void SetDefaultWearables() 432 protected virtual void SetDefaultWearables()
@@ -449,14 +446,8 @@ namespace OpenSim.Framework
449 protected virtual void SetDefaultTexture() 446 protected virtual void SetDefaultTexture()
450 { 447 {
451 m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); 448 m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
452 // The initialization of these seems to force a rebake regardless of whether it is needed 449 for (uint i = 0; i < TEXTURE_COUNT; i++)
453 // m_textures.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012"); 450 m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE);
454 // m_textures.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
455 // m_textures.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID;
456 // m_textures.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
457 // m_textures.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
458 // m_textures.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010");
459 // m_textures.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011");
460 } 451 }
461 452
462 /// <summary> 453 /// <summary>
@@ -473,7 +464,7 @@ namespace OpenSim.Framework
473 // made. We determine if any of the textures actually 464 // made. We determine if any of the textures actually
474 // changed to know if the appearance should be saved later 465 // changed to know if the appearance should be saved later
475 bool changed = false; 466 bool changed = false;
476 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) 467 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
477 { 468 {
478 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i]; 469 Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i];
479 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i]; 470 Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i];
@@ -487,14 +478,14 @@ namespace OpenSim.Framework
487 if (oldface != null && oldface.TextureID == newface.TextureID) continue; 478 if (oldface != null && oldface.TextureID == newface.TextureID) continue;
488 } 479 }
489 480
490 m_texture.FaceTextures[i] = (newface != null) ? new Primitive.TextureEntryFace(newface) : null;
491 changed = true; 481 changed = true;
492// DEBUG ON 482// DEBUG ON
493 if (newface != null) 483 if (newface != null)
494 m_log.WarnFormat("[SCENEPRESENCE] index {0}, new texture id {1}",i,newface.TextureID); 484 m_log.WarnFormat("[AVATAR APPEARANCE] index {0}, new texture id {1}",i,newface.TextureID);
495// DEBUG OFF 485// DEBUG OFF
496 } 486 }
497 487
488 m_texture = textureEntry;
498 return changed; 489 return changed;
499 } 490 }
500 491
@@ -517,8 +508,8 @@ namespace OpenSim.Framework
517 if (visualParams[i] != m_visualparams[i]) 508 if (visualParams[i] != m_visualparams[i])
518 { 509 {
519// DEBUG ON 510// DEBUG ON
520 m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", 511// m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}",
521 i,m_visualparams[i],visualParams[i]); 512// i,m_visualparams[i],visualParams[i]);
522// DEBUG OFF 513// DEBUG OFF
523 m_visualparams[i] = visualParams[i]; 514 m_visualparams[i] = visualParams[i];
524 changed = true; 515 changed = true;
@@ -569,6 +560,9 @@ namespace OpenSim.Framework
569 public override String ToString() 560 public override String ToString()
570 { 561 {
571 String s = ""; 562 String s = "";
563
564 s += String.Format("Serial: {0}\n",m_serial);
565
572 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) 566 for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
573 if (m_texture.FaceTextures[i] != null) 567 if (m_texture.FaceTextures[i] != null)
574 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID); 568 s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID);
@@ -585,12 +579,41 @@ namespace OpenSim.Framework
585 } 579 }
586// DEBUG OFF 580// DEBUG OFF
587 581
588 public void SetAttachments(AvatarAttachment[] data) 582 /// <summary>
583 /// Get a list of the attachments, note that there may be
584 /// duplicate attachpoints
585 /// </summary>
586 public List<AvatarAttachment> GetAttachments()
587 {
588 List<AvatarAttachment> alist = new List<AvatarAttachment>();
589 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
590 {
591 foreach (AvatarAttachment attach in kvp.Value)
592 alist.Add(new AvatarAttachment(attach));
593 }
594
595 return alist;
596 }
597
598 internal void AppendAttachment(AvatarAttachment attach)
589 { 599 {
590 foreach (AvatarAttachment attach in data) 600 if (! m_attachments.ContainsKey(attach.AttachPoint))
591 m_attachments[attach.AttachPoint] = new AvatarAttachment(attach); 601 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
602 m_attachments[attach.AttachPoint].Add(attach);
592 } 603 }
593 604
605 internal void ReplaceAttachment(AvatarAttachment attach)
606 {
607 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
608 m_attachments[attach.AttachPoint].Add(attach);
609 }
610
611 /// <summary>
612 /// Add an attachment, if the attachpoint has the
613 /// 0x80 bit set then we assume this is an append
614 /// operation otherwise we replace whatever is
615 /// currently attached at the attachpoint
616 /// </summary>
594 public void SetAttachment(int attachpoint, UUID item, UUID asset) 617 public void SetAttachment(int attachpoint, UUID item, UUID asset)
595 { 618 {
596 if (attachpoint == 0) 619 if (attachpoint == 0)
@@ -603,67 +626,47 @@ namespace OpenSim.Framework
603 return; 626 return;
604 } 627 }
605 628
606 m_attachments[attachpoint] = new AvatarAttachment(attachpoint,item,asset); 629 // check if this is an append or a replace, 0x80 marks it as an append
607 } 630 if ((attachpoint & 0x80) > 0)
608
609 public Hashtable GetAttachments()
610 {
611 if (m_attachments.Count == 0)
612 return null;
613
614 Hashtable ret = new Hashtable();
615
616 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments)
617 { 631 {
618 Hashtable data = new Hashtable(); 632 // strip the append bit
619 data["item"] = kvp.Value.ItemID.ToString(); 633 int point = attachpoint & 0x7F;
620 data["asset"] = kvp.Value.AssetID.ToString(); 634 AppendAttachment(new AvatarAttachment(point, item, asset));
621 635 }
622 ret[kvp.Key] = data; 636 else
637 {
638 ReplaceAttachment(new AvatarAttachment(attachpoint,item,asset));
623 } 639 }
624
625 return ret;
626 }
627
628 public List<int> GetAttachedPoints()
629 {
630 return new List<int>(m_attachments.Keys);
631 }
632
633 public UUID GetAttachedItem(int attachpoint)
634 {
635 if (!m_attachments.ContainsKey(attachpoint))
636 return UUID.Zero;
637
638 return m_attachments[attachpoint].ItemID;
639 }
640
641 public UUID GetAttachedAsset(int attachpoint)
642 {
643 if (!m_attachments.ContainsKey(attachpoint))
644 return UUID.Zero;
645
646 return m_attachments[attachpoint].AssetID;
647 } 640 }
648 641
649 public int GetAttachpoint(UUID itemID) 642 public int GetAttachpoint(UUID itemID)
650 { 643 {
651 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments) 644 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
652 { 645 {
653 if (kvp.Value.ItemID == itemID) 646 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
654 { 647 if (index >= 0)
655 return kvp.Key; 648 return kvp.Key;
656 }
657 } 649 }
650
658 return 0; 651 return 0;
659 } 652 }
660 653
661 public void DetachAttachment(UUID itemID) 654 public void DetachAttachment(UUID itemID)
662 { 655 {
663 int attachpoint = GetAttachpoint(itemID); 656 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
657 {
658 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
659 if (index >= 0)
660 {
661 // Remove it from the list of attachments at that attach point
662 m_attachments[kvp.Key].RemoveAt(index);
664 663
665 if (attachpoint > 0) 664 // And remove the list if there are no more attachments here
666 m_attachments.Remove(attachpoint); 665 if (m_attachments[kvp.Key].Count == 0)
666 m_attachments.Remove(kvp.Key);
667 return;
668 }
669 }
667 } 670 }
668 671
669 public void ClearAttachments() 672 public void ClearAttachments()
@@ -671,6 +674,8 @@ namespace OpenSim.Framework
671 m_attachments.Clear(); 674 m_attachments.Clear();
672 } 675 }
673 676
677 #region Packing Functions
678
674 /// <summary> 679 /// <summary>
675 /// Create an OSDMap from the appearance data 680 /// Create an OSDMap from the appearance data
676 /// </summary> 681 /// </summary>
@@ -695,7 +700,7 @@ namespace OpenSim.Framework
695 if (m_texture.FaceTextures[i] != null) 700 if (m_texture.FaceTextures[i] != null)
696 textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID)); 701 textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID));
697 else 702 else
698 textures.Add(OSD.FromUUID(UUID.Zero)); 703 textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
699 } 704 }
700 data["textures"] = textures; 705 data["textures"] = textures;
701 706
@@ -705,8 +710,8 @@ namespace OpenSim.Framework
705 710
706 // Attachments 711 // Attachments
707 OSDArray attachs = new OSDArray(m_attachments.Count); 712 OSDArray attachs = new OSDArray(m_attachments.Count);
708 foreach (KeyValuePair<int, AvatarAttachment> kvp in m_attachments) 713 foreach (AvatarAttachment attach in GetAttachments())
709 attachs.Add(kvp.Value.Pack()); 714 attachs.Add(attach.Pack());
710 data["attachments"] = attachs; 715 data["attachments"] = attachs;
711 716
712 return data; 717 return data;
@@ -718,8 +723,8 @@ namespace OpenSim.Framework
718 /// </summary> 723 /// </summary>
719 public void Unpack(OSDMap data) 724 public void Unpack(OSDMap data)
720 { 725 {
721 if ((data != null) && (data["appearance_serial"] != null)) 726 if ((data != null) && (data["serial"] != null))
722 m_serial = data["appearance_serial"].AsInteger(); 727 m_serial = data["serial"].AsInteger();
723 if ((data != null) && (data["height"] != null)) 728 if ((data != null) && (data["height"] != null))
724 m_avatarHeight = (float)data["height"].AsReal(); 729 m_avatarHeight = (float)data["height"].AsReal();
725 if ((data != null) && (data["hipoffset"] != null)) 730 if ((data != null) && (data["hipoffset"] != null))
@@ -747,12 +752,10 @@ namespace OpenSim.Framework
747 OSDArray textures = (OSDArray)(data["textures"]); 752 OSDArray textures = (OSDArray)(data["textures"]);
748 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) 753 for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
749 { 754 {
755 UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
750 if (textures[i] != null) 756 if (textures[i] != null)
751 { 757 textureID = textures[i].AsUUID();
752 UUID textureID = textures[i].AsUUID(); 758 m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
753 if (textureID != UUID.Zero)
754 m_texture.CreateFace((uint)i).TextureID = textureID;
755 }
756 } 759 }
757 } 760 }
758 else 761 else
@@ -773,15 +776,12 @@ namespace OpenSim.Framework
773 } 776 }
774 777
775 // Attachments 778 // Attachments
776 m_attachments = new Dictionary<int, AvatarAttachment>(); 779 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
777 if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array) 780 if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
778 { 781 {
779 OSDArray attachs = (OSDArray)(data["attachments"]); 782 OSDArray attachs = (OSDArray)(data["attachments"]);
780 for (int i = 0; i < attachs.Count; i++) 783 for (int i = 0; i < attachs.Count; i++)
781 { 784 AppendAttachment(new AvatarAttachment((OSDMap)attachs[i]));
782 AvatarAttachment attach = new AvatarAttachment((OSDMap)attachs[i]);
783 m_attachments[attach.AttachPoint] = attach;
784 }
785 } 785 }
786 } 786 }
787 catch (Exception e) 787 catch (Exception e)
@@ -790,6 +790,9 @@ namespace OpenSim.Framework
790 } 790 }
791 } 791 }
792 792
793 #endregion
794
795 #region VPElement
793 796
794 /// <summary> 797 /// <summary>
795 /// Viewer Params Array Element for AgentSetAppearance 798 /// Viewer Params Array Element for AgentSetAppearance
@@ -1553,5 +1556,6 @@ namespace OpenSim.Framework
1553 SKIRT_SKIRT_GREEN = 216, 1556 SKIRT_SKIRT_GREEN = 216,
1554 SKIRT_SKIRT_BLUE = 217 1557 SKIRT_SKIRT_BLUE = 217
1555 } 1558 }
1559 #endregion
1556 } 1560 }
1557} 1561}
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 6b64e12..872de9a 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using log4net; 33using log4net;
34using Nini.Config;
34using OpenMetaverse; 35using OpenMetaverse;
35using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer; 37using OpenSim.Framework.Servers.HttpServer;
@@ -112,6 +113,8 @@ namespace OpenSim.Framework.Capabilities
112 private string m_regionName; 113 private string m_regionName;
113 private object m_fetchLock = new Object(); 114 private object m_fetchLock = new Object();
114 115
116 private bool m_persistBakedTextures = false;
117
115 public bool SSLCaps 118 public bool SSLCaps
116 { 119 {
117 get { return m_httpListener.UseSSL; } 120 get { return m_httpListener.UseSSL; }
@@ -145,6 +148,15 @@ namespace OpenSim.Framework.Capabilities
145 148
146 m_httpListenPort = httpPort; 149 m_httpListenPort = httpPort;
147 150
151 m_persistBakedTextures = false;
152 IConfigSource config = m_Scene.Config;
153 if (config != null)
154 {
155 IConfig sconfig = config.Configs["Startup"];
156 if (sconfig != null)
157 m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures",m_persistBakedTextures);
158 }
159
148 if (httpServer != null && httpServer.UseSSL) 160 if (httpServer != null && httpServer.UseSSL)
149 { 161 {
150 m_httpListenPort = httpServer.SSLPort; 162 m_httpListenPort = httpServer.SSLPort;
@@ -983,7 +995,7 @@ namespace OpenSim.Framework.Capabilities
983 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); 995 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
984 asset.Data = data; 996 asset.Data = data;
985 asset.Temporary = true; 997 asset.Temporary = true;
986 asset.Local = true; 998 asset.Local = ! m_persistBakedTextures; // Local assets aren't persisted, non-local are
987 m_assetCache.Store(asset); 999 m_assetCache.Store(asset);
988 } 1000 }
989 1001
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index fdebba3..66487f7 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
31using OpenMetaverse; 33using OpenMetaverse;
32using OpenMetaverse.StructuredData; 34using OpenMetaverse.StructuredData;
33 35
@@ -310,6 +312,12 @@ namespace OpenSim.Framework
310 // Appearance 312 // Appearance
311 public AvatarAppearance Appearance; 313 public AvatarAppearance Appearance;
312 314
315// DEBUG ON
316 private static readonly ILog m_log =
317 LogManager.GetLogger(
318 MethodBase.GetCurrentMethod().DeclaringType);
319// DEBUG OFF
320
313/* 321/*
314 public byte[] AgentTextures; 322 public byte[] AgentTextures;
315 public byte[] VisualParams; 323 public byte[] VisualParams;
@@ -323,6 +331,10 @@ namespace OpenSim.Framework
323 331
324 public virtual OSDMap Pack() 332 public virtual OSDMap Pack()
325 { 333 {
334// DEBUG ON
335 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data");
336// DEBUG OFF
337
326 OSDMap args = new OSDMap(); 338 OSDMap args = new OSDMap();
327 args["message_type"] = OSD.FromString("AgentData"); 339 args["message_type"] = OSD.FromString("AgentData");
328 340
@@ -387,31 +399,40 @@ namespace OpenSim.Framework
387 // args["agent_textures"] = textures; 399 // args["agent_textures"] = textures;
388 //} 400 //}
389 401
390/* 402 // The code to pack textures, visuals, wearables and attachments
391 if ((AgentTextures != null) && (AgentTextures.Length > 0)) 403 // should be removed; packed appearance contains the full appearance
392 args["texture_entry"] = OSD.FromBinary(AgentTextures); 404 // This is retained for backward compatibility only
405 if (Appearance.Texture != null)
406 {
407 byte[] rawtextures = Appearance.Texture.GetBytes();
408 args["texture_entry"] = OSD.FromBinary(rawtextures);
409 }
393 410
394 if ((VisualParams != null) && (VisualParams.Length > 0)) 411 if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
395 args["visual_params"] = OSD.FromBinary(VisualParams); 412 args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
396 413
397 // We might not pass this in all cases... 414 // We might not pass this in all cases...
398 if ((Wearables != null) && (Wearables.Length > 0)) 415 if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
399 { 416 {
400 OSDArray wears = new OSDArray(Wearables.Length); 417 OSDArray wears = new OSDArray(Appearance.Wearables.Length * 2);
401 foreach (UUID uuid in Wearables) 418 foreach (AvatarWearable awear in Appearance.Wearables)
402 wears.Add(OSD.FromUUID(uuid)); 419 {
420 wears.Add(OSD.FromUUID(awear.ItemID));
421 wears.Add(OSD.FromUUID(awear.AssetID));
422 }
403 args["wearables"] = wears; 423 args["wearables"] = wears;
404 } 424 }
405 425
406 426 List<AvatarAttachment> attachments = Appearance.GetAttachments();
407 if ((Attachments != null) && (Attachments.Length > 0)) 427 if ((attachments != null) && (attachments.Count > 0))
408 { 428 {
409 OSDArray attachs = new OSDArray(Attachments.Length); 429 OSDArray attachs = new OSDArray(attachments.Count);
410 foreach (AvatarAttachment att in Attachments) 430 foreach (AvatarAttachment att in attachments)
411 attachs.Add(att.Pack()); 431 attachs.Add(att.Pack());
412 args["attachments"] = attachs; 432 args["attachments"] = attachs;
413 } 433 }
414*/ 434 // End of code to remove
435
415 if ((Controllers != null) && (Controllers.Length > 0)) 436 if ((Controllers != null) && (Controllers.Length > 0))
416 { 437 {
417 OSDArray controls = new OSDArray(Controllers.Length); 438 OSDArray controls = new OSDArray(Controllers.Length);
@@ -435,6 +456,10 @@ namespace OpenSim.Framework
435 /// <param name="hash"></param> 456 /// <param name="hash"></param>
436 public virtual void Unpack(OSDMap args) 457 public virtual void Unpack(OSDMap args)
437 { 458 {
459// DEBUG ON
460 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data");
461// DEBUG OFF
462
438 if (args.ContainsKey("region_id")) 463 if (args.ContainsKey("region_id"))
439 UUID.TryParse(args["region_id"].AsString(), out RegionID); 464 UUID.TryParse(args["region_id"].AsString(), out RegionID);
440 465
@@ -547,41 +572,54 @@ namespace OpenSim.Framework
547 // AgentTextures[i++] = o.AsUUID(); 572 // AgentTextures[i++] = o.AsUUID();
548 //} 573 //}
549 574
550 if (args["packed_appearance"] != null) 575 Appearance = new AvatarAppearance(AgentID);
551 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); 576
552 else 577 // The code to unpack textures, visuals, wearables and attachments
553 Appearance = new AvatarAppearance(AgentID); 578 // should be removed; packed appearance contains the full appearance
554 579 // This is retained for backward compatibility only
555/*
556 if (args["texture_entry"] != null) 580 if (args["texture_entry"] != null)
557 AgentTextures = args["texture_entry"].AsBinary(); 581 {
582 byte[] rawtextures = args["texture_entry"].AsBinary();
583 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length);
584 Appearance.SetTextureEntries(textures);
585 }
558 586
559 if (args["visual_params"] != null) 587 if (args["visual_params"] != null)
560 VisualParams = args["visual_params"].AsBinary(); 588 Appearance.SetVisualParams(args["visual_params"].AsBinary());
561 589
562 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) 590 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
563 { 591 {
564 OSDArray wears = (OSDArray)(args["wearables"]); 592 OSDArray wears = (OSDArray)(args["wearables"]);
565 Wearables = new UUID[wears.Count]; 593 for (int i = 0; i < wears.Count / 2; i++)
566 int i = 0; 594 {
567 foreach (OSD o in wears) 595 AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID());
568 Wearables[i++] = o.AsUUID(); 596 Appearance.SetWearable(i,awear);
597 }
569 } 598 }
570 599
571 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 600 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
572 { 601 {
573 OSDArray attachs = (OSDArray)(args["attachments"]); 602 OSDArray attachs = (OSDArray)(args["attachments"]);
574 Attachments = new AvatarAttachment[attachs.Count];
575 int i = 0;
576 foreach (OSD o in attachs) 603 foreach (OSD o in attachs)
577 { 604 {
578 if (o.Type == OSDType.Map) 605 if (o.Type == OSDType.Map)
579 { 606 {
580 Attachments[i++] = new AvatarAttachment((OSDMap)o); 607 // We know all of these must end up as attachments so we
608 // append rather than replace to ensure multiple attachments
609 // per point continues to work
610 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
581 } 611 }
582 } 612 }
583 } 613 }
584*/ 614 // end of code to remove
615
616 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
617 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
618// DEBUG ON
619 else
620 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
621// DEBUG OFF
622
585 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 623 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
586 { 624 {
587 OSDArray controls = (OSDArray)(args["controllers"]); 625 OSDArray controls = (OSDArray)(args["controllers"]);