Skip to content

Commit

Permalink
Add unregister for GLTFDocumentExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
RedMser committed Nov 22, 2022
1 parent e3a51e5 commit 9c50e99
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/gltf/doc_classes/GLTFDocument.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,17 @@
<param index="0" name="extension" type="GLTFDocumentExtension" />
<param index="1" name="first_priority" type="bool" default="false" />
<description>
Registers this GLTFDocumentExtension instance with GLTFDocument. If [param first_priority] is true, this extension will be ran first. Otherwise, it will be ran last.
Registers the given [GLTFDocumentExtension] instance with GLTFDocument. If [param first_priority] is true, this extension will be run first. Otherwise, it will be run last.
[b]Note:[/b] Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the [code]set_additional_data[/code] and [code]get_additional_data[/code] methods in [GLTFState] or [GLTFNode].
</description>
</method>
<method name="unregister_gltf_document_extension" qualifiers="static">
<return type="void" />
<param index="0" name="extension" type="GLTFDocumentExtension" />
<description>
Unregisters the given [GLTFDocumentExtension] instance.
</description>
</method>
<method name="write_to_filesystem">
<return type="int" enum="Error" />
<param index="0" name="state" type="GLTFState" />
Expand Down
6 changes: 6 additions & 0 deletions modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6761,6 +6761,8 @@ void GLTFDocument::_bind_methods() {

ClassDB::bind_static_method("GLTFDocument", D_METHOD("register_gltf_document_extension", "extension", "first_priority"),
&GLTFDocument::register_gltf_document_extension, DEFVAL(false));
ClassDB::bind_static_method("GLTFDocument", D_METHOD("unregister_gltf_document_extension", "extension"),
&GLTFDocument::unregister_gltf_document_extension);
}

void GLTFDocument::_build_parent_hierachy(Ref<GLTFState> state) {
Expand Down Expand Up @@ -6789,6 +6791,10 @@ void GLTFDocument::register_gltf_document_extension(Ref<GLTFDocumentExtension> p
}
}

void GLTFDocument::unregister_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension) {
all_document_extensions.erase(p_extension);
}

void GLTFDocument::unregister_all_gltf_document_extensions() {
all_document_extensions.clear();
}
Expand Down
1 change: 1 addition & 0 deletions modules/gltf/gltf_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class GLTFDocument : public Resource {

public:
static void register_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension, bool p_first_priority = false);
static void unregister_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension);
static void unregister_all_gltf_document_extensions();

private:
Expand Down

0 comments on commit 9c50e99

Please sign in to comment.