Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move animation slice processing to _post_fix_animations #83036

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,38 +961,6 @@ Node *ResourceImporterScene::_pre_fix_animations(Node *p_node, Node *p_root, con
List<StringName> anims;
ap->get_animation_list(&anims);

for (const StringName &name : anims) {
Ref<Animation> anim = ap->get_animation(name);
Array animation_slices;

if (p_animation_data.has(name)) {
Dictionary anim_settings = p_animation_data[name];
int slices_count = anim_settings["slices/amount"];

for (int i = 0; i < slices_count; i++) {
String slice_name = anim_settings["slice_" + itos(i + 1) + "/name"];
int from_frame = anim_settings["slice_" + itos(i + 1) + "/start_frame"];
int end_frame = anim_settings["slice_" + itos(i + 1) + "/end_frame"];
Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)anim_settings["slice_" + itos(i + 1) + "/loop_mode"]);
bool save_to_file = anim_settings["slice_" + itos(i + 1) + "/save_to_file/enabled"];
bool save_to_path = anim_settings["slice_" + itos(i + 1) + "/save_to_file/path"];
bool save_to_file_keep_custom = anim_settings["slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"];

animation_slices.push_back(slice_name);
animation_slices.push_back(from_frame / p_animation_fps);
animation_slices.push_back(end_frame / p_animation_fps);
animation_slices.push_back(loop_mode);
animation_slices.push_back(save_to_file);
animation_slices.push_back(save_to_path);
animation_slices.push_back(save_to_file_keep_custom);
}
}

if (animation_slices.size() > 0) {
_create_slices(ap, anim, animation_slices, true);
}
}

AnimationImportTracks import_tracks_mode[TRACK_CHANNEL_MAX] = {
AnimationImportTracks(int(node_settings["import_tracks/position"])),
AnimationImportTracks(int(node_settings["import_tracks/rotation"])),
Expand Down Expand Up @@ -1059,8 +1027,36 @@ Node *ResourceImporterScene::_post_fix_animations(Node *p_node, Node *p_root, co
ap->get_animation_list(&anims);
for (const StringName &name : anims) {
Ref<Animation> anim = ap->get_animation(name);
Array animation_slices;

if (p_animation_data.has(name)) {
Dictionary anim_settings = p_animation_data[name];

{
int slices_count = anim_settings["slices/amount"];

for (int i = 0; i < slices_count; i++) {
String slice_name = anim_settings["slice_" + itos(i + 1) + "/name"];
int from_frame = anim_settings["slice_" + itos(i + 1) + "/start_frame"];
int end_frame = anim_settings["slice_" + itos(i + 1) + "/end_frame"];
Animation::LoopMode loop_mode = static_cast<Animation::LoopMode>((int)anim_settings["slice_" + itos(i + 1) + "/loop_mode"]);
bool save_to_file = anim_settings["slice_" + itos(i + 1) + "/save_to_file/enabled"];
String save_to_path = anim_settings["slice_" + itos(i + 1) + "/save_to_file/path"];
bool save_to_file_keep_custom = anim_settings["slice_" + itos(i + 1) + "/save_to_file/keep_custom_tracks"];

animation_slices.push_back(slice_name);
animation_slices.push_back(from_frame / p_animation_fps);
animation_slices.push_back(end_frame / p_animation_fps);
animation_slices.push_back(loop_mode);
animation_slices.push_back(save_to_file);
animation_slices.push_back(save_to_path);
animation_slices.push_back(save_to_file_keep_custom);
}

if (animation_slices.size() > 0) {
_create_slices(ap, anim, animation_slices, true);
}
}
{
//fill with default values
List<ImportOption> iopts;
Expand Down
Loading