From 19163fd0fea6c92712b37e29f34b72edbbfe152d Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 18 Jan 2024 10:33:02 -0600 Subject: Allow for upload of 2k textures (#652) * SL-20760 Allow 2k texture uploads * SL-20760 Fix for textures not downloading. --- indra/newview/llmaterialeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 34f2f77d25..45bb350e1f 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1872,7 +1872,7 @@ static void pack_textures( if (normal_img) { // create a losslessly compressed version of the normal map - normal_j2c = LLViewerTextureList::convertToUploadFile(normal_img, 1024, false, true); + normal_j2c = LLViewerTextureList::convertToUploadFile(normal_img, 2048, false, true); LL_DEBUGS("MaterialEditor") << "Normal: " << normal_j2c->getDataSize() << LL_ENDL; } -- cgit v1.2.3 From d0458c4853a6b1923439af8ebc2701410d838473 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 18 Mar 2024 13:57:01 -0700 Subject: secondlife/viewer#1006: Move blank material constant to indra_constants.h --- indra/newview/llmaterialeditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index f939418893..b54617870c 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2124,7 +2124,7 @@ bool can_use_objects_material(LLSelectedTEGetMatData& func, const std::vector 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 From e1e0b6fc5bb3eaa210fac24e2421fefbaeafe561 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 29 Mar 2024 21:57:58 +0200 Subject: viewer#1081 Account for 2K texture upload price in bulk upload --- indra/newview/llmaterialeditor.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index fc3c0bb022..1783621530 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -492,16 +492,16 @@ BOOL LLMaterialEditor::postBuild() 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); + 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); + 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); + 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); + 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)); } @@ -855,7 +855,7 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) S32 upload_2k_texture_count = 0; if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId() && mBaseColorFetched) { - if (mBaseColorFetched->getFullHeight() * mBaseColorFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + if (mBaseColorFetched->getFullHeight() * mBaseColorFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { upload_2k_texture_count++; } @@ -866,7 +866,7 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) } if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId() && mMetallicRoughnessFetched) { - if (mMetallicRoughnessFetched->getFullHeight() * mMetallicRoughnessFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + if (mMetallicRoughnessFetched->getFullHeight() * mMetallicRoughnessFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { upload_2k_texture_count++; } @@ -877,7 +877,7 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) } if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId() && mEmissiveFetched) { - if (mEmissiveFetched->getFullHeight() * mEmissiveFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + if (mEmissiveFetched->getFullHeight() * mEmissiveFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { upload_2k_texture_count++; } @@ -888,7 +888,7 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) } if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId() && mNormalFetched) { - if (mNormalFetched->getFullHeight() * mNormalFetched->getFullWidth() > LLAgentBenefits::MIN_2K_TEXTURE_AREA) + if (mNormalFetched->getFullHeight() * mNormalFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { upload_2k_texture_count++; } @@ -899,7 +899,12 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) } mExpectedUploadCost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost(); - mExpectedUploadCost += upload_2k_texture_count * LLAgentBenefitsMgr::current().get2KTextureUploadCost(); + S32 cost_2k = LLAgentBenefitsMgr::current().get2KTextureUploadCost(); + if (cost_2k < 0) + { + cost_2k = 0; + } + mExpectedUploadCost += upload_2k_texture_count * cost_2k; getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); } @@ -3535,7 +3540,7 @@ 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) + if (img->getWidth() * img->getHeight() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { expected_upload_cost = LLAgentBenefitsMgr::current().get2KTextureUploadCost(); } -- cgit v1.2.3 From 7df1bc9e65a6dd7532ac4a22ea6960cc8d8c9ee8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 12 Apr 2024 03:36:23 +0300 Subject: viewer#1081 2K texture apload price arrives as an array #2 --- indra/newview/llmaterialeditor.cpp | 71 ++++++-------------------------------- 1 file changed, 10 insertions(+), 61 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 1783621530..84446b626a 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -489,20 +489,10 @@ BOOL LLMaterialEditor::postBuild() } else { - 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)); + getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched))); + getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched))); + getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched))); + getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched))); } boost::function changes_callback = [this](LLUICtrl * ctrl, void* userData) @@ -851,60 +841,24 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) setCanSave(false); } - S32 upload_texture_count = 0; - S32 upload_2k_texture_count = 0; + mExpectedUploadCost = 0; if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId() && mBaseColorFetched) { - if (mBaseColorFetched->getFullHeight() * mBaseColorFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) - { - upload_2k_texture_count++; - } - else - { - upload_texture_count++; - } + mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched); } if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId() && mMetallicRoughnessFetched) { - if (mMetallicRoughnessFetched->getFullHeight() * mMetallicRoughnessFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) - { - upload_2k_texture_count++; - } - else - { - upload_texture_count++; - } + mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched); } if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId() && mEmissiveFetched) { - if (mEmissiveFetched->getFullHeight() * mEmissiveFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) - { - upload_2k_texture_count++; - } - else - { - upload_texture_count++; - } + mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched); } if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId() && mNormalFetched) { - if (mNormalFetched->getFullHeight() * mNormalFetched->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) - { - upload_2k_texture_count++; - } - else - { - upload_texture_count++; - } + mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched); } - mExpectedUploadCost = upload_texture_count * LLAgentBenefitsMgr::current().getTextureUploadCost(); - S32 cost_2k = LLAgentBenefitsMgr::current().get2KTextureUploadCost(); - if (cost_2k < 0) - { - cost_2k = 0; - } - mExpectedUploadCost += upload_2k_texture_count * cost_2k; getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); } @@ -3539,12 +3493,7 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con std::string buffer; 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(); - } - + U32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(img); LLSD key = getKey(); std::function failed_upload([key](LLUUID assetId, LLSD response, std::string reason) { -- cgit v1.2.3 From b06a99f7c76950484972e25d9dbbee8660a6a6c3 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Wed, 15 May 2024 12:47:27 +0300 Subject: Post-merge spaces fix --- indra/newview/llmaterialeditor.cpp | 82 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 84446b626a..208b289ca9 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llmaterialeditor.cpp * @brief Implementation of the gltf material editor * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -48,7 +48,7 @@ #include "llviewertexture.h" #include "llsdutil.h" #include "llselectmgr.h" -#include "llstatusbar.h" // can_afford_transaction() +#include "llstatusbar.h" // can_afford_transaction() #include "lltoolpie.h" #include "llviewerinventory.h" #include "llinventory.h" @@ -502,7 +502,7 @@ BOOL LLMaterialEditor::postBuild() // Apply changes to object live applyToSelection(); }; - + childSetCommitCallback("double sided", changes_callback, (void*)&MATERIAL_DOUBLE_SIDED_DIRTY); // BaseColor @@ -550,7 +550,7 @@ BOOL LLMaterialEditor::postBuild() // Disable/enable setCanApplyImmediately() based on // working from inventory, upload or editing inworld - return LLPreview::postBuild(); + return LLPreview::postBuild(); } void LLMaterialEditor::onClickCloseBtn(bool app_quitting) @@ -1226,7 +1226,7 @@ std::string LLMaterialEditor::getEncodedAsset() bool LLMaterialEditor::decodeAsset(const std::vector& buffer) { LLSD asset; - + std::istrstream str(&buffer[0], buffer.size()); if (LLSDSerialize::deserialize(asset, str, buffer.size())) { @@ -1290,7 +1290,7 @@ const std::string LLMaterialEditor::buildMaterialDescription() desc << LLTrans::getString("Material Texture Name Header"); // add the texture names for each just so long as the material - // we loaded has an entry for it (i think testing the texture + // we loaded has an entry for it (i think testing the texture // control UUI for NULL is a valid metric for if it was loaded // or not but I suspect this code will change a lot so may need // to revisit @@ -1372,7 +1372,7 @@ bool LLMaterialEditor::saveIfNeeded() } } else - { + { // Make a new inventory item and set upload permissions LLPermissions local_permissions; local_permissions.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); @@ -1401,7 +1401,7 @@ bool LLMaterialEditor::saveIfNeeded() // We do not update floater with uploaded asset yet, so just close it. closeFloater(); } - + return true; } @@ -1816,7 +1816,7 @@ void LLMaterialEditor::onSaveAsMsgCallback(const LLSD& notification, const LLSD& } else { - LLNotificationsUtil::add("InvalidMaterialName", LLSD(), LLSD(), [this](const LLSD& notification, const LLSD& response) + LLNotificationsUtil::add("InvalidMaterialName", LLSD(), LLSD(), [this](const LLSD& notification, const LLSD& response) { LLNotificationsUtil::add("SaveMaterialAs", LLSD().with("DESC", mMaterialName), LLSD(), boost::bind(&LLMaterialEditor::onSaveAsMsgCallback, this, _1, _2)); @@ -1976,7 +1976,7 @@ void LLMaterialEditor::loadMaterialFromFile(const std::string& filename, S32 ind std::list material_list; std::vector::const_iterator mat_iter = model_in.materials.begin(); std::vector::const_iterator mat_end = model_in.materials.end(); - + for (; mat_iter != mat_end; mat_iter++) { std::string mat_name = mat_iter->name; @@ -2615,28 +2615,28 @@ bool LLMaterialEditor::setFromGltfModel(const tinygltf::Model& model, S32 index, } /** - * Build a texture name from the contents of the (in tinyGLFT parlance) + * Build a texture name from the contents of the (in tinyGLFT parlance) * Image URI. This often is filepath to the original image on the users' * local file system. */ const std::string LLMaterialEditor::getImageNameFromUri(std::string image_uri, const std::string texture_type) { - // getBaseFileName() works differently on each platform and file patchs - // can contain both types of delimiter so unify them then extract the + // getBaseFileName() works differently on each platform and file patchs + // can contain both types of delimiter so unify them then extract the // base name (no path or extension) std::replace(image_uri.begin(), image_uri.end(), '\\', gDirUtilp->getDirDelimiter()[0]); std::replace(image_uri.begin(), image_uri.end(), '/', gDirUtilp->getDirDelimiter()[0]); const bool strip_extension = true; std::string stripped_uri = gDirUtilp->getBaseFileName(image_uri, strip_extension); - // sometimes they can be really long and unwieldy - 64 chars is enough for anyone :) + // sometimes they can be really long and unwieldy - 64 chars is enough for anyone :) const int max_texture_name_length = 64; if (stripped_uri.length() > max_texture_name_length) { stripped_uri = stripped_uri.substr(0, max_texture_name_length - 1); } - // We intend to append the type of texture (base color, emissive etc.) to the + // We intend to append the type of texture (base color, emissive etc.) to the // name of the texture but sometimes the creator already did that. To try // to avoid repeats (not perfect), we look for the texture type in the name // and if we find it, do not append the type, later on. One way this fails @@ -2702,15 +2702,15 @@ const std::string LLMaterialEditor::getImageNameFromUri(std::string image_uri, c /** * Update the metadata for the material based on what we find in the loaded * file (along with some assumptions and interpretations...). Fields include - * the name of the material, a material description and the names of the + * the name of the material, a material description and the names of the * composite textures. */ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const tinygltf::Model& model, S32 index) { - // Use the name (without any path/extension) of the file that was - // uploaded as the base of the material name. Then if the name of the + // Use the name (without any path/extension) of the file that was + // uploaded as the base of the material name. Then if the name of the // scene is present and not blank, append that and use the result as - // the name of the material. This is a first pass at creating a + // the name of the material. This is a first pass at creating a // naming scheme that is useful to real content creators and hopefully // avoid 500 materials in your inventory called "scene" or "Default" const bool strip_extension = true; @@ -2741,10 +2741,10 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti // scene name isn't present so no point using it } - // If we have a valid material or scene name, use it to build the short and - // long versions of the material name. The long version is used + // If we have a valid material or scene name, use it to build the short and + // long versions of the material name. The long version is used // as you might expect, for the material name. The short version is - // used as part of the image/texture name - the theory is that will + // used as part of the image/texture name - the theory is that will // allow content creators to track the material and the corresponding // textures if (material_name.length()) @@ -2752,9 +2752,9 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti mMaterialNameShort = base_filename; mMaterialName = STRINGIZE( - base_filename << - " " << - "(" << + base_filename << + " " << + "(" << material_name << ")" ); @@ -2770,14 +2770,14 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti LLInventoryObject::correctInventoryName(mMaterialName); LLInventoryObject::correctInventoryName(mMaterialNameShort); - // We also set the title of the floater to match the + // We also set the title of the floater to match the // name of the material setTitle(mMaterialName); /** - * Extract / derive the names of each composite texture. For each, the + * Extract / derive the names of each composite texture. For each, the * index is used to to determine which of the "Images" is used. If the index - * is -1 then that texture type is not present in the material (Seems to be + * is -1 then that texture type is not present in the material (Seems to be * quite common that a material is missing 1 or more types of texture) */ if (model.materials.size() > index) @@ -2785,8 +2785,8 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, const ti const tinygltf::Material& first_material = model.materials[index]; mBaseColorName = MATERIAL_BASE_COLOR_DEFAULT_NAME; - // note: unlike the other textures, base color doesn't have its own entry - // in the tinyGLTF Material struct. Rather, it is taken from a + // note: unlike the other textures, base color doesn't have its own entry + // in the tinyGLTF Material struct. Rather, it is taken from a // sub-texture in the pbrMetallicRoughness member int index = first_material.pbrMetallicRoughness.baseColorTexture.index; if (index > -1 && index < model.images.size()) @@ -2940,7 +2940,7 @@ public: else { // mSavedGLTFOverrideMaterials[te] being present but null - // means we need to use a default value + // means we need to use a default value revert_mat = new LLGLTFMaterial(); } } @@ -3281,7 +3281,7 @@ bool LLMaterialEditor::setFromSelection() // Ovverdired might have been updated, // refresh state of local textures in overrides - // + // // Todo: this probably shouldn't be here, but in localbitmap, // subscried to all material overrides if we want copied // objects to get properly updated as well @@ -3304,7 +3304,7 @@ void LLMaterialEditor::loadAsset() { item = getItem(); } - + bool fail = false; if (item) @@ -3508,16 +3508,16 @@ void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, con LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared( buffer, asset_id, - name, - name, + name, + name, 0, - LLFolderType::FT_TEXTURE, + LLFolderType::FT_TEXTURE, LLInventoryType::IT_TEXTURE, LLAssetType::AT_TEXTURE, LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost, + expected_upload_cost, false, cb, failed_upload)); -- cgit v1.2.3 From 7ed053d9a257087b76937d750b9f2b0c96f6df38 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 20 May 2024 19:02:13 +0300 Subject: viewer#1520 Material upload floater displays wrong upload fee --- indra/newview/llmaterialeditor.cpp | 60 +++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'indra/newview/llmaterialeditor.cpp') diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 208b289ca9..36a0834845 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -489,10 +489,7 @@ BOOL LLMaterialEditor::postBuild() } else { - getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched))); - getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched))); - getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched))); - getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched))); + refreshUploadCost(); } boost::function changes_callback = [this](LLUICtrl * ctrl, void* userData) @@ -811,6 +808,37 @@ void LLMaterialEditor::resetUnsavedChanges() } } +void LLMaterialEditor::refreshUploadCost() +{ + mExpectedUploadCost = 0; + if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId() && mBaseColorFetched) + { + S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched); + mExpectedUploadCost += upload_cost; + getChild("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + } + if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId() && mMetallicRoughnessFetched) + { + S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched); + mExpectedUploadCost += upload_cost; + getChild("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + } + if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId() && mEmissiveFetched) + { + S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched); + mExpectedUploadCost += upload_cost; + getChild("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + } + if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId() && mNormalFetched) + { + S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched); + mExpectedUploadCost += upload_cost; + getChild("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", upload_cost)); + } + + getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); +} + void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) { mUnsavedChanges |= dirty_flag; @@ -841,25 +869,15 @@ void LLMaterialEditor::markChangesUnsaved(U32 dirty_flag) setCanSave(false); } - mExpectedUploadCost = 0; - if (mBaseColorTextureUploadId.notNull() && mBaseColorTextureUploadId == getBaseColorId() && mBaseColorFetched) + if ((dirty_flag & MATERIAL_BASE_COLOR_TEX_DIRTY) + || (dirty_flag & MATERIAL_NORMAL_TEX_DIRTY) + || (dirty_flag & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY) + || (dirty_flag & MATERIAL_EMISIVE_TEX_DIRTY) + || (dirty_flag == 0) + || (dirty_flag == U32_MAX)) { - mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched); + refreshUploadCost(); } - if (mMetallicTextureUploadId.notNull() && mMetallicTextureUploadId == getMetallicRoughnessId() && mMetallicRoughnessFetched) - { - mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched); - } - if (mEmissiveTextureUploadId.notNull() && mEmissiveTextureUploadId == getEmissiveId() && mEmissiveFetched) - { - mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched); - } - if (mNormalTextureUploadId.notNull() && mNormalTextureUploadId == getNormalId() && mNormalFetched) - { - mExpectedUploadCost += LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched); - } - - getChild("total_upload_fee")->setTextArg("[FEE]", llformat("%d", mExpectedUploadCost)); } void LLMaterialEditor::setCanSaveAs(bool value) -- cgit v1.2.3