From 57d785bd7c27dccf32db4f8bc19e1ac39c6d0c55 Mon Sep 17 00:00:00 2001 From: bernatx Date: Fri, 9 Jun 2023 15:52:07 +0200 Subject: [PATCH] fix weather --- .../Carla/Source/Carla/Weather/Weather.cpp | 18 ++++-------------- .../Carla/Source/Carla/Weather/Weather.h | 3 --- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp index 4aa08c1c0..35dfe20a5 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp @@ -36,17 +36,11 @@ void AWeather::CheckWeatherPostProcessEffects() else ActiveBlendables.Remove(DustStormPostProcessMaterial); - for (int32 i = 0; i < Sensors.Num(); i++) + TArray SensorActors; + UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASceneCaptureCamera::StaticClass(), SensorActors); + for (AActor* SensorActor : SensorActors) { - auto& Sensor = Sensors[i]; - - if (!IsValid(Sensor)) - { - Sensors.RemoveAtSwap(i); - if (i == Sensors.Num()) - break; - } - + ASceneCaptureCamera* Sensor = Cast(SensorActor); for (auto& ActiveBlendable : ActiveBlendables) Sensor->GetCaptureComponent2D()->PostProcessSettings.AddBlendable(ActiveBlendable.Key, ActiveBlendable.Value); } @@ -81,10 +75,6 @@ void AWeather::ApplyWeather(const FWeatherParameters& InWeather) void AWeather::NotifyWeather(ASensor* Sensor) { - auto AsSceneCaptureCamera = Cast(Sensor); - if (AsSceneCaptureCamera != nullptr) - Sensors.Add(AsSceneCaptureCamera); - CheckWeatherPostProcessEffects(); // Call the blueprint that actually changes the weather. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h index efdd5d499..98e129739 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h @@ -69,9 +69,6 @@ private: TMap ActiveBlendables; - UPROPERTY(VisibleAnywhere) - TArray Sensors; - UPROPERTY(EditAnywhere, Category = "Weather") bool DayNightCycle = true; };