summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/resource.cpp2
-rw-r--r--doc/classes/EditorSceneFormatImporter.xml1
-rw-r--r--editor/animation_track_editor.cpp4
-rw-r--r--editor/editor_autoload_settings.cpp8
-rw-r--r--editor/editor_feature_profile.cpp8
-rw-r--r--editor/editor_file_system.cpp7
-rw-r--r--editor/editor_inspector.cpp8
-rw-r--r--editor/editor_node.cpp11
-rw-r--r--editor/editor_properties_array_dict.cpp2
-rw-r--r--editor/import/editor_import_collada.cpp6
-rw-r--r--editor/import/editor_import_collada.h2
-rw-r--r--editor/import/resource_importer_obj.cpp2
-rw-r--r--editor/import/resource_importer_obj.h2
-rw-r--r--editor/import/resource_importer_scene.cpp24
-rw-r--r--editor/import/resource_importer_scene.h10
-rw-r--r--modules/gltf/doc_classes/GLTFDocument.xml8
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp2
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp6
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.h2
-rw-r--r--modules/gltf/editor/editor_scene_importer_fbx.cpp6
-rw-r--r--modules/gltf/editor/editor_scene_importer_fbx.h2
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp6
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.h2
-rw-r--r--modules/gltf/gltf_document.cpp110
-rw-r--r--modules/gltf/gltf_document.h14
-rw-r--r--platform/ios/app_delegate.mm9
-rw-r--r--platform/ios/godot_ios.mm8
-rw-r--r--platform/ios/os_ios.h5
-rw-r--r--platform/ios/os_ios.mm32
29 files changed, 164 insertions, 145 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index ab30fb1ca3..be75ad7e25 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -436,7 +436,7 @@ void Resource::_bind_methods() {
ADD_GROUP("Resource", "resource_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_path", "get_path");
- ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "resource_name"), "set_name", "get_name");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_name"), "set_name", "get_name");
MethodInfo get_rid_bind("_get_rid");
get_rid_bind.return_val.type = Variant::RID;
diff --git a/doc/classes/EditorSceneFormatImporter.xml b/doc/classes/EditorSceneFormatImporter.xml
index 6de9c2c5dc..db93cab14c 100644
--- a/doc/classes/EditorSceneFormatImporter.xml
+++ b/doc/classes/EditorSceneFormatImporter.xml
@@ -39,7 +39,6 @@
<param index="0" name="path" type="String" />
<param index="1" name="flags" type="int" />
<param index="2" name="options" type="Dictionary" />
- <param index="3" name="bake_fps" type="int" />
<description>
</description>
</method>
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 9a628d8794..7c403b7523 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1754,7 +1754,9 @@ void AnimationTimelineEdit::update_values() {
length->set_step(1);
length->set_tooltip_text(TTR("Animation length (frames)"));
time_icon->set_tooltip_text(TTR("Animation length (frames)"));
- track_edit->editor->_update_key_edit();
+ if (track_edit) {
+ track_edit->editor->_update_key_edit();
+ }
} else {
length->set_value(animation->get_length());
length->set_step(0.001);
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 8cb1dfd24e..41b3d45a1f 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -541,8 +541,6 @@ void EditorAutoloadSettings::update_autoload() {
info.node->queue_free();
info.node = nullptr;
}
-
- ProjectSettings::get_singleton()->remove_autoload(info.name);
}
// Load new/changed autoloads
@@ -567,12 +565,6 @@ void EditorAutoloadSettings::update_autoload() {
}
}
- ProjectSettings::AutoloadInfo prop_info;
- prop_info.name = info->name;
- prop_info.path = info->path;
- prop_info.is_singleton = info->is_singleton;
- ProjectSettings::get_singleton()->add_autoload(prop_info);
-
if (!info->in_editor && !info->is_singleton) {
// No reason to keep this node
memdelete(info->node);
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp
index 49fb16a095..7080cdbdd5 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -309,7 +309,11 @@ void EditorFeatureProfile::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_MAX);
}
-EditorFeatureProfile::EditorFeatureProfile() {}
+EditorFeatureProfile::EditorFeatureProfile() {
+ for (int i = 0; i < FEATURE_MAX; i++) {
+ features_disabled[i] = false;
+ }
+}
//////////////////////////
@@ -746,6 +750,8 @@ void EditorFeatureProfileManager::_update_selected_profile() {
class_list->clear();
String profile = _get_selected_profile();
+ profile_actions[PROFILE_SET]->set_disabled(profile == current_profile);
+
if (profile.is_empty()) { //nothing selected, nothing edited
property_list->clear();
edited.unref();
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index a261fc0f33..5d137ce290 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -620,7 +620,12 @@ bool EditorFileSystem::_update_scan_actions() {
if (_test_for_reimport(full_path, false)) {
//must reimport
reimports.push_back(full_path);
- reimports.append_array(_get_dependencies(full_path));
+ Vector<String> dependencies = _get_dependencies(full_path);
+ for (const String &dependency_path : dependencies) {
+ if (import_extensions.has(dependency_path.get_extension())) {
+ reimports.push_back(dependency_path);
+ }
+ }
} else {
//must not reimport, all was good
//update modified times, to avoid reimport
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 0457dc81ff..a5397a8e6a 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -660,6 +660,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
}
if (keying_rect.has_point(mpos)) {
+ accept_event();
emit_signal(SNAME("property_keyed"), property, use_keying_next());
if (use_keying_next()) {
@@ -683,10 +684,12 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
}
}
if (delete_rect.has_point(mpos)) {
+ accept_event();
emit_signal(SNAME("property_deleted"), property);
}
if (revert_rect.has_point(mpos)) {
+ accept_event();
bool is_valid_revert = false;
Variant revert_value = EditorPropertyRevert::get_property_revert_value(object, property, &is_valid_revert);
ERR_FAIL_COND(!is_valid_revert);
@@ -695,11 +698,13 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
}
if (check_rect.has_point(mpos)) {
+ accept_event();
checked = !checked;
queue_redraw();
emit_signal(SNAME("property_checked"), property, checked);
}
} else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
+ accept_event();
_update_popup();
menu->set_position(get_screen_position() + get_local_mouse_position());
menu->reset_size();
@@ -1482,6 +1487,8 @@ void EditorInspectorSection::gui_input(const Ref<InputEvent> &p_event) {
return;
}
+ accept_event();
+
bool should_unfold = !object->editor_is_section_unfolded(section);
if (should_unfold) {
unfold();
@@ -1680,6 +1687,7 @@ void EditorInspectorArray::_panel_gui_input(Ref<InputEvent> p_event, int p_index
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
if (movable && mb->get_button_index() == MouseButton::RIGHT) {
+ array_elements[p_index].panel->accept_event();
popup_array_index_pressed = begin_array_index + p_index;
rmb_popup->set_item_disabled(OPTION_MOVE_UP, popup_array_index_pressed == 0);
rmb_popup->set_item_disabled(OPTION_MOVE_DOWN, popup_array_index_pressed == count - 1);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 961a8ab271..d00a64f796 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3356,7 +3356,9 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) {
- for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
+ // Remove the main editor button and update the bindings of
+ // all buttons behind it to point to the correct main window.
+ for (int i = singleton->main_editor_buttons.size() - 1; i >= 0; i--) {
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->editor_select(EDITOR_SCRIPT);
@@ -3366,6 +3368,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
singleton->main_editor_buttons.remove_at(i);
break;
+ } else {
+ singleton->main_editor_buttons[i]->disconnect("pressed", callable_mp(singleton, &EditorNode::editor_select));
+ singleton->main_editor_buttons[i]->connect("pressed", callable_mp(singleton, &EditorNode::editor_select).bind(i - 1));
}
}
@@ -5877,10 +5882,6 @@ void EditorNode::_feature_profile_changed() {
node_tabs->set_tab_hidden(node_tabs->get_tab_idx_from_control(NodeDock::get_singleton()), false);
fs_tabs->set_tab_hidden(fs_tabs->get_tab_idx_from_control(FileSystemDock::get_singleton()), false);
history_tabs->set_tab_hidden(history_tabs->get_tab_idx_from_control(history_dock), false);
- history_dock->set_visible(true);
- ImportDock::get_singleton()->set_visible(true);
- NodeDock::get_singleton()->set_visible(true);
- FileSystemDock::get_singleton()->set_visible(true);
main_editor_buttons[EDITOR_3D]->set_visible(true);
main_editor_buttons[EDITOR_SCRIPT]->set_visible(true);
if (AssetLibraryEditorPlugin::is_available()) {
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index d881444849..edda6c5d7b 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -693,6 +693,8 @@ void EditorPropertyArray::_reorder_button_up() {
reorder_mouse_y_delta = 0.0f;
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
+
+ ERR_FAIL_NULL(reorder_selected_button);
reorder_selected_button->warp_mouse(reorder_selected_button->get_size() / 2.0f);
reorder_selected_element_hbox = nullptr;
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 6890a46193..c335655d4e 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -65,7 +65,7 @@ struct ColladaImport {
bool force_make_tangents = false;
bool apply_mesh_xform_to_vertices = true;
bool use_mesh_builtin_materials = false;
- float bake_fps = 15;
+ float bake_fps = 30;
HashMap<String, NodeMap> node_map; //map from collada node to engine node
HashMap<String, String> node_name_map; //map from collada node to engine node
@@ -1760,7 +1760,7 @@ void EditorSceneFormatImporterCollada::get_extensions(List<String> *r_extensions
r_extensions->push_back("dae");
}
-Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err) {
if (r_err) {
*r_err = OK;
}
@@ -1771,7 +1771,7 @@ Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint3
}
state.use_mesh_builtin_materials = true;
- state.bake_fps = p_bake_fps;
+ state.bake_fps = (float)p_options["animation/fps"];
Error err = state.load(p_path, flags, p_flags & EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, false);
diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h
index a75b0a903f..ec30c91c1b 100644
--- a/editor/import/editor_import_collada.h
+++ b/editor/import/editor_import_collada.h
@@ -39,7 +39,7 @@ class EditorSceneFormatImporterCollada : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr) override;
EditorSceneFormatImporterCollada();
};
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index fe70fd58b5..f19b4dbe56 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -422,7 +422,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
return OK;
}
-Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err) {
List<Ref<Mesh>> meshes;
Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, false, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps);
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 4dfac90fa1..121d8e6d36 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -39,7 +39,7 @@ class EditorOBJImporter : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr) override;
EditorOBJImporter();
};
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index ffe6954484..a9ce6e9f88 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -74,13 +74,13 @@ void EditorSceneFormatImporter::get_extensions(List<String> *r_extensions) const
ERR_FAIL();
}
-Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporter::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err) {
Dictionary options_dict;
for (const KeyValue<StringName, Variant> &elem : p_options) {
options_dict[elem.key] = elem.value;
}
Object *ret = nullptr;
- if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, options_dict, p_bake_fps, ret)) {
+ if (GDVIRTUAL_CALL(_import_scene, p_path, p_flags, options_dict, ret)) {
return Object::cast_to<Node>(ret);
}
@@ -100,7 +100,7 @@ Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, b
void EditorSceneFormatImporter::_bind_methods() {
GDVIRTUAL_BIND(_get_import_flags);
GDVIRTUAL_BIND(_get_extensions);
- GDVIRTUAL_BIND(_import_scene, "path", "flags", "options", "bake_fps");
+ GDVIRTUAL_BIND(_import_scene, "path", "flags", "options");
GDVIRTUAL_BIND(_get_import_options, "path");
GDVIRTUAL_BIND(_get_option_visibility, "path", "for_animation", "option");
@@ -1864,6 +1864,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "skins/use_named_skins"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 30));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/trimming"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "import_script/path", PROPERTY_HINT_FILE, script_ext_hint), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "_subresources", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), Dictionary()));
@@ -2281,13 +2282,8 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashM
ERR_FAIL_COND_V(!importer.is_valid(), nullptr);
- int bake_fps = 30;
- if (p_options.has(SNAME("animation/fps"))) {
- bake_fps = p_options[SNAME("animation/fps")];
- }
-
Error err = OK;
- Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_options, bake_fps, nullptr, &err);
+ Node *scene = importer->import_scene(p_source_file, EditorSceneFormatImporter::IMPORT_ANIMATION | EditorSceneFormatImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_options, nullptr, &err);
if (!scene || err != OK) {
return nullptr;
}
@@ -2326,8 +2322,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
ERR_FAIL_COND_V(!importer.is_valid(), ERR_FILE_UNRECOGNIZED);
- float fps = p_options["animation/fps"];
-
int import_flags = 0;
if (animation_importer) {
@@ -2350,7 +2344,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Error err = OK;
List<String> missing_deps; // for now, not much will be done with this
- Node *scene = importer->import_scene(src_path, import_flags, p_options, fps, &missing_deps, &err);
+ Node *scene = importer->import_scene(src_path, import_flags, p_options, &missing_deps, &err);
if (!scene || err != OK) {
return err;
}
@@ -2398,6 +2392,10 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
post_importer_plugins.write[i]->pre_process(scene, p_options);
}
+ float fps = 30;
+ if (p_options.has(SNAME("animation/fps"))) {
+ fps = (float)p_options[SNAME("animation/fps")];
+ }
_pre_fix_animations(scene, scene, node_data, animation_data, fps);
_post_fix_node(scene, scene, collision_map, occluder_arrays, scanned_meshes, node_data, material_data, animation_data, fps);
_post_fix_animations(scene, scene, node_data, animation_data, fps);
@@ -2612,7 +2610,7 @@ void EditorSceneFormatImporterESCN::get_extensions(List<String> *r_extensions) c
r_extensions->push_back("escn");
}
-Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) {
+Node *EditorSceneFormatImporterESCN::import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err) {
Error error;
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 5f64330453..678251372b 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -53,12 +53,12 @@ class EditorSceneFormatImporter : public RefCounted {
protected:
static void _bind_methods();
- Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options, int p_bake_fps);
- Ref<Animation> import_animation_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options, int p_bake_fps);
+ Node *import_scene_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options);
+ Ref<Animation> import_animation_wrapper(const String &p_path, uint32_t p_flags, Dictionary p_options);
GDVIRTUAL0RC(int, _get_import_flags)
GDVIRTUAL0RC(Vector<String>, _get_extensions)
- GDVIRTUAL4R(Object *, _import_scene, String, uint32_t, Dictionary, uint32_t)
+ GDVIRTUAL3R(Object *, _import_scene, String, uint32_t, Dictionary)
GDVIRTUAL1(_get_import_options, String)
GDVIRTUAL3RC(Variant, _get_option_visibility, String, bool, String)
@@ -74,7 +74,7 @@ public:
virtual uint32_t get_import_flags() const;
virtual void get_extensions(List<String> *r_extensions) const;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr);
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option, const HashMap<StringName, Variant> &p_options);
@@ -310,7 +310,7 @@ class EditorSceneFormatImporterESCN : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags, const HashMap<StringName, Variant> &p_options, List<String> *r_missing_deps, Error *r_err = nullptr) override;
};
template <class M>
diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml
index 588015de62..f313f4b28f 100644
--- a/modules/gltf/doc_classes/GLTFDocument.xml
+++ b/modules/gltf/doc_classes/GLTFDocument.xml
@@ -14,7 +14,6 @@
<param index="1" name="base_path" type="String" />
<param index="2" name="state" type="GLTFState" />
<param index="3" name="flags" type="int" default="0" />
- <param index="4" name="bake_fps" type="int" default="30" />
<description>
Takes a [PackedByteArray] defining a gLTF and returns a [GLTFState] object through the [param state] parameter.
[b]Note:[/b] The [param base_path] tells [method append_from_buffer] where to find dependencies and can be empty.
@@ -25,8 +24,7 @@
<param index="0" name="path" type="String" />
<param index="1" name="state" type="GLTFState" />
<param index="2" name="flags" type="int" default="0" />
- <param index="3" name="bake_fps" type="int" default="30" />
- <param index="4" name="base_path" type="String" default="&quot;&quot;" />
+ <param index="3" name="base_path" type="String" default="&quot;&quot;" />
<description>
Takes a path to a gLTF file and returns a [GLTFState] object through the [param state] parameter.
[b]Note:[/b] The [param base_path] tells [method append_from_file] where to find dependencies and can be empty.
@@ -37,7 +35,6 @@
<param index="0" name="node" type="Node" />
<param index="1" name="state" type="GLTFState" />
<param index="2" name="flags" type="int" default="0" />
- <param index="3" name="bake_fps" type="int" default="30" />
<description>
Takes a Godot Engine scene node and returns a [GLTFState] object through the [param state] parameter.
</description>
@@ -52,7 +49,8 @@
<method name="generate_scene">
<return type="Node" />
<param index="0" name="state" type="GLTFState" />
- <param index="1" name="bake_fps" type="int" default="30" />
+ <param index="1" name="bake_fps" type="float" default="30" />
+ <param index="2" name="trimming" type="bool" default="false" />
<description>
Takes a [GLTFState] object through the [param state] parameter and returns a Godot Engine scene node.
</description>
diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
index 95db1c0965..0c0b134bd1 100644
--- a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
@@ -85,7 +85,7 @@ void SceneExporterGLTFPlugin::_gltf2_dialog_action(String p_file) {
state.instantiate();
int32_t flags = 0;
flags |= EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
- Error err = doc->append_from_scene(root, state, flags, 30.0f);
+ Error err = doc->append_from_scene(root, state, flags);
if (err != OK) {
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
}
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
index f0f642dd72..7007ea5d13 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.cpp
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -59,7 +59,7 @@ void EditorSceneFormatImporterBlend::get_extensions(List<String> *r_extensions)
}
Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) {
// Get global paths for source and sink.
@@ -228,14 +228,14 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
if (p_options.has(SNAME("blender/materials/unpack_enabled")) && p_options[SNAME("blender/materials/unpack_enabled")]) {
base_dir = sink.get_base_dir();
}
- Error err = gltf->append_from_file(sink.get_basename() + ".gltf", state, p_flags, p_bake_fps, base_dir);
+ Error err = gltf->append_from_file(sink.get_basename() + ".gltf", state, p_flags, base_dir);
if (err != OK) {
if (r_err) {
*r_err = FAILED;
}
return nullptr;
}
- return gltf->generate_scene(state, p_bake_fps);
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
}
Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,
diff --git a/modules/gltf/editor/editor_scene_importer_blend.h b/modules/gltf/editor/editor_scene_importer_blend.h
index a1485ff82e..fe687f19fc 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.h
+++ b/modules/gltf/editor/editor_scene_importer_blend.h
@@ -66,7 +66,7 @@ public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override;
diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp
index 017a44cccf..14f2117413 100644
--- a/modules/gltf/editor/editor_scene_importer_fbx.cpp
+++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp
@@ -49,7 +49,7 @@ void EditorSceneFormatImporterFBX::get_extensions(List<String> *r_extensions) co
}
Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) {
// Get global paths for source and sink.
@@ -95,14 +95,14 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
Ref<GLTFState> state;
state.instantiate();
print_verbose(vformat("glTF path: %s", sink));
- Error err = gltf->append_from_file(sink, state, p_flags, p_bake_fps);
+ Error err = gltf->append_from_file(sink, state, p_flags);
if (err != OK) {
if (r_err) {
*r_err = FAILED;
}
return nullptr;
}
- return gltf->generate_scene(state, p_bake_fps);
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
}
Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, bool p_for_animation,
diff --git a/modules/gltf/editor/editor_scene_importer_fbx.h b/modules/gltf/editor/editor_scene_importer_fbx.h
index b0039b1c8f..6bf9f3e033 100644
--- a/modules/gltf/editor/editor_scene_importer_fbx.h
+++ b/modules/gltf/editor/editor_scene_importer_fbx.h
@@ -45,7 +45,7 @@ public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err = nullptr) override;
virtual void get_import_options(const String &p_path,
List<ResourceImporter::ImportOption> *r_options) override;
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index 161808aade..3cf49a3046 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -47,13 +47,13 @@ void EditorSceneFormatImporterGLTF::get_extensions(List<String> *r_extensions) c
}
Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) {
Ref<GLTFDocument> doc;
doc.instantiate();
Ref<GLTFState> state;
state.instantiate();
- Error err = doc->append_from_file(p_path, state, p_flags, p_bake_fps);
+ Error err = doc->append_from_file(p_path, state, p_flags);
if (err != OK) {
if (r_err) {
*r_err = err;
@@ -63,7 +63,7 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
if (p_options.has("animation/import")) {
state->set_create_animations(bool(p_options["animation/import"]));
}
- return doc->generate_scene(state, p_bake_fps);
+ return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
}
#endif // TOOLS_ENABLED
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h
index edca038532..c0582b26c1 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor/editor_scene_importer_gltf.h
@@ -45,7 +45,7 @@ public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
- const HashMap<StringName, Variant> &p_options, int p_bake_fps,
+ const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err = nullptr) override;
};
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index eb8f7e5ebc..735e35ac1e 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -5860,7 +5860,7 @@ T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T
ERR_FAIL_V(p_values[0]);
}
-void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps) {
+void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap, const GLTFAnimationIndex index, const float bake_fps, const bool trimming) {
Ref<GLTFAnimation> anim = state->animations[index];
String anim_name = anim->get_name();
@@ -5877,7 +5877,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
animation->set_loop_mode(Animation::LOOP_LINEAR);
}
- float length = 0.0;
+ double anim_start = trimming ? INFINITY : 0.0;
+ double anim_end = 0.0;
for (const KeyValue<int, GLTFAnimation::Track> &track_i : anim->get_tracks()) {
const GLTFAnimation::Track &track = track_i.value;
@@ -5907,19 +5908,40 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
transform_node_path = node_path;
}
- for (int i = 0; i < track.rotation_track.times.size(); i++) {
- length = MAX(length, track.rotation_track.times[i]);
- }
- for (int i = 0; i < track.position_track.times.size(); i++) {
- length = MAX(length, track.position_track.times[i]);
- }
- for (int i = 0; i < track.scale_track.times.size(); i++) {
- length = MAX(length, track.scale_track.times[i]);
- }
-
- for (int i = 0; i < track.weight_tracks.size(); i++) {
- for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
- length = MAX(length, track.weight_tracks[i].times[j]);
+ if (trimming) {
+ for (int i = 0; i < track.rotation_track.times.size(); i++) {
+ anim_start = MIN(anim_start, track.rotation_track.times[i]);
+ anim_end = MAX(anim_end, track.rotation_track.times[i]);
+ }
+ for (int i = 0; i < track.position_track.times.size(); i++) {
+ anim_start = MIN(anim_start, track.position_track.times[i]);
+ anim_end = MAX(anim_end, track.position_track.times[i]);
+ }
+ for (int i = 0; i < track.scale_track.times.size(); i++) {
+ anim_start = MIN(anim_start, track.scale_track.times[i]);
+ anim_end = MAX(anim_end, track.scale_track.times[i]);
+ }
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ anim_start = MIN(anim_start, track.weight_tracks[i].times[j]);
+ anim_end = MAX(anim_end, track.weight_tracks[i].times[j]);
+ }
+ }
+ } else {
+ // If you don't use trimming and the first key time is not at 0.0, fake keys will be inserted.
+ for (int i = 0; i < track.rotation_track.times.size(); i++) {
+ anim_end = MAX(anim_end, track.rotation_track.times[i]);
+ }
+ for (int i = 0; i < track.position_track.times.size(); i++) {
+ anim_end = MAX(anim_end, track.position_track.times[i]);
+ }
+ for (int i = 0; i < track.scale_track.times.size(); i++) {
+ anim_end = MAX(anim_end, track.scale_track.times[i]);
+ }
+ for (int i = 0; i < track.weight_tracks.size(); i++) {
+ for (int j = 0; j < track.weight_tracks[i].times.size(); j++) {
+ anim_end = MAX(anim_end, track.weight_tracks[i].times[j]);
+ }
}
}
@@ -5988,10 +6010,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
}
}
- //first determine animation length
-
const double increment = 1.0 / bake_fps;
- double time = 0.0;
+ double time = anim_start;
Vector3 base_pos;
Quaternion base_rot;
@@ -6017,26 +6037,26 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
if (position_idx >= 0) {
pos = _interpolate_track<Vector3>(track.position_track.times, track.position_track.values, time, track.position_track.interpolation);
- animation->position_track_insert_key(position_idx, time, pos);
+ animation->position_track_insert_key(position_idx, time - anim_start, pos);
}
if (rotation_idx >= 0) {
rot = _interpolate_track<Quaternion>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation);
- animation->rotation_track_insert_key(rotation_idx, time, rot);
+ animation->rotation_track_insert_key(rotation_idx, time - anim_start, rot);
}
if (scale_idx >= 0) {
scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation);
- animation->scale_track_insert_key(scale_idx, time, scale);
+ animation->scale_track_insert_key(scale_idx, time - anim_start, scale);
}
if (last) {
break;
}
time += increment;
- if (time >= length) {
+ if (time >= anim_end) {
last = true;
- time = length;
+ time = anim_end;
}
}
}
@@ -6071,21 +6091,21 @@ void GLTFDocument::_import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
bool last = false;
while (true) {
real_t blend = _interpolate_track<real_t>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, gltf_interp);
- animation->blend_shape_track_insert_key(track_idx, time, blend);
+ animation->blend_shape_track_insert_key(track_idx, time - anim_start, blend);
if (last) {
break;
}
time += increment;
- if (time >= length) {
+ if (time >= anim_end) {
last = true;
- time = length;
+ time = anim_end;
}
}
}
}
}
- animation->set_length(length);
+ animation->set_length(anim_end - anim_start);
Ref<AnimationLibrary> library;
if (!ap->has_animation_library("")) {
@@ -6585,7 +6605,7 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
}
}
-Error GLTFDocument::_parse(Ref<GLTFState> state, String p_path, Ref<FileAccess> f, int p_bake_fps) {
+Error GLTFDocument::_parse(Ref<GLTFState> state, String p_path, Ref<FileAccess> f) {
Error err;
if (f.is_null()) {
return FAILED;
@@ -6636,7 +6656,7 @@ Error GLTFDocument::_parse(Ref<GLTFState> state, String p_path, Ref<FileAccess>
}
}
- err = _parse_gltf_state(state, p_path, p_bake_fps);
+ err = _parse_gltf_state(state, p_path);
ERR_FAIL_COND_V(err != OK, err);
return OK;
@@ -6754,14 +6774,14 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
}
void GLTFDocument::_bind_methods() {
- ClassDB::bind_method(D_METHOD("append_from_file", "path", "state", "flags", "bake_fps", "base_path"),
- &GLTFDocument::append_from_file, DEFVAL(0), DEFVAL(30), DEFVAL(String()));
- ClassDB::bind_method(D_METHOD("append_from_buffer", "bytes", "base_path", "state", "flags", "bake_fps"),
- &GLTFDocument::append_from_buffer, DEFVAL(0), DEFVAL(30));
- ClassDB::bind_method(D_METHOD("append_from_scene", "node", "state", "flags", "bake_fps"),
- &GLTFDocument::append_from_scene, DEFVAL(0), DEFVAL(30));
- ClassDB::bind_method(D_METHOD("generate_scene", "state", "bake_fps"),
- &GLTFDocument::generate_scene, DEFVAL(30));
+ ClassDB::bind_method(D_METHOD("append_from_file", "path", "state", "flags", "base_path"),
+ &GLTFDocument::append_from_file, DEFVAL(0), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("append_from_buffer", "bytes", "base_path", "state", "flags"),
+ &GLTFDocument::append_from_buffer, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("append_from_scene", "node", "state", "flags"),
+ &GLTFDocument::append_from_scene, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("generate_scene", "state", "bake_fps", "trimming"),
+ &GLTFDocument::generate_scene, DEFVAL(30), DEFVAL(false));
ClassDB::bind_method(D_METHOD("generate_buffer", "state"),
&GLTFDocument::generate_buffer);
ClassDB::bind_method(D_METHOD("write_to_filesystem", "state", "path"),
@@ -6870,7 +6890,7 @@ Error GLTFDocument::write_to_filesystem(Ref<GLTFState> state, const String &p_pa
return OK;
}
-Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
+Node *GLTFDocument::generate_scene(Ref<GLTFState> state, float p_bake_fps, bool p_trimming) {
ERR_FAIL_NULL_V(state, nullptr);
ERR_FAIL_INDEX_V(0, state->root_nodes.size(), nullptr);
Error err = OK;
@@ -6884,7 +6904,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
root->add_child(ap, true);
ap->set_owner(root);
for (int i = 0; i < state->animations.size(); i++) {
- _import_animation(state, ap, i, p_bake_fps);
+ _import_animation(state, ap, i, p_bake_fps, p_trimming);
}
}
for (KeyValue<GLTFNodeIndex, Node *> E : state->scene_nodes) {
@@ -6910,7 +6930,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
return root;
}
-Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> state, uint32_t p_flags, int32_t p_bake_fps) {
+Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> state, uint32_t p_flags) {
ERR_FAIL_COND_V(state.is_null(), FAILED);
state->use_named_skin_binds = p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
state->discard_meshes_and_materials = p_flags & GLTF_IMPORT_DISCARD_MESHES_AND_MATERIALS;
@@ -6930,7 +6950,7 @@ Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> state, uint32
return OK;
}
-Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> state, uint32_t p_flags, int32_t p_bake_fps) {
+Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> state, uint32_t p_flags) {
ERR_FAIL_COND_V(state.is_null(), FAILED);
// TODO Add missing texture and missing .bin file paths to r_missing_deps 2021-09-10 fire
Error err = FAILED;
@@ -6941,7 +6961,7 @@ Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_pa
file_access.instantiate();
file_access->open_custom(p_bytes.ptr(), p_bytes.size());
state->base_path = p_base_path.get_base_dir();
- err = _parse(state, state->base_path, file_access, p_bake_fps);
+ err = _parse(state, state->base_path, file_access);
ERR_FAIL_COND_V(err != OK, err);
for (Ref<GLTFDocumentExtension> ext : document_extensions) {
ERR_CONTINUE(ext.is_null());
@@ -6951,7 +6971,7 @@ Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_pa
return OK;
}
-Error GLTFDocument::_parse_gltf_state(Ref<GLTFState> state, const String &p_search_path, float p_bake_fps) {
+Error GLTFDocument::_parse_gltf_state(Ref<GLTFState> state, const String &p_search_path) {
Error err;
/* PARSE EXTENSIONS */
@@ -7047,7 +7067,7 @@ Error GLTFDocument::_parse_gltf_state(Ref<GLTFState> state, const String &p_sear
return OK;
}
-Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags, int32_t p_bake_fps, String p_base_path) {
+Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags, String p_base_path) {
// TODO Add missing texture and missing .bin file paths to r_missing_deps 2021-09-10 fire
if (r_state == Ref<GLTFState>()) {
r_state.instantiate();
@@ -7064,7 +7084,7 @@ Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint
base_path = p_path.get_base_dir();
}
r_state->base_path = base_path;
- err = _parse(r_state, base_path, f, p_bake_fps);
+ err = _parse(r_state, base_path, f);
ERR_FAIL_COND_V(err != OK, err);
for (Ref<GLTFDocumentExtension> ext : document_extensions) {
ERR_CONTINUE(ext.is_null());
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index 5a0e4ff498..6eb38354a2 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -292,17 +292,17 @@ private:
static float get_max_component(const Color &p_color);
public:
- Error append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30, String p_base_path = String());
- Error append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30);
- Error append_from_scene(Node *p_node, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30);
+ Error append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, String p_base_path = String());
+ Error append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> r_state, uint32_t p_flags = 0);
+ Error append_from_scene(Node *p_node, Ref<GLTFState> r_state, uint32_t p_flags = 0);
public:
- Node *generate_scene(Ref<GLTFState> state, int32_t p_bake_fps = 30.0f);
+ Node *generate_scene(Ref<GLTFState> state, float p_bake_fps = 30.0f, bool p_trimming = false);
PackedByteArray generate_buffer(Ref<GLTFState> state);
Error write_to_filesystem(Ref<GLTFState> state, const String &p_path);
public:
- Error _parse_gltf_state(Ref<GLTFState> state, const String &p_search_path, float p_bake_fps);
+ Error _parse_gltf_state(Ref<GLTFState> state, const String &p_search_path);
Error _parse_gltf_extensions(Ref<GLTFState> state);
void _process_mesh_instances(Ref<GLTFState> state, Node *scene_root);
void _generate_scene_node(Ref<GLTFState> state, Node *scene_parent,
@@ -310,7 +310,7 @@ public:
const GLTFNodeIndex node_index);
void _generate_skeleton_bone_node(Ref<GLTFState> state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
void _import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
- const GLTFAnimationIndex index, const int bake_fps);
+ const GLTFAnimationIndex index, const float bake_fps, const bool trimming);
void _convert_mesh_instances(Ref<GLTFState> state);
GLTFCameraIndex _convert_camera(Ref<GLTFState> state, Camera3D *p_camera);
void _convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Ref<GLTFNode> gltf_node);
@@ -368,7 +368,7 @@ public:
void _convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
String p_animation_track_name);
Error _serialize(Ref<GLTFState> state, const String &p_path);
- Error _parse(Ref<GLTFState> state, String p_path, Ref<FileAccess> f, int p_bake_fps);
+ Error _parse(Ref<GLTFState> state, String p_path, Ref<FileAccess> f);
};
#endif // GLTF_DOCUMENT_H
diff --git a/platform/ios/app_delegate.mm b/platform/ios/app_delegate.mm
index fb183d52d4..3ebd530585 100644
--- a/platform/ios/app_delegate.mm
+++ b/platform/ios/app_delegate.mm
@@ -45,7 +45,7 @@
extern int gargc;
extern char **gargv;
-extern int ios_main(int, char **, String, String);
+extern int ios_main(int, char **);
extern void ios_finish();
@implementation AppDelegate
@@ -66,12 +66,7 @@ static ViewController *mainViewController = nil;
// Create a full-screen window
self.window = [[UIWindow alloc] initWithFrame:windowBounds];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- NSString *cacheDirectory = [paths objectAtIndex:0];
-
- int err = ios_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String]));
+ int err = ios_main(gargc, gargv);
if (err != 0) {
// bail, things did not go very well for us, should probably output a message on screen with our error code...
diff --git a/platform/ios/godot_ios.mm b/platform/ios/godot_ios.mm
index 5f3e786b8a..abe7c59ce2 100644
--- a/platform/ios/godot_ios.mm
+++ b/platform/ios/godot_ios.mm
@@ -38,10 +38,6 @@
static OS_IOS *os = nullptr;
-int add_path(int, char **);
-int add_cmdline(int, char **);
-int ios_main(int, char **, String);
-
int add_path(int p_argc, char **p_args) {
NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
if (!str) {
@@ -74,7 +70,7 @@ int add_cmdline(int p_argc, char **p_args) {
return p_argc;
}
-int ios_main(int argc, char **argv, String data_dir, String cache_dir) {
+int ios_main(int argc, char **argv) {
size_t len = strlen(argv[0]);
while (len--) {
@@ -95,7 +91,7 @@ int ios_main(int argc, char **argv, String data_dir, String cache_dir) {
char cwd[512];
getcwd(cwd, sizeof(cwd));
printf("cwd %s\n", cwd);
- os = new OS_IOS(data_dir, cache_dir);
+ os = new OS_IOS();
// We must override main when testing is enabled
TEST_MAIN_OVERRIDE
diff --git a/platform/ios/os_ios.h b/platform/ios/os_ios.h
index 0c23b216c5..3560de7486 100644
--- a/platform/ios/os_ios.h
+++ b/platform/ios/os_ios.h
@@ -71,9 +71,6 @@ private:
virtual void finalize() override;
- String user_data_dir;
- String cache_dir;
-
bool is_focused = false;
void deinitialize_modules();
@@ -81,7 +78,7 @@ private:
public:
static OS_IOS *get_singleton();
- OS_IOS(String p_data_dir, String p_cache_dir);
+ OS_IOS();
~OS_IOS();
void initialize_modules();
diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm
index 160724618f..9a8cfc2593 100644
--- a/platform/ios/os_ios.mm
+++ b/platform/ios/os_ios.mm
@@ -90,7 +90,7 @@ OS_IOS *OS_IOS::get_singleton() {
return (OS_IOS *)OS::get_singleton();
}
-OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) {
+OS_IOS::OS_IOS() {
for (int i = 0; i < ios_init_callbacks_count; ++i) {
ios_init_callbacks[i]();
}
@@ -101,11 +101,6 @@ OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) {
main_loop = nullptr;
- // can't call set_data_dir from here, since it requires DirAccess
- // which is initialized in initialize_core
- user_data_dir = p_data_dir;
- cache_dir = p_cache_dir;
-
Vector<Logger *> loggers;
loggers.push_back(memnew(SyslogLogger));
#ifdef DEBUG_ENABLED
@@ -272,20 +267,25 @@ Error OS_IOS::shell_open(String p_uri) {
}
String OS_IOS::get_user_data_dir() const {
- static bool user_data_dir_set = false;
- if (user_data_dir_set) {
- String old_dir = user_data_dir;
- Ref<DirAccess> da = DirAccess::open(old_dir);
- const_cast<OS_IOS *>(this)->user_data_dir = da->get_current_dir();
- user_data_dir_set = true;
-
- printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), old_dir.utf8().get_data());
+ static String ret;
+ if (ret.is_empty()) {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ if (paths && [paths count] >= 1) {
+ ret.parse_utf8([[paths firstObject] UTF8String]);
+ }
}
- return user_data_dir;
+ return ret;
}
String OS_IOS::get_cache_path() const {
- return cache_dir;
+ static String ret;
+ if (ret.is_empty()) {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+ if (paths && [paths count] >= 1) {
+ ret.parse_utf8([[paths firstObject] UTF8String]);
+ }
+ }
+ return ret;
}
String OS_IOS::get_locale() const {