Skip to content

Commit

Permalink
Improved fix for Transformers: Fall of Cybertron animation
Browse files Browse the repository at this point in the history
Crashed on psa export when animation sequence has no tracks
  • Loading branch information
gildor2 committed Aug 11, 2021
1 parent 10fdbca commit d73e1db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions Unreal/UnrealMesh/UnAnim3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ static void ReadArgonautsTimeArray(const TArray<unsigned> &SourceArray, int Firs

#if TRANSFORMERS

void UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
bool UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
{
guard(UAnimSequence::DecodeTrans3Anims);

if (CompressedByteStream.Num() == 0)
{
// This situation is true for some sequences
return;
return false;
}

// read some counts first
Expand Down Expand Up @@ -525,6 +525,7 @@ void UAnimSequence::DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const
DBG(" - %s\n", *Owner->TrackBoneNames[Bone]);
}

return true;
unguard;
}

Expand Down Expand Up @@ -710,12 +711,20 @@ void UAnimSet::ConvertAnims()
if (ArGame == GAME_Transformers && Seq->Trans3Data.Num())
{
CAnimSequence *Dst = new CAnimSequence(Seq);
AnimSet->Sequences.Add(Dst);
Dst->Name = Seq->SequenceName;
Dst->NumFrames = Seq->NumFrames;
Dst->Rate = Seq->NumFrames / Seq->SequenceLength * Seq->RateScale;
Dst->bAdditive = Seq->bIsAdditive;
Seq->DecodeTrans3Anims(Dst, this);

if (Seq->DecodeTrans3Anims(Dst, this))
{
AnimSet->Sequences.Add(Dst);
}
else
{
// Failed to decode, drop the track
delete Dst;
}
continue;
}
#endif // TRANSFORMERS
Expand Down
2 changes: 1 addition & 1 deletion Unreal/UnrealMesh/UnMesh3.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class UAnimSequence : public UObject
void DecodeBatman2Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
#endif
#if TRANSFORMERS
void DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
bool DecodeTrans3Anims(CAnimSequence *Dst, UAnimSet *Owner) const;
#endif
};

Expand Down

0 comments on commit d73e1db

Please sign in to comment.