summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorCallum Linden <callum@lindenlab.com>2022-08-10 12:52:14 -0700
committerCallum Linden <callum@lindenlab.com>2022-08-10 12:52:14 -0700
commit8645ffe172e1e847758249af7536eef71e430a17 (patch)
tree68f6f4dcc34375214442924f0326c5f43116a741 /indra
parentc989e202f2cc2703b7e11bc769f412f350f24445 (diff)
SL-17695 Sensible names for material properties - sanitize the various names we use to store inventory items using a built in function
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmaterialeditor.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index ecaca1255b..ce2b229de9 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -42,6 +42,7 @@
#include "llselectmgr.h"
#include "llstatusbar.h" // can_afford_transaction()
#include "llviewerinventory.h"
+#include "llinventory.h"
#include "llviewerregion.h"
#include "llvovolume.h"
#include "roles_constants.h"
@@ -693,6 +694,9 @@ const std::string LLMaterialEditor::buildMaterialDescription()
desc.str().erase(iter);
}
+ // sanitize the material description so that it's compatible with the inventory
+ LLInventoryObject::correctInventoryName(desc.str());
+
return desc.str();
}
@@ -1531,6 +1535,10 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, tinygltf
mMaterialName = base_filename;
}
+ // sanitize the material name so that it's compatible with the inventory
+ LLInventoryObject::correctInventoryName(mMaterialName);
+ LLInventoryObject::correctInventoryName(mMaterialNameShort);
+
// We also set the title of the floater to match the
// name of the material
setTitle(mMaterialName);
@@ -1547,31 +1555,43 @@ void LLMaterialEditor::setFromGltfMetaData(const std::string& filename, tinygltf
const tinygltf::Material& first_material = model.materials[0];
mAlbedoName = MATERIAL_ALBEDO_DEFAULT_NAME;
+ // note: unlike the other textures, albedo 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())
{
- mAlbedoName = getImageNameFromUri(model.images[index].uri, MATERIAL_ALBEDO_DEFAULT_NAME);
+ // sanitize the name we decide to use for each texture
+ std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_ALBEDO_DEFAULT_NAME);
+ LLInventoryObject::correctInventoryName(texture_name);
+ mAlbedoName = texture_name;
}
mEmissiveName = MATERIAL_EMISSIVE_DEFAULT_NAME;
index = first_material.emissiveTexture.index;
if (index > -1 && index < model.images.size())
{
- mEmissiveName = getImageNameFromUri(model.images[index].uri, MATERIAL_EMISSIVE_DEFAULT_NAME);
+ std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_EMISSIVE_DEFAULT_NAME);
+ LLInventoryObject::correctInventoryName(texture_name);
+ mEmissiveName = texture_name;
}
mMetallicRoughnessName = MATERIAL_METALLIC_DEFAULT_NAME;
index = first_material.pbrMetallicRoughness.metallicRoughnessTexture.index;
if (index > -1 && index < model.images.size())
{
- mMetallicRoughnessName = getImageNameFromUri(model.images[index].uri, MATERIAL_METALLIC_DEFAULT_NAME);
+ std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_METALLIC_DEFAULT_NAME);
+ LLInventoryObject::correctInventoryName(texture_name);
+ mMetallicRoughnessName = texture_name;
}
mNormalName = MATERIAL_NORMAL_DEFAULT_NAME;
index = first_material.normalTexture.index;
if (index > -1 && index < model.images.size())
{
- mNormalName = getImageNameFromUri(model.images[index].uri, MATERIAL_NORMAL_DEFAULT_NAME);
+ std::string texture_name = getImageNameFromUri(model.images[index].uri, MATERIAL_NORMAL_DEFAULT_NAME);
+ LLInventoryObject::correctInventoryName(texture_name);
+ mNormalName = texture_name;
}
}
}