From cc535ecccc3c415655a52cc597b33102e5ea21db Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Mon, 27 Jun 2022 13:40:17 -0700 Subject: Continuing progress on SL-17602 inventory support for Materials. now have working inventory bridge implementations --- indra/newview/llpanelobjectinventory.cpp | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'indra/newview/llpanelobjectinventory.cpp') diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 0d987df6ca..defd7025b8 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -1150,6 +1150,56 @@ LLSettingsType::type_e LLTaskSettingsBridge::getSettingsType() const return LLSettingsType::ST_NONE; } +///---------------------------------------------------------------------------- +/// Class LLTaskMaterialBridge +///---------------------------------------------------------------------------- + +class LLTaskMaterialBridge : public LLTaskInvFVBridge +{ +public: + LLTaskMaterialBridge(LLPanelObjectInventory* panel, + const LLUUID& uuid, + const std::string& name) : + LLTaskInvFVBridge(panel, uuid, name) {} + + BOOL canOpenItem() const override { return TRUE; } + void openItem() override; + BOOL removeItem() override; +}; + +void LLTaskMaterialBridge::openItem() +{ + LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID()); + if(!object || object->isInventoryPending()) + { + return; + } + + // Note: even if we are not allowed to modify copyable notecard, we should be able to view it + LLInventoryItem *item = dynamic_cast(object->getInventoryObject(mUUID)); + BOOL item_copy = item && gAgent.allowOperation(PERM_COPY, item->getPermissions(), GP_OBJECT_MANIPULATE); + if( item_copy + || object->permModify() + || gAgent.isGodlike()) + { + LLSD floater_key; + floater_key["taskid"] = mPanel->getTaskUUID(); + floater_key["itemid"] = mUUID; + LLPreviewNotecard* preview = LLFloaterReg::showTypedInstance("preview_notecard", floater_key, TAKE_FOCUS_YES); + if (preview) + { + preview->setObjectID(mPanel->getTaskUUID()); + } + } +} + +BOOL LLTaskMaterialBridge::removeItem() +{ + LLFloaterReg::hideInstance("preview_notecard", LLSD(mUUID)); + return LLTaskInvFVBridge::removeItem(); +} + + ///---------------------------------------------------------------------------- /// LLTaskInvFVBridge impl //---------------------------------------------------------------------------- @@ -1237,6 +1287,11 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory* object_name, itemflags); break; + case LLAssetType::AT_MATERIAL: + new_bridge = new LLTaskMaterialBridge(panel, + object_id, + object_name); + break; default: LL_INFOS() << "Unhandled inventory type (llassetstorage.h): " << (S32)type << LL_ENDL; -- cgit v1.3 From fd6b5ea8c3df7e8b4b648ac7ecc9f30eedd4b7c0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Jun 2022 17:59:09 -0500 Subject: SL-17685 Drag and drop material support WIP --- indra/llprimitive/llprimitive.cpp | 109 ++++++++++++++++++++++++++----- indra/llprimitive/llprimitive.h | 24 +++++-- indra/newview/llinventorybridge.cpp | 2 + indra/newview/llpanelgroupnotices.cpp | 1 + indra/newview/llpanelobjectinventory.cpp | 1 + indra/newview/lltooldraganddrop.cpp | 82 ++++++++++++++++++++++- indra/newview/lltooldraganddrop.h | 10 +++ indra/newview/llviewerobject.cpp | 55 ++++++++++++++++ indra/newview/llviewerobject.h | 7 ++ indra/newview/llviewertexteditor.cpp | 1 + indra/newview/llvovolume.cpp | 25 ++----- indra/newview/llvovolume.h | 2 +- 12 files changed, 273 insertions(+), 46 deletions(-) (limited to 'indra/newview/llpanelobjectinventory.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 9e0a079fd9..6df7111a47 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1700,7 +1700,7 @@ BOOL LLNetworkData::isValid(U16 param_type, U32 size) case PARAMS_EXTENDED_MESH: return (size == 4); case PARAMS_RENDER_MATERIAL: - return (size == 16); + return (size > 1); } return FALSE; @@ -2312,18 +2312,32 @@ LLRenderMaterialParams::LLRenderMaterialParams() mType = PARAMS_RENDER_MATERIAL; } -BOOL LLRenderMaterialParams::pack(LLDataPacker &dp) const +BOOL LLRenderMaterialParams::pack(LLDataPacker& dp) const { - return dp.packUUID(mMaterial, "material"); + U8 count = (U8)llmin((S32)mEntries.size(), 14); //limited to 255 bytes, no more than 14 material ids -// return TRUE; + dp.packU8(count, "count"); + for (auto& entry : mEntries) + { + dp.packU8(entry.te_idx, "te_idx"); + dp.packUUID(entry.id, "id"); + } + + return TRUE; } -BOOL LLRenderMaterialParams::unpack(LLDataPacker &dp) +BOOL LLRenderMaterialParams::unpack(LLDataPacker& dp) { - return dp.unpackUUID(mMaterial, "material"); + U8 count; + dp.unpackU8(count, "count"); + mEntries.resize(count); + for (auto& entry : mEntries) + { + dp.unpackU8(entry.te_idx, "te_idx"); + dp.unpackUUID(entry.id, "te_id"); + } -// return TRUE; + return TRUE; } bool LLRenderMaterialParams::operator==(const LLNetworkData& data) const @@ -2333,40 +2347,99 @@ bool LLRenderMaterialParams::operator==(const LLNetworkData& data) const return false; } - const LLRenderMaterialParams ¶m = static_cast(data); + const LLRenderMaterialParams& param = static_cast(data); + + if (param.mEntries.size() != mEntries.size()) + { + return false; + } + + for (auto& entry : mEntries) + { + if (param.getMaterial(entry.te_idx) != entry.id) + { + return false; + } + } - return param.mMaterial == mMaterial; + return true; } void LLRenderMaterialParams::copy(const LLNetworkData& data) { llassert_always(data.mType == PARAMS_RENDER_MATERIAL); - const LLRenderMaterialParams ¶m = static_cast(data); - mMaterial = param.mMaterial; + const LLRenderMaterialParams& param = static_cast(data); + mEntries = param.mEntries; } LLSD LLRenderMaterialParams::asLLSD() const { - return llsd::map("material", mMaterial); + LLSD ret; + + for (int i = 0; i < mEntries.size(); ++i) + { + ret[i]["te_idx"] = mEntries[i].te_idx; + ret[i]["id"] = mEntries[i].id; + } + + return ret; } bool LLRenderMaterialParams::fromLLSD(LLSD& sd) { - if (sd.has("material")) + if (sd.isArray()) { - setMaterial(sd["material"]); + mEntries.resize(sd.size()); + for (int i = 0; i < sd.size(); ++i) + { + if (sd[i].has("te_idx") && sd.has("id")) + { + mEntries[i].te_idx = sd[i]["te_idx"].asInteger(); + mEntries[i].id = sd[i]["id"].asUUID(); + } + else + { + return false; + } + } + return true; } return false; } -void LLRenderMaterialParams::setMaterial(const LLUUID & id) +void LLRenderMaterialParams::setMaterial(U8 te, const LLUUID& id) { - mMaterial = id; + for (int i = 0; i < mEntries.size(); ++i) + { + if (mEntries[i].te_idx == te) + { + if (id.isNull()) + { + mEntries.erase(mEntries.begin() + i); + } + else + { + mEntries[i].id = id; + } + return; + } + } + + mEntries.push_back({ te, id }); } -LLUUID LLRenderMaterialParams::getMaterial() const +LLUUID LLRenderMaterialParams::getMaterial(U8 te) const { - return mMaterial; + for (int i = 0; i < mEntries.size(); ++i) + { + if (mEntries[i].te_idx == te) + { + return mEntries[i].id; + } + } + + return LLUUID::null; } + diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 25196fb894..1c290185b0 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -369,22 +369,30 @@ public: class LLRenderMaterialParams : public LLNetworkData { private: - LLUUID mMaterial; + struct Entry + { + U8 te_idx; + LLUUID id; + }; + std::vector< Entry > mEntries; public: LLRenderMaterialParams(); - BOOL pack(LLDataPacker &dp) const override; - BOOL unpack(LLDataPacker &dp) override; + BOOL pack(LLDataPacker& dp) const override; + BOOL unpack(LLDataPacker& dp) override; bool operator==(const LLNetworkData& data) const override; void copy(const LLNetworkData& data) override; LLSD asLLSD() const; operator LLSD() const { return asLLSD(); } bool fromLLSD(LLSD& sd); - void setMaterial(const LLUUID & id); - LLUUID getMaterial() const; + void setMaterial(U8 te_idx, const LLUUID& id); + LLUUID getMaterial(U8 te_idx) const; + + bool isEmpty() { return mEntries.empty(); } }; + // This code is not naming-standards compliant. Leaving it like this for // now to make the connection to code in // BOOL packTEMessage(LLDataPacker &dp) const; @@ -480,12 +488,12 @@ public: virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); - virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); + virtual S32 setTEMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams); virtual BOOL setMaterial(const U8 material); // returns TRUE if material changed virtual void setTESelected(const U8 te, bool sel); LLMaterialPtr getTEMaterialParams(const U8 index); - + void copyTEs(const LLPrimitive *primitive); S32 packTEField(U8 *cur_ptr, U8 *data_ptr, U8 data_size, U8 last_face_index, EMsgVariableType type) const; BOOL packTEMessage(LLMessageSystem *mesgsys) const; @@ -563,6 +571,8 @@ public: static LLPCode legacyToPCode(const U8 legacy); static U8 pCodeToLegacy(const LLPCode pcode); static bool getTESTAxes(const U8 face, U32* s_axis, U32* t_axis); + + BOOL hasRenderMaterialParams() const; inline static BOOL isPrimitive(const LLPCode pcode); inline static BOOL isApp(const LLPCode pcode); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 2bb2c9676b..d325831c8f 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4403,6 +4403,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_GESTURE: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: accept = dragItemIntoFolder(inv_item, drop, tooltip_msg); break; case DAD_LINK: @@ -6032,6 +6033,7 @@ BOOL LLCallingCardBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_GESTURE: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: { LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data; const LLPermissions& perm = inv_item->getPermissions(); diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index ab32ea3956..82f880c9ee 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -156,6 +156,7 @@ BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, case DAD_CALLINGCARD: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: { LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; if(gInventory.getItem(inv_item->getUUID()) diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index defd7025b8..998cffef4a 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -704,6 +704,7 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop, case DAD_CALLINGCARD: case DAD_MESH: case DAD_SETTINGS: + case DAD_MATERIAL: accept = LLToolDragAndDrop::isInventoryDropAcceptable(object, (LLViewerInventoryItem*)cargo_data); if(accept && drop) { diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 50868d0fa5..a4b34bb5b6 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -256,7 +256,8 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary() // |-------------------------------|----------------------------------------------|-----------------------------------------------|---------------------------------------------------|--------------------------------| addEntry(DAD_NONE, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_TEXTURE, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dTextureObject, &LLToolDragAndDrop::dad3dNULL)); - addEntry(DAD_SOUND, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); + addEntry(DAD_MATERIAL, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dMaterialObject, &LLToolDragAndDrop::dad3dNULL)); + addEntry(DAD_SOUND, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_CALLINGCARD, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_LANDMARK, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_SCRIPT, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dRezScript, &LLToolDragAndDrop::dad3dNULL)); @@ -271,6 +272,7 @@ LLToolDragAndDrop::LLDragAndDropDictionary::LLDragAndDropDictionary() addEntry(DAD_LINK, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_MESH, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dMeshObject, &LLToolDragAndDrop::dad3dNULL)); addEntry(DAD_SETTINGS, new DragAndDropEntry(&LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dNULL, &LLToolDragAndDrop::dad3dGiveInventory, &LLToolDragAndDrop::dad3dUpdateInventory, &LLToolDragAndDrop::dad3dNULL)); + // TODO: animation on self could play it? edit it? // TODO: gesture on self could play it? edit it? }; @@ -1062,6 +1064,66 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, hit_obj->sendTEUpdate(); } + +void LLToolDragAndDrop::dropMaterialOneFace(LLViewerObject* hit_obj, + S32 hit_face, + LLInventoryItem* item, + LLToolDragAndDrop::ESource source, + const LLUUID& src_id) +{ + if (hit_face == -1) return; + if (!item || item->getInventoryType() != LLInventoryType::IT_MATERIAL) + { + LL_WARNS() << "LLToolDragAndDrop::dropTextureOneFace no material item." << LL_ENDL; + return; + } + LLUUID asset_id = item->getAssetUUID(); + BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + if (!success) + { + return; + } + + LLTextureEntry* tep = hit_obj ? (hit_obj->getTE(hit_face)) : NULL; + + hit_obj->setRenderMaterialID(hit_face, asset_id); + + dialog_refresh_all(); + + // send the update to the simulator + hit_obj->sendTEUpdate(); +} + + +void LLToolDragAndDrop::dropMaterialAllFaces(LLViewerObject* hit_obj, + LLInventoryItem* item, + LLToolDragAndDrop::ESource source, + const LLUUID& src_id) +{ + if (!item || item->getInventoryType() != LLInventoryType::IT_MATERIAL) + { + LL_WARNS() << "LLToolDragAndDrop::dropTextureAllFaces no material item." << LL_ENDL; + return; + } + LLUUID asset_id = item->getAssetUUID(); + BOOL success = handleDropTextureProtections(hit_obj, item, source, src_id); + if (!success) + { + return; + } + + S32 num_faces = hit_obj->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + // update viewer side material in anticipation of update from simulator + hit_obj->setRenderMaterialID(face, asset_id); + dialog_refresh_all(); + } + // send the update to the simulator + hit_obj->sendTEUpdate(); +} + + void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj, LLInventoryItem* item, LLToolDragAndDrop::ESource source, @@ -1628,6 +1690,7 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_ case DAD_MESH: case DAD_CATEGORY: case DAD_SETTINGS: + case DAD_MATERIAL: { LLInventoryObject* inv_obj = (LLInventoryObject*)cargo_data; if(gInventory.getCategory(inv_obj->getUUID()) || (gInventory.getItem(inv_obj->getUUID()) @@ -1982,6 +2045,17 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject( dropTextureOneFace(obj, face, item, mSource, mSourceID); } } + else if (cargo_type == DAD_MATERIAL) + { + if ((mask & MASK_SHIFT)) + { + dropMaterialAllFaces(obj, item, mSource, mSourceID); + } + else + { + dropMaterialOneFace(obj, face, item, mSource, mSourceID); + } + } else if (cargo_type == DAD_MESH) { dropMesh(obj, item, mSource, mSourceID); @@ -2010,6 +2084,12 @@ EAcceptance LLToolDragAndDrop::dad3dTextureObject( return dad3dApplyToObject(obj, face, mask, drop, DAD_TEXTURE); } +EAcceptance LLToolDragAndDrop::dad3dMaterialObject( + LLViewerObject* obj, S32 face, MASK mask, BOOL drop) +{ + return dad3dApplyToObject(obj, face, mask, drop, DAD_MATERIAL); +} + EAcceptance LLToolDragAndDrop::dad3dMeshObject( LLViewerObject* obj, S32 face, MASK mask, BOOL drop) { diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h index 24a712029c..2f6423080e 100644 --- a/indra/newview/lltooldraganddrop.h +++ b/indra/newview/lltooldraganddrop.h @@ -168,6 +168,8 @@ protected: MASK mask, BOOL drop); EAcceptance dad3dTextureObject(LLViewerObject* obj, S32 face, MASK mask, BOOL drop); + EAcceptance dad3dMaterialObject(LLViewerObject* obj, S32 face, + MASK mask, BOOL drop); EAcceptance dad3dMeshObject(LLViewerObject* obj, S32 face, MASK mask, BOOL drop); // EAcceptance dad3dTextureSelf(LLViewerObject* obj, S32 face, @@ -249,6 +251,14 @@ public: LLInventoryItem* item, ESource source, const LLUUID& src_id); + static void dropMaterialOneFace(LLViewerObject* hit_obj, S32 hit_face, + LLInventoryItem* item, + ESource source, + const LLUUID& src_id); + static void dropMaterialAllFaces(LLViewerObject* hit_obj, + LLInventoryItem* item, + ESource source, + const LLUUID& src_id); static void dropMesh(LLViewerObject* hit_obj, LLInventoryItem* item, ESource source, diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 16479e02a2..232e51896e 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6991,6 +6991,61 @@ LLVOAvatar* LLViewerObject::getAvatar() const return NULL; } +bool LLViewerObject::hasRenderMaterialParams() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL); +} + +void LLViewerObject::setHasRenderMaterialParams(bool has_materials) +{ + bool had_materials = hasRenderMaterialParams(); + + if (had_materials != has_materials) + { + if (has_materials) + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, FALSE, true); + } + } +} + +const LLUUID& LLViewerObject::getRenderMaterialID(U8 te) const +{ + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + return param_block->getMaterial(te); + } + + return LLUUID::null; +} + +void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id) +{ + if (id.notNull()) + { + setHasRenderMaterialParams(true); + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + param_block->setMaterial(te, id); + + if (param_block->isEmpty()) + { // might be empty if id is null + setHasRenderMaterialParams(false); + } + else + { + parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } +} class ObjectPhysicsProperties : public LLHTTPNode { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5136a7e5ee..1392caa855 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -179,6 +179,13 @@ public: const std::string& getAttachmentItemName() const; virtual LLVOAvatar* getAvatar() const; //get the avatar this object is attached to, or NULL if object is not an attachment + + bool hasRenderMaterialParams() const; + void setHasRenderMaterialParams(bool has_params); + + const LLUUID& getRenderMaterialID(U8 te) const; + void setRenderMaterialID(U8 te, const LLUUID& id); + virtual BOOL isHUDAttachment() const { return FALSE; } virtual BOOL isTempAttachment() const; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index e2de7ac825..7c860936a5 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -879,6 +879,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask, case DAD_ANIMATION: case DAD_GESTURE: case DAD_MESH: + case DAD_MATERIAL: { supported = true; break; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 0706e26fb1..f220547499 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2162,6 +2162,7 @@ void LLVOVolume::setNumTEs(const U8 num_tes) return ; } + //virtual void LLVOVolume::changeTEImage(S32 index, LLViewerTexture* imagep) { @@ -3501,6 +3502,11 @@ F32 LLVOVolume::getLightCutoff() const } } +BOOL LLVOVolume::isReflectionProbe() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); +} + void LLVOVolume::setIsReflectionProbe(BOOL is_probe) { BOOL was_probe = isReflectionProbe(); @@ -3571,25 +3577,6 @@ void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) } } - -BOOL LLVOVolume::isReflectionProbe() const -{ - // HACK - make this object a Reflection Probe if a certain UUID is detected - static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); - LLUUID probe_id(reflection_probe_id); - - for (U8 i = 0; i < getNumTEs(); ++i) - { - if (getTE(i)->getID() == probe_id) - { - return true; - } - } - // END HACK - - return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); -} - F32 LLVOVolume::getReflectionProbeAmbiance() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index f0a4fd427e..79049851b4 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -284,7 +284,7 @@ public: F32 getLightRadius() const; F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; - + // Reflection Probes void setIsReflectionProbe(BOOL is_probe); void setReflectionProbeAmbiance(F32 ambiance); -- cgit v1.3 From 6b46793771a1d1db1601105604ac7bc82f8db7b3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 28 Sep 2022 20:01:06 +0300 Subject: SL-18233 Double clicking material in an object shows notecard --- indra/newview/llmaterialeditor.cpp | 19 +++++++++++++++---- indra/newview/llmaterialeditor.h | 4 +++- indra/newview/llpanelobjectinventory.cpp | 9 +++++---- 3 files changed, 23 insertions(+), 9 deletions(-) (limited to 'indra/newview/llpanelobjectinventory.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 4f51030fc0..1592235dba 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -180,6 +180,16 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key) } } +void LLMaterialEditor::setObjectID(const LLUUID& object_id) +{ + LLPreview::setObjectID(object_id); + const LLInventoryItem* item = getItem(); + if (item) + { + mAssetID = item->getAssetUUID(); + } +} + BOOL LLMaterialEditor::postBuild() { mBaseColorTextureCtrl = getChild("base_color_texture"); @@ -751,7 +761,8 @@ bool LLMaterialEditor::decodeAsset(const std::vector& buffer) if (loader.LoadASCIIFromString(&model_in, &error_msg, &warn_msg, data.c_str(), data.length(), "")) { - return setFromGltfModel(model_in, true); + // assets are only supposed to have one item + return setFromGltfModel(model_in, 0, true); } else { @@ -1878,8 +1889,8 @@ void LLMaterialEditor::onLoadComplete(const LLUUID& asset_uuid, editor->decodeAsset(buffer); - BOOL allow_modify = editor->canModify(editor->mObjectID, editor->getItem()); - BOOL source_library = editor->mObjectID.isNull() && gInventory.isObjectDescendentOf(editor->mItemUUID, gInventory.getLibraryRootFolderID()); + BOOL allow_modify = editor->canModify(editor->mObjectUUID, editor->getItem()); + BOOL source_library = editor->mObjectUUID.isNull() && gInventory.isObjectDescendentOf(editor->mItemUUID, gInventory.getLibraryRootFolderID()); editor->setEnableEditing(allow_modify && !source_library); editor->setHasUnsavedChanges(false); editor->mAssetStatus = PREVIEW_ASSET_LOADED; @@ -2083,5 +2094,5 @@ void LLMaterialEditor::loadDefaults() { tinygltf::Model model_in; model_in.materials.resize(1); - setFromGltfModel(model_in, true); + setFromGltfModel(model_in, 0, true); } diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 7fd8e950a3..c6b976ea5a 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -143,6 +143,9 @@ public: void onClickCancel(); void onCancelMsgCallback(const LLSD& notification, const LLSD& response); + // llpreview + void setObjectID(const LLUUID& object_id) override; + // llpanel BOOL postBuild() override; void onClickCloseBtn(bool app_quitting = false) override; @@ -211,7 +214,6 @@ private: friend class LLMaterialFilePicker; LLUUID mAssetID; - LLUUID mObjectID; LLTextureCtrl* mBaseColorTextureCtrl; LLTextureCtrl* mMetallicTextureCtrl; diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index 2faa3a7137..c5bf18a065 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -50,6 +50,7 @@ #include "llinventoryicon.h" #include "llinventoryfilter.h" #include "llinventoryfunctions.h" +#include "llmaterialeditor.h" #include "llpreviewanim.h" #include "llpreviewgesture.h" #include "llpreviewnotecard.h" @@ -1197,17 +1198,17 @@ void LLTaskMaterialBridge::openItem() LLSD floater_key; floater_key["taskid"] = mPanel->getTaskUUID(); floater_key["itemid"] = mUUID; - LLPreviewNotecard* preview = LLFloaterReg::showTypedInstance("preview_notecard", floater_key, TAKE_FOCUS_YES); - if (preview) + LLMaterialEditor* mat = LLFloaterReg::showTypedInstance("material_editor", floater_key, TAKE_FOCUS_YES); + if (mat) { - preview->setObjectID(mPanel->getTaskUUID()); + mat->setObjectID(mPanel->getTaskUUID()); } } } BOOL LLTaskMaterialBridge::removeItem() { - LLFloaterReg::hideInstance("preview_notecard", LLSD(mUUID)); + LLFloaterReg::hideInstance("material_editor", LLSD(mUUID)); return LLTaskInvFVBridge::removeItem(); } -- cgit v1.3 From 2fa8bce1cffe932089a05ad1c7834bb20b435fcf Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 7 Oct 2022 23:46:01 +0300 Subject: SL-18326 GLTF material functionality in a Notecard --- indra/newview/llmaterialeditor.cpp | 166 +++++++++++++++++++++++++------ indra/newview/llmaterialeditor.h | 7 +- indra/newview/llpanelobjectinventory.cpp | 4 +- indra/newview/llpreview.h | 2 +- indra/newview/llviewertexteditor.cpp | 25 +++++ indra/newview/llviewertexteditor.h | 1 + 6 files changed, 172 insertions(+), 33 deletions(-) (limited to 'indra/newview/llpanelobjectinventory.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index a2cd68259b..27b5d508e0 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1,6 +1,6 @@ /** * @file llmaterialeditor.cpp - * @brief Implementation of the notecard editor + * @brief Implementation of the gltf material editor * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code @@ -150,16 +150,44 @@ void LLFloaterComboOptions::onCancel() class LLMaterialEditorCopiedCallback : public LLInventoryCallback { public: - LLMaterialEditorCopiedCallback(const std::string &buffer, const LLUUID &old_item_id) : mBuffer(buffer), mOldItemId(old_item_id) {} + LLMaterialEditorCopiedCallback( + const std::string &buffer, + const LLSD &old_key, + bool has_unsaved_changes) + : mBuffer(buffer), + mOldKey(old_key), + mHasUnsavedChanges(has_unsaved_changes) + {} + + LLMaterialEditorCopiedCallback( + const LLSD &old_key, + const std::string &new_name) + : mOldKey(old_key), + mNewName(new_name), + mHasUnsavedChanges(false) + {} virtual void fire(const LLUUID& inv_item_id) { - LLMaterialEditor::finishSaveAs(mOldItemId, inv_item_id, mBuffer); + if (!mNewName.empty()) + { + // making a copy from a notecard doesn't change name, do it now + LLViewerInventoryItem* item = gInventory.getItem(inv_item_id); + if (item->getName() != mNewName) + { + LLSD updates; + updates["name"] = mNewName; + update_inventory_item(inv_item_id, updates, NULL); + } + } + LLMaterialEditor::finishSaveAs(mOldKey, inv_item_id, mBuffer, mHasUnsavedChanges); } private: std::string mBuffer; - LLUUID mOldItemId; + LLSD mOldKey; + std::string mNewName; + bool mHasUnsavedChanges; }; ///---------------------------------------------------------------------------- @@ -190,6 +218,15 @@ void LLMaterialEditor::setObjectID(const LLUUID& object_id) } } +void LLMaterialEditor::setAuxItem(const LLInventoryItem* item) +{ + LLPreview::setAuxItem(item); + if (item) + { + mAssetID = item->getAssetUUID(); + } +} + BOOL LLMaterialEditor::postBuild() { mBaseColorTextureCtrl = getChild("base_color_texture"); @@ -456,10 +493,25 @@ void LLMaterialEditor::setDoubleSided(bool double_sided) void LLMaterialEditor::setHasUnsavedChanges(bool value) { - if (value != mHasUnsavedChanges) + mHasUnsavedChanges = value; + childSetVisible("unsaved_changes", value); + + if (mHasUnsavedChanges) { - mHasUnsavedChanges = value; - childSetVisible("unsaved_changes", value); + const LLInventoryItem* item = getItem(); + if (item) + { + LLPermissions perm(item->getPermissions()); + bool allow_modify = canModify(mObjectUUID, item); + bool source_library = mObjectUUID.isNull() && gInventory.isObjectDescendentOf(mItemUUID, gInventory.getLibraryRootFolderID()); + bool source_notecard = mNotecardInventoryID.notNull(); + + setCanSave(allow_modify && !source_library && !source_notecard); + } + } + else + { + setCanSave(false); } S32 upload_texture_count = 0; @@ -1019,23 +1071,39 @@ void LLMaterialEditor::finishTaskUpload(LLUUID itemId, LLUUID newAssetId, LLUUID } } -void LLMaterialEditor::finishSaveAs(const LLUUID &oldItemId, const LLUUID &newItemId, const std::string &buffer) +void LLMaterialEditor::finishSaveAs( + const LLSD &oldKey, + const LLUUID &newItemId, + const std::string &buffer, + bool has_unsaved_changes) { - LLMaterialEditor* me = LLFloaterReg::findTypedInstance("material_editor", LLSD(oldItemId)); + LLMaterialEditor* me = LLFloaterReg::findTypedInstance("material_editor", oldKey); LLViewerInventoryItem* item = gInventory.getItem(newItemId); if (item) { if (me) { me->mItemUUID = newItemId; + me->mObjectUUID = LLUUID::null; + me->mNotecardInventoryID = LLUUID::null; + me->mNotecardObjectID = LLUUID::null; + me->mAuxItem = nullptr; me->setKey(LLSD(newItemId)); // for findTypedInstance me->setMaterialName(item->getName()); - if (!saveToInventoryItem(buffer, newItemId, LLUUID::null)) + if (has_unsaved_changes) { + if (!saveToInventoryItem(buffer, newItemId, LLUUID::null)) + { + me->setEnabled(true); + } + } + else + { + me->loadAsset(); me->setEnabled(true); } } - else + else if(has_unsaved_changes) { saveToInventoryItem(buffer, newItemId, LLUUID::null); } @@ -1052,17 +1120,24 @@ void LLMaterialEditor::refreshFromInventory(const LLUUID& new_item_id) if (new_item_id.notNull()) { mItemUUID = new_item_id; - if (mObjectUUID.isNull()) + if (mNotecardInventoryID.notNull()) { - setKey(LLSD(new_item_id)); + LLSD floater_key; + floater_key["objectid"] = mNotecardObjectID; + floater_key["notecardid"] = mNotecardInventoryID; + setKey(floater_key); } - else + else if (mObjectUUID.notNull()) { LLSD floater_key; floater_key["taskid"] = new_item_id; floater_key["itemid"] = mObjectUUID; setKey(floater_key); } + else + { + setKey(LLSD(new_item_id)); + } } LL_DEBUGS() << "LLPreviewNotecard::refreshFromInventory()" << LL_ENDL; loadAsset(); @@ -1094,7 +1169,15 @@ void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& LLInventoryObject::correctInventoryName(new_name); if (!new_name.empty()) { - const LLInventoryItem* item = getItem(); + const LLInventoryItem* item; + if (mNotecardInventoryID.notNull()) + { + item = mAuxItem.get(); + } + else + { + item = getItem(); + } if (item) { const LLUUID &marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); @@ -1105,15 +1188,27 @@ void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& } // A two step process, first copy an existing item, then create new asset - std::string buffer = getEncodedAsset(); - LLPointer cb = new LLMaterialEditorCopiedCallback(buffer, item->getUUID()); - copy_inventory_item( - gAgent.getID(), - item->getPermissions().getOwner(), - item->getUUID(), - parent_id, - new_name, - cb); + if (mNotecardInventoryID.notNull()) + { + LLPointer cb = new LLMaterialEditorCopiedCallback(getKey(), new_name); + copy_inventory_from_notecard(parent_id, + mNotecardObjectID, + mNotecardInventoryID, + mAuxItem.get(), + gInventoryCallbacks.registerCB(cb)); + } + else + { + std::string buffer = getEncodedAsset(); + LLPointer cb = new LLMaterialEditorCopiedCallback(buffer, getKey(), mHasUnsavedChanges); + copy_inventory_item( + gAgent.getID(), + item->getPermissions().getOwner(), + item->getUUID(), + parent_id, + new_name, + cb); + } mAssetStatus = PREVIEW_ASSET_LOADING; setEnabled(false); @@ -1772,19 +1867,26 @@ void LLMaterialEditor::loadAsset() // TODO: see commented out "editor" references and make them do something appropriate to the UI // request the asset. - const LLInventoryItem* item = getItem(); + const LLInventoryItem* item; + if (mNotecardInventoryID.notNull()) + { + item = mAuxItem.get(); + } + else + { + item = getItem(); + } bool fail = false; if (item) { LLPermissions perm(item->getPermissions()); - BOOL allow_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE); - BOOL allow_modify = canModify(mObjectUUID, item); - BOOL source_library = mObjectUUID.isNull() && gInventory.isObjectDescendentOf(mItemUUID, gInventory.getLibraryRootFolderID()); + bool allow_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE); + bool allow_modify = canModify(mObjectUUID, item); + bool source_library = mObjectUUID.isNull() && gInventory.isObjectDescendentOf(mItemUUID, gInventory.getLibraryRootFolderID()); setCanSaveAs(allow_copy); - setCanSave(allow_modify && !source_library); setMaterialName(item->getName()); { @@ -1801,7 +1903,11 @@ void LLMaterialEditor::loadAsset() LLHost source_sim = LLHost(); LLSD* user_data = new LLSD(); - if (mObjectUUID.notNull()) + if (mNotecardInventoryID.notNull()) + { + user_data->with("objectid", mNotecardObjectID).with("notecardid", mNotecardInventoryID); + } + else if (mObjectUUID.notNull()) { LLViewerObject* objectp = gObjectList.findObject(mObjectUUID); if (objectp && objectp->getRegion()) diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 4e17cee154..d329222648 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -136,7 +136,11 @@ public: static void finishTaskUpload(LLUUID itemId, LLUUID newAssetId, LLUUID taskId); - static void finishSaveAs(const LLUUID &oldItemId, const LLUUID &newItemId, const std::string &buffer); + static void finishSaveAs( + const LLSD &oldKey, + const LLUUID &newItemId, + const std::string &buffer, + bool has_unsaved_changes); void refreshFromInventory(const LLUUID& new_item_id = LLUUID::null); @@ -147,6 +151,7 @@ public: // llpreview void setObjectID(const LLUUID& object_id) override; + void setAuxItem(const LLInventoryItem* item) override; // llpanel BOOL postBuild() override; diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp index c5bf18a065..d61cc26f62 100644 --- a/indra/newview/llpanelobjectinventory.cpp +++ b/indra/newview/llpanelobjectinventory.cpp @@ -1198,10 +1198,12 @@ void LLTaskMaterialBridge::openItem() LLSD floater_key; floater_key["taskid"] = mPanel->getTaskUUID(); floater_key["itemid"] = mUUID; - LLMaterialEditor* mat = LLFloaterReg::showTypedInstance("material_editor", floater_key, TAKE_FOCUS_YES); + LLMaterialEditor* mat = LLFloaterReg::getTypedInstance("material_editor", floater_key); if (mat) { mat->setObjectID(mPanel->getTaskUUID()); + mat->openFloater(floater_key); + mat->setFocus(TRUE); } } } diff --git a/indra/newview/llpreview.h b/indra/newview/llpreview.h index 9ac15d1639..ab60f4c008 100644 --- a/indra/newview/llpreview.h +++ b/indra/newview/llpreview.h @@ -83,7 +83,7 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual void onOpen(const LLSD& key); - void setAuxItem( const LLInventoryItem* item ); + virtual void setAuxItem( const LLInventoryItem* item ); static void onBtnCopyToInv(void* userdata); diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 7c860936a5..3f302d4f45 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -42,6 +42,7 @@ #include "lllandmark.h" #include "lllandmarkactions.h" #include "lllandmarklist.h" +#include "llmaterialeditor.h" #include "llmemorystream.h" #include "llmenugl.h" #include "llnotecard.h" @@ -542,6 +543,7 @@ LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const case LLAssetType::AT_GESTURE: img_name = "Inv_Gesture"; break; case LLAssetType::AT_MESH: img_name = "Inv_Mesh"; break; case LLAssetType::AT_SETTINGS: img_name = "Inv_Settings"; break; + case LLAssetType::AT_MATERIAL: img_name = "Inv_Material"; break; default: img_name = "Inv_Invalid"; break; // use the Inv_Invalid icon for undefined object types (see MAINT-3981) } @@ -1127,6 +1129,9 @@ BOOL LLViewerTextEditor::openEmbeddedItem(LLPointer item, llwch case LLAssetType::AT_SETTINGS: openEmbeddedSetting(item, wc); return TRUE; + case LLAssetType::AT_MATERIAL: + openEmbeddedGLTFMaterial(item, wc); + return TRUE; case LLAssetType::AT_NOTECARD: case LLAssetType::AT_LSL_TEXT: case LLAssetType::AT_CLOTHING: @@ -1213,6 +1218,26 @@ void LLViewerTextEditor::openEmbeddedSetting(LLInventoryItem* item, llwchar wc) } } +void LLViewerTextEditor::openEmbeddedGLTFMaterial(LLInventoryItem* item, llwchar wc) +{ + if (!item) + { + return; + } + + LLSD floater_key; + floater_key["objectid"] = mObjectID; + floater_key["notecardid"] = mNotecardInventoryID; + LLMaterialEditor* preview = LLFloaterReg::getTypedInstance("material_editor", floater_key); + if (preview) + { + preview->setAuxItem(item); + preview->setNotecardInfo(mNotecardInventoryID, mObjectID); + preview->openFloater(floater_key); + preview->setFocus(TRUE); + } +} + void LLViewerTextEditor::showUnsavedAlertDialog( LLInventoryItem* item ) { LLSD payload; diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h index a6d7fef409..6170d476b8 100644 --- a/indra/newview/llviewertexteditor.h +++ b/indra/newview/llviewertexteditor.h @@ -108,6 +108,7 @@ private: void openEmbeddedLandmark( LLPointer item_ptr, llwchar wc ); void openEmbeddedCallingcard( LLInventoryItem* item, llwchar wc); void openEmbeddedSetting(LLInventoryItem* item, llwchar wc); + void openEmbeddedGLTFMaterial(LLInventoryItem* item, llwchar wc); void showCopyToInvDialog( LLInventoryItem* item, llwchar wc ); void showUnsavedAlertDialog( LLInventoryItem* item ); -- cgit v1.3