CARLA
Loading...
Searching...
No Matches
DigitalTwinsTrafficLight.h
Go to the documentation of this file.
1// Copyright (c) 2024 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include "CoreMinimal.h"
11#include "DigitalTwinsTrafficLight.generated.h"
12
13/**
14 * Traffic light class specifically for DigitalTwins meshes.
15 * Implements visual material updates for DigitalTwins atlas system.
16 */
17UCLASS()
19{
20 GENERATED_BODY()
21
22public:
23 ADigitalTwinsTrafficLight(const FObjectInitializer &ObjectInitializer);
24
25 virtual void BeginPlay() override;
26
27private:
28 // Called when traffic light state changes via the LightChangeDispatcher
29 UFUNCTION()
30 void OnLightStateChanged();
31
32private:
33 /// Update material parameters for DigitalTwins meshes based on traffic light state
34 void UpdateDigitalTwinsMaterials(ETrafficLightState State);
35
36 /// Scan every "led_*" material slot of this actor's meshes and sort the lamps into states.
37 /// Called lazily from UpdateDigitalTwinsMaterials, and again whenever the actor's mesh
38 /// component count changes (UMapLogicParser re-parents the baked rig's meshes onto us).
39 void BuildLampMap();
40
41 /// Get the emissive color for a given traffic light state
42 FLinearColor GetColorForState(ETrafficLightState State) const;
43
44 /// Every lamp this actor drives, and the state it belongs to. A rig may carry any number of
45 /// lamps per state (a mast arm repeats the three aspects on each head, a combi head adds
46 /// arrow aspects), so this is not limited to three entries.
47 TMap<UMaterialInstanceDynamic*, ETrafficLightState> MaterialToLightType;
48
49 /// Lamps that belong to no state -- the stateless atlas glyphs (Tram, tram lines, Circle,
50 /// Triangle) and anything unclassifiable. Baked lit at intensity 50000, so they are
51 /// switched off once and never touched again.
52 TArray<UMaterialInstanceDynamic*> DarkMaterials;
53
54 /// Mesh component count the lamp map was built from.
55 int32 CachedMeshComponentCount = 0;
56};
Traffic light class specifically for DigitalTwins meshes.
TArray< UMaterialInstanceDynamic * > DarkMaterials
Lamps that belong to no state – the stateless atlas glyphs (Tram, tram lines, Circle,...
TMap< UMaterialInstanceDynamic *, ETrafficLightState > MaterialToLightType
Every lamp this actor drives, and the state it belongs to.