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/llfloaterregioninfo.cpp | 183 +++++++++++++++++++--------------- indra/newview/llfloaterregioninfo.h | 2 +- indra/newview/llvlcomposition.cpp | 14 ++- indra/newview/llvlcomposition.h | 2 +- 4 files changed, 108 insertions(+), 93 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 8b335d57d7..8e2fb24923 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -340,7 +340,6 @@ void LLFloaterRegionInfo::onRegionChanged() } } -// static void LLFloaterRegionInfo::requestRegionInfo() { LLTabContainer* tab = findChild("region_panels"); @@ -1327,9 +1326,6 @@ void LLPanelRegionDebugInfo::onClickDebugConsole(void* data) BOOL LLPanelRegionTerrainInfo::validateTextureSizes() { - // *TODO: Don't early-exit in PBR material terrain editing mode, and - // instead do some reasonable checks that the PBR material is compatible - // with the terrain rendering pipeline. Err on the side of permissive. LLComboBox* material_type_ctrl = getChild("terrain_material_type"); if (material_type_ctrl) { @@ -1446,54 +1442,24 @@ BOOL LLPanelRegionTerrainInfo::postBuild() mRegionChangedSlot = gAgent.addRegionChangedCallback(boost::bind(&LLPanelRegionTerrainInfo::onRegionChanged,this)); } - refresh(); - return LLPanelRegionInfo::postBuild(); } -// virtual -void LLPanelRegionTerrainInfo::refresh() +void LLPanelRegionTerrainInfo::onSelectMaterialType() { - static LLCachedControl feature_pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); - - LLTextBox* texture_text = getChild("detail_texture_text"); - if (texture_text) { texture_text->setVisible(!feature_pbr_terrain_enabled); } - - LLComboBox* material_type_ctrl = getChild("terrain_material_type"); - if (material_type_ctrl) - { - material_type_ctrl->setVisible(feature_pbr_terrain_enabled); - - bool has_material_assets = false; - - std::string buffer; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("material_detail_%d", i); - LLTextureCtrl* material_ctrl = getChild(buffer); - if (material_ctrl && material_ctrl->getImageAssetID().notNull()) - { - has_material_assets = true; - break; - } - } - - TerrainMaterialType material_type = material_type_from_index(material_type_ctrl->getCurrentIndex()); - - if (!feature_pbr_terrain_enabled) { material_type = TerrainMaterialType::TEXTURE; } - - const bool is_material_selected = material_type == TerrainMaterialType::PBR_MATERIAL; - material_type_ctrl->setEnabled(feature_pbr_terrain_enabled && !(is_material_selected && has_material_assets)); - } + updateForMaterialType(); + onChangeAnything(); } -void LLPanelRegionTerrainInfo::onSelectMaterialType() +void LLPanelRegionTerrainInfo::updateForMaterialType() { LLComboBox* material_type_ctrl = getChild("terrain_material_type"); if (!material_type_ctrl) { return; } const TerrainMaterialType material_type = material_type_from_index(material_type_ctrl->getCurrentIndex()); const bool show_texture_controls = material_type == TerrainMaterialType::TEXTURE; const bool show_material_controls = material_type == TerrainMaterialType::PBR_MATERIAL; + + // Toggle visibility of correct swatches std::string buffer; LLTextureCtrl* texture_ctrl; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) @@ -1554,31 +1520,98 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) LLVLComposition* compp = region->getComposition(); - // Are these 4 texture IDs or 4 material IDs? Who knows! Let's set the IDs on both pickers for now. + static LLCachedControl feature_pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); + + const bool textures_ready = compp->texturesReady(false, false); + const bool materials_ready = feature_pbr_terrain_enabled && compp->materialsReady(false, false); + + LLTextBox* texture_text = getChild("detail_texture_text"); + if (texture_text) { texture_text->setVisible(!feature_pbr_terrain_enabled); } + + bool set_texture_swatches; + bool set_material_swatches; + bool clear_texture_swatches; + bool clear_material_swatches; + LLTerrainMaterials::Type material_type; + if (!textures_ready && !materials_ready) + { + // Are these 4 texture IDs or 4 material IDs? Who knows! Let's set + // the IDs on both pickers for now. + material_type = LLTerrainMaterials::Type::TEXTURE; + set_texture_swatches = true; + set_material_swatches = true; + clear_texture_swatches = false; + clear_material_swatches = false; + } + else + { + material_type = compp->getMaterialType(); + set_texture_swatches = material_type == LLTerrainMaterials::Type::TEXTURE; + set_material_swatches = !set_texture_swatches; + clear_texture_swatches = !set_texture_swatches; + clear_material_swatches = !set_material_swatches; + } + + LLComboBox* material_type_ctrl = getChild("terrain_material_type"); + if (material_type_ctrl) { material_type_ctrl->setCurrentByIndex(S32(material_type)); } + updateForMaterialType(); + LLTextureCtrl* asset_ctrl; std::string buffer; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("texture_detail_%d", i); - asset_ctrl = getChild(buffer); - if(asset_ctrl) - { - LL_DEBUGS() << "Detail Texture " << i << ": " - << compp->getDetailAssetID(i) << LL_ENDL; - LLUUID tmp_id(compp->getDetailAssetID(i)); - asset_ctrl->setImageAssetID(tmp_id); - } - } - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("material_detail_%d", i); - asset_ctrl = getChild(buffer); - if(asset_ctrl) - { - LLUUID tmp_id(compp->getDetailAssetID(i)); - asset_ctrl->setImageAssetID(tmp_id); - } - } + if (set_texture_swatches) + { + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("texture_detail_%d", i); + asset_ctrl = getChild(buffer); + if(asset_ctrl) + { + LL_DEBUGS() << "Detail Texture " << i << ": " + << compp->getDetailAssetID(i) << LL_ENDL; + LLUUID tmp_id(compp->getDetailAssetID(i)); + asset_ctrl->setImageAssetID(tmp_id); + } + } + } + if (set_material_swatches) + { + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("material_detail_%d", i); + asset_ctrl = getChild(buffer); + if(asset_ctrl) + { + LL_DEBUGS() << "Detail Material " << i << ": " + << compp->getDetailAssetID(i) << LL_ENDL; + LLUUID tmp_id(compp->getDetailAssetID(i)); + asset_ctrl->setImageAssetID(tmp_id); + } + } + } + if (clear_texture_swatches) + { + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("texture_detail_%d", i); + asset_ctrl = getChild(buffer); + if(asset_ctrl) + { + asset_ctrl->setImageAssetID(LLUUID::null); + } + } + } + if (clear_material_swatches) + { + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("material_detail_%d", i); + asset_ctrl = getChild(buffer); + if(asset_ctrl) + { + asset_ctrl->setImageAssetID(LLUUID::null); + } + } + } for(S32 i = 0; i < CORNER_COUNT; ++i) { @@ -1650,29 +1683,13 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() std::string id_str; LLMessageSystem* msg = gMessageSystem; - // Use material IDs instead of texture IDs if all material IDs are set, AND the mode is set to PBR materials. - S32 materials_used = 0; + // Send either material IDs instead of texture IDs depending on + // terrain_material_type - they both occupy the same slot. LLComboBox* material_type_ctrl = getChild("terrain_material_type"); - if (material_type_ctrl) - { - const TerrainMaterialType material_type = material_type_from_index(material_type_ctrl->getCurrentIndex()); - const bool is_material_selected = material_type == TerrainMaterialType::PBR_MATERIAL; - if (is_material_selected) - { - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("material_detail_%d", i); - asset_ctrl = getChild(buffer); - if(asset_ctrl && asset_ctrl->getImageAssetID().notNull()) - { - ++materials_used; - } - } - } - } + const TerrainMaterialType material_type = material_type_ctrl ? material_type_from_index(material_type_ctrl->getCurrentIndex()) : TerrainMaterialType::TEXTURE; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - if (materials_used == TERRAIN_TEXTURE_COUNT) + if (material_type == TerrainMaterialType::PBR_MATERIAL) { buffer = llformat("material_detail_%d", i); asset_ctrl = getChild(buffer); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 91e1f5b058..abd8e21503 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -258,8 +258,8 @@ public: //static void onChangeAnything(LLUICtrl* ctrl, void* userData); // callback for any change, to enable commit button - void refresh() override; void onSelectMaterialType(); + void updateForMaterialType(); static void onClickDownloadRaw(void*); static void onClickUploadRaw(void*); 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. diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index 73bfca6ed4..dea776849a 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -58,7 +58,7 @@ public: BOOL generateMaterials(); - LLUUID getDetailAssetID(S32 asset); + virtual LLUUID getDetailAssetID(S32 asset); virtual void setDetailAssetID(S32 asset, const LLUUID& id); Type getMaterialType(); bool texturesReady(bool boost, bool strict); -- 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/llfloaterregioninfo.cpp | 88 ++++++++++++++++++++++------------- indra/newview/llfloaterregioninfo.h | 5 +- indra/newview/llvlcomposition.cpp | 22 +++++++-- indra/newview/llvlcomposition.h | 9 ++-- 4 files changed, 81 insertions(+), 43 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 8e2fb24923..a865ad19d3 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -86,7 +86,6 @@ #include "llviewerstats.h" #include "llviewertexteditor.h" #include "llviewerwindow.h" -#include "llvlcomposition.h" #include "lltrans.h" #include "llagentui.h" #include "llmeshrepository.h" @@ -100,7 +99,6 @@ #include "llavatarnamecache.h" #include "llenvironment.h" -const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; const U32 MAX_LISTED_NAMES = 100; @@ -1335,7 +1333,7 @@ BOOL LLPanelRegionTerrainInfo::validateTextureSizes() } static const S32 MAX_TERRAIN_TEXTURE_SIZE = 1024; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { std::string buffer; buffer = llformat("texture_detail_%d", i); @@ -1397,6 +1395,21 @@ BOOL LLPanelRegionTerrainInfo::validateTextureHeights() ///////////////////////////////////////////////////////////////////////////// // LLPanelRegionTerrainInfo ///////////////////////////////////////////////////////////////////////////// + +LLPanelRegionTerrainInfo::LLPanelRegionTerrainInfo() +: LLPanelRegionInfo() +{ + const LLUUID (&default_textures)[LLVLComposition::ASSET_COUNT] = LLVLComposition::getDefaultTextures(); + for (S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) + { + mLastSetTextures[i] = default_textures[i]; + } + for (S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) + { + mLastSetMaterials[i] = LLUUID::null; + } +} + // Initialize statics BOOL LLPanelRegionTerrainInfo::postBuild() @@ -1411,12 +1424,12 @@ BOOL LLPanelRegionTerrainInfo::postBuild() std::string buffer; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("texture_detail_%d", i); initCtrl(buffer); } - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("material_detail_%d", i); initCtrl(buffer); @@ -1462,7 +1475,7 @@ void LLPanelRegionTerrainInfo::updateForMaterialType() // Toggle visibility of correct swatches std::string buffer; LLTextureCtrl* texture_ctrl; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("texture_detail_%d", i); texture_ctrl = getChild(buffer); @@ -1471,7 +1484,7 @@ void LLPanelRegionTerrainInfo::updateForMaterialType() texture_ctrl->setVisible(show_texture_controls); } } - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("material_detail_%d", i); texture_ctrl = getChild(buffer); @@ -1530,8 +1543,8 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) bool set_texture_swatches; bool set_material_swatches; - bool clear_texture_swatches; - bool clear_material_swatches; + bool reset_texture_swatches; + bool reset_material_swatches; LLTerrainMaterials::Type material_type; if (!textures_ready && !materials_ready) { @@ -1540,16 +1553,16 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) material_type = LLTerrainMaterials::Type::TEXTURE; set_texture_swatches = true; set_material_swatches = true; - clear_texture_swatches = false; - clear_material_swatches = false; + reset_texture_swatches = false; + reset_material_swatches = false; } else { material_type = compp->getMaterialType(); set_texture_swatches = material_type == LLTerrainMaterials::Type::TEXTURE; set_material_swatches = !set_texture_swatches; - clear_texture_swatches = !set_texture_swatches; - clear_material_swatches = !set_material_swatches; + reset_texture_swatches = !set_texture_swatches; + reset_material_swatches = !set_material_swatches; } LLComboBox* material_type_ctrl = getChild("terrain_material_type"); @@ -1560,7 +1573,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) std::string buffer; if (set_texture_swatches) { - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("texture_detail_%d", i); asset_ctrl = getChild(buffer); @@ -1575,7 +1588,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) } if (set_material_swatches) { - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("material_detail_%d", i); asset_ctrl = getChild(buffer); @@ -1588,27 +1601,27 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) } } } - if (clear_texture_swatches) + if (reset_texture_swatches) { - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("texture_detail_%d", i); asset_ctrl = getChild(buffer); if(asset_ctrl) { - asset_ctrl->setImageAssetID(LLUUID::null); + asset_ctrl->setImageAssetID(mLastSetTextures[i]); } } } - if (clear_material_swatches) + if (reset_material_swatches) { - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { buffer = llformat("material_detail_%d", i); asset_ctrl = getChild(buffer); if(asset_ctrl) { - asset_ctrl->setImageAssetID(LLUUID::null); + asset_ctrl->setImageAssetID(mLastSetMaterials[i]); } } } @@ -1687,26 +1700,35 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() // terrain_material_type - they both occupy the same slot. LLComboBox* material_type_ctrl = getChild("terrain_material_type"); const TerrainMaterialType material_type = material_type_ctrl ? material_type_from_index(material_type_ctrl->getCurrentIndex()) : TerrainMaterialType::TEXTURE; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { + for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) + { if (material_type == TerrainMaterialType::PBR_MATERIAL) { buffer = llformat("material_detail_%d", i); - asset_ctrl = getChild(buffer); } else { buffer = llformat("texture_detail_%d", i); - asset_ctrl = getChild(buffer); } - if(asset_ctrl) - { - LLUUID tmp_id(asset_ctrl->getImageAssetID()); - tmp_id.toString(id_str); - buffer = llformat("%d %s", i, id_str.c_str()); - strings.push_back(buffer); - } - } + asset_ctrl = getChild(buffer); + + if (!asset_ctrl) { continue; } + + LLUUID tmp_id(asset_ctrl->getImageAssetID()); + tmp_id.toString(id_str); + buffer = llformat("%d %s", i, id_str.c_str()); + strings.push_back(buffer); + + // Store asset for later terrain editing + if (material_type == TerrainMaterialType::PBR_MATERIAL) + { + mLastSetMaterials[i] = tmp_id; + } + else + { + mLastSetTextures[i] = tmp_id; + } + } sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); strings.clear(); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index abd8e21503..315c6aca0f 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -36,6 +36,7 @@ #include "llpanel.h" #include "llextendedstatus.h" #include "llpanelenvironment.h" +#include "llvlcomposition.h" #include "lleventcoro.h" @@ -243,7 +244,7 @@ class LLPanelRegionTerrainInfo : public LLPanelRegionInfo LOG_CLASS(LLPanelRegionTerrainInfo); public: - LLPanelRegionTerrainInfo() : LLPanelRegionInfo() {} + LLPanelRegionTerrainInfo(); ~LLPanelRegionTerrainInfo() {} BOOL postBuild() override; @@ -274,6 +275,8 @@ private: bool mConfirmedTextureHeights; bool mAskedTextureHeights; boost::signals2::connection mRegionChangedSlot; + LLUUID mLastSetTextures[LLTerrainMaterials::ASSET_COUNT]; + LLUUID mLastSetMaterials[LLTerrainMaterials::ASSET_COUNT]; }; ///////////////////////////////////////////////////////////////////////////// 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; diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index dea776849a..7397ff1e8d 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -82,6 +82,11 @@ extern LLTerrainMaterials gLocalTerrainMaterials; class LLVLComposition : public LLTerrainMaterials, public LLViewerLayer { public: + // Heights map into textures (or materials) as 0-1 = first, 1-2 = second, etc. + // So we need to compress heights into this range. + static const S32 ASSET_COUNT = 4; + static const LLUUID (&getDefaultTextures())[ASSET_COUNT]; + LLVLComposition(LLSurface *surfacep, const U32 width, const F32 scale); /*virtual*/ ~LLVLComposition(); @@ -93,10 +98,6 @@ public: // Generate texture from composition values. BOOL generateMinimapTileLand(const F32 x, const F32 y, const F32 width, const F32 height); - // Heights map into textures (or materials) as 0-1 = first, 1-2 = second, etc. - // So we need to compress heights into this range. - static const S32 ASSET_COUNT = 4; - // Use these as indeces ito the get/setters below that use 'corner' enum ECorner { -- cgit v1.2.3 From 94c5baeb6146598a9a280e27e584c241b7b3b9e0 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 1 Mar 2024 17:26:24 -0800 Subject: secondlife/viewer#712: Use checkbox to make it more obvious that only one set of terrain assets is preserved. Clean up enums. --- indra/newview/llfloaterregioninfo.cpp | 56 ++++++++++------------ .../skins/default/xui/en/panel_region_terrain.xml | 45 ++++++++--------- 2 files changed, 46 insertions(+), 55 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a865ad19d3..6e8e37621e 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -602,24 +602,14 @@ LLPanelRegionEnvironment* LLFloaterRegionInfo::getPanelEnvironment() return panel; } -enum class TerrainMaterialType +LLTerrainMaterials::Type material_type_from_ctrl(LLCheckBoxCtrl* ctrl) { - TEXTURE, - PBR_MATERIAL, - COUNT -}; + return ctrl->get() ? LLTerrainMaterials::Type::PBR : LLTerrainMaterials::Type::TEXTURE; +} -TerrainMaterialType material_type_from_index(S32 index) +void material_type_to_ctrl(LLCheckBoxCtrl* ctrl, LLTerrainMaterials::Type new_type) { - if (index == 0) - { - return TerrainMaterialType::TEXTURE; - } - if (index == 1) - { - return TerrainMaterialType::PBR_MATERIAL; - } - return TerrainMaterialType::COUNT; + ctrl->set(new_type == LLTerrainMaterials::Type::PBR); } // static @@ -1324,11 +1314,11 @@ void LLPanelRegionDebugInfo::onClickDebugConsole(void* data) BOOL LLPanelRegionTerrainInfo::validateTextureSizes() { - LLComboBox* material_type_ctrl = getChild("terrain_material_type"); + LLCheckBoxCtrl* material_type_ctrl = getChild("terrain_material_type"); if (material_type_ctrl) { - const TerrainMaterialType material_type = material_type_from_index(material_type_ctrl->getCurrentIndex()); - const bool is_material_selected = material_type == TerrainMaterialType::PBR_MATERIAL; + const LLTerrainMaterials::Type material_type = material_type_from_ctrl(material_type_ctrl); + const bool is_material_selected = material_type == LLTerrainMaterials::Type::PBR; if (is_material_selected) { return TRUE; } } @@ -1466,11 +1456,11 @@ void LLPanelRegionTerrainInfo::onSelectMaterialType() void LLPanelRegionTerrainInfo::updateForMaterialType() { - LLComboBox* material_type_ctrl = getChild("terrain_material_type"); + LLCheckBoxCtrl* material_type_ctrl = getChild("terrain_material_type"); if (!material_type_ctrl) { return; } - const TerrainMaterialType material_type = material_type_from_index(material_type_ctrl->getCurrentIndex()); - const bool show_texture_controls = material_type == TerrainMaterialType::TEXTURE; - const bool show_material_controls = material_type == TerrainMaterialType::PBR_MATERIAL; + const LLTerrainMaterials::Type material_type = material_type_from_ctrl(material_type_ctrl); + const bool show_texture_controls = material_type == LLTerrainMaterials::Type::TEXTURE; + const bool show_material_controls = material_type == LLTerrainMaterials::Type::PBR; // Toggle visibility of correct swatches std::string buffer; @@ -1493,6 +1483,12 @@ void LLPanelRegionTerrainInfo::updateForMaterialType() texture_ctrl->setVisible(show_material_controls); } } + + // Toggle visibility of labels + LLUICtrl* texture_label = getChild("detail_texture_text"); + if (texture_label) { texture_label->setVisible(show_texture_controls); } + LLUICtrl* material_label = getChild("detail_material_text"); + if (material_label) { material_label->setVisible(show_material_controls); } } void LLPanelRegionTerrainInfo::onRegionChanged() @@ -1538,9 +1534,6 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) const bool textures_ready = compp->texturesReady(false, false); const bool materials_ready = feature_pbr_terrain_enabled && compp->materialsReady(false, false); - LLTextBox* texture_text = getChild("detail_texture_text"); - if (texture_text) { texture_text->setVisible(!feature_pbr_terrain_enabled); } - bool set_texture_swatches; bool set_material_swatches; bool reset_texture_swatches; @@ -1565,9 +1558,10 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) reset_material_swatches = !set_material_swatches; } - LLComboBox* material_type_ctrl = getChild("terrain_material_type"); - if (material_type_ctrl) { material_type_ctrl->setCurrentByIndex(S32(material_type)); } + LLCheckBoxCtrl* material_type_ctrl = getChild("terrain_material_type"); + if (material_type_ctrl) { material_type_to_ctrl(material_type_ctrl, material_type); } updateForMaterialType(); + material_type_ctrl->setVisible(feature_pbr_terrain_enabled); LLTextureCtrl* asset_ctrl; std::string buffer; @@ -1698,11 +1692,11 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() // Send either material IDs instead of texture IDs depending on // terrain_material_type - they both occupy the same slot. - LLComboBox* material_type_ctrl = getChild("terrain_material_type"); - const TerrainMaterialType material_type = material_type_ctrl ? material_type_from_index(material_type_ctrl->getCurrentIndex()) : TerrainMaterialType::TEXTURE; + LLCheckBoxCtrl* material_type_ctrl = getChild("terrain_material_type"); + const LLTerrainMaterials::Type material_type = material_type_ctrl ? material_type_from_ctrl(material_type_ctrl) : LLTerrainMaterials::Type::TEXTURE; for(S32 i = 0; i < LLTerrainMaterials::ASSET_COUNT; ++i) { - if (material_type == TerrainMaterialType::PBR_MATERIAL) + if (material_type == LLTerrainMaterials::Type::PBR) { buffer = llformat("material_detail_%d", i); } @@ -1720,7 +1714,7 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() strings.push_back(buffer); // Store asset for later terrain editing - if (material_type == TerrainMaterialType::PBR_MATERIAL) + if (material_type == LLTerrainMaterials::Type::PBR) { mLastSetMaterials[i] = tmp_id; } diff --git a/indra/newview/skins/default/xui/en/panel_region_terrain.xml b/indra/newview/skins/default/xui/en/panel_region_terrain.xml index 88855ab739..f8d2c90d0a 100644 --- a/indra/newview/skins/default/xui/en/panel_region_terrain.xml +++ b/indra/newview/skins/default/xui/en/panel_region_terrain.xml @@ -76,33 +76,17 @@ left="8" top="30" width="460" /> - - - - Terrain Textures @@ -114,12 +98,25 @@ follows="left|top" height="20" layout="topleft" - top_delta="0" - left_delta="180" - name="detail_texture_limits_text" - width="200"> - Maximum size: 1024x1024 + name="detail_material_text" + left="10" + top="105" + width="170"> + Terrain Materials +