diff options
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 183 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.h | 2 | ||||
-rw-r--r-- | indra/newview/llvlcomposition.cpp | 14 | ||||
-rw-r--r-- | indra/newview/llvlcomposition.h | 2 |
4 files changed, 108 insertions, 93 deletions
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<LLTabContainer>("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<LLComboBox>("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<bool> feature_pbr_terrain_enabled(gSavedSettings, "RenderTerrainPBREnabled", false); - - LLTextBox* texture_text = getChild<LLTextBox>("detail_texture_text"); - if (texture_text) { texture_text->setVisible(!feature_pbr_terrain_enabled); } - - LLComboBox* material_type_ctrl = getChild<LLComboBox>("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<LLTextureCtrl>(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<LLComboBox>("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<bool> 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<LLTextBox>("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<LLComboBox>("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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLComboBox>("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<LLTextureCtrl>(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<LLTextureCtrl>(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<LLViewerFetchedTexture> 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<LLFetchedGLTFMaterial> &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<LLFetchedGLTFMaterial> &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); |