summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNyx (Neal Orman) <nyx@lindenlab.com>2010-06-03 21:09:49 -0400
committerNyx (Neal Orman) <nyx@lindenlab.com>2010-06-03 21:09:49 -0400
commit47beb6dc9c4f7c1557536f8116cc98b8bbc24629 (patch)
treecda277cd11cc31ad59f34ea6860fefc2c2e6be16 /indra
parent6286b1cbd495ec589286ee89699a93ce9c1bed77 (diff)
AVP-44 WIP Multi-wearables architecture
One step closer to full support of multi-wearables architecture code will be reviewed before pushing.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llappearancemgr.cpp21
-rw-r--r--indra/newview/llviewermenu.cpp5
-rw-r--r--indra/newview/llvoavatarself.cpp60
-rw-r--r--indra/newview/llwearable.cpp2
4 files changed, 54 insertions, 34 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 5071b1c14a..9da47c9214 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -682,14 +682,15 @@ bool LLAppearanceMgr::wearItemOnAvatar(const LLUUID& item_id_to_wear, bool do_up
switch (item_to_wear->getType())
{
case LLAssetType::AT_CLOTHING:
- if (replace && gAgentWearables.areWearablesLoaded())
+ if (gAgentWearables.areWearablesLoaded())
{
S32 wearable_count = gAgentWearables.getWearableCount(item_to_wear->getWearableType());
- if (wearable_count != 0)
+ if ((replace && wearable_count != 0) ||
+ (wearable_count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE) )
{
removeCOFItemLinks(gAgentWearables.getWearableItemID(item_to_wear->getWearableType(), wearable_count-1), false);
}
- }
+ }
case LLAssetType::AT_BODYPART:
// Don't wear anything until initial wearables are loaded, can
// destroy clothing items.
@@ -1584,6 +1585,7 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update
item_array,
LLInventoryModel::EXCLUDE_TRASH);
bool linked_already = false;
+ U32 count = 0;
for (S32 i=0; i<item_array.count(); i++)
{
// Are these links to the same object?
@@ -1601,15 +1603,22 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update
}
// Are these links to different items of the same body part
// type? If so, new item will replace old.
- // TODO: MULTI-WEARABLE: check for wearable limit for clothing types
- else if (is_body_part && (vitem->isWearableType()) && (vitem->getWearableType() == wearable_type))
+ else if ((vitem->isWearableType()) && (vitem->getWearableType() == wearable_type))
{
- if (inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type))
+ if (is_body_part && inv_item->getIsLinkType() && (vitem->getWearableType() == wearable_type))
+ {
+ gInventory.purgeObject(inv_item->getUUID());
+ }
+ ++count;
+
+ // MULTI-WEARABLES: make sure we don't go over MAX_CLOTHING_PER_TYPE
+ if (count >= LLAgentWearables::MAX_CLOTHING_PER_TYPE)
{
gInventory.purgeObject(inv_item->getUUID());
}
}
}
+
if (linked_already)
{
if (do_update)
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index a1b909c609..23fb97a358 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7497,8 +7497,9 @@ class LLEditTakeOff : public view_listener_t
LLWearableType::EType type = LLWearableType::typeNameToType(clothing);
if (type >= LLWearableType::WT_SHAPE && type < LLWearableType::WT_COUNT)
{
- // MULTI-WEARABLES
- LLViewerInventoryItem *item = dynamic_cast<LLViewerInventoryItem*>(gAgentWearables.getWearableInventoryItem(type,0));
+ // MULTI-WEARABLES: assuming user wanted to remove top shirt.
+ U32 wearable_index = gAgentWearables.getWearableCount(type) - 1;
+ LLViewerInventoryItem *item = dynamic_cast<LLViewerInventoryItem*>(gAgentWearables.getWearableInventoryItem(type,wearable_index));
LLWearableBridge::removeItemFromAvatar(item);
}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 462c442954..af042b4e3e 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1975,37 +1975,47 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
++iter)
{
const ETextureIndex t_index = (*iter);
- lldebugs << "Checking index " << (U32) t_index << llendl;
- // MULTI-WEARABLE: old method. replace.
- const LLUUID& texture_id = getTEImage( t_index )->getID();
- if (texture_id != IMG_DEFAULT_AVATAR)
- {
- // Search inventory for this texture.
- LLViewerInventoryCategory::cat_array_t cats;
- LLViewerInventoryItem::item_array_t items;
- LLAssetIDMatches asset_id_matches(texture_id);
- gInventory.collectDescendentsIf(LLUUID::null,
- cats,
- items,
- LLInventoryModel::INCLUDE_TRASH,
- asset_id_matches);
-
- BOOL can_grab = FALSE;
- lldebugs << "item count for asset " << texture_id << ": " << items.count() << llendl;
- if (items.count())
+ LLWearableType::EType wearable_type = LLVOAvatarDictionary::getTEWearableType(t_index);
+ U32 count = gAgentWearables.getWearableCount(wearable_type);
+ lldebugs << "Checking index " << (U32) t_index << " count: " << count << llendl;
+
+ for (U32 wearable_index = 0; wearable_index < count; ++wearable_index)
+ {
+ LLWearable *wearable = gAgentWearables.getWearable(wearable_type, wearable_index);
+ if (wearable)
{
- // search for full permissions version
- for (S32 i = 0; i < items.count(); i++)
+ const LLLocalTextureObject *texture = wearable->getLocalTextureObject((S32)t_index);
+ const LLUUID& texture_id = texture->getID();
+ if (texture_id != IMG_DEFAULT_AVATAR)
{
- LLViewerInventoryItem* itemp = items[i];
- if (itemp->getIsFullPerm())
+ // Search inventory for this texture.
+ LLViewerInventoryCategory::cat_array_t cats;
+ LLViewerInventoryItem::item_array_t items;
+ LLAssetIDMatches asset_id_matches(texture_id);
+ gInventory.collectDescendentsIf(LLUUID::null,
+ cats,
+ items,
+ LLInventoryModel::INCLUDE_TRASH,
+ asset_id_matches);
+
+ BOOL can_grab = FALSE;
+ lldebugs << "item count for asset " << texture_id << ": " << items.count() << llendl;
+ if (items.count())
{
- can_grab = TRUE;
- break;
+ // search for full permissions version
+ for (S32 i = 0; i < items.count(); i++)
+ {
+ LLViewerInventoryItem* itemp = items[i];
+ if (itemp->getIsFullPerm())
+ {
+ can_grab = TRUE;
+ break;
+ }
+ }
}
+ if (!can_grab) return FALSE;
}
}
- if (!can_grab) return FALSE;
}
}
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index 9e9b46473e..121e691710 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -656,7 +656,7 @@ void LLWearable::writeToAvatar()
image_id = LLVOAvatarDictionary::getDefaultTextureImageID((ETextureIndex) te);
}
LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture( image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE );
- // MULTI-WEARABLE: replace hard-coded 0
+ // MULTI-WEARABLE: assume index 0 will be used when writing to avatar. TODO: eliminate the need for this.
gAgentAvatarp->setLocalTextureTE(te, image, 0);
}
}