From 18ef2e3b2ba5a6f0ac397fe6f0652c5b55bdaea8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 29 Mar 2024 01:30:16 +0200 Subject: viewer#1081 Account for 2K texture upload price in material and texture upload --- indra/newview/llmaterialeditor.cpp | 69 +++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 13 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index b54617870c..fc3c0bb022 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -489,11 +489,20 @@ BOOL LLMaterialEditor::postBuild() } else { - S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); - getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); - getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); - getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); - getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + S32 upload_cost_base = LLAgentBenefitsMgr::current().getTextureUploadCost(); + S32 upload_cost_2k = LLAgentBenefitsMgr::current().get2KTextureUploadCost(); + + bool large_texture = mBaseColorFetched && (mBaseColorFetched->getFullHeight() * mBaseColorFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA); + getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", large_texture ? upload_cost_2k : upload_cost_base)); + + large_texture = mMetallicRoughnessFetched && (mMetallicRoughnessFetched->getFullHeight() * mMetallicRoughnessFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA); + getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", large_texture ? upload_cost_2k : upload_cost_base)); + + large_texture = mEmissiveFetched && (mEmissiveFetched->getFullHeight() * mEmissiveFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA); + getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", large_texture ? upload_cost_2k : upload_cost_base)); + + large_texture = mNormalFetched && (mNormalFetched->getFullHeight() * mNormalFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA); + getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", large_texture ? upload_cost_2k : upload_cost_base)); } boost::function changes_callback = [this](LLUICtrl * ctrl, void* userData) @@ -843,24 +852,54 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) } S32 upload_texture_count = 0; - if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId()) + S32 upload_2k_texture_count = 0; + if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId() && mBaseColorFetched) { - upload_texture_count++; + if (mBaseColorFetched->getFullHeight() * mBaseColorFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + upload_2k_texture_count++; + } + else + { + upload_texture_count++; + } } - if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId()) + if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId() && mMetallicRoughnessFetched) { - upload_texture_count++; + if (mMetallicRoughnessFetched->getFullHeight() * mMetallicRoughnessFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + upload_2k_texture_count++; + } + else + { + upload_texture_count++; + } } - if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId()) + if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId() && mEmissiveFetched) { - upload_texture_count++; + if (mEmissiveFetched->getFullHeight() * mEmissiveFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + upload_2k_texture_count++; + } + else + { + upload_texture_count++; + } } - if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId()) + if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId() && mNormalFetched) { - upload_texture_count++; + if (mNormalFetched->getFullHeight() * mNormalFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + upload_2k_texture_count++; + } + else + { + upload_texture_count++; + } } mExpectedUploadCost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost(); + mExpectedUploadCost += upload_2k_texture_count * LLAgentBenefitsMgr::current().get2KTextureUploadCost(); getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); } @@ -3496,6 +3535,10 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con buffer.assign((const char*) img->getData(), img->getDataSize()); U32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + if (img->getWidth() * img->getHeight() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + expected_upload_cost = LLAgentBenefitsMgr::current().get2KTextureUploadCost(); + } LLSD key = getKey(); std::function failed_upload([key](LLUUID assetId, LLSD response, std::string reason) -- cgit v1.2.3