summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_import_collada.cpp4
-rw-r--r--editor/import/editor_importer_bake_reset.cpp17
-rw-r--r--editor/import/resource_importer_scene.cpp25
3 files changed, 21 insertions, 25 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index b615c73422..54b93edcdd 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1414,7 +1414,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
//animation->set_loop(true);
//create animation tracks
- Vector<float> base_snapshots;
+ Vector<real_t> base_snapshots;
float f = 0;
float snapshot_interval = 1.0 / bake_fps; //should be customizable somewhere...
@@ -1466,7 +1466,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
animation->track_set_path(track, path);
animation->track_set_imported(track, true); //helps merging later
- Vector<float> snapshots = base_snapshots;
+ Vector<real_t> snapshots = base_snapshots;
if (nm.anim_tracks.size() == 1) {
//use snapshot keys from anim track instead, because this was most likely exported baked
diff --git a/editor/import/editor_importer_bake_reset.cpp b/editor/import/editor_importer_bake_reset.cpp
index 939c47faa4..00dce6850e 100644
--- a/editor/import/editor_importer_bake_reset.cpp
+++ b/editor/import/editor_importer_bake_reset.cpp
@@ -30,6 +30,7 @@
#include "editor/import/editor_importer_bake_reset.h"
+#include "core/error/error_list.h"
#include "core/error/error_macros.h"
#include "core/math/transform_3d.h"
#include "editor/import/scene_importer_mesh_node_3d.h"
@@ -151,13 +152,20 @@ void BakeReset::_align_animations(AnimationPlayer *p_ap, const Map<StringName, B
}
void BakeReset::_fetch_reset_animation(AnimationPlayer *p_ap, Map<StringName, BakeResetRestBone> &r_rest_bones, const String &p_bake_anim) {
- ERR_FAIL_NULL(p_ap);
+ if (!p_ap) {
+ return;
+ }
List<StringName> anim_names;
p_ap->get_animation_list(&anim_names);
Node *root = p_ap->get_owner();
ERR_FAIL_NULL(root);
+ if (!p_ap->has_animation(p_bake_anim)) {
+ return;
+ }
Ref<Animation> a = p_ap->get_animation(p_bake_anim);
- ERR_FAIL_NULL(a);
+ if (a.is_null()) {
+ return;
+ }
for (int32_t track = 0; track < a->get_track_count(); track++) {
NodePath path = a->track_get_path(track);
String string_path = path;
@@ -171,7 +179,10 @@ void BakeReset::_fetch_reset_animation(AnimationPlayer *p_ap, Map<StringName, Ba
Quaternion rot;
Vector3 scale;
Error err = a->transform_track_get_key(track, key_i, &loc, &rot, &scale);
- ERR_CONTINUE(err);
+ if (err != OK) {
+ ERR_PRINT_ONCE("Reset animation baker can't get key.");
+ continue;
+ }
rot.normalize();
Basis rot_basis = Basis(rot, scale);
BakeResetRestBone rest_bone;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 1e642462dc..50aae6c434 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -234,21 +234,6 @@ static String _fixstr(const String &p_what, const String &p_str) {
return what;
}
-static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) {
- ERR_FAIL_NULL_MSG(mesh, "Cannot generate shape list with null mesh value");
- if (!p_convex) {
- Ref<Shape3D> shape = mesh->create_trimesh_shape();
- r_shape_list.push_back(shape);
- } else {
- Vector<Ref<Shape3D>> cd = mesh->convex_decompose();
- if (cd.size()) {
- for (int i = 0; i < cd.size(); i++) {
- r_shape_list.push_back(cd[i]);
- }
- }
- }
-}
-
static void _pre_gen_shape_list(const Ref<EditorSceneImporterMesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) {
ERR_FAIL_NULL_MSG(mesh, "Cannot generate shape list with null mesh value");
if (!p_convex) {
@@ -426,7 +411,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else {
- _gen_shape_list(mesh, shapes, true);
+ _pre_gen_shape_list(mesh, shapes, true);
}
RigidBody3D *rigid_body = memnew(RigidBody3D);
@@ -452,10 +437,10 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else if (_teststr(name, "col")) {
- _gen_shape_list(mesh, shapes, false);
+ _pre_gen_shape_list(mesh, shapes, false);
collision_map[mesh] = shapes;
} else if (_teststr(name, "convcol")) {
- _gen_shape_list(mesh, shapes, true);
+ _pre_gen_shape_list(mesh, shapes, true);
collision_map[mesh] = shapes;
}
@@ -510,11 +495,11 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else if (_teststr(mesh->get_name(), "col")) {
- _gen_shape_list(mesh, shapes, false);
+ _pre_gen_shape_list(mesh, shapes, false);
collision_map[mesh] = shapes;
mesh->set_name(_fixstr(mesh->get_name(), "col"));
} else if (_teststr(mesh->get_name(), "convcol")) {
- _gen_shape_list(mesh, shapes, true);
+ _pre_gen_shape_list(mesh, shapes, true);
collision_map[mesh] = shapes;
mesh->set_name(_fixstr(mesh->get_name(), "convcol"));
}