From c801eb7678e18020951c839e81ace148e0a973bb Mon Sep 17 00:00:00 2001 From: Zi Ree Date: Wed, 29 Nov 2023 22:42:56 +0100 Subject: [PATCH] FIRE-33414 - fix animation overrider not being able to add animations to empty states --- indra/newview/ao.cpp | 12 ++++------ indra/newview/aoengine.cpp | 47 ++++++++++++++++++++++++++++++++------ indra/newview/aoengine.h | 4 ++-- indra/newview/aoset.h | 3 +++ 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/indra/newview/ao.cpp b/indra/newview/ao.cpp index c684781fc2..e9029c8037 100644 --- a/indra/newview/ao.cpp +++ b/indra/newview/ao.cpp @@ -891,14 +891,12 @@ BOOL FloaterAO::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDr *accept = ACCEPT_YES_MULTI; if (item && drop) { - if (AOEngine::instance().addAnimation(mSelectedSet, mSelectedState, item)) - { - addAnimation(item->getName()); + AOEngine::instance().addAnimation(mSelectedSet, mSelectedState, item); + addAnimation(item->getName()); - // TODO: this would be the right thing to do, but it blocks multi drop - // before final release this must be resolved - reloading(true); - } + // TODO: this would be the right thing to do, but it blocks multi drop + // before final release this must be resolved + reloading(true); } } else diff --git a/indra/newview/aoengine.cpp b/indra/newview/aoengine.cpp index 569f5d3662..9373ed525a 100644 --- a/indra/newview/aoengine.cpp +++ b/indra/newview/aoengine.cpp @@ -1000,7 +1000,7 @@ void AOEngine::addSet(const std::string& name, inventory_func_type callback, boo } } -bool AOEngine::createAnimationLink(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item) +bool AOEngine::createAnimationLink(AOSet::AOState* state, const LLInventoryItem* item) { LL_DEBUGS("AOEngine") << "Asset ID " << item->getAssetUUID() << " inventory id " << item->getUUID() << " category id " << state->mInventoryUUID << LL_ENDL; LL_DEBUGS("AOEngine") << "state " << state->mName << " item " << item->getName() << LL_ENDL; @@ -1019,7 +1019,7 @@ bool AOEngine::createAnimationLink(const AOSet* set, AOSet::AOState* state, cons return true; } -bool AOEngine::addAnimation(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item, bool reload) +void AOEngine::addAnimation(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item, bool reload) { AOSet::AOAnimation anim; anim.mAssetUUID = item->getAssetUUID(); @@ -1030,14 +1030,47 @@ bool AOEngine::addAnimation(const AOSet* set, AOSet::AOState* state, const LLInv BOOL wasProtected = gSavedPerAccountSettings.getBOOL("LockAOFolders"); gSavedPerAccountSettings.setBOOL("LockAOFolders", FALSE); - createAnimationLink(set, state, item); + bool success = createAnimationLink(state, item); gSavedPerAccountSettings.setBOOL("LockAOFolders", wasProtected); - if (reload) + if(success) { - mTimerCollection.enableReloadTimer(true); + if (reload) + { + mTimerCollection.enableReloadTimer(true); + } + return; + } + + // creating the animation link failed, so we need to create a new folder for this state - + // add the animation asset to the queue of animations to insert into the state - this takes + // care of multi animation drag & drop that come in faster than the viewer can create a new + // inventory folder + state->mAddQueue.push_back(item); + + // if this is the first queued animation for this state, create the folder asyncronously + if(state->mAddQueue.size() == 1) + { + gInventory.createNewCategory(set->getInventoryUUID(), LLFolderType::FT_NONE, state->mName, [this, state, reload, wasProtected](const LLUUID &new_cat_id) + { + state->mInventoryUUID = new_cat_id; + gSavedPerAccountSettings.setBOOL("LockAOFolders", FALSE); + + // add all queued animations to this state's folder and then clear the queue + for (const auto item : state->mAddQueue) + { + createAnimationLink(state, item); + } + state->mAddQueue.clear(); + + gSavedPerAccountSettings.setBOOL("LockAOFolders", wasProtected); + + if (reload) + { + mTimerCollection.enableReloadTimer(true); + } + }); } - return true; } bool AOEngine::findForeignItems(const LLUUID& uuid) const @@ -2203,7 +2236,7 @@ void AOEngine::processImport(bool from_timer) while (!state->mAnimations.empty()) { LL_DEBUGS("AOEngine") << "linking animation " << state->mAnimations[animationIndex].mName << LL_ENDL; - if (createAnimationLink(mImportSet, state, gInventory.getItem(state->mAnimations[animationIndex].mInventoryUUID))) + if (createAnimationLink(state, gInventory.getItem(state->mAnimations[animationIndex].mInventoryUUID))) { LL_DEBUGS("AOEngine") << "link success, size " << state->mAnimations.size() << ", removing animation " << state->mAnimations[animationIndex].mName << " from import state" << LL_ENDL; diff --git a/indra/newview/aoengine.h b/indra/newview/aoengine.h index fdbbd7acfe..baa01381d3 100644 --- a/indra/newview/aoengine.h +++ b/indra/newview/aoengine.h @@ -109,7 +109,7 @@ class AOEngine void addSet(const std::string& name, inventory_func_type callback, bool reload = true); bool removeSet(AOSet* set); - bool addAnimation(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item, bool reload = true); + void addAnimation(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item, bool reload = true); bool removeAnimation(const AOSet* set, AOSet::AOState* state, S32 index); void checkSitCancel(); void checkBelowWater(bool check_underwater); @@ -176,7 +176,7 @@ class AOEngine void saveSet(const AOSet* set); void saveState(const AOSet::AOState* state); - bool createAnimationLink(const AOSet* set, AOSet::AOState* state, const LLInventoryItem* item); + bool createAnimationLink(AOSet::AOState* state, const LLInventoryItem* item); bool findForeignItems(const LLUUID& uuid) const; void purgeFolder(const LLUUID& uuid) const; diff --git a/indra/newview/aoset.h b/indra/newview/aoset.h index 0e7d229bac..e40890cf55 100644 --- a/indra/newview/aoset.h +++ b/indra/newview/aoset.h @@ -27,6 +27,8 @@ #include "lleventtimer.h" +class LLInventoryItem; + class AOSet : public LLEventTimer { @@ -78,6 +80,7 @@ class AOSet { std::string mName; std::vector mAlternateNames; + std::vector mAddQueue; LLUUID mRemapID; bool mCycle; bool mRandom;