From d79498e25991e425510643ecd1303a5675c5fbf6 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 28 Feb 2024 15:02:18 -0800 Subject: secondlife/viewer#712: More intuitive selection of PBR vs texture terrain, and update dropdown to match --- indra/newview/llvlcomposition.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'indra/newview/llvlcomposition.cpp') diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index 09b21e4e0a..9c64381a07 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -91,10 +91,10 @@ BOOL LLTerrainMaterials::generateMaterials() LLUUID LLTerrainMaterials::getDetailAssetID(S32 asset) { llassert(mDetailTextures[asset] && mDetailMaterials[asset]); - // *HACK: Assume both the the material and texture were fetched in the same - // way using the same UUID. However, we may not know at this point which - // one will load. - return mDetailTextures[asset]->getID(); + // Assume both the the material and texture were fetched in the same way + // using the same UUID. However, we may not know at this point which one + // will load. + return mDetailTextures[asset] ? mDetailTextures[asset]->getID() : LLUUID::null; } LLPointer fetch_terrain_texture(const LLUUID& id) @@ -133,7 +133,7 @@ bool LLTerrainMaterials::texturesReady(bool boost, bool strict) // *NOTE: Calls to textureReady may boost textures. Do not early-return. for (S32 i = 0; i < ASSET_COUNT; i++) { - ready[i] = textureReady(mDetailTextures[i], boost); + ready[i] = mDetailTextures[i].notNull() && textureReady(mDetailTextures[i], boost); } bool one_ready = false; @@ -250,6 +250,7 @@ bool LLTerrainMaterials::materialReady(LLPointer &mat, bo // Material is loaded, but textures may not be if (!textures_set) { + textures_set = true; // *NOTE: These can sometimes be set to to nullptr due to // updateTEMaterialTextures. For the sake of robustness, we emulate // that fetching behavior by setting textures of null IDs to nullptr. @@ -257,9 +258,6 @@ bool LLTerrainMaterials::materialReady(LLPointer &mat, bo mat->mNormalTexture = fetch_terrain_texture(mat->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL]); mat->mMetallicRoughnessTexture = fetch_terrain_texture(mat->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS]); mat->mEmissiveTexture = fetch_terrain_texture(mat->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE]); - textures_set = true; - - return false; } // *NOTE: Calls to textureReady may boost textures. Do not early-return. -- cgit v1.2.3 From 0cb9e7f7e5bd02ded8b9f2bd9cd6c57a70187dcc Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 29 Feb 2024 16:52:35 -0800 Subject: secondlife/viewer#712: Remember previously set textures/materials when possible. Not persistent. --- indra/newview/llvlcomposition.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'indra/newview/llvlcomposition.cpp') diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index 9c64381a07..506ab005c5 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -44,7 +44,6 @@ static const U32 BASE_SIZE = 128; - F32 bilinear(const F32 v00, const F32 v01, const F32 v10, const F32 v11, const F32 x_frac, const F32 y_frac) { // Not sure if this is the right math... @@ -286,16 +285,29 @@ bool LLTerrainMaterials::materialReady(LLPointer &mat, bo return true; } +// static +const LLUUID (&LLVLComposition::getDefaultTextures())[ASSET_COUNT] +{ + const static LLUUID default_textures[LLVLComposition::ASSET_COUNT] = + { + TERRAIN_DIRT_DETAIL, + TERRAIN_GRASS_DETAIL, + TERRAIN_MOUNTAIN_DETAIL, + TERRAIN_ROCK_DETAIL + }; + return default_textures; +} LLVLComposition::LLVLComposition(LLSurface *surfacep, const U32 width, const F32 scale) : LLTerrainMaterials(), LLViewerLayer(width, scale) { // Load Terrain Textures - Original ones - setDetailAssetID(0, TERRAIN_DIRT_DETAIL); - setDetailAssetID(1, TERRAIN_GRASS_DETAIL); - setDetailAssetID(2, TERRAIN_MOUNTAIN_DETAIL); - setDetailAssetID(3, TERRAIN_ROCK_DETAIL); + const LLUUID (&default_textures)[LLVLComposition::ASSET_COUNT] = LLVLComposition::getDefaultTextures(); + for (S32 i = 0; i < ASSET_COUNT; ++i) + { + setDetailAssetID(i, default_textures[i]); + } mSurfacep = surfacep; -- cgit v1.2.3