diff options
| -rw-r--r-- | indra/newview/llmaterialeditor.cpp | 72 | ||||
| -rw-r--r-- | indra/newview/llmaterialeditor.h | 12 | ||||
| -rw-r--r-- | indra/newview/llpanelface.cpp | 23 | ||||
| -rw-r--r-- | indra/newview/llviewermenu.cpp | 86 | 
4 files changed, 70 insertions, 123 deletions
| diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 0256ab32da..58cebecb23 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -65,6 +65,8 @@ const std::string MATERIAL_NORMAL_DEFAULT_NAME = "Normal";  const std::string MATERIAL_METALLIC_DEFAULT_NAME = "Metallic Roughness";  const std::string MATERIAL_EMISSIVE_DEFAULT_NAME = "Emissive"; +const LLUUID LIVE_MATERIAL_EDITOR_KEY("6cf97162-8b68-49eb-b627-79886c9fd17d"); +  LLFloaterComboOptions::LLFloaterComboOptions()      : LLFloater(LLSD())  { @@ -1399,14 +1401,24 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind      }  } -void LLMaterialEditor::loadLiveMaterial(LLGLTFMaterial * material, bool make_copy) +void LLMaterialEditor::loadLiveMaterial(LLUUID &asset_id) +{ +    LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor", LLSD(LIVE_MATERIAL_EDITOR_KEY)); +    me->setTitle(me->getString("material_override_title")); +    me->setAssetId(asset_id); +    me->setFromGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); +    me->openFloater(); +    me->setFocus(TRUE); +} + +void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id)  { -    if (!material) -    { -        return; -    }      LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor"); -    me->loadMaterial(material, make_copy); +    me->setTitle(LLTrans::getString("New Material")); +    me->setHasUnsavedChanges(true); +    me->setFromGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); +    me->openFloater(); +    me->setFocus(TRUE);  }  void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename_lc, S32 index) @@ -1513,43 +1525,6 @@ void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::      applyToSelection();  } -void LLMaterialEditor::loadMaterial(LLGLTFMaterial * material, bool make_copy) -{ -    setBaseColorId(material->mBaseColorId); -    setMetallicRoughnessId(material->mMetallicRoughnessId); -    setEmissiveId(material->mEmissiveId); -    setNormalId(material->mNormalId); - -    setAlphaMode(material->getAlphaMode()); -    setAlphaCutoff(material->mAlphaCutoff); - -    setBaseColor(material->mBaseColor); -    setEmissiveColor(material->mEmissiveColor); - -    setMetalnessFactor(material->mMetallicFactor); -    setRoughnessFactor(material->mRoughnessFactor); - -    setDoubleSided(material->mDoubleSided); - -    if (make_copy) -    { -        setTitle(LLTrans::getString("New Material")); -    } -    else -    { -        setTitle(getString("material_override_title")); -    } - -    // Todo: At the moment it always makes a 'copy' -    // Will need a way to expand existing material -    // once overrides are done - -    setHasUnsavedChanges(make_copy); - -    openFloater(); -    setFocus(TRUE); -} -  bool LLMaterialEditor::setFromGltfModel(const tinygltf::Model& model, S32 index, bool set_textures)  {      if (model.materials.size() > index) @@ -1863,7 +1838,7 @@ public:      {      } -    virtual bool apply(LLViewerObject* objectp, S32 te) +    bool apply(LLViewerObject* objectp, S32 te) override      {          if (objectp && objectp->permModify() && objectp->getVolume())          { @@ -1938,6 +1913,15 @@ private:  void LLMaterialEditor::applyToSelection()  { +    if (!mKey.isUUID() || mKey.asUUID() != LIVE_MATERIAL_EDITOR_KEY) +    { +        // Only apply if working with 'live' materials +        // Might need a better way to distinguish 'live' mode. +        // But only one live edit is supposed to work at a time +        // as a pair to tools floater. +        return; +    } +      std::string url = gAgent.getRegionCapability("ModifyMaterialParams");      if (!url.empty())      { diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 9bc6be4b92..8945e113a4 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -98,13 +98,14 @@ public:      void getGLTFMaterial(LLGLTFMaterial* mat); -    void setFromGLTFMaterial(LLGLTFMaterial* mat); -      void loadAsset() override;      // @index if -1 and file contains more than one material,      // will promt to select specific one      static void loadMaterialFromFile(const std::string& filename, S32 index = -1); -    static void loadLiveMaterial(LLGLTFMaterial * material, bool make_copy); + +    static void LLMaterialEditor::loadLiveMaterial(LLUUID &asset_id); + +    static void LLMaterialEditor::loadFromGLTFMaterial(LLUUID &asset_id);      static void onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type, void* user_data, S32 status, LLExtStat ext_status); @@ -220,10 +221,9 @@ public:      void modifyMaterialCoro(std::string cap_url, LLSD overrides);  private: +    void setFromGLTFMaterial(LLGLTFMaterial* mat); +      void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index); -    // if make_copy is set, will make a copy for saving, -    // otherwise will edit existing material -    void loadMaterial(LLGLTFMaterial * material, bool make_copy);      friend class LLMaterialFilePicker; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 457ff525c5..f4b75c9154 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -4580,24 +4580,15 @@ 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) -    { -        bool   identical; -        LLUUID material_id; -        LLSelectedTE::getPbrMaterialId(material_id, identical); +void LLPanelFace::onPbrStartEditing() +{ +    bool   identical; +    LLUUID material_id; +    LLSelectedTE::getPbrMaterialId(material_id, identical); -        LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL; +    LL_DEBUGS() << "loading material live editor with asset " << material_id << LL_ENDL; -        LLPointer<LLGLTFMaterial> material = gGLTFMaterialList.getMaterial(material_id); -        editor->setTitle(editor->getString("material_override_title")); -        editor->setAssetId(material_id); -        editor->setFromGLTFMaterial(material); -    } +    LLMaterialEditor::loadLiveMaterial(material_id);  }  bool LLPanelFace::isIdenticalPlanarTexgen() diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 8a92d9062f..ffa104230e 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2782,47 +2782,36 @@ void handle_object_open()  	LLFloaterReg::showInstance("openobject");  } -bool enable_object_edit_gltf_material() +struct LLSelectedTEGetmatIdAndPermissions : public LLSelectedTEGetFunctor<LLUUID>  { -    struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> +    LLSelectedTEGetmatIdAndPermissions() : mCanCopy(true), mCanModify(true), mCanTransfer(true) {} +    LLUUID get(LLViewerObject* object, S32 te_index)      { -        LLSelectedTEGetmatId() : mCanModify(true) {} -        LLUUID get(LLViewerObject* object, S32 te_index) -        { -            mCanModify &= (bool)object->permModify(); -            // Todo: probabnly should compare material -            // pointers instead -            return object->getRenderMaterialID(te_index); -        } -        bool mCanModify; -    } func; +        mCanCopy &= (bool)object->permCopy(); +        mCanTransfer &= (bool)object->permTransfer(); +        mCanModify &= (bool)object->permModify(); +        // return true if all ids are identical +        return object->getRenderMaterialID(te_index); +    } +    bool mCanCopy; +    bool mCanModify; +    bool mCanTransfer; +}; + +bool enable_object_edit_gltf_material() +{ +    LLSelectedTEGetmatIdAndPermissions func;      LLUUID mat_id; -    bool identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); -    LL_INFOS() << " Placeholder " << identical << " " << mat_id << LL_ENDL; -    // Todo: this is a placeholder for overrides, -    // it will have to make sure all selection is identical +    LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); +      return func.mCanModify;  }  bool enable_object_save_gltf_material()  { -    struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor<LLUUID> -    { -        LLSelectedTEGetmatId() : mCanCopy(true) {} -        LLUUID get(LLViewerObject* object, S32 te_index) -        { -            mCanCopy &= (bool)object->permCopy(); -            // permTransfer probably should be passed to editor instead -            mCanCopy &= (bool)object->permTransfer(); -            return object->getRenderMaterialID(te_index); -        } -        bool mCanCopy; -    } func; +    LLSelectedTEGetmatIdAndPermissions func;      LLUUID mat_id; -    bool identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); -    LL_INFOS() << " Placeholder " << identical << " " << mat_id << LL_ENDL; -    // Todo: this is a placeholder for overrides, -    // it will have to make sure all selection is identical +    LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id);      return func.mCanCopy;  } @@ -2942,38 +2931,21 @@ void handle_object_edit()  void load_life_gltf_material(bool copy)  { -    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); -    // All materials are supposed to be identical, so pcik any node -    LLViewerObject* object = selection->getFirstNode()->getObject(); -    if (!object) -    { -        return; -    } +    update_camera(); -    // This functionality is a plcaholder for overrides -    // so id doesn't load object by id, but instead gets material directly -    LLGLTFMaterial * mat = NULL; +    LLSelectedTEGetmatIdAndPermissions func; +    LLUUID mat_id; +    LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, mat_id); -    const S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces -    for (S32 face = 0; face < num_tes; ++face) +    if (copy)      { -        LLTextureEntry *te = object->getTE(face); -        if (te->isSelected()) -        { -            mat = te->getGLTFMaterial(); -            break; -        } +        LLMaterialEditor::loadFromGLTFMaterial(mat_id);      } - -    if (mat == NULL) +    else      { -        return; +        LLMaterialEditor::loadLiveMaterial(mat_id);      } -    update_camera(); - -    LLMaterialEditor::loadLiveMaterial(mat, copy); -      LLViewerJoystick::getInstance()->moveObjects(true);      LLViewerJoystick::getInstance()->setNeedsReset(true);  } | 
