diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 54 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.h | 7 | ||||
-rw-r--r-- | indra/newview/llpanelface.cpp | 33 | ||||
-rw-r--r-- | indra/newview/llpanelface.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewerregion.cpp | 1 |
5 files changed, 95 insertions, 1 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 4a75426265..9738030e97 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -200,6 +200,8 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key) , mHasUnsavedChanges(false) , mExpectedUploadCost(0) , mUploadingTexturesCount(0) + , mOverrideObjectId(LLUUID::null) + , mOverrideFace(0) { const LLInventoryItem* item = getItem(); if (item) @@ -1832,6 +1834,7 @@ private: void LLMaterialEditor::applyToSelection() { +#if 0 // local preview placeholder hack // Placehodler. Will be removed once override systems gets finished. LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(); getGLTFMaterial(mat); @@ -1839,7 +1842,19 @@ void LLMaterialEditor::applyToSelection() gGLTFMaterialList.addMaterial(placeholder, mat); LLRemderMaterialFunctor mat_func(placeholder); LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); - selected_objects->applyToTEs(&mat_func); + //selected_objects->applyToTEs(&mat_func); +#else + std::string url = gAgent.getRegionCapability("ModifyMaterialParams"); + if (!url.empty()) + { + LLSDMap overrides; + LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, this, url, overrides)); + } + else + { + LL_WARNS() << "not connected to materials capable region, missing ModifyMaterialParams cap" << LL_ENDL; + } +#endif } void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) @@ -2232,3 +2247,40 @@ void LLMaterialEditor::loadDefaults() model_in.materials.resize(1); setFromGltfModel(model_in, 0, true); } + +void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("modifyMaterialCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); + LLCore::HttpHeaders::ptr_t httpHeaders; + + httpOpts->setFollowRedirects(true); + LLSD body = llsd::map( + "local_id", mOverrideObjectId, + "face", mOverrideFace, + "overrides", overrides + ); + + LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, body, httpOpts, httpHeaders); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + LL_WARNS() << "Failed to modify material." << LL_ENDL; + } + else if (!result["success"].asBoolean()) + { + LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL; + } +} + +void LLMaterialEditor::setOverrideTarget(const LLUUID& object_id, S32 face) +{ + mOverrideObjectId = object_id; + mOverrideFace = face; +} diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index d329222648..aa24b52a96 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -215,6 +215,10 @@ public: // initialize the UI from a default GLTF material void loadDefaults(); + + void modifyMaterialCoro(std::string cap_url, LLSD overrides); + void setOverrideTarget(const LLUUID& object_id, S32 face_id); + private: void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index); @@ -264,5 +268,8 @@ private: S32 mExpectedUploadCost; std::string mMaterialNameShort; std::string mMaterialName; + + LLUUID mOverrideObjectId; + S32 mOverrideFace; }; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index aaee64485a..ff5128e0c2 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -46,6 +46,7 @@ #include "llcombobox.h" #include "lldrawpoolbump.h" #include "llface.h" +#include "llgltfmateriallist.h" #include "llinventoryfunctions.h" #include "llinventorymodel.h" // gInventory #include "llinventorymodelbackgroundfetch.h" @@ -53,6 +54,7 @@ #include "llfloaterreg.h" #include "lllineeditor.h" #include "llmaterialmgr.h" +#include "llmaterialeditor.h" #include "llmediactrl.h" #include "llmediaentry.h" #include "llmenubutton.h" @@ -91,6 +93,7 @@ #include "llsdserialize.h" #include "llinventorymodel.h" +using namespace std::literals; // // Constant definitions for comboboxes @@ -234,6 +237,9 @@ BOOL LLPanelFace::postBuild() pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); pbr_ctrl->setBakeTextureEnabled(false); pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + + // TODO - design real UI for activating live editing + pbr_ctrl->setRightMouseUpCallback(boost::bind(&LLPanelFace::onPbrStartEditing, this)); } mTextureCtrl = getChild<LLTextureCtrl>("texture control"); @@ -4574,6 +4580,33 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) } } +void LLPanelFace::onPbrStartEditing() { + LL_DEBUGS() << "begin live editing material" << LL_ENDL; + + LLMaterialEditor *editor = + dynamic_cast<LLMaterialEditor *>(LLFloaterReg::showInstance("material_editor", LLSD(LLUUID::null), TAKE_FOCUS_YES)); + if (editor) + { + LLObjectSelection *select = LLSelectMgr::getInstance()->getSelection(); + LLViewerObject * objectp = select->getFirstObject(); + LLUUID object_id = objectp->getID(); + + bool identical; + LLUUID material_id; + LLSelectedTE::getPbrMaterialId(material_id, identical); + + S32 face = 0; + + LL_DEBUGS() << "loading material live editor with asset " << material_id << " on object " << object_id << LL_ENDL; + + LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id); + editor->setTitle("Editing material on "s + object_id.asString()); + editor->setAssetId(material_id); + editor->setFromGLTFMaterial(material); + editor->setOverrideTarget(object_id, face); + } +} + bool LLPanelFace::isIdenticalPlanarTexgen() { LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 725cfb0f5f..cc46116545 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -438,6 +438,7 @@ private: */ void onTextureSelectionChanged(LLInventoryItem* itemp); void onPbrSelectionChanged(LLInventoryItem* itemp); + void onPbrStartEditing(); LLMenuButton* mMenuClipboardColor; LLMenuButton* mMenuClipboardTexture; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 3167d1161c..31752a5a8b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -3082,6 +3082,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("MapLayer"); capabilityNames.append("MapLayerGod"); capabilityNames.append("MeshUploadFlag"); + capabilityNames.append("ModifyMaterialParams"); capabilityNames.append("NavMeshGenerationStatus"); capabilityNames.append("NewFileAgentInventory"); capabilityNames.append("ObjectAnimation"); |