diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 109 |
1 files changed, 74 insertions, 35 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 18a5733..be15e1b 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> |
@@ -435,9 +459,12 @@ namespace OpenSim.Framework | |||
435 | 459 | ||
436 | if (item == UUID.Zero) | 460 | if (item == UUID.Zero) |
437 | { | 461 | { |
438 | if (m_attachments.ContainsKey(attachpoint)) | 462 | lock (m_attachments) |
439 | m_attachments.Remove(attachpoint); | 463 | { |
440 | return; | 464 | if (m_attachments.ContainsKey(attachpoint)) |
465 | m_attachments.Remove(attachpoint); | ||
466 | return; | ||
467 | } | ||
441 | } | 468 | } |
442 | 469 | ||
443 | // check if this is an append or a replace, 0x80 marks it as an append | 470 | // check if this is an append or a replace, 0x80 marks it as an append |
@@ -455,37 +482,46 @@ namespace OpenSim.Framework | |||
455 | 482 | ||
456 | public int GetAttachpoint(UUID itemID) | 483 | public int GetAttachpoint(UUID itemID) |
457 | { | 484 | { |
458 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) | 485 | lock (m_attachments) |
459 | { | 486 | { |
460 | int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); | 487 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) |
461 | if (index >= 0) | 488 | { |
462 | return kvp.Key; | 489 | int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); |
463 | } | 490 | if (index >= 0) |
491 | return kvp.Key; | ||
492 | } | ||
464 | 493 | ||
465 | return 0; | 494 | return 0; |
495 | } | ||
466 | } | 496 | } |
467 | 497 | ||
468 | public void DetachAttachment(UUID itemID) | 498 | public void DetachAttachment(UUID itemID) |
469 | { | 499 | { |
470 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) | 500 | lock (m_attachments) |
471 | { | 501 | { |
472 | int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); | 502 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) |
473 | if (index >= 0) | ||
474 | { | 503 | { |
475 | // Remove it from the list of attachments at that attach point | 504 | int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); |
476 | m_attachments[kvp.Key].RemoveAt(index); | 505 | if (index >= 0) |
506 | { | ||
507 | // Remove it from the list of attachments at that attach point | ||
508 | m_attachments[kvp.Key].RemoveAt(index); | ||
477 | 509 | ||
478 | // And remove the list if there are no more attachments here | 510 | // And remove the list if there are no more attachments here |
479 | if (m_attachments[kvp.Key].Count == 0) | 511 | if (m_attachments[kvp.Key].Count == 0) |
480 | m_attachments.Remove(kvp.Key); | 512 | m_attachments.Remove(kvp.Key); |
481 | return; | 513 | return; |
514 | } | ||
482 | } | 515 | } |
483 | } | 516 | } |
484 | } | 517 | } |
485 | 518 | ||
486 | public void ClearAttachments() | 519 | public void ClearAttachments() |
487 | { | 520 | { |
488 | m_attachments.Clear(); | 521 | lock (m_attachments) |
522 | { | ||
523 | m_attachments.Clear(); | ||
524 | } | ||
489 | } | 525 | } |
490 | 526 | ||
491 | #region Packing Functions | 527 | #region Packing Functions |
@@ -522,11 +558,14 @@ namespace OpenSim.Framework | |||
522 | OSDBinary visualparams = new OSDBinary(m_visualparams); | 558 | OSDBinary visualparams = new OSDBinary(m_visualparams); |
523 | data["visualparams"] = visualparams; | 559 | data["visualparams"] = visualparams; |
524 | 560 | ||
525 | // Attachments | 561 | lock (m_attachments) |
526 | OSDArray attachs = new OSDArray(m_attachments.Count); | 562 | { |
527 | foreach (AvatarAttachment attach in GetAttachments()) | 563 | // Attachments |
528 | attachs.Add(attach.Pack()); | 564 | OSDArray attachs = new OSDArray(m_attachments.Count); |
529 | data["attachments"] = attachs; | 565 | foreach (AvatarAttachment attach in GetAttachments()) |
566 | attachs.Add(attach.Pack()); | ||
567 | data["attachments"] = attachs; | ||
568 | } | ||
530 | 569 | ||
531 | return data; | 570 | return data; |
532 | } | 571 | } |