-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose GLTFDocument.get_registered_gltf_document_extensions
#100783
base: master
Are you sure you want to change the base?
Expose GLTFDocument.get_registered_gltf_document_extensions
#100783
Conversation
9614754
to
3bf3312
Compare
3bf3312
to
d13d101
Compare
modules/gltf/doc_classes/GLTFDocumentExtensionConvertImporterMesh.xml
Outdated
Show resolved
Hide resolved
modules/gltf/doc_classes/GLTFDocumentExtensionConvertImporterMesh.xml
Outdated
Show resolved
Hide resolved
d13d101
to
7ff6321
Compare
GLTFDocument.get_registered_gltf_document_extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature is good, but I have to nitpick the name and docs.
<method name="get_supported_gltf_extensions" qualifiers="static"> | ||
<return type="PackedStringArray" /> | ||
<description> | ||
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. | ||
[b]Note:[/b] This method is static: Registered instances will be shared by all [GLTFDocument] instances. Consider using this method to check if a given [GLTFDocumentExtension] is already registered. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be 2 separate notes. Also, specifically, this method isn't useful for checking for GLTFDocumentExtension classes (that's what the other one is for, the new method you're exposing), this is only for checking the list of supported glTF extensions, which is separate from the list of Godot implementations via GLTFDocumentExtension.
[b]Note:[/b] This method is static: Registered instances will be shared by all [GLTFDocument] instances. Consider using this method to check if a given [GLTFDocumentExtension] is already registered. 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. | |
[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. | |
[b]Note:[/b] This method is static: Registered instances will be shared by all [GLTFDocument] instances. This method may be used to check if a given glTF extension is already supported by Godot's glTF importer, such as via a registered [GLTFDocumentExtension] class. |
@@ -85,6 +85,7 @@ class GLTFDocument : public Resource { | |||
static void unregister_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension); | |||
static void unregister_all_gltf_document_extensions(); | |||
static Vector<Ref<GLTFDocumentExtension>> get_all_gltf_document_extensions(); | |||
static TypedArray<GLTFDocumentExtension> get_registered_gltf_document_extensions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is just a script binding version of the existing get_all_gltf_document_extensions
function, we should use the same name for both (one can be suffixed with _bind
and exposed without the _bind
in ClassDB::bind_static_method
).
These APIs were not exposed, but I found I had a lot of difficulty using GLTFDocumentExtensions, particularly at runtime, without the ability to see and modify the current static list of extensions. My game only needs
get_registered_gltf_document_extensions
.I explained some context for this change from chat:
I also improved the documentation, particularly to warn against the pitfalls I encountered, notably not realizing the list was static, and registering multiple copies of the same extension.
Also, a note about
get_supported_gltf_extensions()
: I know this API already exists, but it only works in cases where a GLTFDocumentExtension implements a glTF extension, and it also doesn't allow for getting a reference to the extension itself if it needs to be unregistered. Not all extensions, notably the built-in GLTFDocumentExtensionConvertImporterMesh, implement a glTF extension, so they will not appear inget_supported_gltf_extensions
. That's why I want a new API to return the instances themselves.