summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gltf')
-rw-r--r--modules/gltf/SCsub3
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp (renamed from modules/gltf/editor_scene_exporter_gltf_plugin.cpp)11
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.h (renamed from modules/gltf/editor_scene_exporter_gltf_plugin.h)5
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp (renamed from modules/gltf/editor_scene_importer_gltf.cpp)7
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.h (renamed from modules/gltf/editor_scene_importer_gltf.h)7
-rw-r--r--modules/gltf/gltf_document.cpp23
-rw-r--r--modules/gltf/gltf_mesh.h1
-rw-r--r--modules/gltf/register_types.cpp15
8 files changed, 45 insertions, 27 deletions
diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub
index 5d03ee8361..3379404a00 100644
--- a/modules/gltf/SCsub
+++ b/modules/gltf/SCsub
@@ -4,7 +4,8 @@ Import("env")
Import("env_modules")
env_gltf = env_modules.Clone()
-env_gltf.Prepend(CPPPATH=["."])
# Godot's own source files
env_gltf.add_source_files(env.modules_sources, "*.cpp")
+if env["tools"]:
+ env_gltf.add_source_files(env.modules_sources, "editor/*.cpp")
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
index 601c70791c..23a7b7fed6 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
@@ -28,23 +28,24 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#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 "gltf_document.h"
-#include "gltf_state.h"
+#include "editor/editor_node.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/check_box.h"
#include "scene/main/node.h"
-#include "editor/editor_node.h"
-
String SceneExporterGLTFPlugin::get_name() const {
return "ConvertGLTF2";
}
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.h b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h
index c2c3f5710c..5af46bc752 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.h
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h
@@ -31,7 +31,8 @@
#ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
#define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#include "editor/editor_plugin.h"
#include "editor_scene_importer_gltf.h"
@@ -47,5 +48,7 @@ public:
bool has_main_screen() const override;
SceneExporterGLTFPlugin();
};
+
#endif // TOOLS_ENABLED
+
#endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index f063cc1e2b..f9193c2a42 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -28,11 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#include "editor_scene_importer_gltf.h"
-#include "gltf_document.h"
-#include "gltf_state.h"
+#include "../gltf_document.h"
+#include "../gltf_state.h"
#include "scene/3d/node_3d.h"
#include "scene/animation/animation_player.h"
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h
index 4410559b3d..206fe63426 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor/editor_scene_importer_gltf.h
@@ -30,10 +30,11 @@
#ifndef EDITOR_SCENE_IMPORTER_GLTF_H
#define EDITOR_SCENE_IMPORTER_GLTF_H
+
#ifdef TOOLS_ENABLED
-#include "gltf_state.h"
-#include "gltf_document_extension.h"
+#include "../gltf_document_extension.h"
+#include "../gltf_state.h"
#include "editor/import/resource_importer_scene.h"
#include "scene/main/node.h"
@@ -51,5 +52,7 @@ public:
virtual Ref<Animation> import_animation(const String &p_path,
uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override;
};
+
#endif // TOOLS_ENABLED
+
#endif // EDITOR_SCENE_IMPORTER_GLTF_H
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index c70081a620..56f31fd812 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -58,7 +58,6 @@
#include "core/variant/variant.h"
#include "core/version.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/mesh_instance_3d.h"
@@ -79,6 +78,9 @@
#include "modules/gridmap/grid_map.h"
#endif // MODULE_GRIDMAP_ENABLED
+// FIXME: Hardcoded to avoid editor dependency.
+#define GLTF_IMPORT_USE_NAMED_SKIN_BINDS 16
+
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
@@ -2907,6 +2909,13 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
}
array_copy = blend_surface_tool->commit_to_arrays();
+ // Enforce blend shape mask array format
+ for (int l = 0; l < Mesh::ARRAY_MAX; l++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << l))) {
+ array_copy[l] = Variant();
+ }
+ }
+
morphs.push_back(array_copy);
}
}
@@ -5741,7 +5750,7 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> state, Node *scen
}
template <class T>
-struct EditorSceneFormatImporterGLTFInterpolate {
+struct SceneFormatImporterGLTFInterpolate {
T lerp(const T &a, const T &b, float c) const {
return a + (b - a) * c;
}
@@ -5767,7 +5776,7 @@ struct EditorSceneFormatImporterGLTFInterpolate {
// thank you for existing, partial specialization
template <>
-struct EditorSceneFormatImporterGLTFInterpolate<Quaternion> {
+struct SceneFormatImporterGLTFInterpolate<Quaternion> {
Quaternion lerp(const Quaternion &a, const Quaternion &b, const float c) const {
ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quaternion(), "The quaternion \"a\" must be normalized.");
ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quaternion(), "The quaternion \"b\" must be normalized.");
@@ -5806,7 +5815,7 @@ T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T
idx++;
}
- EditorSceneFormatImporterGLTFInterpolate<T> interp;
+ SceneFormatImporterGLTFInterpolate<T> interp;
switch (p_interp) {
case GLTFAnimation::INTERP_LINEAR: {
@@ -6899,7 +6908,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> state, uint32_t p_flags, int32_t p_bake_fps) {
ERR_FAIL_COND_V(state.is_null(), FAILED);
state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
_convert_scene_node(state, p_node, -1, -1);
if (!state->buffers.size()) {
@@ -6919,7 +6928,7 @@ Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_pa
// TODO Add missing texture and missing .bin file paths to r_missing_deps 2021-09-10 fire
Error err = FAILED;
state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
FileAccessMemory *file_access = memnew(FileAccessMemory);
file_access->open_custom(p_bytes.ptr(), p_bytes.size());
err = _parse(state, p_base_path.get_base_dir(), file_access, p_bake_fps);
@@ -7022,7 +7031,7 @@ Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint
}
r_state->filename = p_path.get_file().get_basename();
r_state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
diff --git a/modules/gltf/gltf_mesh.h b/modules/gltf/gltf_mesh.h
index aeab1ad68f..4a0533933a 100644
--- a/modules/gltf/gltf_mesh.h
+++ b/modules/gltf/gltf_mesh.h
@@ -32,7 +32,6 @@
#define GLTF_MESH_H
#include "core/io/resource.h"
-#include "editor/import/resource_importer_scene.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/resources/importer_mesh.h"
#include "scene/resources/mesh.h"
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index 6ab202096d..ef30628dbb 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -30,9 +30,8 @@
#include "register_types.h"
-#include "editor/editor_node.h"
-#include "editor_scene_exporter_gltf_plugin.h"
-#include "editor_scene_importer_gltf.h"
+#ifndef _3D_DISABLED
+
#include "gltf_accessor.h"
#include "gltf_animation.h"
#include "gltf_buffer_view.h"
@@ -49,18 +48,19 @@
#include "gltf_state.h"
#include "gltf_texture.h"
-#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
+#include "editor/editor_scene_exporter_gltf_plugin.h"
+#include "editor/editor_scene_importer_gltf.h"
+
static void _editor_init() {
Ref<EditorSceneFormatImporterGLTF> import_gltf;
import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
}
#endif
-#endif
void register_gltf_types() {
-#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
@@ -84,8 +84,9 @@ void register_gltf_types() {
GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
GDREGISTER_CLASS(GLTFDocumentExtension);
GDREGISTER_CLASS(GLTFDocument);
-#endif
}
void unregister_gltf_types() {
}
+
+#endif // _3D_DISABLED