viewer#1081 2K texture apload price arrives as an array #2
parent
5156347c4d
commit
7df1bc9e65
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llagentbenefits.h"
|
||||
#include "llviewertexture.h"
|
||||
|
||||
LLAgentBenefits::LLAgentBenefits():
|
||||
m_initalized(false),
|
||||
|
|
@ -34,8 +35,7 @@ LLAgentBenefits::LLAgentBenefits():
|
|||
m_group_membership_limit(-1),
|
||||
m_picks_limit(-1),
|
||||
m_sound_upload_cost(-1),
|
||||
m_texture_upload_cost(-1),
|
||||
m_2k_texture_upload_cost(-1)
|
||||
m_texture_upload_cost(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,26 @@ bool LLAgentBenefits::init(const LLSD& benefits_sd)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
get_required_S32(benefits_sd, "large_texture_upload_cost", m_2k_texture_upload_cost);
|
||||
|
||||
if (benefits_sd.has("large_texture_upload_cost"))
|
||||
{
|
||||
LLSD large_texture_cost = benefits_sd.get("large_texture_upload_cost");
|
||||
if (large_texture_cost.isArray())
|
||||
{
|
||||
LLSD::array_const_iterator end = large_texture_cost.endArray();
|
||||
LLSD::array_const_iterator it = large_texture_cost.beginArray();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
m_2k_texture_upload_cost.push_back(it->asInteger());
|
||||
}
|
||||
std::sort(m_2k_texture_upload_cost.begin(), m_2k_texture_upload_cost.end());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_2k_texture_upload_cost.empty())
|
||||
{
|
||||
m_2k_texture_upload_cost.push_back(m_texture_upload_cost);
|
||||
}
|
||||
|
||||
// FIXME PREMIUM - either use this field or get rid of it
|
||||
m_initalized = true;
|
||||
|
|
@ -142,9 +161,60 @@ S32 LLAgentBenefits::getTextureUploadCost() const
|
|||
return m_texture_upload_cost;
|
||||
}
|
||||
|
||||
S32 LLAgentBenefits::get2KTextureUploadCost() const
|
||||
S32 LLAgentBenefits::getTextureUploadCost(const LLViewerTexture* tex) const
|
||||
{
|
||||
return m_2k_texture_upload_cost;
|
||||
if (tex)
|
||||
{
|
||||
S32 area = tex->getFullHeight() * tex->getFullWidth();
|
||||
if (area >= MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
return get2KTextureUploadCost(area);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getTextureUploadCost();
|
||||
}
|
||||
}
|
||||
return getTextureUploadCost();
|
||||
}
|
||||
|
||||
S32 LLAgentBenefits::getTextureUploadCost(const LLImageBase* tex) const
|
||||
{
|
||||
if (tex)
|
||||
{
|
||||
S32 area = tex->getHeight() * tex->getWidth();
|
||||
if (area >= MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
return get2KTextureUploadCost(area);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getTextureUploadCost();
|
||||
}
|
||||
}
|
||||
return getTextureUploadCost();
|
||||
}
|
||||
|
||||
S32 LLAgentBenefits::get2KTextureUploadCost(S32 area) const
|
||||
{
|
||||
if (m_2k_texture_upload_cost.empty())
|
||||
{
|
||||
return m_texture_upload_cost;
|
||||
}
|
||||
const S32 TEXTURE_SEGMENTS = 1024;
|
||||
if (m_2k_texture_upload_cost.size() == TEXTURE_SEGMENTS)
|
||||
{
|
||||
S32 index = (S32)llceil(sqrt((F32)area));
|
||||
// 1..1024 pixels uses m_texture_upload_cost
|
||||
// 1025..2048 uses m_2k_texture_upload_cost
|
||||
// Translate 1025..2048 to 0..1023 of the
|
||||
// cost array
|
||||
const S32 PIXELS_TO_2K_ARRAY_TRANLATE = 1025;
|
||||
index -= PIXELS_TO_2K_ARRAY_TRANLATE;
|
||||
index = llclamp(index, 0, TEXTURE_SEGMENTS - 1);
|
||||
return m_2k_texture_upload_cost[index];
|
||||
}
|
||||
return m_2k_texture_upload_cost[0];
|
||||
}
|
||||
|
||||
bool LLAgentBenefits::findUploadCost(LLAssetType::EType& asset_type, S32& cost) const
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@
|
|||
#include "llsd.h"
|
||||
#include "llassettype.h"
|
||||
|
||||
class LLViewerTexture;
|
||||
class LLImageBase;
|
||||
|
||||
class LLAgentBenefits
|
||||
{
|
||||
public:
|
||||
|
|
@ -49,7 +52,9 @@ public:
|
|||
S32 getPicksLimit() const;
|
||||
S32 getSoundUploadCost() const;
|
||||
S32 getTextureUploadCost() const;
|
||||
S32 get2KTextureUploadCost() const;
|
||||
S32 getTextureUploadCost(const LLViewerTexture* tex) const;
|
||||
S32 getTextureUploadCost(const LLImageBase* tex) const;
|
||||
S32 get2KTextureUploadCost(S32 area) const;
|
||||
|
||||
bool findUploadCost(LLAssetType::EType& asset_type, S32& cost) const;
|
||||
|
||||
|
|
@ -62,7 +67,7 @@ private:
|
|||
S32 m_picks_limit;
|
||||
S32 m_sound_upload_cost;
|
||||
S32 m_texture_upload_cost;
|
||||
S32 m_2k_texture_upload_cost;
|
||||
std::vector<S32> m_2k_texture_upload_cost;
|
||||
|
||||
bool m_initalized;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -151,18 +151,7 @@ BOOL LLFloaterImagePreview::postBuild()
|
|||
//-----------------------------------------------------------------------------
|
||||
S32 LLFloaterImagePreview::getExpectedUploadCost() const
|
||||
{
|
||||
if (mRawImagep.notNull())
|
||||
{
|
||||
if (mRawImagep->getWidth() * mRawImagep->getHeight() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
return LLAgentBenefitsMgr::current().get2KTextureUploadCost();
|
||||
}
|
||||
else
|
||||
{
|
||||
return LLAgentBenefitsMgr::current().getTextureUploadCost();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return LLAgentBenefitsMgr::current().getTextureUploadCost(mRawImagep);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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<LLUICtrl>("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<LLUICtrl>("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<LLUICtrl>("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<LLUICtrl>("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", large_texture ? upload_cost_2k : upload_cost_base));
|
||||
getChild<LLUICtrl>("base_color_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mBaseColorFetched)));
|
||||
getChild<LLUICtrl>("metallic_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mMetallicRoughnessFetched)));
|
||||
getChild<LLUICtrl>("emissive_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mEmissiveFetched)));
|
||||
getChild<LLUICtrl>("normal_upload_fee")->setTextArg("[FEE]", llformat("%d", LLAgentBenefitsMgr::current().getTextureUploadCost(mNormalFetched)));
|
||||
}
|
||||
|
||||
boost::function<void(LLUICtrl*, void*)> 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<LLUICtrl>("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<bool(LLUUID itemId, LLSD response, std::string reason)> failed_upload([key](LLUUID assetId, LLSD response, std::string reason)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -556,19 +556,8 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification
|
|||
LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec);
|
||||
if (gDirUtilp->fileExists(filename) && image_frmted->load(filename))
|
||||
{
|
||||
if (image_frmted->getWidth() * image_frmted->getHeight() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
expected_upload_cost = LLAgentBenefitsMgr::current().get2KTextureUploadCost();
|
||||
if (expected_upload_cost >= 0)
|
||||
{
|
||||
resource_upload = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
|
||||
resource_upload = true;
|
||||
}
|
||||
expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted);
|
||||
resource_upload = true;
|
||||
}
|
||||
}
|
||||
else if (LLAgentBenefitsMgr::current().findUploadCost(asset_type, expected_upload_cost))
|
||||
|
|
@ -617,8 +606,6 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3
|
|||
total_cost = 0;
|
||||
file_count = 0;
|
||||
bvh_count = 0;
|
||||
S32 texture_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost();
|
||||
S32 texture_2k_upload_cost = LLAgentBenefitsMgr::current().get2KTextureUploadCost();
|
||||
for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter)
|
||||
{
|
||||
std::string filename = (*in_iter);
|
||||
|
|
@ -640,19 +627,8 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3
|
|||
LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec);
|
||||
if (gDirUtilp->fileExists(filename) && image_frmted->load(filename))
|
||||
{
|
||||
if (image_frmted->getWidth() * image_frmted->getHeight() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
if (texture_2k_upload_cost >= 0)
|
||||
{
|
||||
total_cost += texture_2k_upload_cost;
|
||||
file_count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
total_cost += texture_upload_cost;
|
||||
file_count++;
|
||||
}
|
||||
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted);
|
||||
file_count++;
|
||||
}
|
||||
}
|
||||
else if (LLAgentBenefitsMgr::current().findUploadCost(asset_type, cost))
|
||||
|
|
@ -680,53 +656,22 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3
|
|||
{
|
||||
// Todo: make it account for possibility of same texture in different
|
||||
// materials and even in scope of same material
|
||||
S32 texture_count = 0;
|
||||
S32 texture_2k_count = 0;
|
||||
if (material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR].notNull() && material->mBaseColorTexture)
|
||||
{
|
||||
if (material->mBaseColorTexture->getFullHeight() * material->mBaseColorTexture->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
texture_2k_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_count++;
|
||||
}
|
||||
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(material->mBaseColorTexture);
|
||||
}
|
||||
if (material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS].notNull() && material->mMetallicRoughnessTexture)
|
||||
{
|
||||
if (material->mMetallicRoughnessTexture->getFullHeight() * material->mMetallicRoughnessTexture->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
texture_2k_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_count++;
|
||||
}
|
||||
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(material->mMetallicRoughnessTexture);
|
||||
}
|
||||
if (material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL].notNull() && material->mNormalTexture)
|
||||
{
|
||||
if (material->mNormalTexture->getFullHeight() * material->mNormalTexture->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
texture_2k_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_count++;
|
||||
}
|
||||
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(material->mNormalTexture);
|
||||
}
|
||||
if (material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE].notNull() && material->mEmissiveTexture)
|
||||
{
|
||||
if (material->mEmissiveTexture->getFullHeight() * material->mEmissiveTexture->getFullWidth() >= LLAgentBenefits::MIN_2K_TEXTURE_AREA)
|
||||
{
|
||||
texture_2k_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_count++;
|
||||
}
|
||||
total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(material->mEmissiveTexture);
|
||||
}
|
||||
total_cost += texture_count * texture_upload_cost + texture_2k_count * texture_2k_upload_cost;
|
||||
file_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue