185 - Frame History

This commit is contained in:
Kingsmedia 2022-05-27 15:36:32 +02:00
parent ac378b01da
commit 61501fc27c
2 changed files with 28 additions and 5 deletions

View File

@ -13,10 +13,7 @@ ULagCompensationComponent::ULagCompensationComponent()
void ULagCompensationComponent::BeginPlay()
{
Super::BeginPlay();
FFramePackage Package;
SaveFramePackage(Package);
ShowFramePackage(Package, FColor::Orange);
}
void ULagCompensationComponent::SaveFramePackage(FFramePackage& Package)
@ -47,7 +44,8 @@ void ULagCompensationComponent::ShowFramePackage(const FFramePackage& Package, c
BoxInfo.Value.BoxExtend,
FQuat(BoxInfo.Value.Rotation),
Color,
true
false,
4.f
);
}
}
@ -55,5 +53,25 @@ void ULagCompensationComponent::ShowFramePackage(const FFramePackage& Package, c
void ULagCompensationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (FrameHistory.Num() <= 1)
{
FFramePackage ThisFrame;
SaveFramePackage(ThisFrame);
FrameHistory.AddHead(ThisFrame);
}
else
{
float HistoryLength = FrameHistory.GetHead()->GetValue().Time - FrameHistory.GetTail()->GetValue().Time;
while (HistoryLength > MaxRecordTime)
{
FrameHistory.RemoveNode(FrameHistory.GetTail());
HistoryLength = FrameHistory.GetHead()->GetValue().Time - FrameHistory.GetTail()->GetValue().Time;
}
FFramePackage ThisFrame;
SaveFramePackage(ThisFrame);
FrameHistory.AddHead(ThisFrame);
ShowFramePackage(ThisFrame, FColor::Red);
}
}

View File

@ -55,5 +55,10 @@ private:
UPROPERTY()
ABlasterPlayerController* Controller;
TDoubleLinkedList<FFramePackage> FrameHistory;
UPROPERTY(EditAnywhere)
float MaxRecordTime = 4.f;
};