Change FPS to Simulation Step in HUD

This commit is contained in:
nsubiron 2018-06-06 12:03:19 +02:00
parent 19df29c379
commit 5b30e285fa
3 changed files with 8 additions and 7 deletions

View File

@ -69,11 +69,12 @@ static FText GetHUDText(const ACarlaPlayerState &Vehicle)
HighPrecision.MinimumFractionalDigits = 2u;
HighPrecision.MaximumFractionalDigits = 2u;
constexpr float TO_MILLISECONDS = 1e3;
constexpr float TO_METERS = 1e-2;
constexpr float TO_KMPH = 0.036f;
FFormatNamedArguments Args;
Args.Add("FPS", RoundedFloatAsText(Vehicle.GetFramesPerSecond()));
Args.Add("SimStep", RoundedFloatAsText(Vehicle.GetSimulationStepInSeconds() * TO_MILLISECONDS));
Args.Add("Location", GetVectorAsText(Vehicle.GetLocation() * TO_METERS));
Args.Add("Acceleration", GetVectorAsText(Vehicle.GetAcceleration() * TO_METERS, HighPrecision));
Args.Add("Orientation", GetVectorAsText(Vehicle.GetOrientation(), HighPrecision));
@ -88,7 +89,7 @@ static FText GetHUDText(const ACarlaPlayerState &Vehicle)
Args.Add("IntersectionOffRoad", RoundedFloatAsText(100.0f * Vehicle.GetOffRoadIntersectionFactor()));
return FText::Format(
LOCTEXT("HUDTextFormat",
"FPS: {FPS}\n"
"Simulation Step: {SimStep} ms\n"
"\n"
"Speed: {Speed} km/h\n"
"Gear: {Gear}\n"

View File

@ -28,7 +28,7 @@ void ACarlaPlayerState::CopyProperties(APlayerState *PlayerState)
if (Other != nullptr)
{
FrameNumber = Other->FrameNumber;
FramesPerSecond = Other->FramesPerSecond;
SimulationStepInSeconds = Other->SimulationStepInSeconds;
PlatformTimeStamp = Other->PlatformTimeStamp;
GameTimeStamp = Other->GameTimeStamp;
Transform = Other->Transform;
@ -78,7 +78,7 @@ static int32 RoundToMilliseconds(float Seconds)
void ACarlaPlayerState::UpdateTimeStamp(float DeltaSeconds)
{
FrameNumber = GFrameCounter;
FramesPerSecond = 1.0f / DeltaSeconds;
SimulationStepInSeconds = DeltaSeconds;
PlatformTimeStamp = RoundToMilliseconds(FPlatformTime::Seconds());
GameTimeStamp += RoundToMilliseconds(DeltaSeconds);
}

View File

@ -46,9 +46,9 @@ public:
}
UFUNCTION(BlueprintCallable)
float GetFramesPerSecond() const
float GetSimulationStepInSeconds() const
{
return FramesPerSecond;
return SimulationStepInSeconds;
}
UFUNCTION(BlueprintCallable)
@ -229,7 +229,7 @@ private:
uint64 FrameNumber;
UPROPERTY(VisibleAnywhere)
float FramesPerSecond;
float SimulationStepInSeconds;
UPROPERTY(VisibleAnywhere)
int32 PlatformTimeStamp;