diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-27 23:26:25 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2022-09-27 23:26:25 +0300 |
commit | e6fad1ea5fb353f8ffd6423f2dcebe35002e8d2b (patch) | |
tree | c94a978c4c61de4d6684d31c3fd5e10b69a5e4c1 | |
parent | 3e59ae1c43a70f41fba9cf6ba7d33aeed22d3a9f (diff) |
SL-17999 Material with limited permissions should be copied to object's inventory
-rw-r--r-- | indra/newview/llinventorymodel.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llpanelvolume.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llselectmgr.cpp | 69 | ||||
-rw-r--r-- | indra/newview/llselectmgr.h | 1 | ||||
-rw-r--r-- | indra/newview/lltooldraganddrop.cpp | 36 | ||||
-rw-r--r-- | indra/newview/lltooldraganddrop.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewerobject.cpp | 30 | ||||
-rw-r--r-- | indra/newview/llviewerobject.h | 6 |
8 files changed, 106 insertions, 41 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 63152d167d..bbe9330bc7 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -2841,6 +2841,7 @@ void LLInventoryModel::createCommonSystemCategories() gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, true); gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK, true); // folder should exist before user tries to 'landmark this' gInventory.findCategoryUUIDForType(LLFolderType::FT_SETTINGS, true); + gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL, true); // probably should be server created gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX, true); } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 7ddce19bd0..db37938448 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -1334,7 +1334,7 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item LLViewerInventoryItem* item = gInventory.getItem(item_id); if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { - LLToolDragAndDrop::handleDropTextureProtections(volobjp, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(volobjp, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } volobjp->setLightTextureID(asset_id); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 8f674afc24..d103141669 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1747,6 +1747,7 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); bool texture_copied = false; + bool updated = false; for (S32 te = 0; te < num_tes; ++te) { if (node->isTESelected(te)) @@ -1755,22 +1756,68 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) // without making any copies if (!texture_copied) { - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); texture_copied = true; } // apply texture for the selected faces add(LLStatViewer::EDIT_TEXTURE, 1); object->setTEImage(te, image); - dialog_refresh_all(); - - // send the update to the simulator - object->sendTEUpdate(); + updated = true; } } + + if (updated) // not nessesary? sendTEUpdate update supposed to be done by sendfunc + { + dialog_refresh_all(); + + // send the update to the simulator + object->sendTEUpdate(); + } } } +void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item) +{ + if (!item) + { + return; + } + + LLUUID asset_id = item->getAssetUUID(); + + for (iterator iter = begin(); iter != end(); ++iter) + { + LLSelectNode* node = *iter; + LLViewerObject* object = (*iter)->getObject(); + if (!object) + { + continue; + } + + S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); + bool material_copied = false; + for (S32 te = 0; te < num_tes; ++te) + { + if (node->isTESelected(te)) + { + //(no-copy) materials must be moved to the object's inventory only once + // without making any copies + if (!material_copied && asset_id.notNull()) + { + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + material_copied = true; + } + + // apply texture for the selected faces + //add(LLStatViewer::EDIT_TEXTURE, 1); + object->setRenderMaterialID(te, asset_id, false /*will be sent later*/); + } + } + } +} + + //----------------------------------------------------------------------------- // selectionSetImage() //----------------------------------------------------------------------------- @@ -1952,12 +1999,11 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) } }; - // TODO: once PBR starts supporting permissions, implement/figure this out - /*if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { - getSelection()->applyNoCopyTextureToTEs(item); + getSelection()->applyNoCopyPbrMaterialToTEs(item); } - else*/ + else { f setfunc(item, mat_id); getSelection()->applyToTEs(&setfunc); @@ -1997,6 +2043,7 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) effectp->setColor(LLColor4U(gAgent.getEffectColor())); } + dialog_refresh_all(); object->sendTEUpdate(); return true; } @@ -2263,7 +2310,7 @@ void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); if (!object) return; - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); @@ -2323,7 +2370,7 @@ void LLSelectMgr::selectionSetShiny(U8 shiny, const LLUUID &image_id) { LLViewerObject *object = mSelectedObjects->getFirstRootObject(); if (!object) return; - LLToolDragAndDrop::handleDropTextureProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); + LLToolDragAndDrop::handleDropMaterialProtections(object, item, LLToolDragAndDrop::SOURCE_AGENT, LLUUID::null); } getSelection()->applyToTEs(&setfunc); diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index cc6815296e..573eea7a8a 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -368,6 +368,7 @@ public: * Then this only texture is used for all selected faces. */ void applyNoCopyTextureToTEs(LLViewerInventoryItem* item); + void applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item); ESelectType getSelectType() const { return mSelectType; } diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index be42e6f2b2..dd6ac89cc3 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -923,17 +923,17 @@ void LLToolDragAndDrop::pick(const LLPickInfo& pick_info) } // static -BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, +BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj, LLInventoryItem* item, LLToolDragAndDrop::ESource source, const LLUUID& src_id) { // Always succeed if.... - // texture is from the library + // material is from the library // or already in the contents of the object if (SOURCE_LIBRARY == source) { - // dropping a texture from the library always just works. + // dropping a material from the library always just works. return TRUE; } @@ -964,15 +964,15 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { - // Check that we can add the texture as inventory to the object + // Check that we can add the material as inventory to the object if (willObjectAcceptInventory(hit_obj,item) < ACCEPT_YES_COPY_SINGLE ) { return FALSE; } - // make sure the object has the texture in it's inventory. + // make sure the object has the material in it's inventory. if (SOURCE_AGENT == source) { - // Remove the texture from local inventory. The server + // Remove the material from local inventory. The server // will actually remove the item from agent inventory. gInventory.deleteObject(item->getUUID()); gInventory.notifyObservers(); @@ -994,10 +994,11 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, } } // Add the texture item to the target object's inventory. - if (LLAssetType::AT_TEXTURE == new_item->getType()) - { - hit_obj->updateTextureInventory(new_item, TASK_INVENTORY_ITEM_KEY, true); - } + if (LLAssetType::AT_TEXTURE == new_item->getType() + || LLAssetType::AT_MATERIAL == new_item->getType()) + { + hit_obj->updateMaterialInventory(new_item, TASK_INVENTORY_ITEM_KEY, true); + } else { hit_obj->updateInventory(new_item, TASK_INVENTORY_ITEM_KEY, true); @@ -1016,9 +1017,10 @@ 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. - if (LLAssetType::AT_TEXTURE == new_item->getType()) + if (LLAssetType::AT_TEXTURE == new_item->getType() + || LLAssetType::AT_MATERIAL == new_item->getType()) { - hit_obj->updateTextureInventory(new_item, TASK_INVENTORY_ITEM_KEY, true); + hit_obj->updateMaterialInventory(new_item, TASK_INVENTORY_ITEM_KEY, true); } else { @@ -1045,7 +1047,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, return; } LLUUID asset_id = item->getAssetUUID(); - BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if (!success) { return; @@ -1078,7 +1080,7 @@ void LLToolDragAndDrop::dropMaterialOneFace(LLViewerObject* hit_obj, return; } LLUUID asset_id = item->getAssetUUID(); - BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if (!success) { return; @@ -1104,7 +1106,7 @@ void LLToolDragAndDrop::dropMaterialAllFaces(LLViewerObject* hit_obj, return; } LLUUID asset_id = item->getAssetUUID(); - BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if (!success) { return; @@ -1128,7 +1130,7 @@ void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj, return; } LLUUID asset_id = item->getAssetUUID(); - BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if(!success) { return; @@ -1165,7 +1167,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, return; } LLUUID asset_id = item->getAssetUUID(); - BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + BOOL success = handleDropMaterialProtections(hit_obj, item, source, src_id); if (!success) { return; diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h index cfdbd931ce..bf35840964 100644 --- a/indra/newview/lltooldraganddrop.h +++ b/indra/newview/lltooldraganddrop.h @@ -94,7 +94,7 @@ public: // deal with permissions of object, etc. returns TRUE if drop can // proceed, otherwise FALSE. - static BOOL handleDropTextureProtections(LLViewerObject* hit_obj, + static BOOL handleDropMaterialProtections(LLViewerObject* hit_obj, LLInventoryItem* item, LLToolDragAndDrop::ESource source, const LLUUID& src_id); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e866658a6..b4fad16dba 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3498,11 +3498,11 @@ void LLViewerObject::removeInventory(const LLUUID& item_id) ++mExpectedInventorySerialNum; } -bool LLViewerObject::isTextureInInventory(LLViewerInventoryItem* item) +bool LLViewerObject::isAssetInInventory(LLViewerInventoryItem* item) { bool result = false; - if (item && LLAssetType::AT_TEXTURE == item->getType()) + if (item) { std::list<LLUUID>::iterator begin = mPendingInventoryItemsIDs.begin(); std::list<LLUUID>::iterator end = mPendingInventoryItemsIDs.end(); @@ -3516,13 +3516,27 @@ bool LLViewerObject::isTextureInInventory(LLViewerInventoryItem* item) return result; } -void LLViewerObject::updateTextureInventory(LLViewerInventoryItem* item, U8 key, bool is_new) +void LLViewerObject::updateMaterialInventory(LLViewerInventoryItem* item, U8 key, bool is_new) { - if (item && !isTextureInInventory(item)) - { - mPendingInventoryItemsIDs.push_back(item->getAssetUUID()); - updateInventory(item, key, is_new); - } + if (!item) + { + return; + } + if (LLAssetType::AT_TEXTURE != item->getType() + && LLAssetType::AT_MATERIAL != item->getType()) + { + // Not supported + return; + } + + if (isAssetInInventory(item)) + { + // already there + return; + } + + mPendingInventoryItemsIDs.push_back(item->getAssetUUID()); + updateInventory(item, key, is_new); } void LLViewerObject::updateInventory( diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 1bb67fa80f..9d80f095c9 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -490,7 +490,7 @@ 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); + void updateMaterialInventory(LLViewerInventoryItem* item, U8 key, bool is_new); LLInventoryObject* getInventoryObject(const LLUUID& item_id); // Get content except for root category @@ -499,8 +499,6 @@ public: 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, @@ -629,6 +627,8 @@ public: std::vector<LLVector3> mUnselectedChildrenPositions ; private: + bool isAssetInInventory(LLViewerInventoryItem* item); + ExtraParameter* createNewParameterEntry(U16 param_type); ExtraParameter* getExtraParameterEntry(U16 param_type) const; ExtraParameter* getExtraParameterEntryCreate(U16 param_type); |