Browse Source

Merge pull request #69372 from aaronfranke/gltf-cleanup

GLTF module: Clean up lots of includes
Rémi Verschelde 2 years ago
parent
commit
0c1273629d

+ 3 - 3
modules/gltf/doc_classes/GLTFDocumentExtension.xml

@@ -45,7 +45,7 @@
 			<param index="0" name="root" type="Node" />
 			<description>
 				Part of the export process. This method is run first, before all other parts of the export process.
-				The return value is used to determine if this GLTFDocumentExtension class should be used for exporting a given GLTF file. If [constant OK], the export will use this GLTFDocumentExtension class. If not overridden, [constant OK] is returned.
+				The return value is used to determine if this [GLTFDocumentExtension] instance should be used for exporting a given GLTF file. If [constant OK], the export will use this [GLTFDocumentExtension] instance. If not overridden, [constant OK] is returned.
 			</description>
 		</method>
 		<method name="_generate_scene_node" qualifiers="virtual">
@@ -99,7 +99,7 @@
 			<param index="1" name="extensions" type="PackedStringArray" />
 			<description>
 				Part of the import process. This method is run first, before all other parts of the import process.
-				The return value is used to determine if this GLTFDocumentExtension class should be used for importing a given GLTF file. If [constant OK], the import will use this GLTFDocumentExtension class. If not overridden, [constant OK] is returned.
+				The return value is used to determine if this [GLTFDocumentExtension] instance should be used for importing a given GLTF file. If [constant OK], the import will use this [GLTFDocumentExtension] instance. If not overridden, [constant OK] is returned.
 			</description>
 		</method>
 		<method name="_parse_node_extensions" qualifiers="virtual">
@@ -109,7 +109,7 @@
 			<param index="2" name="extensions" type="Dictionary" />
 			<description>
 				Part of the import process. This method is run after [method _get_supported_extensions] and before [method _generate_scene_node].
-				Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by [method _generate_scene_node].
+				Runs when parsing the node extensions of a GLTFNode. This method can be used to process the extension JSON data into a format that can be used by [method _generate_scene_node]. The return value should be a member of the [enum Error] enum.
 			</description>
 		</method>
 	</methods>

+ 0 - 8
modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp

@@ -33,18 +33,10 @@
 #include "editor_scene_exporter_gltf_plugin.h"
 
 #include "../gltf_document.h"
-#include "../gltf_state.h"
 
-#include "core/config/project_settings.h"
-#include "core/error/error_list.h"
-#include "core/object/object.h"
-#include "core/templates/vector.h"
 #include "editor/editor_file_dialog.h"
 #include "editor/editor_file_system.h"
 #include "editor/editor_node.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/gui/check_box.h"
-#include "scene/main/node.h"
 
 String SceneExporterGLTFPlugin::get_name() const {
 	return "ConvertGLTF2";

+ 0 - 3
modules/gltf/editor/editor_scene_importer_blend.cpp

@@ -33,7 +33,6 @@
 #ifdef TOOLS_ENABLED
 
 #include "../gltf_document.h"
-#include "../gltf_state.h"
 
 #include "core/config/project_settings.h"
 #include "editor/editor_file_dialog.h"
@@ -42,8 +41,6 @@
 #include "editor/editor_settings.h"
 #include "main/main.h"
 #include "scene/gui/line_edit.h"
-#include "scene/main/node.h"
-#include "scene/resources/animation.h"
 
 #ifdef WINDOWS_ENABLED
 // Code by Pedro Estebanez (https://github.com/godotengine/godot/pull/59766)

+ 0 - 3
modules/gltf/editor/editor_scene_importer_fbx.cpp

@@ -33,12 +33,9 @@
 #ifdef TOOLS_ENABLED
 
 #include "../gltf_document.h"
-#include "../gltf_state.h"
 
 #include "core/config/project_settings.h"
 #include "editor/editor_settings.h"
-#include "scene/main/node.h"
-#include "scene/resources/animation.h"
 
 uint32_t EditorSceneFormatImporterFBX::get_import_flags() const {
 	return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;

+ 0 - 3
modules/gltf/editor/editor_scene_importer_gltf.cpp

@@ -33,9 +33,6 @@
 #include "editor_scene_importer_gltf.h"
 
 #include "../gltf_document.h"
-#include "../gltf_state.h"
-
-#include "scene/resources/animation.h"
 
 uint32_t EditorSceneFormatImporterGLTF::get_import_flags() const {
 	return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;

+ 1 - 3
modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.cpp

@@ -30,9 +30,7 @@
 
 #include "gltf_document_extension_convert_importer_mesh.h"
 
-#include "../gltf_state.h"
-
-#include "core/error/error_macros.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
 #include "scene/3d/mesh_instance_3d.h"
 #include "scene/resources/importer_mesh.h"
 

+ 0 - 4
modules/gltf/extensions/gltf_document_extension_convert_importer_mesh.h

@@ -33,10 +33,6 @@
 
 #include "gltf_document_extension.h"
 
-#include "scene/3d/importer_mesh_instance_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/resources/importer_mesh.h"
-
 class GLTFDocumentExtensionConvertImporterMesh : public GLTFDocumentExtension {
 	GDCLASS(GLTFDocumentExtensionConvertImporterMesh, GLTFDocumentExtension);
 

+ 2 - 0
modules/gltf/extensions/gltf_light.cpp

@@ -30,6 +30,8 @@
 
 #include "gltf_light.h"
 
+#include "scene/3d/light_3d.h"
+
 void GLTFLight::_bind_methods() {
 	ClassDB::bind_static_method("GLTFLight", D_METHOD("from_node", "light_node"), &GLTFLight::from_node);
 	ClassDB::bind_method(D_METHOD("to_node"), &GLTFLight::to_node);

+ 2 - 2
modules/gltf/extensions/gltf_light.h

@@ -31,9 +31,9 @@
 #ifndef GLTF_LIGHT_H
 #define GLTF_LIGHT_H
 
-#include "core/config/engine.h"
 #include "core/io/resource.h"
-#include "scene/3d/light_3d.h"
+
+class Light3D;
 
 // https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual
 

+ 2 - 0
modules/gltf/extensions/gltf_spec_gloss.cpp

@@ -30,6 +30,8 @@
 
 #include "gltf_spec_gloss.h"
 
+#include "core/io/image.h"
+
 void GLTFSpecGloss::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_diffuse_img"), &GLTFSpecGloss::get_diffuse_img);
 	ClassDB::bind_method(D_METHOD("set_diffuse_img", "diffuse_img"), &GLTFSpecGloss::set_diffuse_img);

+ 2 - 1
modules/gltf/extensions/gltf_spec_gloss.h

@@ -31,9 +31,10 @@
 #ifndef GLTF_SPEC_GLOSS_H
 #define GLTF_SPEC_GLOSS_H
 
-#include "core/io/image.h"
 #include "core/io/resource.h"
 
+class Image;
+
 // KHR_materials_pbrSpecularGlossiness is an archived GLTF extension.
 // This means that it is deprecated and not recommended for new files.
 // However, it is still supported for loading old files.

+ 2 - 1
modules/gltf/gltf_defines.h

@@ -36,9 +36,10 @@
 // Godot classes used by GLTF headers.
 class BoneAttachment3D;
 class CSGShape3D;
-class DirectionalLight3D;
 class GridMap;
+class ImporterMeshInstance3D;
 class Light3D;
+class MeshInstance3D;
 class MultiMeshInstance3D;
 class Skeleton3D;
 class Skin;

+ 5 - 13
modules/gltf/gltf_document.cpp

@@ -31,31 +31,23 @@
 #include "gltf_document.h"
 
 #include "extensions/gltf_spec_gloss.h"
-#include "gltf_state.h"
 
 #include "core/crypto/crypto_core.h"
-#include "core/error/error_macros.h"
 #include "core/io/dir_access.h"
 #include "core/io/file_access.h"
 #include "core/io/file_access_memory.h"
 #include "core/io/json.h"
 #include "core/io/stream_peer.h"
 #include "core/math/disjoint_set.h"
-#include "core/math/vector2.h"
-#include "core/variant/dictionary.h"
-#include "core/variant/typed_array.h"
-#include "core/variant/variant.h"
 #include "core/version.h"
 #include "drivers/png/png_driver_common.h"
-#include "scene/2d/node_2d.h"
+#include "scene/3d/bone_attachment_3d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
+#include "scene/3d/light_3d.h"
 #include "scene/3d/mesh_instance_3d.h"
 #include "scene/3d/multimesh_instance_3d.h"
-#include "scene/3d/node_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/importer_mesh.h"
-#include "scene/resources/material.h"
-#include "scene/resources/mesh.h"
-#include "scene/resources/multimesh.h"
+#include "scene/resources/skin.h"
 #include "scene/resources/surface_tool.h"
 
 #include "modules/modules_enabled.gen.h" // For csg, gridmap.

+ 0 - 7
modules/gltf/gltf_document.h

@@ -32,13 +32,6 @@
 #define GLTF_DOCUMENT_H
 
 #include "extensions/gltf_document_extension.h"
-#include "structures/gltf_animation.h"
-
-#include "scene/3d/bone_attachment_3d.h"
-#include "scene/3d/importer_mesh_instance_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/material.h"
 
 #include "modules/modules_enabled.gen.h" // For csg, gridmap.
 

+ 2 - 0
modules/gltf/gltf_state.cpp

@@ -30,6 +30,8 @@
 
 #include "gltf_state.h"
 
+#include "gltf_template_convert.h"
+
 void GLTFState::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("add_used_extension", "extension_name", "required"), &GLTFState::add_used_extension);
 	ClassDB::bind_method(D_METHOD("get_json"), &GLTFState::get_json);

+ 0 - 20
modules/gltf/gltf_state.h

@@ -32,7 +32,6 @@
 #define GLTF_STATE_H
 
 #include "extensions/gltf_light.h"
-#include "gltf_template_convert.h"
 #include "structures/gltf_accessor.h"
 #include "structures/gltf_animation.h"
 #include "structures/gltf_buffer_view.h"
@@ -44,10 +43,6 @@
 #include "structures/gltf_texture.h"
 #include "structures/gltf_texture_sampler.h"
 
-#include "core/templates/rb_map.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/texture.h"
-
 class GLTFState : public Resource {
 	GDCLASS(GLTFState, Resource);
 	friend class GLTFDocument;
@@ -194,21 +189,6 @@ public:
 
 	Variant get_additional_data(const StringName &p_extension_name);
 	void set_additional_data(const StringName &p_extension_name, Variant p_additional_data);
-
-	//void set_scene_nodes(RBMap<GLTFNodeIndex, Node *> p_scene_nodes) {
-	//	this->scene_nodes = p_scene_nodes;
-	//}
-
-	//void set_animation_players(Vector<AnimationPlayer *> p_animation_players) {
-	//	this->animation_players = p_animation_players;
-	//}
-
-	//RBMap<Ref<Material>, GLTFMaterialIndex> get_material_cache() {
-	//	return this->material_cache;
-	//}
-	//void set_material_cache(RBMap<Ref<Material>, GLTFMaterialIndex> p_material_cache) {
-	//	this->material_cache = p_material_cache;
-	//}
 };
 
 #endif // GLTF_STATE_H

+ 0 - 16
modules/gltf/register_types.cpp

@@ -30,23 +30,9 @@
 
 #include "register_types.h"
 
-#ifndef _3D_DISABLED
-
 #include "extensions/gltf_document_extension_convert_importer_mesh.h"
-#include "extensions/gltf_light.h"
 #include "extensions/gltf_spec_gloss.h"
 #include "gltf_document.h"
-#include "gltf_state.h"
-#include "structures/gltf_accessor.h"
-#include "structures/gltf_animation.h"
-#include "structures/gltf_buffer_view.h"
-#include "structures/gltf_camera.h"
-#include "structures/gltf_mesh.h"
-#include "structures/gltf_node.h"
-#include "structures/gltf_skeleton.h"
-#include "structures/gltf_skin.h"
-#include "structures/gltf_texture.h"
-#include "structures/gltf_texture_sampler.h"
 
 #ifdef TOOLS_ENABLED
 #include "core/config/project_settings.h"
@@ -172,5 +158,3 @@ void uninitialize_gltf_module(ModuleInitializationLevel p_level) {
 	}
 	GLTFDocument::unregister_all_gltf_document_extensions();
 }
-
-#endif // _3D_DISABLED

+ 1 - 2
modules/gltf/structures/gltf_accessor.h

@@ -31,9 +31,8 @@
 #ifndef GLTF_ACCESSOR_H
 #define GLTF_ACCESSOR_H
 
-#include "core/io/resource.h"
-
 #include "../gltf_defines.h"
+#include "core/io/resource.h"
 
 struct GLTFAccessor : public Resource {
 	GDCLASS(GLTFAccessor, Resource);

+ 1 - 1
modules/gltf/structures/gltf_animation.h

@@ -31,7 +31,7 @@
 #ifndef GLTF_ANIMATION_H
 #define GLTF_ANIMATION_H
 
-#include "core/io/resource.h"
+#include "scene/animation/animation_player.h"
 
 class GLTFAnimation : public Resource {
 	GDCLASS(GLTFAnimation, Resource);

+ 2 - 0
modules/gltf/structures/gltf_camera.cpp

@@ -30,6 +30,8 @@
 
 #include "gltf_camera.h"
 
+#include "scene/3d/camera_3d.h"
+
 void GLTFCamera::_bind_methods() {
 	ClassDB::bind_static_method("GLTFCamera", D_METHOD("from_node", "camera_node"), &GLTFCamera::from_node);
 	ClassDB::bind_method(D_METHOD("to_node"), &GLTFCamera::to_node);

+ 2 - 1
modules/gltf/structures/gltf_camera.h

@@ -32,7 +32,8 @@
 #define GLTF_CAMERA_H
 
 #include "core/io/resource.h"
-#include "scene/3d/camera_3d.h"
+
+class Camera3D;
 
 // Reference and test file:
 // https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_015_SimpleCameras.md

+ 1 - 3
modules/gltf/structures/gltf_mesh.h

@@ -31,10 +31,8 @@
 #ifndef GLTF_MESH_H
 #define GLTF_MESH_H
 
-#include "core/io/resource.h"
-#include "scene/3d/importer_mesh_instance_3d.h"
+#include "../gltf_defines.h"
 #include "scene/resources/importer_mesh.h"
-#include "scene/resources/mesh.h"
 
 class GLTFMesh : public Resource {
 	GDCLASS(GLTFMesh, Resource);

+ 0 - 1
modules/gltf/structures/gltf_texture_sampler.h

@@ -31,7 +31,6 @@
 #ifndef GLTF_TEXTURE_SAMPLER_H
 #define GLTF_TEXTURE_SAMPLER_H
 
-#include "core/io/resource.h"
 #include "scene/resources/material.h"
 
 class GLTFTextureSampler : public Resource {