diff options
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llfetchedgltfmaterial.cpp | 12 | ||||
| -rw-r--r-- | indra/newview/llfetchedgltfmaterial.h | 2 | ||||
| -rw-r--r-- | indra/newview/lllocalgltfmaterials.cpp | 31 | ||||
| -rw-r--r-- | indra/newview/lllocalgltfmaterials.h | 5 | ||||
| -rw-r--r-- | indra/newview/llviewerobject.cpp | 9 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/floater_material_editor.xml | 1 | 
6 files changed, 54 insertions, 6 deletions
| diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 80074cc655..2e71b4fa87 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -46,6 +46,18 @@ LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial()  } +LLFetchedGLTFMaterial& LLFetchedGLTFMaterial::operator=(const LLFetchedGLTFMaterial& rhs) +{ +    LLGLTFMaterial::operator =(rhs); + +    mBaseColorTexture = rhs.mBaseColorTexture; +    mNormalTexture = rhs.mNormalTexture; +    mMetallicRoughnessTexture = rhs.mMetallicRoughnessTexture; +    mEmissiveTexture = rhs.mEmissiveTexture; + +    return *this; +} +  void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex)  {      // glTF 2.0 Specification 3.9.4. Alpha Coverage diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 0b51770493..1668657281 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -39,6 +39,8 @@ public:      LLFetchedGLTFMaterial();      virtual ~LLFetchedGLTFMaterial(); +    LLFetchedGLTFMaterial& operator=(const LLFetchedGLTFMaterial& rhs); +      // If this material is loaded, fire the given function      void onMaterialComplete(std::function<void()> material_complete); diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index 996b168262..d464ea0571 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -45,6 +45,7 @@  #include "llmaterialmgr.h"  #include "llnotificationsutil.h"  #include "llscrolllistctrl.h" +#include "lltextureentry.h"  #include "lltinygltfhelper.h"  #include "llviewertexture.h" @@ -118,6 +119,15 @@ S32 LLLocalGLTFMaterial::getIndexInFile() const      return mMaterialIndex;  } +void LLLocalGLTFMaterial::addTextureEntry(LLTextureEntry* te) +{ +    mTextureEntires.insert(te); +} +void LLLocalGLTFMaterial::removeTextureEntry(LLTextureEntry* te) +{ +    mTextureEntires.erase(te); +} +  /* update functions */  bool LLLocalGLTFMaterial::updateSelf()  { @@ -154,6 +164,27 @@ bool LLLocalGLTFMaterial::updateSelf()                      gGLTFMaterialList.addMaterial(mWorldID, this);                      mUpdateRetries = LL_LOCAL_UPDATE_RETRIES; + +                    for (LLTextureEntry* entry : mTextureEntires) +                    { +                        // Normally a change in applied material id is supposed to +                        // drop overrides thus reset material, but local materials +                        // currently reuse their existing asset id, and purpose is +                        // to preview how material will work in-world, overrides +                        // included, so do an override to render update instead. +                        LLGLTFMaterial* override_mat = entry->getGLTFMaterialOverride(); +                        if (override_mat) +                        { +                            // do not create a new material, reuse existing pointer +                            LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)entry->getGLTFRenderMaterial(); +                            if (render_mat) +                            { +                                *render_mat = *this; +                                render_mat->applyOverride(*override_mat); +                            } +                        } +                    } +                      updated = true;                  } diff --git a/indra/newview/lllocalgltfmaterials.h b/indra/newview/lllocalgltfmaterials.h index 6919b9b4b2..1442b83a40 100644 --- a/indra/newview/lllocalgltfmaterials.h +++ b/indra/newview/lllocalgltfmaterials.h @@ -34,6 +34,7 @@  class LLScrollListCtrl;  class LLGLTFMaterial;  class LLViewerObject; +class LLTextureEntry;  class LLLocalGLTFMaterial : public LLFetchedGLTFMaterial  { @@ -48,6 +49,9 @@ public: /* accessors */      LLUUID		getWorldID() const;      S32			getIndexInFile() const; +    void addTextureEntry(LLTextureEntry* te) override; +    void removeTextureEntry(LLTextureEntry* te) override; +  public:      bool updateSelf(); @@ -77,6 +81,7 @@ private: /* members */      ELinkStatus mLinkStatus;      S32         mUpdateRetries;      S32         mMaterialIndex; // Single file can have more than one +    std::set<LLTextureEntry*> mTextureEntires;  };  class LLLocalGLTFMaterialTimer : public LLEventTimer diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index cb1694821d..a3a825c199 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5368,8 +5368,10 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma      LLFetchedGLTFMaterial* src_mat = (LLFetchedGLTFMaterial*) tep->getGLTFMaterial(); +    // if override mat exists, we must also have a source mat      if (!src_mat) -    { // we can get into this state if an override has arrived before the viewer has +    { +        // we can get into this state if an override has arrived before the viewer has          // received or handled an update, return TEM_CHANGE_NONE to signal to LLGLTFMaterialList that it          // should queue the update for later          return retval; @@ -5383,10 +5385,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma      tep->setGLTFMaterialOverride(override_mat); -    // if override mat exists, we must also have a source mat -    llassert(override_mat ? bool(src_mat) : true); - -    if (override_mat && src_mat) +    if (override_mat)      {          LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat);          render_mat->applyOverride(*override_mat); diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 1c58ea6977..a6a401f43e 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -29,7 +29,6 @@     color="DkGray2"     opaque="true"     tab_stop="true" -   border="false"     reserve_scroll_corner="false">      <panel       name="panel_material" | 
