diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-18 13:22:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 13:22:28 +0100 |
commit | 48a760da559109a849fa151c8141201190498e51 (patch) | |
tree | 29a7da02d92d29d7957986f7ca376a3ea3e0857e | |
parent | bfed10185a55004b258eaad7fbb3e6049448edf9 (diff) | |
parent | f70cc0a60e6459917c1156160a7f8e4c51a8cf74 (diff) |
Merge pull request #43640 from akien-mga/gltf-workaround-bogus-images
glTF: Workaround import failure with invalid embedded images
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 266df78949..0c860a8965 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1304,12 +1304,14 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b String uri = d["uri"]; if (uri.begins_with("data:")) { // Embedded data using base64. - // Validate data MIME types and throw an error if it's one we don't know/support. + // Validate data MIME types and throw a warning if it's one we don't know/support. if (!uri.begins_with("data:application/octet-stream;base64") && !uri.begins_with("data:application/gltf-buffer;base64") && !uri.begins_with("data:image/png;base64") && !uri.begins_with("data:image/jpeg;base64")) { - ERR_PRINT("glTF: Got image data with an unknown URI data type: " + uri); + WARN_PRINT(vformat("glTF: Image index '%d' uses an unsupported URI data type: %s. Skipping it.", i, uri)); + state.images.push_back(Ref<Texture2D>()); // Placeholder to keep count. + continue; } data = _parse_base64_uri(uri); data_ptr = data.ptr(); @@ -1344,7 +1346,8 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } } else if (d.has("bufferView")) { // Handles the third bullet point from the spec (bufferView). - ERR_FAIL_COND_V_MSG(mimetype.empty(), ERR_FILE_CORRUPT, "glTF: Image specifies 'bufferView' but no 'mimeType', which is invalid."); + ERR_FAIL_COND_V_MSG(mimetype.empty(), ERR_FILE_CORRUPT, + vformat("glTF: Image index '%d' specifies 'bufferView' but no 'mimeType', which is invalid.", i)); const GLTFBufferViewIndex bvi = d["bufferView"]; @@ -1381,7 +1384,8 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } } - ERR_FAIL_COND_V_MSG(img.is_null(), ERR_FILE_CORRUPT, "glTF: Couldn't load image with its given mimetype: " + mimetype); + ERR_FAIL_COND_V_MSG(img.is_null(), ERR_FILE_CORRUPT, + vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype)); Ref<ImageTexture> t; t.instance(); |