187 - Interp Between Frames
This commit is contained in:
parent
bd20b76da7
commit
650b206797
|
@ -34,6 +34,31 @@ void ULagCompensationComponent::SaveFramePackage(FFramePackage& Package)
|
|||
}
|
||||
}
|
||||
|
||||
FFramePackage ULagCompensationComponent::InterpBetweenFrames(const FFramePackage& OlderFrame, const FFramePackage& YoungerFrame, float HitTime)
|
||||
{
|
||||
const float Distance = YoungerFrame.Time - OlderFrame.Time;
|
||||
const float InterpFraction = FMath::Clamp((HitTime - OlderFrame.Time) / Distance, 0.f, 1.f);
|
||||
|
||||
FFramePackage InterpFramePackage;
|
||||
InterpFramePackage.Time = HitTime;
|
||||
|
||||
for (auto& YoungerPair : YoungerFrame.HitBoxInfo)
|
||||
{
|
||||
const FName& BoxInfoName = YoungerPair.Key;
|
||||
const FBoxInformation& OlderBox = OlderFrame.HitBoxInfo[BoxInfoName];
|
||||
const FBoxInformation& YoungerBox = YoungerFrame.HitBoxInfo[BoxInfoName];
|
||||
|
||||
FBoxInformation InterpBoxInfo;
|
||||
InterpBoxInfo.Location = FMath::VInterpTo(OlderBox.Location, YoungerBox.Location, 1.f, InterpFraction);
|
||||
InterpBoxInfo.Rotation = FMath::RInterpTo(OlderBox.Rotation, YoungerBox.Rotation, 1.f, InterpFraction);
|
||||
InterpBoxInfo.BoxExtend = OlderBox.BoxExtend;
|
||||
|
||||
InterpFramePackage.HitBoxInfo.Add(BoxInfoName, InterpBoxInfo);
|
||||
}
|
||||
|
||||
return InterpFramePackage;
|
||||
}
|
||||
|
||||
void ULagCompensationComponent::ShowFramePackage(const FFramePackage& Package, const FColor Color)
|
||||
{
|
||||
for (auto& BoxInfo : Package.HitBoxInfo)
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void SaveFramePackage(FFramePackage& Package);
|
||||
FFramePackage InterpBetweenFrames(const FFramePackage& OlderFrame, const FFramePackage& YoungerFrame, float HitTime);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue