Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions indra/newview/gltf/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ namespace LL
"KHR_texture_transform"
};

static std::unordered_set<std::string> ExtensionsIgnored = {
"KHR_materials_pbrSpecularGlossiness"
};

Material::AlphaMode gltf_alpha_mode_to_enum(const std::string& alpha_mode)
{
if (alpha_mode == "OPAQUE")
Expand Down Expand Up @@ -494,10 +498,21 @@ bool Asset::prep()
{
if (ExtensionsSupported.find(extension) == ExtensionsSupported.end())
{
LL_WARNS() << "Unsupported extension: " << extension << LL_ENDL;
mUnsupportedExtensions.push_back(extension);
if (ExtensionsIgnored.find(extension) == ExtensionsIgnored.end())
{
LL_WARNS() << "Unsupported extension: " << extension << LL_ENDL;
mUnsupportedExtensions.push_back(extension);
}
else
{
mIgnoredExtensions.push_back(extension);
}
}
}
if (mUnsupportedExtensions.size() > 0)
{
return false;
}

// do buffers first as other resources depend on them
for (auto& buffer : mBuffers)
Expand Down
1 change: 1 addition & 0 deletions indra/newview/gltf/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ namespace LL
bool mLoadIntoVRAM = false;

std::vector<std::string> mUnsupportedExtensions;
std::vector<std::string> mIgnoredExtensions;

// prepare for first time use
bool prep();
Expand Down
43 changes: 22 additions & 21 deletions indra/newview/gltf/llgltfloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,18 @@ LLGLTFLoader::~LLGLTFLoader() {}
bool LLGLTFLoader::OpenFile(const std::string &filename)
{
tinygltf::TinyGLTF loader;
std::string error_msg;
std::string warn_msg;
std::string filename_lc(filename);
LLStringUtil::toLower(filename_lc);

mGltfLoaded = mGLTFAsset.load(filename, false);

if (!mGltfLoaded)
{
if (!warn_msg.empty())
LL_WARNS("GLTF_IMPORT") << "gltf load warning: " << warn_msg.c_str() << LL_ENDL;
if (!error_msg.empty())
LL_WARNS("GLTF_IMPORT") << "gltf load error: " << error_msg.c_str() << LL_ENDL;
notifyUnsupportedExtension(true);
return false;
}

if (mGLTFAsset.mUnsupportedExtensions.size() > 0)
{
LLSD args;
args["Message"] = "UnsupportedExtension";
std::string del;
std::string ext;
for (auto& extension : mGLTFAsset.mUnsupportedExtensions)
{
ext += del;
ext += extension;
del = ",";
}
args["EXT"] = ext;
mWarningsArray.append(args);
}
notifyUnsupportedExtension(false);

mMeshesLoaded = parseMeshes();
if (mMeshesLoaded) uploadMeshes();
Expand Down Expand Up @@ -1347,3 +1328,23 @@ LLUUID LLGLTFLoader::imageBufferToTextureUUID(const gltf_texture& tex)
return LLUUID::null;
}

void LLGLTFLoader::notifyUnsupportedExtension(bool unsupported)
{
std::vector<std::string> extensions = unsupported ? mGLTFAsset.mUnsupportedExtensions : mGLTFAsset.mIgnoredExtensions;
if (extensions.size() > 0)
{
LLSD args;
args["Message"] = unsupported ? "UnsupportedExtension" : "IgnoredExtension";
std::string del;
std::string ext;
for (auto& extension : extensions)
{
ext += del;
ext += extension;
del = ",";
}
args["EXT"] = ext;
mWarningsArray.append(args);
}
}

2 changes: 2 additions & 0 deletions indra/newview/gltf/llgltfloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class LLGLTFLoader : public LLModelLoader
S32 findGLTFRootJoint(const LL::GLTF::Skin& gltf_skin) const; // if there are multiple roots, gltf stores them under one commor joint
LLUUID imageBufferToTextureUUID(const gltf_texture& tex);

void notifyUnsupportedExtension(bool unsupported);

// bool mPreprocessGLTF;

/* Below inherited from dae loader - unknown if/how useful here
Expand Down
3 changes: 2 additions & 1 deletion indra/newview/skins/default/xui/en/floater_model_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
<string name="ParsingErrorNoScene">Document has no visual_scene</string>
<string name="ParsingErrorPositionInvalidModel">Unable to process mesh without position data. Invalid model.</string>
<string name="InvalidGeometryNonTriangulated">Invalid geometry: GLTF files must contain triangulated meshes only.</string>
<string name="UnsupportedExtension">Model uses unsupported extension, related material properties are ignored: [EXT]</string>
<string name="IgnoredExtension">Model uses unsupported extension: [EXT], related material properties are ignored.</string>
<string name="UnsupportedExtension">Unable to load a model, unsupported extension: [EXT]</string>

<panel
follows="top|left"
Expand Down