diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.cpp index 4fef475c4..770daf8c0 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.cpp @@ -199,6 +199,15 @@ void ACarlaGameModeBase::BeginPlay() GameController->BeginPlay(); } +void ACarlaGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) +{ + Super::EndPlay(EndPlayReason); + if(CarlaSettingsDelegate!=nullptr && EndPlayReason==EEndPlayReason::EndPlayInEditor) + { + CarlaSettingsDelegate->Reset(); + } +} + void ACarlaGameModeBase::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.h index f475956b8..41ce8a73b 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaGameModeBase.h @@ -38,6 +38,8 @@ public: virtual void BeginPlay() override; + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; + virtual void Tick(float DeltaSeconds) override; FDataRouter &GetDataRouter() diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.cpp index 3c94b7df0..179d457b9 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.cpp @@ -11,11 +11,20 @@ #include "Engine/PostProcessVolume.h" #include "UObjectIterator.h" +///quality settings configuration between runs +EQualitySettingsLevel UCarlaSettingsDelegate::AppliedLowPostResetQualitySettingsLevel = EQualitySettingsLevel::Epic; + UCarlaSettingsDelegate::UCarlaSettingsDelegate() : ActorSpawnedDelegate(FOnActorSpawned::FDelegate::CreateUObject(this, &UCarlaSettingsDelegate::OnActorSpawned)) { } +void UCarlaSettingsDelegate::Reset() +{ + LaunchEpicQualityCommands(GetLocalWorld()); + AppliedLowPostResetQualitySettingsLevel = EQualitySettingsLevel::Epic; +} + void UCarlaSettingsDelegate::RegisterSpawnHandler(UWorld *InWorld) { CheckCarlaSettings(InWorld); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.h index 7dd3e6c97..77a5105af 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettingsDelegate.h @@ -21,6 +21,9 @@ public: /** Constructor */ UCarlaSettingsDelegate(); + /** Reset settings to default */ + void Reset(); + /** Create the event trigger handler for all new spawned actors to be processed with a custom function here */ void RegisterSpawnHandler(UWorld *World); @@ -65,7 +68,7 @@ private: private: /** currently applied settings level after level is restarted */ - EQualitySettingsLevel AppliedLowPostResetQualitySettingsLevel = EQualitySettingsLevel::Epic; + static EQualitySettingsLevel AppliedLowPostResetQualitySettingsLevel; /** */ UCarlaSettings* CarlaSettings = nullptr; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleSpawnerBase.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleSpawnerBase.cpp index 0292fe784..17bc78da4 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleSpawnerBase.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleSpawnerBase.cpp @@ -90,7 +90,7 @@ void AVehicleSpawnerBase::SetNumberOfVehicles(const int32 Count) void AVehicleSpawnerBase::TryToSpawnRandomVehicle() { auto SpawnPoint = GetRandomSpawnPoint(); - if ((SpawnPoint != nullptr)) { + if (SpawnPoint != nullptr) { SpawnVehicleAtSpawnPoint(*SpawnPoint); } else { UE_LOG(LogCarla, Error, TEXT("Unable to find spawn point"));