diff --git a/Source/Engine/ContentImporters/ImportModel.cpp b/Source/Engine/ContentImporters/ImportModel.cpp index 6f0a9c626..611b58089 100644 --- a/Source/Engine/ContentImporters/ImportModel.cpp +++ b/Source/Engine/ContentImporters/ImportModel.cpp @@ -638,7 +638,17 @@ CreateAssetResult ImportModel::CreateAnimation(CreateAssetContext& context, Mode // Save animation data MemoryWriteStream stream(8182); - const int32 animIndex = options && options->ObjectIndex != -1 ? options->ObjectIndex : 0; // Single animation per asset + int32 animIndex = options ? options->ObjectIndex : -1; // Single animation per asset + if (animIndex == -1) + { + // Pick the longest animation by default (eg. to skip ref pose anim if exported as the first one) + animIndex = 0; + for (int32 i = 1; i < modelData.Animations.Count(); i++) + { + if (modelData.Animations[i].GetLength() > modelData.Animations[animIndex].GetLength()) + animIndex = i; + } + } if (modelData.Pack2AnimationHeader(&stream, animIndex)) return CreateAssetResult::Error; if (context.AllocateChunk(0)) diff --git a/Source/Engine/Tools/ModelTool/ModelTool.cpp b/Source/Engine/Tools/ModelTool/ModelTool.cpp index 296a21827..07cac95bb 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.cpp @@ -1053,14 +1053,16 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option } if (EnumHasAnyFlags(options.ImportTypes, ImportDataTypes::Animations)) { + int32 index = 0; for (auto& animation : data.Animations) { - LOG(Info, "Imported animation '{}' has {} channels, duration: {} frames, frames per second: {}", animation.Name, animation.Channels.Count(), animation.Duration, animation.FramesPerSecond); + LOG(Info, "Imported animation '{}' at index {} has {} channels, duration: {} frames ({} seconds), frames per second: {}", animation.Name, index, animation.Channels.Count(), animation.Duration, animation.GetLength(), animation.FramesPerSecond); if (animation.Duration <= ZeroTolerance || animation.FramesPerSecond <= ZeroTolerance) { errorMsg = TEXT("Invalid animation duration."); return true; } + index++; } } switch (options.Type)