185 - Frame History
This commit is contained in:
parent
ac378b01da
commit
61501fc27c
|
@ -14,9 +14,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,4 +56,9 @@ private:
|
|||
UPROPERTY()
|
||||
ABlasterPlayerController* Controller;
|
||||
|
||||
TDoubleLinkedList<FFramePackage> FrameHistory;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float MaxRecordTime = 4.f;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue