Skip to content

Commit 136149d

Browse files
#4191 skip loading model compressed with Draco
1 parent be40d20 commit 136149d

File tree

5 files changed

+44
-24
lines changed

5 files changed

+44
-24
lines changed

indra/newview/gltf/asset.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ namespace LL
5050
"KHR_texture_transform"
5151
};
5252

53+
static std::unordered_set<std::string> ExtensionsIgnored = {
54+
"KHR_materials_pbrSpecularGlossiness"
55+
};
56+
5357
Material::AlphaMode gltf_alpha_mode_to_enum(const std::string& alpha_mode)
5458
{
5559
if (alpha_mode == "OPAQUE")
@@ -494,10 +498,21 @@ bool Asset::prep()
494498
{
495499
if (ExtensionsSupported.find(extension) == ExtensionsSupported.end())
496500
{
497-
LL_WARNS() << "Unsupported extension: " << extension << LL_ENDL;
498-
mUnsupportedExtensions.push_back(extension);
501+
if (ExtensionsIgnored.find(extension) == ExtensionsIgnored.end())
502+
{
503+
LL_WARNS() << "Unsupported extension: " << extension << LL_ENDL;
504+
mUnsupportedExtensions.push_back(extension);
505+
}
506+
else
507+
{
508+
mIgnoredExtensions.push_back(extension);
509+
}
499510
}
500511
}
512+
if (mUnsupportedExtensions.size() > 0)
513+
{
514+
return false;
515+
}
501516

502517
// do buffers first as other resources depend on them
503518
for (auto& buffer : mBuffers)

indra/newview/gltf/asset.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ namespace LL
397397
bool mLoadIntoVRAM = false;
398398

399399
std::vector<std::string> mUnsupportedExtensions;
400+
std::vector<std::string> mIgnoredExtensions;
400401

401402
// prepare for first time use
402403
bool prep();

indra/newview/gltf/llgltfloader.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,18 @@ LLGLTFLoader::~LLGLTFLoader() {}
111111
bool LLGLTFLoader::OpenFile(const std::string &filename)
112112
{
113113
tinygltf::TinyGLTF loader;
114-
std::string error_msg;
115-
std::string warn_msg;
116114
std::string filename_lc(filename);
117115
LLStringUtil::toLower(filename_lc);
118116

119117
mGltfLoaded = mGLTFAsset.load(filename, false);
120118

121119
if (!mGltfLoaded)
122120
{
123-
if (!warn_msg.empty())
124-
LL_WARNS("GLTF_IMPORT") << "gltf load warning: " << warn_msg.c_str() << LL_ENDL;
125-
if (!error_msg.empty())
126-
LL_WARNS("GLTF_IMPORT") << "gltf load error: " << error_msg.c_str() << LL_ENDL;
121+
notifyUnsupportedExtension(true);
127122
return false;
128123
}
129124

130-
if (mGLTFAsset.mUnsupportedExtensions.size() > 0)
131-
{
132-
LLSD args;
133-
args["Message"] = "UnsupportedExtension";
134-
std::string del;
135-
std::string ext;
136-
for (auto& extension : mGLTFAsset.mUnsupportedExtensions)
137-
{
138-
ext += del;
139-
ext += extension;
140-
del = ",";
141-
}
142-
args["EXT"] = ext;
143-
mWarningsArray.append(args);
144-
}
125+
notifyUnsupportedExtension(false);
145126

146127
mMeshesLoaded = parseMeshes();
147128
if (mMeshesLoaded) uploadMeshes();
@@ -1347,3 +1328,23 @@ LLUUID LLGLTFLoader::imageBufferToTextureUUID(const gltf_texture& tex)
13471328
return LLUUID::null;
13481329
}
13491330

1331+
void LLGLTFLoader::notifyUnsupportedExtension(bool unsupported)
1332+
{
1333+
std::vector<std::string> extensions = unsupported ? mGLTFAsset.mUnsupportedExtensions : mGLTFAsset.mIgnoredExtensions;
1334+
if (extensions.size() > 0)
1335+
{
1336+
LLSD args;
1337+
args["Message"] = unsupported ? "UnsupportedExtension" : "IgnoredExtension";
1338+
std::string del;
1339+
std::string ext;
1340+
for (auto& extension : extensions)
1341+
{
1342+
ext += del;
1343+
ext += extension;
1344+
del = ",";
1345+
}
1346+
args["EXT"] = ext;
1347+
mWarningsArray.append(args);
1348+
}
1349+
}
1350+

indra/newview/gltf/llgltfloader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class LLGLTFLoader : public LLModelLoader
174174
S32 findGLTFRootJoint(const LL::GLTF::Skin& gltf_skin) const; // if there are multiple roots, gltf stores them under one commor joint
175175
LLUUID imageBufferToTextureUUID(const gltf_texture& tex);
176176

177+
void notifyUnsupportedExtension(bool unsupported);
178+
177179
// bool mPreprocessGLTF;
178180

179181
/* Below inherited from dae loader - unknown if/how useful here

indra/newview/skins/default/xui/en/floater_model_preview.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
<string name="ParsingErrorNoScene">Document has no visual_scene</string>
6363
<string name="ParsingErrorPositionInvalidModel">Unable to process mesh without position data. Invalid model.</string>
6464
<string name="InvalidGeometryNonTriangulated">Invalid geometry: GLTF files must contain triangulated meshes only.</string>
65-
<string name="UnsupportedExtension">Model uses unsupported extension, related material properties are ignored: [EXT]</string>
65+
<string name="IgnoredExtension">Model uses unsupported extension: [EXT], related material properties are ignored.</string>
66+
<string name="UnsupportedExtension">Unable to load a model, unsupported extension: [EXT]</string>
6667

6768
<panel
6869
follows="top|left"

0 commit comments

Comments
 (0)