WIP for SL-18103 and SL-17697 live editing of materials using ModifyMaterialParams cap
parent
a2b09df2db
commit
bda4206627
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -438,6 +438,7 @@ private:
|
|||
*/
|
||||
void onTextureSelectionChanged(LLInventoryItem* itemp);
|
||||
void onPbrSelectionChanged(LLInventoryItem* itemp);
|
||||
void onPbrStartEditing();
|
||||
|
||||
LLMenuButton* mMenuClipboardColor;
|
||||
LLMenuButton* mMenuClipboardTexture;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue