aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs111
1 files changed, 75 insertions, 36 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 5a6b265..c0bc47e 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -256,6 +256,21 @@ namespace OpenSim.Framework
256// } 256// }
257 } 257 }
258 258
259 /// <summary>
260 /// Invalidate all of the baked textures in the appearance, useful
261 /// if you know that none are valid
262 /// </summary>
263 public virtual void ResetBakedTextures()
264 {
265 SetDefaultTexture();
266
267 //for (int i = 0; i < BAKE_INDICES.Length; i++)
268 // {
269 // int idx = BAKE_INDICES[i];
270 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
271 // }
272 }
273
259 protected virtual void SetDefaultTexture() 274 protected virtual void SetDefaultTexture()
260 { 275 {
261 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); 276 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
@@ -399,27 +414,36 @@ namespace OpenSim.Framework
399 /// </summary> 414 /// </summary>
400 public List<AvatarAttachment> GetAttachments() 415 public List<AvatarAttachment> GetAttachments()
401 { 416 {
402 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 417 lock (m_attachments)
403 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
404 { 418 {
405 foreach (AvatarAttachment attach in kvp.Value) 419 List<AvatarAttachment> alist = new List<AvatarAttachment>();
406 alist.Add(new AvatarAttachment(attach)); 420 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
407 } 421 {
422 foreach (AvatarAttachment attach in kvp.Value)
423 alist.Add(new AvatarAttachment(attach));
424 }
408 425
409 return alist; 426 return alist;
427 }
410 } 428 }
411 429
412 internal void AppendAttachment(AvatarAttachment attach) 430 internal void AppendAttachment(AvatarAttachment attach)
413 { 431 {
414 if (! m_attachments.ContainsKey(attach.AttachPoint)) 432 lock (m_attachments)
415 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 433 {
416 m_attachments[attach.AttachPoint].Add(attach); 434 if (!m_attachments.ContainsKey(attach.AttachPoint))
435 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
436 m_attachments[attach.AttachPoint].Add(attach);
437 }
417 } 438 }
418 439
419 internal void ReplaceAttachment(AvatarAttachment attach) 440 internal void ReplaceAttachment(AvatarAttachment attach)
420 { 441 {
421 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 442 lock (m_attachments)
422 m_attachments[attach.AttachPoint].Add(attach); 443 {
444 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
445 m_attachments[attach.AttachPoint].Add(attach);
446 }
423 } 447 }
424 448
425 /// <summary> 449 /// <summary>
@@ -436,12 +460,15 @@ namespace OpenSim.Framework
436 460
437 if (item == UUID.Zero) 461 if (item == UUID.Zero)
438 { 462 {
439 if (m_attachments.ContainsKey(attachpoint)) 463 lock (m_attachments)
440 { 464 {
441 m_attachments.Remove(attachpoint); 465 if (m_attachments.ContainsKey(attachpoint))
442 return true; 466 {
467 m_attachments.Remove(attachpoint);
468 return true;
469 }
470 return false;
443 } 471 }
444 return false;
445 } 472 }
446 473
447 // check if the item is already attached at this point 474 // check if the item is already attached at this point
@@ -467,30 +494,36 @@ namespace OpenSim.Framework
467 494
468 public int GetAttachpoint(UUID itemID) 495 public int GetAttachpoint(UUID itemID)
469 { 496 {
470 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 497 lock (m_attachments)
471 { 498 {
472 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 499 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
473 if (index >= 0) 500 {
474 return kvp.Key; 501 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
475 } 502 if (index >= 0)
503 return kvp.Key;
504 }
476 505
477 return 0; 506 return 0;
507 }
478 } 508 }
479 509
480 public bool DetachAttachment(UUID itemID) 510 public bool DetachAttachment(UUID itemID)
481 { 511 {
482 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 512 lock (m_attachments)
483 { 513 {
484 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 514 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
485 if (index >= 0)
486 { 515 {
487 // Remove it from the list of attachments at that attach point 516 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
488 m_attachments[kvp.Key].RemoveAt(index); 517 if (index >= 0)
518 {
519 // Remove it from the list of attachments at that attach point
520 m_attachments[kvp.Key].RemoveAt(index);
489 521
490 // And remove the list if there are no more attachments here 522 // And remove the list if there are no more attachments here
491 if (m_attachments[kvp.Key].Count == 0) 523 if (m_attachments[kvp.Key].Count == 0)
492 m_attachments.Remove(kvp.Key); 524 m_attachments.Remove(kvp.Key);
493 return true; 525 return true;
526 }
494 } 527 }
495 } 528 }
496 return false; 529 return false;
@@ -498,7 +531,10 @@ namespace OpenSim.Framework
498 531
499 public void ClearAttachments() 532 public void ClearAttachments()
500 { 533 {
501 m_attachments.Clear(); 534 lock (m_attachments)
535 {
536 m_attachments.Clear();
537 }
502 } 538 }
503 539
504 #region Packing Functions 540 #region Packing Functions
@@ -535,11 +571,14 @@ namespace OpenSim.Framework
535 OSDBinary visualparams = new OSDBinary(m_visualparams); 571 OSDBinary visualparams = new OSDBinary(m_visualparams);
536 data["visualparams"] = visualparams; 572 data["visualparams"] = visualparams;
537 573
538 // Attachments 574 lock (m_attachments)
539 OSDArray attachs = new OSDArray(m_attachments.Count); 575 {
540 foreach (AvatarAttachment attach in GetAttachments()) 576 // Attachments
541 attachs.Add(attach.Pack()); 577 OSDArray attachs = new OSDArray(m_attachments.Count);
542 data["attachments"] = attachs; 578 foreach (AvatarAttachment attach in GetAttachments())
579 attachs.Add(attach.Pack());
580 data["attachments"] = attachs;
581 }
543 582
544 return data; 583 return data;
545 } 584 }