summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gltf')
-rw-r--r--modules/gltf/doc_classes/GLTFSkeleton.xml30
-rw-r--r--modules/gltf/doc_classes/GLTFSkin.xml27
-rw-r--r--modules/gltf/doc_classes/GLTFState.xml153
-rw-r--r--modules/gltf/doc_classes/PackedSceneGLTF.xml45
-rw-r--r--modules/gltf/editor_scene_importer_gltf.cpp22
-rw-r--r--modules/gltf/editor_scene_importer_gltf.h21
-rw-r--r--modules/gltf/gltf_document.cpp85
-rw-r--r--modules/gltf/gltf_document.h12
-rw-r--r--modules/gltf/gltf_state.h6
-rw-r--r--modules/gltf/register_types.cpp30
10 files changed, 164 insertions, 267 deletions
diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml
index 40563c9ac6..6e83cec252 100644
--- a/modules/gltf/doc_classes/GLTFSkeleton.xml
+++ b/modules/gltf/doc_classes/GLTFSkeleton.xml
@@ -8,50 +8,40 @@
</tutorials>
<methods>
<method name="get_bone_attachment">
- <return type="BoneAttachment3D">
- </return>
- <argument index="0" name="idx" type="int">
- </argument>
+ <return type="BoneAttachment3D" />
+ <argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_bone_attachment_count">
- <return type="int">
- </return>
+ <return type="int" />
<description>
</description>
</method>
<method name="get_godot_bone_node">
- <return type="Dictionary">
- </return>
+ <return type="Dictionary" />
<description>
</description>
</method>
<method name="get_godot_skeleton">
- <return type="Skeleton3D">
- </return>
+ <return type="Skeleton3D" />
<description>
</description>
</method>
<method name="get_unique_names">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="set_godot_bone_node">
- <return type="void">
- </return>
- <argument index="0" name="godot_bone_node" type="Dictionary">
- </argument>
+ <return type="void" />
+ <argument index="0" name="godot_bone_node" type="Dictionary" />
<description>
</description>
</method>
<method name="set_unique_names">
- <return type="void">
- </return>
- <argument index="0" name="unique_names" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="unique_names" type="Array" />
<description>
</description>
</method>
diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml
index e20e127e52..107ca960cd 100644
--- a/modules/gltf/doc_classes/GLTFSkin.xml
+++ b/modules/gltf/doc_classes/GLTFSkin.xml
@@ -8,44 +8,35 @@
</tutorials>
<methods>
<method name="get_inverse_binds">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_joint_i_to_bone_i">
- <return type="Dictionary">
- </return>
+ <return type="Dictionary" />
<description>
</description>
</method>
<method name="get_joint_i_to_name">
- <return type="Dictionary">
- </return>
+ <return type="Dictionary" />
<description>
</description>
</method>
<method name="set_inverse_binds">
- <return type="void">
- </return>
- <argument index="0" name="inverse_binds" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="inverse_binds" type="Array" />
<description>
</description>
</method>
<method name="set_joint_i_to_bone_i">
- <return type="void">
- </return>
- <argument index="0" name="joint_i_to_bone_i" type="Dictionary">
- </argument>
+ <return type="void" />
+ <argument index="0" name="joint_i_to_bone_i" type="Dictionary" />
<description>
</description>
</method>
<method name="set_joint_i_to_name">
- <return type="void">
- </return>
- <argument index="0" name="joint_i_to_name" type="Dictionary">
- </argument>
+ <return type="void" />
+ <argument index="0" name="joint_i_to_name" type="Dictionary" />
<description>
</description>
</method>
diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml
index a7b5b7b43e..ae976fc04c 100644
--- a/modules/gltf/doc_classes/GLTFState.xml
+++ b/modules/gltf/doc_classes/GLTFState.xml
@@ -8,236 +8,185 @@
</tutorials>
<methods>
<method name="get_accessors">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_animation_player">
- <return type="AnimationPlayer">
- </return>
- <argument index="0" name="idx" type="int">
- </argument>
+ <return type="AnimationPlayer" />
+ <argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_animation_players_count">
- <return type="int">
- </return>
- <argument index="0" name="idx" type="int">
- </argument>
+ <return type="int" />
+ <argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_animations">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_buffer_views">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_cameras">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_images">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_lights">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_materials">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_meshes">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_nodes">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_scene_node">
- <return type="Node">
- </return>
- <argument index="0" name="idx" type="int">
- </argument>
+ <return type="Node" />
+ <argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_skeleton_to_node">
- <return type="Dictionary">
- </return>
+ <return type="Dictionary" />
<description>
</description>
</method>
<method name="get_skeletons">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_skins">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_textures">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_unique_animation_names">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="get_unique_names">
- <return type="Array">
- </return>
+ <return type="Array" />
<description>
</description>
</method>
<method name="set_accessors">
- <return type="void">
- </return>
- <argument index="0" name="accessors" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="accessors" type="Array" />
<description>
</description>
</method>
<method name="set_animations">
- <return type="void">
- </return>
- <argument index="0" name="animations" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="animations" type="Array" />
<description>
</description>
</method>
<method name="set_buffer_views">
- <return type="void">
- </return>
- <argument index="0" name="buffer_views" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="buffer_views" type="Array" />
<description>
</description>
</method>
<method name="set_cameras">
- <return type="void">
- </return>
- <argument index="0" name="cameras" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="cameras" type="Array" />
<description>
</description>
</method>
<method name="set_images">
- <return type="void">
- </return>
- <argument index="0" name="images" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="images" type="Array" />
<description>
</description>
</method>
<method name="set_lights">
- <return type="void">
- </return>
- <argument index="0" name="lights" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="lights" type="Array" />
<description>
</description>
</method>
<method name="set_materials">
- <return type="void">
- </return>
- <argument index="0" name="materials" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="materials" type="Array" />
<description>
</description>
</method>
<method name="set_meshes">
- <return type="void">
- </return>
- <argument index="0" name="meshes" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="meshes" type="Array" />
<description>
</description>
</method>
<method name="set_nodes">
- <return type="void">
- </return>
- <argument index="0" name="nodes" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="nodes" type="Array" />
<description>
</description>
</method>
<method name="set_skeleton_to_node">
- <return type="void">
- </return>
- <argument index="0" name="skeleton_to_node" type="Dictionary">
- </argument>
+ <return type="void" />
+ <argument index="0" name="skeleton_to_node" type="Dictionary" />
<description>
</description>
</method>
<method name="set_skeletons">
- <return type="void">
- </return>
- <argument index="0" name="skeletons" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="skeletons" type="Array" />
<description>
</description>
</method>
<method name="set_skins">
- <return type="void">
- </return>
- <argument index="0" name="skins" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="skins" type="Array" />
<description>
</description>
</method>
<method name="set_textures">
- <return type="void">
- </return>
- <argument index="0" name="textures" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="textures" type="Array" />
<description>
</description>
</method>
<method name="set_unique_animation_names">
- <return type="void">
- </return>
- <argument index="0" name="unique_animation_names" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="unique_animation_names" type="Array" />
<description>
</description>
</method>
<method name="set_unique_names">
- <return type="void">
- </return>
- <argument index="0" name="unique_names" type="Array">
- </argument>
+ <return type="void" />
+ <argument index="0" name="unique_names" type="Array" />
<description>
</description>
</method>
diff --git a/modules/gltf/doc_classes/PackedSceneGLTF.xml b/modules/gltf/doc_classes/PackedSceneGLTF.xml
index a22111e9b7..d0136c6402 100644
--- a/modules/gltf/doc_classes/PackedSceneGLTF.xml
+++ b/modules/gltf/doc_classes/PackedSceneGLTF.xml
@@ -8,44 +8,29 @@
</tutorials>
<methods>
<method name="export_gltf">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="node" type="Node">
- </argument>
- <argument index="1" name="path" type="String">
- </argument>
- <argument index="2" name="flags" type="int" default="0">
- </argument>
- <argument index="3" name="bake_fps" type="float" default="1000.0">
- </argument>
+ <return type="int" enum="Error" />
+ <argument index="0" name="node" type="Node" />
+ <argument index="1" name="path" type="String" />
+ <argument index="2" name="flags" type="int" default="0" />
+ <argument index="3" name="bake_fps" type="float" default="1000.0" />
<description>
</description>
</method>
<method name="import_gltf_scene">
- <return type="Node">
- </return>
- <argument index="0" name="path" type="String">
- </argument>
- <argument index="1" name="flags" type="int" default="0">
- </argument>
- <argument index="2" name="bake_fps" type="float" default="1000.0">
- </argument>
- <argument index="3" name="state" type="GLTFState" default="null">
- </argument>
+ <return type="Node" />
+ <argument index="0" name="path" type="String" />
+ <argument index="1" name="flags" type="int" default="0" />
+ <argument index="2" name="bake_fps" type="float" default="1000.0" />
+ <argument index="3" name="state" type="GLTFState" default="null" />
<description>
</description>
</method>
<method name="pack_gltf">
- <return type="void">
- </return>
- <argument index="0" name="path" type="String">
- </argument>
- <argument index="1" name="flags" type="int" default="0">
- </argument>
- <argument index="2" name="bake_fps" type="float" default="1000.0">
- </argument>
- <argument index="3" name="state" type="GLTFState" default="null">
- </argument>
+ <return type="void" />
+ <argument index="0" name="path" type="String" />
+ <argument index="1" name="flags" type="int" default="0" />
+ <argument index="2" name="bake_fps" type="float" default="1000.0" />
+ <argument index="3" name="state" type="GLTFState" default="null" />
<description>
</description>
</method>
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp
index cef5278f03..eca1c85bf3 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor_scene_importer_gltf.cpp
@@ -28,22 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/crypto/crypto_core.h"
-#include "core/io/file_access.h"
-#include "core/math/disjoint_set.h"
-#include "core/math/math_defs.h"
-#include "core/os/os.h"
-#include "editor/import/resource_importer_scene.h"
-#include "modules/gltf/gltf_state.h"
-#include "modules/regex/regex.h"
-#include "scene/3d/bone_attachment_3d.h"
-#include "scene/3d/camera_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/resources/packed_scene.h"
-#include "scene/resources/surface_tool.h"
+#include "editor_scene_importer_gltf.h"
+
+#include "gltf_document.h"
+#include "gltf_state.h"
-#include "modules/gltf/editor_scene_importer_gltf.h"
+#include "scene/3d/node_3d.h"
+#include "scene/animation/animation_player.h"
+#include "scene/resources/animation.h"
uint32_t EditorSceneImporterGLTF::get_import_flags() const {
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h
index 566d5cfd34..7bc5f594ed 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor_scene_importer_gltf.h
@@ -31,28 +31,13 @@
#ifndef EDITOR_SCENE_IMPORTER_GLTF_H
#define EDITOR_SCENE_IMPORTER_GLTF_H
-#include "core/config/project_settings.h"
-#include "core/object/object.h"
-#include "core/templates/vector.h"
+#include "gltf_state.h"
+
#include "editor/import/resource_importer_scene.h"
-#include "modules/csg/csg_shape.h"
-#include "modules/gridmap/grid_map.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/3d/multimesh_instance_3d.h"
-#include "scene/3d/node_3d.h"
-#include "scene/3d/skeleton_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/gui/check_box.h"
#include "scene/main/node.h"
#include "scene/resources/packed_scene.h"
-#include "scene/resources/surface_tool.h"
-
-#include "gltf_document.h"
-#include "gltf_state.h"
-class AnimationPlayer;
-class BoneAttachment;
-class EditorSceneImporterMeshNode3D;
+class Animation;
#ifdef TOOLS_ENABLED
class EditorSceneImporterGLTF : public EditorSceneImporter {
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 660c2ab305..ff0579a11c 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -29,9 +29,7 @@
/*************************************************************************/
#include "gltf_document.h"
-#include "core/error/error_list.h"
-#include "core/error/error_macros.h"
-#include "core/variant/variant.h"
+
#include "gltf_accessor.h"
#include "gltf_animation.h"
#include "gltf_camera.h"
@@ -44,35 +42,34 @@
#include "gltf_state.h"
#include "gltf_texture.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "core/core_bind.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/json.h"
#include "core/math/disjoint_set.h"
#include "core/variant/typed_array.h"
+#include "core/variant/variant.h"
#include "core/version.h"
#include "core/version_hash.gen.h"
#include "drivers/png/png_driver_common.h"
#include "editor/import/resource_importer_scene.h"
+#include "scene/2d/node_2d.h"
+#include "scene/3d/camera_3d.h"
+#include "scene/3d/multimesh_instance_3d.h"
+#include "scene/animation/animation_player.h"
+#include "scene/resources/surface_tool.h"
+
+#include "modules/modules_enabled.gen.h"
#ifdef MODULE_CSG_ENABLED
#include "modules/csg/csg_shape.h"
#endif // MODULE_CSG_ENABLED
#ifdef MODULE_GRIDMAP_ENABLED
#include "modules/gridmap/grid_map.h"
#endif // MODULE_GRIDMAP_ENABLED
-#include "scene/2d/node_2d.h"
-#include "scene/3d/bone_attachment_3d.h"
-#include "scene/3d/camera_3d.h"
-#include "scene/3d/mesh_instance_3d.h"
-#include "scene/3d/multimesh_instance_3d.h"
-#include "scene/3d/node_3d.h"
-#include "scene/3d/skeleton_3d.h"
-#include "scene/animation/animation_player.h"
-#include "scene/main/node.h"
-#include "scene/resources/surface_tool.h"
+
+#include <stdio.h>
+#include <stdlib.h>
#include <limits>
Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String &p_path) {
@@ -2800,7 +2797,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
mat = mat3d;
}
- import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat);
+ import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat, mat.is_valid() ? mat->get_name() : String());
}
Vector<float> blend_weights;
@@ -2873,16 +2870,13 @@ Error GLTFDocument::_serialize_images(Ref<GLTFState> state, const String &p_path
name = itos(i);
}
name = _gen_unique_name(state, name);
- name = name.pad_zeros(3);
- Ref<_Directory> dir;
- dir.instantiate();
+ name = name.pad_zeros(3) + ".png";
String texture_dir = "textures";
String new_texture_dir = p_path.get_base_dir() + "/" + texture_dir;
- dir->open(p_path.get_base_dir());
- if (!dir->dir_exists(new_texture_dir)) {
- dir->make_dir(new_texture_dir);
+ DirAccessRef da = DirAccess::open(p_path.get_base_dir());
+ if (!da->dir_exists(new_texture_dir)) {
+ da->make_dir(new_texture_dir);
}
- name = name + ".png";
image->save_png(new_texture_dir.plus_file(name));
d["uri"] = texture_dir.plus_file(name);
}
@@ -3009,24 +3003,31 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> state, const String &p_base_pat
Ref<Image> img;
+ // First we honor the mime types if they were defined.
if (mimetype == "image/png") { // Load buffer as PNG.
ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE);
img = Image::_png_mem_loader_func(data_ptr, data_size);
} else if (mimetype == "image/jpeg") { // Loader buffer as JPEG.
ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE);
img = Image::_jpg_mem_loader_func(data_ptr, data_size);
- } else {
- // We can land here if we got an URI with base64-encoded data with application/* MIME type,
- // and the optional mimeType property was not defined to tell us how to handle this data (or was invalid).
- // So let's try PNG first, then JPEG.
+ }
+
+ // If we didn't pass the above tests, we attempt loading as PNG and then
+ // JPEG directly.
+ // This covers URIs with base64-encoded data with application/* type but
+ // no optional mimeType property, or bufferViews with a bogus mimeType
+ // (e.g. `image/jpeg` but the data is actually PNG).
+ // That's not *exactly* what the spec mandates but this lets us be
+ // lenient with bogus glb files which do exist in production.
+ if (img.is_null()) { // Try PNG first.
ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE);
img = Image::_png_mem_loader_func(data_ptr, data_size);
- if (img.is_null()) {
- ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE);
- img = Image::_jpg_mem_loader_func(data_ptr, data_size);
- }
}
-
+ if (img.is_null()) { // And then JPEG.
+ ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE);
+ img = Image::_jpg_mem_loader_func(data_ptr, data_size);
+ }
+ // Now we've done our best, fix your scenes.
if (img.is_null()) {
ERR_PRINT(vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype));
state->images.push_back(Ref<Texture2D>());
@@ -4469,9 +4470,9 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) {
const Dictionary &spot = d["spot"];
light->inner_cone_angle = spot["innerConeAngle"];
light->outer_cone_angle = spot["outerConeAngle"];
- ERR_FAIL_COND_V_MSG(light->inner_cone_angle >= light->outer_cone_angle, ERR_PARSE_ERROR, "The inner angle must be smaller than the outer angle.");
+ ERR_CONTINUE_MSG(light->inner_cone_angle >= light->outer_cone_angle, "The inner angle must be smaller than the outer angle.");
} else if (type != "point" && type != "directional") {
- ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Light type is unknown.");
+ ERR_CONTINUE_MSG(ERR_PARSE_ERROR, "Light type is unknown.");
}
state->lights.push_back(light);
@@ -5380,15 +5381,16 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> state, Node *scene_parent
// and attach it to the bone_attachment
scene_parent = bone_attachment;
}
-
- // We still have not managed to make a node
if (gltf_node->mesh >= 0) {
current_node = _generate_mesh_instance(state, scene_parent, node_index);
} else if (gltf_node->camera >= 0) {
current_node = _generate_camera(state, scene_parent, node_index);
} else if (gltf_node->light >= 0) {
current_node = _generate_light(state, scene_parent, node_index);
- } else {
+ }
+
+ // We still have not managed to make a node.
+ if (!current_node) {
current_node = _generate_spatial(state, scene_parent, node_index);
}
@@ -5538,7 +5540,10 @@ struct EditorSceneImporterGLTFInterpolate<Quaternion> {
template <class T>
T GLTFDocument::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) {
ERR_FAIL_COND_V(!p_values.size(), T());
- ERR_FAIL_COND_V(p_times.size() != p_values.size(), p_values[0]);
+ if (p_times.size() != p_values.size()) {
+ ERR_PRINT_ONCE("The interpolated values are not corresponding to its times.");
+ return p_values[0];
+ }
//could use binary search, worth it?
int idx = -1;
for (int i = 0; i < p_times.size(); i++) {
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index 514373c4f0..7a826897a9 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -31,11 +31,9 @@
#ifndef GLTF_DOCUMENT_H
#define GLTF_DOCUMENT_H
-#include "editor/import/resource_importer_scene.h"
-#include "editor/import/scene_importer_mesh_node_3d.h"
#include "gltf_animation.h"
-#include "modules/modules_enabled.gen.h"
-#include "scene/2d/node_2d.h"
+
+#include "editor/import/scene_importer_mesh_node_3d.h"
#include "scene/3d/bone_attachment_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
@@ -45,6 +43,8 @@
#include "scene/resources/material.h"
#include "scene/resources/texture.h"
+#include "modules/modules_enabled.gen.h"
+
class GLTFState;
class GLTFSkin;
class GLTFNode;
@@ -346,8 +346,8 @@ private:
Error _serialize_extensions(Ref<GLTFState> state) const;
public:
- // http://www.itu.int/rec/R-REC-BT.601
- // http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
+ // https://www.itu.int/rec/R-REC-BT.601
+ // https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
static constexpr float R_BRIGHTNESS_COEFF = 0.299f;
static constexpr float G_BRIGHTNESS_COEFF = 0.587f;
static constexpr float B_BRIGHTNESS_COEFF = 0.114f;
diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h
index ba6bf8a533..d8209523c5 100644
--- a/modules/gltf/gltf_state.h
+++ b/modules/gltf/gltf_state.h
@@ -31,9 +31,6 @@
#ifndef GLTF_STATE_H
#define GLTF_STATE_H
-#include "core/io/resource.h"
-#include "core/templates/vector.h"
-#include "editor_scene_importer_gltf.h"
#include "gltf_accessor.h"
#include "gltf_animation.h"
#include "gltf_buffer_view.h"
@@ -45,6 +42,9 @@
#include "gltf_skeleton.h"
#include "gltf_skin.h"
#include "gltf_texture.h"
+
+#include "core/io/resource.h"
+#include "core/templates/vector.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/texture.h"
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index d11c7cb9cd..85921490d2 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -62,25 +62,25 @@ void register_gltf_types() {
#ifdef TOOLS_ENABLED
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
- ClassDB::register_class<EditorSceneImporterGLTF>();
- ClassDB::register_class<GLTFMesh>();
+ GDREGISTER_CLASS(EditorSceneImporterGLTF);
+ GDREGISTER_CLASS(GLTFMesh);
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
ClassDB::set_current_api(prev_api);
EditorNode::add_init_callback(_editor_init);
#endif
- ClassDB::register_class<GLTFSpecGloss>();
- ClassDB::register_class<GLTFNode>();
- ClassDB::register_class<GLTFAnimation>();
- ClassDB::register_class<GLTFBufferView>();
- ClassDB::register_class<GLTFAccessor>();
- ClassDB::register_class<GLTFTexture>();
- ClassDB::register_class<GLTFSkeleton>();
- ClassDB::register_class<GLTFSkin>();
- ClassDB::register_class<GLTFCamera>();
- ClassDB::register_class<GLTFLight>();
- ClassDB::register_class<GLTFState>();
- ClassDB::register_class<GLTFDocument>();
- ClassDB::register_class<PackedSceneGLTF>();
+ GDREGISTER_CLASS(GLTFSpecGloss);
+ GDREGISTER_CLASS(GLTFNode);
+ GDREGISTER_CLASS(GLTFAnimation);
+ GDREGISTER_CLASS(GLTFBufferView);
+ GDREGISTER_CLASS(GLTFAccessor);
+ GDREGISTER_CLASS(GLTFTexture);
+ GDREGISTER_CLASS(GLTFSkeleton);
+ GDREGISTER_CLASS(GLTFSkin);
+ GDREGISTER_CLASS(GLTFCamera);
+ GDREGISTER_CLASS(GLTFLight);
+ GDREGISTER_CLASS(GLTFState);
+ GDREGISTER_CLASS(GLTFDocument);
+ GDREGISTER_CLASS(PackedSceneGLTF);
#endif
}