summaryrefslogtreecommitdiff
path: root/modules/gltf/gltf_document.cpp
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2022-09-18 20:35:13 -0500
committerAaron Franke <arnfranke@yahoo.com>2022-09-19 19:40:06 -0500
commit7097e8add71c8ddaf4ff1cc92d84d0266626a528 (patch)
treedc70566c27b40ea6f55204da573dcf6aa193a7ee /modules/gltf/gltf_document.cpp
parentb72dc0de89eb11e7afdb3c2e3bae737bea40524f (diff)
Add a way to get the GLTF extensions supported by GLTFDocumentExtension
Diffstat (limited to 'modules/gltf/gltf_document.cpp')
-rw-r--r--modules/gltf/gltf_document.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 436fd2a1fc..8d2e37be3a 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -6927,9 +6927,24 @@ Error GLTFDocument::_parse_gltf_extensions(Ref<GLTFState> state) {
Vector<String> ext_array = state->json["extensionsRequired"];
state->extensions_required = ext_array;
}
- if (state->extensions_required.find("KHR_draco_mesh_compression") != -1) {
- ERR_PRINT("glTF2 extension KHR_draco_mesh_compression is not supported.");
- return ERR_UNAVAILABLE;
+ HashSet<String> supported_extensions;
+ supported_extensions.insert("KHR_lights_punctual");
+ supported_extensions.insert("KHR_materials_pbrSpecularGlossiness");
+ supported_extensions.insert("KHR_texture_transform");
+ for (int ext_i = 0; ext_i < document_extensions.size(); ext_i++) {
+ Ref<GLTFDocumentExtension> ext = document_extensions[ext_i];
+ ERR_CONTINUE(ext.is_null());
+ Vector<String> ext_supported_extensions = ext->get_supported_extensions();
+ for (int i = 0; i < ext_supported_extensions.size(); ++i) {
+ supported_extensions.insert(ext_supported_extensions[i]);
+ }
}
- return OK;
+ Error ret = Error::OK;
+ for (int i = 0; i < state->extensions_required.size(); i++) {
+ if (!supported_extensions.has(state->extensions_required[i])) {
+ ERR_PRINT("GLTF: Can't import file '" + state->filename + "', required extension '" + String(state->extensions_required[i]) + "' is not supported. Are you missing a GLTFDocumentExtension plugin?");
+ ret = ERR_UNAVAILABLE;
+ }
+ }
+ return ret;
}