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; };