Skip to content

Commit aa737e1

Browse files
committed
#1759 Fix terrain related material selection
1. Properly register blank material in LLGLTFMaterialList. This means that it will be regularly checked, but shouldn't be an issue. 2. Fix texture picker using IMG_WHITE for blank materials
1 parent f846861 commit aa737e1

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

indra/newview/gltfscenemanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ void GLTFSceneManager::render(Asset& asset, U8 variant)
716716
}
717717
else
718718
{
719-
LLFetchedGLTFMaterial::sDefault.bind();
719+
LLFetchedGLTFMaterial::sDefault->bind();
720720
LLGLSLShader::sCurBoundShaderPtr->uniform1i(LLShaderMgr::GLTF_MATERIAL_ID, -1);
721721
}
722722

indra/newview/llfetchedgltfmaterial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "pipeline.h"
3636

3737
//static
38-
LLFetchedGLTFMaterial LLFetchedGLTFMaterial::sDefault;
38+
LLPointer<LLFetchedGLTFMaterial> LLFetchedGLTFMaterial::sDefault(new LLFetchedGLTFMaterial());
3939

4040
LLFetchedGLTFMaterial::LLFetchedGLTFMaterial()
4141
: LLGLTFMaterial()

indra/newview/llfetchedgltfmaterial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class LLFetchedGLTFMaterial: public LLGLTFMaterial
7171
std::set<LLTextureEntry*> mTextureEntires;
7272

7373
// default material for when assets don't have one
74-
static LLFetchedGLTFMaterial sDefault;
74+
static LLPointer<LLFetchedGLTFMaterial> sDefault;
7575
protected:
7676
// Lifetime management
7777

indra/newview/llgltfmateriallist.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,15 @@ void LLGLTFMaterialList::onAssetLoadComplete(const LLUUID& id, LLAssetType::ETyp
617617
}
618618
}
619619

620+
LLGLTFMaterialList::LLGLTFMaterialList()
621+
{
622+
LLFetchedGLTFMaterial::sDefault->materialBegin();
623+
LLFetchedGLTFMaterial::sDefault->materialComplete(true);
624+
// Hack:
625+
// Saved by Id instead of BLANK_MATERIAL_ASSET_ID because constants aren't initialized.
626+
addMaterial(LLUUID("968cbad0-4dad-d64e-71b5-72bf13ad051a"), LLFetchedGLTFMaterial::sDefault);
627+
}
628+
620629
LLFetchedGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
621630
{
622631
LL_PROFILE_ZONE_SCOPED;

indra/newview/llgltfmateriallist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class LLGLTFOverrideCacheEntry;
4040
class LLGLTFMaterialList
4141
{
4242
public:
43-
LLGLTFMaterialList() {}
43+
LLGLTFMaterialList();
4444

4545

4646
LLFetchedGLTFMaterial* getMaterial(const LLUUID& id);

indra/newview/lltexturectrl.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,10 +1704,16 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
17041704
mDefaultImageName(p.default_image_name),
17051705
mFallbackImage(p.fallback_image)
17061706
{
1707-
1708-
// Default of defaults is white image for diff tex
1709-
//
1710-
setBlankImageAssetID(IMG_WHITE);
1707+
if (mInventoryPickType == PICK_MATERIAL)
1708+
{
1709+
setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID);
1710+
}
1711+
else
1712+
{
1713+
// Default of defaults is white image for diff tex
1714+
//
1715+
setBlankImageAssetID(IMG_WHITE);
1716+
}
17111717

17121718
setAllowNoTexture(p.allow_no_texture);
17131719
setCanApplyImmediately(p.can_apply_immediately);

0 commit comments

Comments
 (0)