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

Traffic light class specifically for DigitalTwins meshes. More...

#include <DigitalTwinsTrafficLight.h>

+ Inheritance diagram for ADigitalTwinsTrafficLight:

Public Member Functions

 ADigitalTwinsTrafficLight (const FObjectInitializer &ObjectInitializer)
 
virtual void BeginPlay () override
 
- Public Member Functions inherited from ATrafficLightBase
void AddTimeToRecorder ()
 
 ATrafficLightBase (const FObjectInitializer &ObjectInitializer)
 
float GetElapsedTime () const
 
float GetGreenTime () const
 
TArray< ATrafficLightBase * > GetGroupTrafficLights () const
 
int GetPoleIndex () const
 
float GetRedTime () const
 
bool GetTimeIsFrozen () const
 
UTrafficLightComponent * GetTrafficLightComponent ()
 
const UTrafficLightComponent * GetTrafficLightComponent () const
 
ETrafficLightState GetTrafficLightState () const
 
float GetYellowTime () const
 
void LightChangedCompatibility (ETrafficLightState NewLightState)
 
void NotifyWheeledVehicle (ACarlaWheeledVehicle *Vehicle)
 
void SetElapsedTime (float InElapsedTime)
 
void SetGreenTime (float InGreenTime)
 
void SetGroupTrafficLights (TArray< ATrafficLightBase * > InGroupTrafficLights)
 
void SetPoleIndex (int InPoleIndex)
 
void SetRedTime (float InRedTime)
 
void SetTimeIsFrozen (bool InTimeIsFrozen)
 
void SetTrafficLightState (ETrafficLightState State)
 
void SetYellowTime (float InYellowTime)
 
void UnNotifyWheeledVehicle (ACarlaWheeledVehicle *Vehicle)
 
- Public Member Functions inherited from ATrafficSignBase
 ATrafficSignBase (const FObjectInitializer &ObjectInitializer)
 
int32 GetSpeedLimitKmh () const
 km/h this sign limits to, -1 when it is not a speed-limit sign.
 
ETrafficSignState GetTrafficSignState () const
 
UBoxComponent * GetTriggerVolume () const
 
TArray< UBoxComponent * > GetTriggerVolumes () const
 
void SetSpeedLimitKmh (int32 Kmh)
 Make this a speed-limit sign for Kmh: picks the dedicated state when one exists, the custom state (value kept in SpeedLimitKmh) otherwise.
 
void SetTrafficSignState (ETrafficSignState State)
 

Private Member Functions

void BuildLampMap ()
 Scan every "led_*" material slot of this actor's meshes and sort the lamps into states.
 
FLinearColor GetColorForState (ETrafficLightState State) const
 Get the emissive color for a given traffic light state.
 
void OnLightStateChanged ()
 
void UpdateDigitalTwinsMaterials (ETrafficLightState State)
 Update material parameters for DigitalTwins meshes based on traffic light state.
 

Private Attributes

int32 CachedMeshComponentCount = 0
 Mesh component count the lamp map was built from.
 
TArray< UMaterialInstanceDynamic * > DarkMaterials
 Lamps that belong to no state – the stateless atlas glyphs (Tram, tram lines, Circle, Triangle) and anything unclassifiable.
 
TMap< UMaterialInstanceDynamic *, ETrafficLightState > MaterialToLightType
 Every lamp this actor drives, and the state it belongs to.
 

Additional Inherited Members

- Public Attributes inherited from ATrafficSignBase
bool bGeneratedFromOpenDRIVE = false
 True for signs/lights generated from the OpenDRIVE map.
 
bool bPositioned = false
 True once this sign has been snapped to the ground, to avoid adjusting it more than once.
 
- Protected Member Functions inherited from ATrafficLightBase
void OnTrafficLightStateChanged (ETrafficLightState TrafficLightState)
 

Detailed Description

Traffic light class specifically for DigitalTwins meshes.

Implements visual material updates for DigitalTwins atlas system.

Definition at line 18 of file DigitalTwinsTrafficLight.h.

Constructor & Destructor Documentation

◆ ADigitalTwinsTrafficLight()

ADigitalTwinsTrafficLight::ADigitalTwinsTrafficLight ( const FObjectInitializer &  ObjectInitializer)

Definition at line 84 of file DigitalTwinsTrafficLight.cpp.

Member Function Documentation

◆ BeginPlay()

void ADigitalTwinsTrafficLight::BeginPlay ( )
overridevirtual

◆ BuildLampMap()

void ADigitalTwinsTrafficLight::BuildLampMap ( )
private

Scan every "led_*" material slot of this actor's meshes and sort the lamps into states.

Called lazily from UpdateDigitalTwinsMaterials, and again whenever the actor's mesh component count changes (UMapLogicParser re-parents the baked rig's meshes onto us).

Definition at line 116 of file DigitalTwinsTrafficLight.cpp.

References CachedMeshComponentCount, DarkMaterials, ATrafficLightBase::GetTrafficLightComponent(), MaterialToLightType, and State.

Referenced by UpdateDigitalTwinsMaterials().

◆ GetColorForState()

FLinearColor ADigitalTwinsTrafficLight::GetColorForState ( ETrafficLightState  State) const
private

Get the emissive color for a given traffic light state.

Definition at line 299 of file DigitalTwinsTrafficLight.cpp.

References State.

◆ OnLightStateChanged()

void ADigitalTwinsTrafficLight::OnLightStateChanged ( )
private

◆ UpdateDigitalTwinsMaterials()

void ADigitalTwinsTrafficLight::UpdateDigitalTwinsMaterials ( ETrafficLightState  State)
private

Update material parameters for DigitalTwins meshes based on traffic light state.

Definition at line 276 of file DigitalTwinsTrafficLight.cpp.

References BuildLampMap(), CachedMeshComponentCount, MaterialToLightType, and State.

Referenced by BeginPlay(), and OnLightStateChanged().

Member Data Documentation

◆ CachedMeshComponentCount

int32 ADigitalTwinsTrafficLight::CachedMeshComponentCount = 0
private

Mesh component count the lamp map was built from.

Definition at line 55 of file DigitalTwinsTrafficLight.h.

Referenced by BuildLampMap(), and UpdateDigitalTwinsMaterials().

◆ DarkMaterials

TArray<UMaterialInstanceDynamic*> ADigitalTwinsTrafficLight::DarkMaterials
private

Lamps that belong to no state – the stateless atlas glyphs (Tram, tram lines, Circle, Triangle) and anything unclassifiable.

Baked lit at intensity 50000, so they are switched off once and never touched again.

Definition at line 52 of file DigitalTwinsTrafficLight.h.

Referenced by BuildLampMap().

◆ MaterialToLightType

TMap<UMaterialInstanceDynamic*, ETrafficLightState> ADigitalTwinsTrafficLight::MaterialToLightType
private

Every lamp this actor drives, and the state it belongs to.

A rig may carry any number of lamps per state (a mast arm repeats the three aspects on each head, a combi head adds arrow aspects), so this is not limited to three entries.

Definition at line 47 of file DigitalTwinsTrafficLight.h.

Referenced by BuildLampMap(), and UpdateDigitalTwinsMaterials().


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