CARLA
Loading...
Searching...
No Matches
CarlaHUD.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9// Workaround to fix Windows conflict: Windows changes the name of some functions (DrawText, LoadLibrary...)
10// with Unicode / ANSI versions for his own API (DrawTextW, DrawTextA, LoadLibraryW, LoadLibraryA...).
11// But the changes are global for the compiler. Deep in headers, Windows has something like:
12// #ifdef UNICODE
13// #define DrawText DrawTextW
14// #define LoadLibrary LoadLibraryW
15// #else
16// #define DrawText DrawTextA
17// #define LoadLibrary LoadLibraryA
18// #endif
19// Then the linker tries to find the function DrawTextW on an external DLL and an unresolved external error happens because
20// Unreal has no function DrawTextW, it has just DrawText.
21// We can fix that by just undefining the function that conflicts with the name of the Windows API in Unicode.
22#undef DrawText
23
24#include "Carla.h"
25
26#include <util/ue-header-guard-begin.h>
27#include "Containers/Array.h"
28#include "GameFramework/HUD.h"
29#include "ChaosWheeledVehicleMovementComponent.h"
30#include <util/ue-header-guard-end.h>
31
32#include "CarlaHUD.generated.h"
33
35{
36 FString Str { "" };
37 FVector Location;
38 FColor Color;
39 double TimeToDie;
40};
41
42/// Class to draw on HUD
43UCLASS()
44class CARLA_API ACarlaHUD : public AHUD
45{
46 GENERATED_BODY()
47
48public:
49
50 ACarlaHUD(const FObjectInitializer& ObjectInitializer)
51 : Super(ObjectInitializer)
52 {
53 PrimaryActorTick.bCanEverTick = false;
54 }
55
56 virtual void DrawHUD() override;
57
58 /** Draw 2D debug text graphs on UI for the wheels, suspension and other systems */
59 void DrawDebug(float& YL, float& YPos);
60
61 UChaosWheeledVehicleMovementComponent* DebugVehicle = nullptr;
62
63 void AddDebugVehicleForTelemetry(UChaosWheeledVehicleMovementComponent* NewDebugVehiclePtr)
64 {
65 DebugVehicle = NewDebugVehiclePtr;
66 }
67
68 void AddHUDString(const FString Str, const FVector Location, const FColor Color, double LifeTime);
69
71 {
72 StringList.Empty();
73 }
74
75private:
76 TArray<HUDString> StringList;
77};
Class to draw on HUD.
Definition CarlaHUD.h:45
void AddDebugVehicleForTelemetry(UChaosWheeledVehicleMovementComponent *NewDebugVehiclePtr)
Definition CarlaHUD.h:63
void ClearDebugStrings()
Definition CarlaHUD.h:70
TArray< HUDString > StringList
Definition CarlaHUD.h:76
ACarlaHUD(const FObjectInitializer &ObjectInitializer)
Definition CarlaHUD.h:50
FVector Location
Definition CarlaHUD.h:37
double TimeToDie
Definition CarlaHUD.h:39
FString Str
Definition CarlaHUD.h:36
FColor Color
Definition CarlaHUD.h:38