From 930742f8b3e235778aa6ceecb8f0d61fc2ceb422 Mon Sep 17 00:00:00 2001 From: Aina <146054046+AinaVT@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:03:12 -0300 Subject: [PATCH 1/2] Fix missing GDScriptParser reference on completion context --- modules/gdscript/gdscript_parser.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index c4cef0287f1..582305d9007 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -260,6 +260,7 @@ void GDScriptParser::override_completion_context(const Node *p_for_node, Complet context.current_line = tokenizer->get_cursor_line(); context.current_argument = p_argument; context.node = p_node; + context.parser = this; completion_context = context; } From ee5e97742ab30fc589f9a8ef820a31877c008933 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 28 Aug 2024 17:46:01 -0700 Subject: [PATCH 2/2] Add get_supported_gltf_extensions to GLTFDocument --- modules/gltf/doc_classes/GLTFDocument.xml | 7 ++++ modules/gltf/gltf_document.cpp | 46 ++++++++++++++++------- modules/gltf/gltf_document.h | 2 + 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml index ebeed015e9d..10534594d36 100644 --- a/modules/gltf/doc_classes/GLTFDocument.xml +++ b/modules/gltf/doc_classes/GLTFDocument.xml @@ -63,6 +63,13 @@ The [param bake_fps] parameter overrides the bake_fps in [param state]. + + + + Returns a list of all support glTF extensions, including extensions supported directly by the engine, and extensions supported by user plugins registering [GLTFDocumentExtension] classes. + [b]Note:[/b] If this method is run before a GLTFDocumentExtension is registered, its extensions won't be included in the list. Be sure to only run this method after all extensions are registered. If you run this when the engine starts, consider waiting a frame before calling this method to ensure all extensions are registered. + + diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index cd25b93e6c0..77bba940cb4 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -7060,6 +7060,8 @@ void GLTFDocument::_bind_methods() { &GLTFDocument::register_gltf_document_extension, DEFVAL(false)); ClassDB::bind_static_method("GLTFDocument", D_METHOD("unregister_gltf_document_extension", "extension"), &GLTFDocument::unregister_gltf_document_extension); + ClassDB::bind_static_method("GLTFDocument", D_METHOD("get_supported_gltf_extensions"), + &GLTFDocument::get_supported_gltf_extensions); } void GLTFDocument::_build_parent_hierachy(Ref p_state) { @@ -7100,6 +7102,36 @@ Vector> GLTFDocument::get_all_gltf_document_extension return all_document_extensions; } +Vector GLTFDocument::get_supported_gltf_extensions() { + HashSet set = get_supported_gltf_extensions_hashset(); + Vector vec; + for (const String &s : set) { + vec.append(s); + } + vec.sort(); + return vec; +} + +HashSet GLTFDocument::get_supported_gltf_extensions_hashset() { + HashSet supported_extensions; + // If the extension is supported directly in GLTFDocument, list it here. + // Other built-in extensions are supported by GLTFDocumentExtension classes. + supported_extensions.insert("GODOT_single_root"); + supported_extensions.insert("KHR_lights_punctual"); + supported_extensions.insert("KHR_materials_emissive_strength"); + supported_extensions.insert("KHR_materials_pbrSpecularGlossiness"); + supported_extensions.insert("KHR_materials_unlit"); + supported_extensions.insert("KHR_texture_transform"); + for (Ref ext : all_document_extensions) { + ERR_CONTINUE(ext.is_null()); + Vector 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 supported_extensions; +} + PackedByteArray GLTFDocument::_serialize_glb_buffer(Ref p_state, Error *r_err) { Error err = _encode_buffer_glb(p_state, ""); if (r_err) { @@ -7452,19 +7484,7 @@ Error GLTFDocument::_parse_gltf_extensions(Ref p_state) { Vector ext_array = p_state->json["extensionsRequired"]; p_state->extensions_required = ext_array; } - HashSet supported_extensions; - supported_extensions.insert("KHR_lights_punctual"); - supported_extensions.insert("KHR_materials_pbrSpecularGlossiness"); - supported_extensions.insert("KHR_texture_transform"); - supported_extensions.insert("KHR_materials_unlit"); - supported_extensions.insert("KHR_materials_emissive_strength"); - for (Ref ext : document_extensions) { - ERR_CONTINUE(ext.is_null()); - Vector ext_supported_extensions = ext->get_supported_extensions(); - for (int i = 0; i < ext_supported_extensions.size(); ++i) { - supported_extensions.insert(ext_supported_extensions[i]); - } - } + HashSet supported_extensions = get_supported_gltf_extensions_hashset(); Error ret = OK; for (int i = 0; i < p_state->extensions_required.size(); i++) { if (!supported_extensions.has(p_state->extensions_required[i])) { diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index d37544750d3..b3e6dcf54a6 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -92,6 +92,8 @@ public: static void unregister_gltf_document_extension(Ref p_extension); static void unregister_all_gltf_document_extensions(); static Vector> get_all_gltf_document_extensions(); + static Vector get_supported_gltf_extensions(); + static HashSet get_supported_gltf_extensions_hashset(); void set_naming_version(int p_version); int get_naming_version() const;