Add picking the longest animation from the imported file instead of the first one as default

#2490
This commit is contained in:
Wojtek Figat
2024-08-29 09:53:22 +02:00
parent ec412d9be0
commit e925af534e
2 changed files with 14 additions and 2 deletions

View File

@@ -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))