summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2022-05-04 19:08:43 +0200
committerGitHub <noreply@github.com>2022-05-04 19:08:43 +0200
commit84f64ddde956f5ecba4674750442df89b75556c9 (patch)
tree920e09993cd21dc3f809735a4669b6adaf7cd7cd /modules/gltf
parent3a82b7eeef005fdc654aaccadbaa80b4520b5f13 (diff)
parentde0ca3b999819a99a5dcab99f0083a760277b95e (diff)
Merge pull request #60723 from reduz/refactor-module-initialization
Diffstat (limited to 'modules/gltf')
-rw-r--r--modules/gltf/register_types.cpp73
-rw-r--r--modules/gltf/register_types.h6
2 files changed, 44 insertions, 35 deletions
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index b656788a10..b8bac79584 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -101,45 +101,52 @@ static void _editor_init() {
}
#endif // TOOLS_ENABLED
-void register_gltf_types() {
- // glTF API available at runtime.
- GDREGISTER_CLASS(GLTFAccessor);
- GDREGISTER_CLASS(GLTFAnimation);
- GDREGISTER_CLASS(GLTFBufferView);
- GDREGISTER_CLASS(GLTFCamera);
- GDREGISTER_CLASS(GLTFDocument);
- GDREGISTER_CLASS(GLTFDocumentExtension);
- GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
- GDREGISTER_CLASS(GLTFLight);
- GDREGISTER_CLASS(GLTFMesh);
- GDREGISTER_CLASS(GLTFNode);
- GDREGISTER_CLASS(GLTFSkeleton);
- GDREGISTER_CLASS(GLTFSkin);
- GDREGISTER_CLASS(GLTFSpecGloss);
- GDREGISTER_CLASS(GLTFState);
- GDREGISTER_CLASS(GLTFTexture);
+void initialize_gltf_module(ModuleInitializationLevel p_level) {
+ if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
+ // glTF API available at runtime.
+ GDREGISTER_CLASS(GLTFAccessor);
+ GDREGISTER_CLASS(GLTFAnimation);
+ GDREGISTER_CLASS(GLTFBufferView);
+ GDREGISTER_CLASS(GLTFCamera);
+ GDREGISTER_CLASS(GLTFDocument);
+ GDREGISTER_CLASS(GLTFDocumentExtension);
+ GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
+ GDREGISTER_CLASS(GLTFLight);
+ GDREGISTER_CLASS(GLTFMesh);
+ GDREGISTER_CLASS(GLTFNode);
+ GDREGISTER_CLASS(GLTFSkeleton);
+ GDREGISTER_CLASS(GLTFSkin);
+ GDREGISTER_CLASS(GLTFSpecGloss);
+ GDREGISTER_CLASS(GLTFState);
+ GDREGISTER_CLASS(GLTFTexture);
+ }
#ifdef TOOLS_ENABLED
- // Editor-specific API.
- ClassDB::APIType prev_api = ClassDB::get_current_api();
- ClassDB::set_current_api(ClassDB::API_EDITOR);
-
- GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
- EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
-
- // Project settings defined here so doctool finds them.
- GLOBAL_DEF_RST("filesystem/import/blender/enabled", true);
- GLOBAL_DEF_RST("filesystem/import/fbx/enabled", true);
- GDREGISTER_CLASS(EditorSceneFormatImporterBlend);
- GDREGISTER_CLASS(EditorSceneFormatImporterFBX);
-
- ClassDB::set_current_api(prev_api);
- EditorNode::add_init_callback(_editor_init);
+ if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
+ // Editor-specific API.
+ ClassDB::APIType prev_api = ClassDB::get_current_api();
+ ClassDB::set_current_api(ClassDB::API_EDITOR);
+
+ GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
+ EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
+
+ // Project settings defined here so doctool finds them.
+ GLOBAL_DEF_RST("filesystem/import/blender/enabled", true);
+ GLOBAL_DEF_RST("filesystem/import/fbx/enabled", true);
+ GDREGISTER_CLASS(EditorSceneFormatImporterBlend);
+ GDREGISTER_CLASS(EditorSceneFormatImporterFBX);
+
+ ClassDB::set_current_api(prev_api);
+ EditorNode::add_init_callback(_editor_init);
+ }
#endif // TOOLS_ENABLED
}
-void unregister_gltf_types() {
+void uninitialize_gltf_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
}
#endif // _3D_DISABLED
diff --git a/modules/gltf/register_types.h b/modules/gltf/register_types.h
index 4a9c31241c..90b9a83c88 100644
--- a/modules/gltf/register_types.h
+++ b/modules/gltf/register_types.h
@@ -28,5 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_gltf_types();
-void unregister_gltf_types();
+#include "modules/register_module_types.h"
+
+void initialize_gltf_module(ModuleInitializationLevel p_level);
+void uninitialize_gltf_module(ModuleInitializationLevel p_level);