Hide and restore GLTF material depending if on the BP or PBR tab to fix visual issues.
parent
bc325fd0de
commit
3f6102bc06
|
|
@ -732,9 +732,6 @@ void FSPanelFace::onMatTabChange()
|
|||
static S32 last_mat = -1;
|
||||
if( auto curr_mat = getCurrentMaterialType(); curr_mat != last_mat )
|
||||
{
|
||||
// Fixes some UI desync
|
||||
updateUI(true);
|
||||
|
||||
LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode();
|
||||
LLViewerObject* objectp = node ? node->getObject() : NULL;
|
||||
if(objectp)
|
||||
|
|
@ -760,6 +757,16 @@ void FSPanelFace::onMatTabChange()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Since we allow both PBR and BP textures to be applied at the same time,
|
||||
// we need to hide or show the GLTF material only locally based on the current tab.
|
||||
if (curr_mat != MATMEDIA_PBR)
|
||||
LLSelectMgr::getInstance()->hideGLTFMaterial();
|
||||
else
|
||||
LLSelectMgr::getInstance()->showGLTFMaterial();
|
||||
|
||||
// Fixes some UI desync
|
||||
updateUI(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1462,13 +1462,6 @@ bool LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
// LLMaterial* mat = tep->getMaterialParams().get();
|
||||
LLMaterial* mat = tep ? tep->getMaterialParams().get() : 0;
|
||||
// </FS:ND>
|
||||
// <FS:Beq> show legacy when editing the fallback materials.
|
||||
static LLCachedControl<bool> showSelectedinBP(gSavedSettings, "FSShowSelectedInBlinnPhong");
|
||||
if( gltf_mat && getViewerObject()->isSelected() && showSelectedinBP )
|
||||
{
|
||||
gltf_mat = nullptr;
|
||||
}
|
||||
// </FS:Beq>
|
||||
|
||||
F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -6236,6 +6236,13 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
|
|||
// might need to be moved to LLGLTFMaterialOverrideDispatchHandler
|
||||
node->saveGLTFMaterials(material_ids, override_materials);
|
||||
}
|
||||
|
||||
// <FS> [FIRE-35138] Show or hide the GLTF Material based on showSelectedinBP
|
||||
static LLCachedControl<bool> showSelectedinBP(gSavedSettings, "FSShowSelectedInBlinnPhong");
|
||||
if (showSelectedinBP)
|
||||
LLSelectMgr::instance().hideGLTFMaterial();
|
||||
else
|
||||
LLSelectMgr::instance().showGLTFMaterial();
|
||||
}
|
||||
|
||||
node->mValid = true;
|
||||
|
|
@ -9074,6 +9081,88 @@ bool LLSelectMgr::selectGetNoIndividual()
|
|||
}
|
||||
// </FS:Zi>
|
||||
|
||||
// <FS> [FIRE-35138] Hide the GLTF Material since we are currently in BP
|
||||
void LLSelectMgr::hideGLTFMaterial()
|
||||
{
|
||||
struct f : public LLSelectedObjectFunctor
|
||||
{
|
||||
f() {}
|
||||
bool apply(LLViewerObject* objectp)
|
||||
{
|
||||
if (!objectp || !objectp->permModify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save the current GLTF materials so they can be restored later
|
||||
objectp->saveGLTFMaterials();
|
||||
|
||||
for (S32 te = 0; te < objectp->getNumTEs(); ++te)
|
||||
{
|
||||
// Blank out most override data on the object and don't send to server
|
||||
objectp->setRenderMaterialID(te, LLUUID(), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
f setfunc;
|
||||
getSelection()->applyToObjects(&setfunc);
|
||||
}
|
||||
// </FS>
|
||||
|
||||
// <FS> [FIRE-35138] Show the GLTF Material since we are no longer in BP
|
||||
void LLSelectMgr::showGLTFMaterial()
|
||||
{
|
||||
struct f : public LLSelectedObjectFunctor
|
||||
{
|
||||
f() {}
|
||||
bool apply(LLViewerObject* objectp)
|
||||
{
|
||||
if (!objectp || !objectp->permModify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const uuid_vec_t& saved_gltf_material_ids = objectp->getSavedGLTFMaterialIds();
|
||||
const gltf_materials_vec_t& saved_gltf_override_materials = objectp->getSavedGLTFOverrideMaterials();
|
||||
|
||||
if (saved_gltf_material_ids.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (S32 te = 0; te < objectp->getNumTEs(); ++te)
|
||||
{
|
||||
if (te >= saved_gltf_material_ids.size())
|
||||
{
|
||||
LL_WARNS("FS") << "TE index out of bounds for saved GLTF materials" << LL_ENDL;
|
||||
break;
|
||||
}
|
||||
|
||||
// Restore gltf material
|
||||
LLUUID asset_id = saved_gltf_material_ids[te];
|
||||
LLGLTFMaterial* material = saved_gltf_override_materials[te];
|
||||
|
||||
// Update material locally
|
||||
objectp->setRenderMaterialID(te, asset_id, false);
|
||||
if (material)
|
||||
{
|
||||
material = new LLGLTFMaterial(*material);
|
||||
objectp->setTEGLTFMaterialOverride(te, material);
|
||||
}
|
||||
|
||||
// Do not enqueue update to server
|
||||
}
|
||||
|
||||
objectp->clearSavedGLTFMaterials();
|
||||
return true;
|
||||
}
|
||||
} setfunc;
|
||||
getSelection()->applyToObjects(&setfunc);
|
||||
}
|
||||
// </FS>
|
||||
|
||||
template<>
|
||||
bool LLCheckIdenticalFunctor<F32>::same(const F32& a, const F32& b, const F32& tolerance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1024,6 +1024,8 @@ public:
|
|||
// (edit linked parts, select face)
|
||||
bool selectGetNoIndividual();
|
||||
// </FS:Zi>
|
||||
void showGLTFMaterial(); // <FS/> [FIRE-35138] Show the GLTF Material since we are no longer in BP
|
||||
void hideGLTFMaterial(); // <FS/> [FIRE-35138] Hide the GLTF Material since we are currently in BP
|
||||
};
|
||||
|
||||
// *DEPRECATED: For callbacks or observers, use
|
||||
|
|
|
|||
|
|
@ -7881,6 +7881,39 @@ void LLViewerObject::setRenderMaterialIDs(const LLUUID& id)
|
|||
setRenderMaterialID(-1, id);
|
||||
}
|
||||
|
||||
// <FS> [FIRE-35138] Helpers for GLTF Materials since we support PBR and BP at same time
|
||||
void LLViewerObject::saveGLTFMaterials()
|
||||
{
|
||||
if (!mSavedGLTFMaterialIds.empty())
|
||||
{
|
||||
// Already saved, no need to do it again
|
||||
return;
|
||||
}
|
||||
|
||||
for (S32 te = 0; te < getNumTEs(); ++te)
|
||||
{
|
||||
mSavedGLTFMaterialIds.emplace_back(getRenderMaterialID(te));
|
||||
|
||||
LLPointer<LLGLTFMaterial> old_override = getTE(te)->getGLTFMaterialOverride();
|
||||
if (old_override.notNull())
|
||||
{
|
||||
LLGLTFMaterial* copy = new LLGLTFMaterial(*old_override);
|
||||
mSavedGLTFOverrideMaterials.emplace_back(copy);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSavedGLTFOverrideMaterials.emplace_back(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLViewerObject::clearSavedGLTFMaterials()
|
||||
{
|
||||
mSavedGLTFMaterialIds.clear();
|
||||
mSavedGLTFOverrideMaterials.clear();
|
||||
}
|
||||
// </FS>
|
||||
|
||||
void LLViewerObject::setRenderMaterialIDs(const LLRenderMaterialParams* material_params, bool local_origin)
|
||||
{
|
||||
if (!local_origin)
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ typedef void (*inventory_callback)(LLViewerObject*,
|
|||
S32 serial_num,
|
||||
void*);
|
||||
|
||||
// <FS> [FIRE-35138] typedef for saved GLTF override materials
|
||||
typedef std::vector<LLPointer<LLGLTFMaterial> > gltf_materials_vec_t;
|
||||
|
||||
// for exporting textured materials from SL
|
||||
struct LLMaterialExportInfo
|
||||
{
|
||||
|
|
@ -135,6 +138,10 @@ protected:
|
|||
LLNetworkData *data;
|
||||
};
|
||||
std::unordered_map<U16, ExtraParameter*> mExtraParameterList;
|
||||
// <FS> [FIRE-35138] Saved GLTF materials to be restored when needed
|
||||
uuid_vec_t mSavedGLTFMaterialIds;
|
||||
gltf_materials_vec_t mSavedGLTFOverrideMaterials;
|
||||
// </FS>
|
||||
|
||||
public:
|
||||
typedef std::list<LLPointer<LLViewerObject> > child_list_t;
|
||||
|
|
@ -204,6 +211,13 @@ public:
|
|||
void setRenderMaterialID(S32 te, const LLUUID& id, bool update_server = true, bool local_origin = true);
|
||||
void setRenderMaterialIDs(const LLUUID& id);
|
||||
|
||||
// <FS> [FIRE-35138] Helpers for GLTF Materials since we support PBR and BP at same time
|
||||
const uuid_vec_t& getSavedGLTFMaterialIds() const { return mSavedGLTFMaterialIds; };
|
||||
const gltf_materials_vec_t& getSavedGLTFOverrideMaterials() const { return mSavedGLTFOverrideMaterials; };
|
||||
void saveGLTFMaterials();
|
||||
void clearSavedGLTFMaterials();
|
||||
// </FS>
|
||||
|
||||
virtual bool isHUDAttachment() const { return false; }
|
||||
virtual bool isTempAttachment() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -5663,14 +5663,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
|
|||
auto* gltf_mat = (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial();
|
||||
llassert(gltf_mat == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(te->getGLTFRenderMaterial()) != nullptr);
|
||||
|
||||
// <FS:Beq> show legacy when editing the fallback materials.
|
||||
static LLCachedControl<bool> showSelectedinBP(gSavedSettings, "FSShowSelectedInBlinnPhong");
|
||||
if( gltf_mat && facep->getViewerObject()->isSelected() && showSelectedinBP )
|
||||
{
|
||||
gltf_mat = nullptr;
|
||||
}
|
||||
// </FS:Beq>
|
||||
|
||||
if (gltf_mat != nullptr)
|
||||
{
|
||||
mat_id = gltf_mat->getHash(); // TODO: cache this hash
|
||||
|
|
@ -6881,14 +6873,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
|
|||
const LLTextureEntry* te = facep->getTextureEntry();
|
||||
LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial();
|
||||
|
||||
// <FS:Beq> show legacy when editing the fallback materials.
|
||||
static LLCachedControl<bool> showSelectedinBP(gSavedSettings, "FSShowSelectedInBlinnPhong");
|
||||
if( gltf_mat && facep->getViewerObject()->isSelected() && showSelectedinBP )
|
||||
{
|
||||
gltf_mat = nullptr;
|
||||
}
|
||||
// </FS:Beq>
|
||||
|
||||
if (hud_group && gltf_mat == nullptr)
|
||||
{ //all hud attachments are fullbright
|
||||
fullbright = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue