CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
AWeather Class Reference

#include <Weather.h>

+ Inheritance diagram for AWeather:

Public Member Functions

void ApplyWeather (const FWeatherParameters &WeatherParameters)
 Update the weather parameters and notifies it to the blueprint's event.
 
 AWeather (const FObjectInitializer &ObjectInitializer)
 
uint64 GetApplySerial () const
 How many times ApplyWeather ran: Multi-GPU secondaries mirror every apply, also the ones that set the same values again.
 
const FWeatherParameters & GetCurrentWeather () const
 Returns the current WeatherParameters.
 
const bool & GetDayNightCycle () const
 Returns whether the day night cycle is active (automatic on/off switch when changin to night mode)
 
void NotifyWeather (ASensor *Sensor=nullptr)
 Notifing the weather to the blueprint's event.
 
void SetDayNightCycle (const bool &active)
 Update the day night cycle.
 
void SetWeather (const FWeatherParameters &WeatherParameters)
 Update the weather parameters without notifing it to the blueprint's event.
 

Static Public Member Functions

static void ApplyWeatherToSkyActor (AActor *SkyActor, const FWeatherParameters &Weather)
 Pushes Weather into a single ASkyBase rig (sun/fog/clouds/atmosphere/ exposure) and runs its blueprint refresh functions – everything PushWeatherToSky does per-actor, factored out so it works on any sky actor directly, without requiring an AWeather instance to exist in the world.
 
static void ClearSkyLightMap (UWorld *World)
 Drops the override and restores the real-time atmosphere capture with the curve-driven intensity.
 
static void FillSkyPostProcessFallback (class UPostProcessComponent *PostProcessComponent)
 Exposure / bloom defaults for the fields the sky's loaded camera profile does not set (see the comment in ApplyWeatherToSkyActor).
 
static bool HasSkyLightMap ()
 
static bool SetSkyLightMap (UWorld *World, class UTextureCube *Cubemap, float Intensity)
 Environment-map override for the sky light (set_sky_light_map RPC): every ASkyBase rig in World switches its sky light to the given cubemap (SLS_SpecifiedCubemap, real-time capture off) at the given intensity, and ApplyWeatherToSkyActor keeps it that way across weather pushes until ClearSkyLightMap.
 

Protected Member Functions

void RefreshWeather (const FWeatherParameters &WeatherParameters)
 

Private Member Functions

virtual void BeginPlay () override
 
void CheckWeatherPostProcessEffects ()
 
UParticleSystemComponent * CreateRainEmitter (AActor *Owner, bool bSensor)
 
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
 
void PushWeatherToSky ()
 Push the current weather into the ASkyBase rig (BP_Carla_Sky) and run its blueprint Update.
 
virtual void Tick (float DeltaSeconds) override
 
void UpdateRain ()
 
void UpdateStreetLightsForDayNight ()
 Broadcast the current day/night state (derived from SunAltitudeAngle) to UCarlaLightSubsystem so registered CarlaLight components (street lamps) react.
 

Private Attributes

TMap< UMaterial *, float > ActiveBlendables
 
uint64 ApplySerial = 0u
 
bool DayNightCycle = true
 
UMaterial * DustStormPostProcessMaterial
 
UMaterial * PrecipitationPostProcessMaterial
 
UCarlaRainCameraModifier * RainCameraModifier = nullptr
 
class UMaterialParameterCollection * RainParameters = nullptr
 
UParticleSystem * RainTemplate = nullptr
 
TMap< TWeakObjectPtr< ASceneCaptureCamera >, TWeakObjectPtr< UParticleSystemComponent > > SensorRain
 
UParticleSystemComponent * ViewportRain = nullptr
 
FWeatherParameters Weather
 

Detailed Description

Definition at line 38 of file Weather.h.

Constructor & Destructor Documentation

◆ AWeather()

AWeather::AWeather ( const FObjectInitializer &  ObjectInitializer)

Member Function Documentation

◆ ApplyWeather()

void AWeather::ApplyWeather ( const FWeatherParameters &  WeatherParameters)

Update the weather parameters and notifies it to the blueprint's event.

Definition at line 2597 of file Weather.cpp.

References ACarlaRecorder::AddWeather(), ApplySerial, CheckWeatherPostProcessEffects(), CarlaRecorderWeather::Cloudiness, FWeatherParameters::Cloudiness, CarlaRecorderWeather::DustStorm, FWeatherParameters::DustStorm, CarlaRecorderWeather::FogDensity, FWeatherParameters::FogDensity, CarlaRecorderWeather::FogDistance, FWeatherParameters::FogDistance, CarlaRecorderWeather::FogFalloff, FWeatherParameters::FogFalloff, UCarlaStatics::GetRecorder(), ACarlaRecorder::IsEnabled(), CarlaRecorderWeather::MieScatteringScale, FWeatherParameters::MieScatteringScale, CarlaRecorderWeather::Precipitation, FWeatherParameters::Precipitation, CarlaRecorderWeather::PrecipitationDeposits, FWeatherParameters::PrecipitationDeposits, PushWeatherToSky(), CarlaRecorderWeather::RayleighScatteringScale, FWeatherParameters::RayleighScatteringScale, RefreshWeather(), CarlaRecorderWeather::ScatteringIntensity, FWeatherParameters::ScatteringIntensity, SetWeather(), CarlaRecorderWeather::SunAltitudeAngle, FWeatherParameters::SunAltitudeAngle, CarlaRecorderWeather::SunAzimuthAngle, FWeatherParameters::SunAzimuthAngle, UpdateRain(), UpdateStreetLightsForDayNight(), Weather, CarlaRecorderWeather::Wetness, FWeatherParameters::Wetness, CarlaRecorderWeather::WindIntensity, and FWeatherParameters::WindIntensity.

Referenced by ACarlaGameModeBase::BeginPlay(), and CarlaReplayerHelper::ProcessReplayerWeather().

◆ ApplyWeatherToSkyActor()

void AWeather::ApplyWeatherToSkyActor ( AActor *  SkyActor,
const FWeatherParameters &  Weather 
)
static

Pushes Weather into a single ASkyBase rig (sun/fog/clouds/atmosphere/ exposure) and runs its blueprint refresh functions – everything PushWeatherToSky does per-actor, factored out so it works on any sky actor directly, without requiring an AWeather instance to exist in the world.

Used by ASkyBase::RefreshWeather/LoadPreset for editor-time preview when no BP_CarlaWeather is placed in the level, and by PushWeatherToSky itself for the full runtime path.

Definition at line 1543 of file Weather.cpp.

References ApplyOvercastBlend(), ApplySunAltitudeFalloff(), FWeatherParameters::Cloudiness, ComputeCloudDeckFactor(), ComputeCloudDeckLightFactor(), ComputeMoonBlend(), ComputeMoonHaloBlend(), ComputeNightBlend(), ComputeOvercastNeutralTint(), ComputeSunTwilightFactor(), ComputeTwilightCloudScale(), CVarCarlaWeatherCityGlow(), CVarCarlaWeatherCityGlowColor(), CVarCarlaWeatherCloudShadowExtentKm(), CVarCarlaWeatherDeckCoverageExponent(), CVarCarlaWeatherDeckExtinctionScale(), CVarCarlaWeatherDeckGlow(), CVarCarlaWeatherDeckGlowColor(), CVarCarlaWeatherDeckNoiseExp(), CVarCarlaWeatherDeckWarpCount(), CVarCarlaWeatherDeckWarpSwitch(), CVarCarlaWeatherEnableOvercastClouds(), CVarCarlaWeatherFogDensityScale(), CVarCarlaWeatherMoonAtmosphereDisk(), CVarCarlaWeatherMoonIntensity(), CVarCarlaWeatherMoonMinAltitudeDeg(), CVarCarlaWeatherNightSkylightIntensity(), CVarCarlaWeatherOvercastAmbientNeutralize(), CVarCarlaWeatherOvercastSunIntensity(), CVarCarlaWeatherOvercastSunNeutralize(), CVarCarlaWeatherOvercastThreshold(), CVarCarlaWeatherRainDeckGlowScale(), CVarCarlaWeatherSkyLightIndirectIntensity(), CVarCarlaWeatherSkySphereCloudOpacity(), CVarCarlaWeatherSkySphereNightColor(), CVarCarlaWeatherSkySphereScale(), CVarCarlaWeatherSkySphereShowDeg(), CVarCarlaWeatherStarsBrightness(), CVarCarlaWeatherStreetLightsOnDeg(), CVarCarlaWeatherSunIndirectIntensity(), CVarCarlaWeatherSunTwilightEndDeg(), CVarCarlaWeatherSunTwilightStartDeg(), CVarCarlaWeatherTransmittanceMinElevationDeg(), CVarCarlaWeatherTransmittanceReleaseDeg(), FillSkyPostProcessFallback(), ASkyBase::FindWeatherParameters(), FWeatherParameters::FogDensity, FWeatherParameters::FogDistance, GetOvercastSkyLightTarget(), NoteLightingChange(), NoteSunRotation(), ParseColorCVar(), FWeatherParameters::Precipitation, RainDeckScale(), SampleCurvePeakAboveHorizon(), FWeatherParameters::SunAltitudeAngle, FWeatherParameters::SunAzimuthAngle, UpdateMoonDisc(), UpdateMoonHalo(), Weather, FWeatherParameters::Wetness, and FWeatherParameters::WindIntensity.

Referenced by ASkyBase::BeginPlay(), ASkyBase::OnConstruction(), and PushWeatherToSky().

◆ BeginPlay()

void AWeather::BeginPlay ( )
overrideprivatevirtual

Definition at line 1310 of file Weather.cpp.

◆ CheckWeatherPostProcessEffects()

void AWeather::CheckWeatherPostProcessEffects ( )
private

◆ ClearSkyLightMap()

void AWeather::ClearSkyLightMap ( UWorld *  World)
static

Drops the override and restores the real-time atmosphere capture with the curve-driven intensity.

Definition at line 1500 of file Weather.cpp.

References UCarlaStatics::GetCurrentEpisode(), and Weather.

Referenced by FCarlaServer::FPimpl::BindActions().

◆ CreateRainEmitter()

UParticleSystemComponent * AWeather::CreateRainEmitter ( AActor *  Owner,
bool  bSensor 
)
private

Definition at line 1183 of file Weather.cpp.

References RainTemplate.

Referenced by UpdateRain().

◆ EndPlay()

void AWeather::EndPlay ( const EEndPlayReason::Type  EndPlayReason)
overrideprivatevirtual

◆ FillSkyPostProcessFallback()

void AWeather::FillSkyPostProcessFallback ( class UPostProcessComponent *  PostProcessComponent)
static

Exposure / bloom defaults for the fields the sky's loaded camera profile does not set (see the comment in ApplyWeatherToSkyActor).

Definition at line 2511 of file Weather.cpp.

References CVarCarlaWeatherBloomIntensity(), CVarCarlaWeatherExposureBias(), and CVarCarlaWeatherExposureMaxEV().

Referenced by ApplyWeatherToSkyActor(), and ASkyBase::BeginPlay().

◆ GetApplySerial()

uint64 AWeather::GetApplySerial ( ) const
inline

How many times ApplyWeather ran: Multi-GPU secondaries mirror every apply, also the ones that set the same values again.

Definition at line 66 of file Weather.h.

◆ GetCurrentWeather()

const FWeatherParameters & AWeather::GetCurrentWeather ( ) const
inline

Returns the current WeatherParameters.

Definition at line 59 of file Weather.h.

References Weather.

Referenced by ACarlaRecorder::AddExistingWeather(), and ACarlaGameModeBase::BeginPlay().

◆ GetDayNightCycle()

const bool & AWeather::GetDayNightCycle ( ) const
inline

Returns whether the day night cycle is active (automatic on/off switch when changin to night mode)

Definition at line 73 of file Weather.h.

◆ HasSkyLightMap()

bool AWeather::HasSkyLightMap ( )
static

Definition at line 1530 of file Weather.cpp.

Referenced by FCarlaServer::FPimpl::BindActions().

◆ NotifyWeather()

void AWeather::NotifyWeather ( ASensor *  Sensor = nullptr)

Notifing the weather to the blueprint's event.

Definition at line 2650 of file Weather.cpp.

References CheckWeatherPostProcessEffects().

Referenced by ASceneCaptureSensor::BeginPlay(), and ASceneCaptureSensor_WideAngleLens::BeginPlay().

◆ PushWeatherToSky()

void AWeather::PushWeatherToSky ( )
private

Push the current weather into the ASkyBase rig (BP_Carla_Sky) and run its blueprint Update.

The UE5 sky rig only refreshes itself from its construction script, so without this call the sun/fog/atmosphere stay frozen at the state saved in the map regardless of the weather API.

Definition at line 1535 of file Weather.cpp.

References ApplyWeatherToSkyActor(), and Weather.

Referenced by ApplyWeather().

◆ RefreshWeather()

void AWeather::RefreshWeather ( const FWeatherParameters &  WeatherParameters)
protected

Referenced by ApplyWeather().

◆ SetDayNightCycle()

void AWeather::SetDayNightCycle ( const bool &  active)

Update the day night cycle.

Definition at line 2666 of file Weather.cpp.

References DayNightCycle.

◆ SetSkyLightMap()

bool AWeather::SetSkyLightMap ( UWorld *  World,
class UTextureCube *  Cubemap,
float  Intensity 
)
static

Environment-map override for the sky light (set_sky_light_map RPC): every ASkyBase rig in World switches its sky light to the given cubemap (SLS_SpecifiedCubemap, real-time capture off) at the given intensity, and ApplyWeatherToSkyActor keeps it that way across weather pushes until ClearSkyLightMap.

Scoped to World: it is dropped when that world is cleaned up (load_world / reload_world), so the next level starts on its own real-time capture. The cubemap is rooted for as long as it is set. Returns false if no sky rig was found.

Definition at line 1465 of file Weather.cpp.

Referenced by FCarlaServer::FPimpl::BindActions().

◆ SetWeather()

void AWeather::SetWeather ( const FWeatherParameters &  WeatherParameters)

Update the weather parameters without notifing it to the blueprint's event.

Definition at line 2661 of file Weather.cpp.

References Weather.

Referenced by ApplyWeather().

◆ Tick()

void AWeather::Tick ( float  DeltaSeconds)
overrideprivatevirtual

◆ UpdateRain()

void AWeather::UpdateRain ( )
private

◆ UpdateStreetLightsForDayNight()

void AWeather::UpdateStreetLightsForDayNight ( )
private

Broadcast the current day/night state (derived from SunAltitudeAngle) to UCarlaLightSubsystem so registered CarlaLight components (street lamps) react.

BP_CarlaWeather's graph does reference the subsystem and DayTimeChangeEvent, but measured behavior is that lights never receive it (same blueprint has other confirmed-dead exec chains that PushWeatherToSky already routes around) – drive it from C++ instead so it does not depend on that graph being reachable.

Definition at line 2580 of file Weather.cpp.

References CVarCarlaWeatherStreetLightsOnDeg(), DayNightCycle, UCarlaLightSubsystem::NotifyDayTimeChange(), UCarlaLightSubsystem::NumLights(), FWeatherParameters::SunAltitudeAngle, and Weather.

Referenced by ApplyWeather().

Member Data Documentation

◆ ActiveBlendables

TMap<UMaterial*, float> AWeather::ActiveBlendables
private

Definition at line 168 of file Weather.h.

Referenced by CheckWeatherPostProcessEffects().

◆ ApplySerial

uint64 AWeather::ApplySerial = 0u
private

Definition at line 173 of file Weather.h.

Referenced by ApplyWeather().

◆ DayNightCycle

bool AWeather::DayNightCycle = true
private

Definition at line 171 of file Weather.h.

Referenced by SetDayNightCycle(), and UpdateStreetLightsForDayNight().

◆ DustStormPostProcessMaterial

UMaterial* AWeather::DustStormPostProcessMaterial
private

Definition at line 166 of file Weather.h.

Referenced by AWeather(), and CheckWeatherPostProcessEffects().

◆ PrecipitationPostProcessMaterial

UMaterial* AWeather::PrecipitationPostProcessMaterial
private

Definition at line 163 of file Weather.h.

Referenced by AWeather(), CheckWeatherPostProcessEffects(), and UpdateRain().

◆ RainCameraModifier

UCarlaRainCameraModifier* AWeather::RainCameraModifier = nullptr
private

Definition at line 139 of file Weather.h.

Referenced by EndPlay(), and UpdateRain().

◆ RainParameters

class UMaterialParameterCollection* AWeather::RainParameters = nullptr
private

Definition at line 130 of file Weather.h.

Referenced by AWeather(), and UpdateRain().

◆ RainTemplate

UParticleSystem* AWeather::RainTemplate = nullptr
private

Definition at line 133 of file Weather.h.

Referenced by AWeather(), and CreateRainEmitter().

◆ SensorRain

TMap<TWeakObjectPtr<ASceneCaptureCamera>, TWeakObjectPtr<UParticleSystemComponent> > AWeather::SensorRain
private

Definition at line 141 of file Weather.h.

Referenced by EndPlay(), and UpdateRain().

◆ ViewportRain

UParticleSystemComponent* AWeather::ViewportRain = nullptr
private

Definition at line 136 of file Weather.h.

Referenced by UpdateRain().

◆ Weather

FWeatherParameters AWeather::Weather
private

The documentation for this class was generated from the following files: