CARLA
CarlaSettingsDelegate.h
Go to the documentation of this file.
1 // Copyright (c) 2017 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 "CoreMinimal.h"
12 #include "Engine/StaticMesh.h"
13 #include "Engine/World.h"
14 
15 #include "CarlaSettingsDelegate.generated.h"
16 
17 class UCarlaSettings;
18 
19 /// Used to set settings for every actor that is spawned into the world.
20 UCLASS(BlueprintType)
21 class CARLA_API UCarlaSettingsDelegate : public UObject
22 {
23  GENERATED_BODY()
24 
25 public:
26 
28 
29  /// Reset settings to default.
30  void Reset();
31 
32  /// Create the event trigger handler for all the newly spawned actors to be
33  /// processed with a custom function here.
34  void RegisterSpawnHandler(UWorld *World);
35 
36  /// After loading a level, apply the current settings.
37  UFUNCTION(BlueprintCallable, Category = "CARLA Settings", meta = (HidePin = "InWorld"))
38  void ApplyQualityLevelPostRestart();
39 
40  /// Before loading a level, apply the current settings.
41  UFUNCTION(BlueprintCallable, Category = "CARLA Settings", meta = (HidePin = "InWorld"))
42  void ApplyQualityLevelPreRestart();
43 
44  void SetAllActorsDrawDistance(UWorld *world, float max_draw_distance) const;
45 
46 private:
47 
48  UWorld *GetLocalWorld();
49 
50  /// Function to apply to the actor that is being spawned to apply the current
51  /// settings.
52  void OnActorSpawned(AActor *Actor);
53 
54  /// Check that the world, instance and settings are valid and save the
55  /// CarlaSettings instance.
56  ///
57  /// @param world used to get the instance of CarlaSettings.
58  void CheckCarlaSettings(UWorld *world);
59 
60  /// Execute engine commands to apply the low quality level to the world.
61  void LaunchLowQualityCommands(UWorld *world) const;
62 
63  void SetAllRoads(
64  UWorld *world,
65  float max_draw_distance,
66  const TArray<FStaticMaterial> &road_pieces_materials) const;
67 
68  void SetActorComponentsDrawDistance(AActor *actor, float max_draw_distance) const;
69 
70  void SetPostProcessEffectsEnabled(UWorld *world, bool enabled) const;
71 
72  /// Execute engine commands to apply the epic quality level to the world.
73  void LaunchEpicQualityCommands(UWorld *world) const;
74 
75  void SetAllLights(
76  UWorld *world,
77  float max_distance_fade,
78  bool cast_shadows,
79  bool hide_non_directional) const;
80 
81 private:
82 
83  /// Currently applied quality level after level is restarted.
85 
86  UCarlaSettings *CarlaSettings = nullptr;
87 
88  FOnActorSpawned::FDelegate ActorSpawnedDelegate;
89 };
EQualityLevel
FOnActorSpawned::FDelegate ActorSpawnedDelegate
Used to set settings for every actor that is spawned into the world.
carla::SharedPtr< cc::Actor > Actor
static EQualityLevel AppliedLowPostResetQualityLevel
Currently applied quality level after level is restarted.
Global settings for CARLA.
Definition: CarlaSettings.h:21