Debian Codegraph @

modules/fbx/register_types.cpp

raw symbols SCIP
1 /**************************************************************************/
2 /* register_types.cpp */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #include "register_types.h"
32
33 #include "../gltf/extensions/gltf_document_extension_convert_importer_mesh.h"
34 #include "fbx_document.h"
35
36 #ifdef TOOLS_ENABLED
37 #include "editor/editor_scene_importer_fbx2gltf.h"
38 #include "editor/editor_scene_importer_ufbx.h"
39
40 #include "core/config/project_settings.h"
41 #include "editor/editor_node.h"
42
43 static void _editor_init() {
44 Ref<EditorSceneFormatImporterUFBX> import_fbx;
45 import_fbx.instantiate();
46 ResourceImporterScene::add_scene_importer(import_fbx);
47
48 bool fbx2gltf_enabled = GLOBAL_GET("filesystem/import/fbx2gltf/enabled");
49 if (fbx2gltf_enabled) {
50 Ref<EditorSceneFormatImporterFBX2GLTF> importer;
51 importer.instantiate();
52 ResourceImporterScene::add_scene_importer(importer);
53 }
54 }
55 #endif // TOOLS_ENABLED
56
57 #define FBX_REGISTER_DOCUMENT_EXTENSION(m_doc_ext_class) \
58 Ref<m_doc_ext_class> extension_##m_doc_ext_class; \
59 extension_##m_doc_ext_class.instantiate(); \
60 FBXDocument::register_gltf_document_extension(extension_##m_doc_ext_class);
61
62 void initialize_fbx_module(ModuleInitializationLevel p_level) {
63 if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
64 GDREGISTER_CLASS(FBXDocument);
65 GDREGISTER_CLASS(FBXState);
66 bool is_editor = Engine::get_singleton()->is_editor_hint();
67 if (!is_editor) {
68 FBX_REGISTER_DOCUMENT_EXTENSION(GLTFDocumentExtensionConvertImporterMesh);
69 }
70 }
71
72 #ifdef TOOLS_ENABLED
73 if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
74 GDREGISTER_CLASS(EditorSceneFormatImporterUFBX);
75
76 GLOBAL_DEF_RST_BASIC("filesystem/import/fbx2gltf/enabled", true);
77 GDREGISTER_CLASS(EditorSceneFormatImporterFBX2GLTF);
78 GLOBAL_DEF_RST("filesystem/import/fbx2gltf/enabled.android", false);
79 GLOBAL_DEF_RST("filesystem/import/fbx2gltf/enabled.web", false);
80
81 EditorNode::add_init_callback(_editor_init);
82 }
83 #endif // TOOLS_ENABLED
84 }
85
86 void uninitialize_fbx_module(ModuleInitializationLevel p_level) {
87 if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
88 return;
89 }
90 FBXDocument::unregister_all_gltf_document_extensions();
91 }