summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-05-03 11:56:08 +0200
committerreduz <reduzio@gmail.com>2022-05-04 17:34:51 +0200
commitde0ca3b999819a99a5dcab99f0083a760277b95e (patch)
tree3078cc65c19bdedfb25c977c48b50e44003a2802 /modules/gltf
parent0a9d31a7eb9debe30cd5078688e895d2ce3f2efa (diff)
Refactor module initialization
* Changed to use the same stages as extensions. * Makes the initialization more coherent, helping solve problems due to lack of stages. * Makes it easier to port between module and extension. * removed the DRIVER initialization level (no longer needed).
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);