CARLA
Loading...
Searching...
No Matches
CarlaSettingsDelegate.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
10
11#include <util/ue-header-guard-begin.h>
12#include "CoreMinimal.h"
13#include "Engine/StaticMesh.h"
14#include "Engine/World.h"
15#include <util/ue-header-guard-end.h>
16
17#include "CarlaSettingsDelegate.generated.h"
18
19class UCarlaSettings;
20
21/// Used to set settings for every actor that is spawned into the world.
22UCLASS(BlueprintType)
23class CARLA_API UCarlaSettingsDelegate : public UObject
24{
25 GENERATED_BODY()
26
27public:
28
30
31 /// Reset settings to default.
32 void Reset();
33
34 /// Create the event trigger handler for all the newly spawned actors to be
35 /// processed with a custom function here.
36 void RegisterSpawnHandler(UWorld *World);
37
38 /// After loading a level, apply the current settings.
39 UFUNCTION(BlueprintCallable, Category = "CARLA Settings", meta = (HidePin = "InWorld"))
40 void ApplyQualityLevelPostRestart();
41
42 /// Before loading a level, apply the current settings.
43 UFUNCTION(BlueprintCallable, Category = "CARLA Settings", meta = (HidePin = "InWorld"))
44 void ApplyQualityLevelPreRestart();
45
46 void SetAllActorsDrawDistance(UWorld *world, float max_draw_distance) const;
47
48private:
49
50 UWorld *GetLocalWorld();
51
52 /// Check that the world, instance and settings are valid and save the
53 /// CarlaSettings instance.
54 ///
55 /// @param world used to get the instance of CarlaSettings.
56 void CheckCarlaSettings(UWorld *world);
57
58 void SetAllRoads(
59 UWorld *world,
60 float max_draw_distance,
61 const TArray<FStaticMaterial> &road_pieces_materials) const;
62
63 void SetActorComponentsDrawDistance(AActor *actor, float max_draw_distance) const;
64
65 void SetPostProcessEffectsEnabled(UWorld *world, bool enabled) const;
66
67 void SetAllLights(
68 UWorld *world,
69 float max_distance_fade,
70 bool cast_shadows,
71 bool hide_non_directional) const;
72
73 /// Single-pass replacement for SetAllLights + SetAllActorsDrawDistance
74 /// when applying a quality tier. Walks the actor list once and dispatches
75 /// per-type, halving the cost of a tier change.
76 void ApplyPerActorQualitySettings(
77 UWorld *world,
78 float light_fade_distance,
79 bool cast_directional_shadows,
80 bool hide_non_directional_lights,
81 float draw_distance) const;
82
83private:
84
85 /// Currently applied quality level after level is restarted.
87
88 UCarlaSettings *CarlaSettings = nullptr;
89};
EQualityLevel
Used to set settings for every actor that is spawned into the world.
static EQualityLevel AppliedLowPostResetQualityLevel
Currently applied quality level after level is restarted.
Global settings for CARLA.