Avoid making duplicate copies in item inventory when no-mod texture is dragged onto faces.
This commit is contained in:
@@ -1035,7 +1035,14 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
|
||||
}
|
||||
}
|
||||
// Add the texture item to the target object's inventory.
|
||||
hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
if (LLAssetType::AT_TEXTURE == new_item->getType())
|
||||
{
|
||||
hit_obj->updateTextureInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
}
|
||||
// TODO: Check to see if adding the item was successful; if not, then
|
||||
// we should return false here.
|
||||
}
|
||||
@@ -1050,7 +1057,14 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
|
||||
// *FIX: may want to make sure agent can paint hit_obj.
|
||||
|
||||
// Add the texture item to the target object's inventory.
|
||||
hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
if (LLAssetType::AT_TEXTURE == new_item->getType())
|
||||
{
|
||||
hit_obj->updateTextureInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true);
|
||||
}
|
||||
// Force the object to update its refetch its inventory so it has this texture.
|
||||
hit_obj->fetchInventoryFromServer();
|
||||
// TODO: Check to see if adding the item was successful; if not, then
|
||||
|
||||
@@ -2984,6 +2984,33 @@ void LLViewerObject::removeInventory(const LLUUID& item_id)
|
||||
//gBuildView->refresh();
|
||||
}
|
||||
|
||||
bool LLViewerObject::isTextureInInventory(LLViewerInventoryItem* item)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (item && LLAssetType::AT_TEXTURE == item->getType())
|
||||
{
|
||||
std::list<LLUUID>::iterator begin = mPendingInventoryItemsIDs.begin();
|
||||
std::list<LLUUID>::iterator end = mPendingInventoryItemsIDs.end();
|
||||
|
||||
bool is_fetching = std::find(begin, end, item->getAssetUUID()) != end;
|
||||
bool is_fetched = getInventoryItemByAsset(item->getAssetUUID()) != NULL;
|
||||
|
||||
result = is_fetched || is_fetching;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void LLViewerObject::updateTextureInventory(LLViewerInventoryItem* item, U8 key, bool is_new)
|
||||
{
|
||||
if (item && !isTextureInInventory(item))
|
||||
{
|
||||
mPendingInventoryItemsIDs.push_back(item->getAssetUUID());
|
||||
updateInventory(item, key, is_new);
|
||||
}
|
||||
}
|
||||
|
||||
void LLViewerObject::updateInventory(
|
||||
LLViewerInventoryItem* item,
|
||||
U8 key,
|
||||
|
||||
@@ -444,12 +444,15 @@ public:
|
||||
// manager until we have better iterators.
|
||||
void updateInventory(LLViewerInventoryItem* item, U8 key, bool is_new);
|
||||
void updateInventoryLocal(LLInventoryItem* item, U8 key); // Update without messaging.
|
||||
void updateTextureInventory(LLViewerInventoryItem* item, U8 key, bool is_new);
|
||||
LLInventoryObject* getInventoryObject(const LLUUID& item_id);
|
||||
void getInventoryContents(LLInventoryObject::object_list_t& objects);
|
||||
LLInventoryObject* getInventoryRoot();
|
||||
LLViewerInventoryItem* getInventoryItemByAsset(const LLUUID& asset_id);
|
||||
S16 getInventorySerial() const { return mInventorySerialNum; }
|
||||
|
||||
bool isTextureInInventory(LLViewerInventoryItem* item);
|
||||
|
||||
// These functions does viewer-side only object inventory modifications
|
||||
void updateViewerInventoryAsset(
|
||||
const LLViewerInventoryItem* item,
|
||||
@@ -698,6 +701,10 @@ protected:
|
||||
F32 mAppAngle; // Apparent visual arc in degrees
|
||||
F32 mPixelArea; // Apparent area in pixels
|
||||
|
||||
// IDs of of all items in the object's content which are added to the object's content,
|
||||
// but not updated on the server yet. After item was updated, its ID will be removed from this list.
|
||||
std::list<LLUUID> mPendingInventoryItemsIDs;
|
||||
|
||||
// This is the object's inventory from the viewer's perspective.
|
||||
LLInventoryObject::object_list_t* mInventory;
|
||||
class LLInventoryCallbackInfo
|
||||
|
||||
Reference in New Issue
Block a user