cinderblocks / libremetaverse

An fork of the libopenmetaverse library striving for performance improvements and up-to-date compatibility with SL/OS/Halcyon
BSD 3-Clause "New" or "Revised" License
61 stars 40 forks source link

[Feature] Implement tracking for worn avatar attachments #24

Closed cxtal closed 4 years ago

cxtal commented 4 years ago

Hello!

The pull request adds a private concurrent dictionary field to AppearanceManager named Attachments, serves a complementary purpose to the Wearables field and can be used to obtain currently worn attachments by attachment point.

Several public methods are added: GetAttachments, GetAttachmentsByItemId, GetAttachmentsByAttachmentPoint and GetAttachmentsByInventoryItem as convenience methods (complementary to the GetWear* set of methods).

The addition should speed up programming since it will no longer be necessary to perform the entire process of obtaining inventory items and the attachment point from primitives manually. Furthermore, the changes are at the lowest level within the library and only accessed via public methods such that along with encapsulation, there should be some consistency guaranteed since the dictionary is updated upon every Attach / Detach and the corresponding derivative methods.

Apparently, it was all in the plan, just never got implemented, citing from comments in Attach (now removed):

// TODO: At some point it might be beneficial to have AppearanceManager track what we
// are currently wearing for attachments to make enumeration and detachment easier

Please apply if useful!

TL;DR: allows access to attached inventory items and the attachment point that the items attach directly without extra calls

cinderblocks commented 4 years ago

Looks good! Thank you!