SL-17653 Perially done restoration functionality

master
Andrey Kleshchev 2022-08-09 00:21:45 +03:00
parent c0d20995c3
commit e73fd2a2f2
4 changed files with 69 additions and 3 deletions

View File

@ -165,6 +165,15 @@ void LLMaterialEditor::onClickCloseBtn(bool app_quitting)
}
}
void LLMaterialEditor::onClose(bool app_quitting)
{
// todo: will only revert whatever was recently selected,
// Later should work based of tools floater
LLSelectMgr::getInstance()->selectionRevertGLTFMaterials();
LLPreview::onClose(app_quitting);
}
LLUUID LLMaterialEditor::getAlbedoId()
{
return mAlbedoTextureCtrl->getValue().asUUID();
@ -1362,17 +1371,17 @@ public:
return true;
}
private:
LLGLTFMaterial *mMat;
LLPointer<LLGLTFMaterial> mMat;
LLUUID mMatId;
};
void LLMaterialEditor::applyToSelection()
{
LLGLTFMaterial* mat = new LLGLTFMaterial();
LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial();
getGLTFMaterial(mat);
const LLUUID placeholder("984e183e-7811-4b05-a502-d79c6f978a98");
LLUUID asset_id = mAssetID.notNull() ? mAssetID : placeholder;
LLRemderMaterialFunctor mat_func(mat, mAssetID);
LLRemderMaterialFunctor mat_func(mat, asset_id);
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
selected_objects->applyToTEs(&mat_func);
}

View File

@ -103,6 +103,8 @@ public:
BOOL postBuild() override;
void onClickCloseBtn(bool app_quitting = false) override;
void onClose(bool app_quitting) override;
LLUUID getAlbedoId();
void setAlbedoId(const LLUUID& id);
void setAlbedoUploadId(const LLUUID& id);

View File

@ -1936,6 +1936,32 @@ BOOL LLSelectMgr::selectionRevertTextures()
return revert_successful;
}
void LLSelectMgr::selectionRevertGLTFMaterials()
{
struct f : public LLSelectedTEFunctor
{
LLObjectSelectionHandle mSelectedObjects;
f(LLObjectSelectionHandle sel) : mSelectedObjects(sel) {}
bool apply(LLViewerObject* object, S32 te)
{
if (object->permModify())
{
LLSelectNode* nodep = mSelectedObjects->findNode(object);
if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size())
{
LLUUID id = nodep->mSavedGLTFMaterials[te];
object->setRenderMaterialID(te, id);
}
}
return true;
}
} setfunc(mSelectedObjects);
getSelection()->applyToTEs(&setfunc);
LLSelectMgrSendFunctor sendfunc;
getSelection()->applyToObjects(&sendfunc);
}
void LLSelectMgr::selectionSetBumpmap(U8 bumpmap, const LLUUID &image_id)
{
struct f : public LLSelectedTEFunctor
@ -5526,6 +5552,17 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// this should be the only place that saved textures is called
node->saveTextures(texture_ids);
}
if (can_copy && can_transfer && node->getObject()->getVolume())
{
uuid_vec_t material_ids;
LLVOVolume* vobjp = (LLVOVolume*)node->getObject();
for (int i = 0; i < vobjp->getNumTEs(); ++i)
{
material_ids.push_back(vobjp->getRenderMaterialID(i));
}
node->savedGLTFMaterials(material_ids);
}
}
node->mValid = TRUE;
@ -6277,6 +6314,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
}
saveTextures(nodep.mSavedTextures);
savedGLTFMaterials(nodep.mSavedGLTFMaterials);
}
LLSelectNode::~LLSelectNode()
@ -6392,6 +6430,20 @@ void LLSelectNode::saveTextures(const uuid_vec_t& textures)
}
}
void LLSelectNode::savedGLTFMaterials(const uuid_vec_t& materials)
{
if (mObject.notNull())
{
mSavedGLTFMaterials.clear();
for (uuid_vec_t::const_iterator materials_it = materials.begin();
materials_it != materials.end(); ++materials_it)
{
mSavedGLTFMaterials.push_back(*materials_it);
}
}
}
void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
{
mTextureScaleRatios.clear();

View File

@ -187,6 +187,7 @@ public:
void saveColors();
void saveShinyColors();
void saveTextures(const uuid_vec_t& textures);
void savedGLTFMaterials(const uuid_vec_t& materials);
void saveTextureScaleRatios(LLRender::eTexIndex index_to_query);
BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
@ -224,6 +225,7 @@ public:
std::vector<LLColor4> mSavedColors;
std::vector<LLColor4> mSavedShinyColors;
uuid_vec_t mSavedTextures;
uuid_vec_t mSavedGLTFMaterials;
std::vector<LLVector3> mTextureScaleRatios;
std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object
@ -609,6 +611,7 @@ public:
void selectionRevertColors();
void selectionRevertShinyColors();
BOOL selectionRevertTextures();
void selectionRevertGLTFMaterials();
void selectionSetBumpmap( U8 bumpmap, const LLUUID &image_id );
void selectionSetTexGen( U8 texgen );
void selectionSetShiny( U8 shiny, const LLUUID &image_id );