Continuing work on SL-17697 Live editing with material overrides.
* Fixed Selection usage so material editor no longer hardcoded to a single object/face * made local preview hack the fallback for when the ModifyMaterialParams cap is missingmeow-7.2.2
parent
77eba62335
commit
53e5216b20
|
|
@ -47,11 +47,22 @@ namespace
|
|||
|
||||
bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
|
||||
{
|
||||
LL_DEBUGS() << "strings: ";
|
||||
for (std::string const & s : strings) {
|
||||
LL_CONT << " " << s;
|
||||
LL_DEBUGS() << "received override: " << s << LL_ENDL;
|
||||
|
||||
#if 0
|
||||
// for now messages are coming in llsd
|
||||
LLSD override_data;
|
||||
std::istringstream input(s);
|
||||
LLSDSerialize::deserialize(override_data, input, s.length());
|
||||
LL_DEBUGS() << "deserialized override: " << override_data << LL_ENDL;
|
||||
#else
|
||||
std::string warn_msg, error_msg;
|
||||
LLGLTFMaterial override_data;
|
||||
override_data.fromJSON(s, warn_msg, error_msg);
|
||||
#endif
|
||||
}
|
||||
LL_CONT << LL_ENDL;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -200,8 +200,6 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key)
|
|||
, mHasUnsavedChanges(false)
|
||||
, mExpectedUploadCost(0)
|
||||
, mUploadingTexturesCount(0)
|
||||
, mOverrideLocalId(0)
|
||||
, mOverrideFace(0)
|
||||
{
|
||||
const LLInventoryItem* item = getItem();
|
||||
if (item)
|
||||
|
|
@ -1875,10 +1873,10 @@ void LLMaterialEditor::importMaterial()
|
|||
true);
|
||||
}
|
||||
|
||||
class LLRemderMaterialFunctor : public LLSelectedTEFunctor
|
||||
class LLRenderMaterialFunctor : public LLSelectedTEFunctor
|
||||
{
|
||||
public:
|
||||
LLRemderMaterialFunctor(const LLUUID &id)
|
||||
LLRenderMaterialFunctor(const LLUUID &id)
|
||||
: mMatId(id)
|
||||
{
|
||||
}
|
||||
|
|
@ -1897,29 +1895,59 @@ private:
|
|||
LLUUID mMatId;
|
||||
};
|
||||
|
||||
class LLRenderMaterialOverrideFunctor : public LLSelectedTEFunctor
|
||||
{
|
||||
public:
|
||||
LLRenderMaterialOverrideFunctor(LLMaterialEditor * me, std::string const & url)
|
||||
: mEditor(me), mCapUrl(url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool apply(LLViewerObject* objectp, S32 te) override
|
||||
{
|
||||
if (objectp && objectp->permModify() && objectp->getVolume())
|
||||
{
|
||||
//LLVOVolume* vobjp = (LLVOVolume*)objectp;
|
||||
S32 local_id = objectp->getLocalID();
|
||||
|
||||
LLSD overrides = llsd::map(
|
||||
"local_id", local_id,
|
||||
"side", te,
|
||||
"overrides", LLSD::emptyMap()
|
||||
);
|
||||
LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, mEditor, mCapUrl, overrides));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
LLMaterialEditor * mEditor;
|
||||
std::string mCapUrl;
|
||||
};
|
||||
|
||||
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);
|
||||
const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98");
|
||||
gGLTFMaterialList.addMaterial(placeholder, mat);
|
||||
LLRemderMaterialFunctor mat_func(placeholder);
|
||||
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
|
||||
//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));
|
||||
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
|
||||
LLRenderMaterialOverrideFunctor override_func(this, url);
|
||||
selected_objects->applyToTEs(&override_func);
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS() << "not connected to materials capable region, missing ModifyMaterialParams cap" << LL_ENDL;
|
||||
|
||||
// Fallback local preview. Will be removed once override systems is finished and new cap is deployed everywhere.
|
||||
LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial();
|
||||
getGLTFMaterial(mat);
|
||||
static const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98");
|
||||
gGLTFMaterialList.addMaterial(placeholder, mat);
|
||||
LLRenderMaterialFunctor mat_func(placeholder);
|
||||
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
|
||||
selected_objects->applyToTEs(&mat_func);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat)
|
||||
|
|
@ -2323,13 +2351,10 @@ void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides)
|
|||
LLCore::HttpHeaders::ptr_t httpHeaders;
|
||||
|
||||
httpOpts->setFollowRedirects(true);
|
||||
LLSD body = llsd::map(
|
||||
"local_id", S32(mOverrideLocalId),
|
||||
"face", mOverrideFace,
|
||||
"overrides", overrides
|
||||
);
|
||||
|
||||
LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, body, httpOpts, httpHeaders);
|
||||
LL_DEBUGS() << "Applying override via ModifyMaterialParams cap: " << overrides << LL_ENDL;
|
||||
|
||||
LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, overrides, httpOpts, httpHeaders);
|
||||
|
||||
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
|
||||
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
|
||||
|
|
@ -2343,9 +2368,3 @@ void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides)
|
|||
LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
void LLMaterialEditor::setOverrideTarget(U32 local_id, S32 face)
|
||||
{
|
||||
mOverrideLocalId = local_id;
|
||||
mOverrideFace = face;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ public:
|
|||
void loadDefaults();
|
||||
|
||||
void modifyMaterialCoro(std::string cap_url, LLSD overrides);
|
||||
void setOverrideTarget(U32 local_id, S32 face_id);
|
||||
|
||||
private:
|
||||
void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index);
|
||||
|
|
@ -272,8 +271,5 @@ private:
|
|||
S32 mExpectedUploadCost;
|
||||
std::string mMaterialNameShort;
|
||||
std::string mMaterialName;
|
||||
|
||||
U32 mOverrideLocalId;
|
||||
S32 mOverrideFace;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4587,23 +4587,16 @@ void LLPanelFace::onPbrStartEditing() {
|
|||
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;
|
||||
LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL;
|
||||
|
||||
LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id);
|
||||
editor->setTitle("Editing material on "s + object_id.asString());
|
||||
editor->setTitle("Editing material on selection"s);
|
||||
editor->setAssetId(material_id);
|
||||
editor->setFromGLTFMaterial(material);
|
||||
editor->setOverrideTarget(objectp->getLocalID(), face);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue