185 - Frame History
This commit is contained in:
parent
ac378b01da
commit
61501fc27c
|
@ -13,10 +13,7 @@ ULagCompensationComponent::ULagCompensationComponent()
|
||||||
void ULagCompensationComponent::BeginPlay()
|
void ULagCompensationComponent::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
FFramePackage Package;
|
|
||||||
SaveFramePackage(Package);
|
|
||||||
ShowFramePackage(Package, FColor::Orange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ULagCompensationComponent::SaveFramePackage(FFramePackage& Package)
|
void ULagCompensationComponent::SaveFramePackage(FFramePackage& Package)
|
||||||
|
@ -47,7 +44,8 @@ void ULagCompensationComponent::ShowFramePackage(const FFramePackage& Package, c
|
||||||
BoxInfo.Value.BoxExtend,
|
BoxInfo.Value.BoxExtend,
|
||||||
FQuat(BoxInfo.Value.Rotation),
|
FQuat(BoxInfo.Value.Rotation),
|
||||||
Color,
|
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)
|
void ULagCompensationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,10 @@ private:
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
ABlasterPlayerController* Controller;
|
ABlasterPlayerController* Controller;
|
||||||
|
|
||||||
|
TDoubleLinkedList<FFramePackage> FrameHistory;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float MaxRecordTime = 4.f;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue