CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Sensor
ShowOnlyFilter.h
Go to the documentation of this file.
1
// Copyright (c) 2026 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 <
util/disable-ue4-macros.h
>
10
#include <
carla/rpc/ObjectLabel.h
>
11
#include <
util/enable-ue4-macros.h
>
12
13
#include <util/ue-header-guard-begin.h>
14
#include "CoreMinimal.h"
15
#include "UObject/WeakObjectPtr.h"
16
#include <util/ue-header-guard-end.h>
17
18
class
AActor
;
19
class
UCarlaEpisode
;
20
class
USceneCaptureComponent2D
;
21
class
UWorld;
22
23
/// Show-only ("render layer") filter shared by every scene-capture camera.
24
///
25
/// Selected through three blueprint attributes:
26
///
27
/// show_only_tags comma separated CARLA semantic label names
28
/// ("Car,Truck,Bus,Motorcycle,Bicycle,Pedestrians").
29
/// shadow_catcher_tags same format; actors carrying these labels are
30
/// rendered too so they can receive the cast shadows
31
/// of the show-only actors ("Roads,Sidewalks").
32
/// show_only_actor_ids comma separated CARLA actor ids, added to the list
33
/// whatever their labels.
34
///
35
/// When show_only_tags or show_only_actor_ids is non-empty the capture
36
/// components switch to PRM_UseShowOnlyList and their ShowOnlyActors list is
37
/// the set of world actors carrying at least one of the labels (any
38
/// primitive component, ATagger label tag or custom-depth stencil), plus the
39
/// id list. Everything else is neither rendered nor casts shadows into the
40
/// capture (the renderer filters shadow casters through the same list), so
41
/// the empty pixels carry only the sky / atmosphere in colour captures,
42
/// stencil 0 in the segmentation captures and the far plane in depth.
43
///
44
/// The actor scan runs only when the world's actor count changes (spawn or
45
/// destroy) so newly spawned vehicles show up on the next capture; every
46
/// other tick costs one integer compare plus copying the cached list into
47
/// the capture components.
48
struct
CARLA_API
FCarlaShowOnlyFilter
49
{
50
using
Label
=
carla::rpc::CityObjectLabel
;
51
52
/// Parse a comma separated list of label names into @a OutLabels using the
53
/// tagger's own name mapping. Returns false and fills @a OutUnknown with
54
/// the tokens that map to no label (they are skipped).
55
static
bool
ParseLabels
(
const
FString &CommaSeparated, TSet<Label> &OutLabels, FString &OutUnknown);
56
57
void
SetShowOnlyTags
(
const
FString &CommaSeparated);
58
59
void
SetShadowCatcherTags
(
const
FString &CommaSeparated);
60
61
void
SetShowOnlyActorIds
(
const
FString &CommaSeparated);
62
63
bool
IsEnabled
()
const
64
{
65
return
ShowOnlyTags
.Num() > 0 ||
ActorIds
.Num() > 0;
66
}
67
68
const
TSet<Label> &
GetShowOnlyTags
()
const
{
return
ShowOnlyTags
; }
69
const
TSet<Label> &
GetShadowCatcherTags
()
const
{
return
ShadowCatcherTags
; }
70
const
TSet<uint32> &
GetShowOnlyActorIds
()
const
{
return
ActorIds
; }
71
72
/// Rebuild the cached actor list if the world changed since the last call.
73
/// Cheap when nothing changed. @a Episode may be null (ids are then
74
/// ignored).
75
void
Refresh(UWorld *World,
const
UCarlaEpisode
*Episode);
76
77
/// Push the current list into @a Capture (or restore full-scene rendering
78
/// when the filter is disabled).
79
void
ApplyTo(
USceneCaptureComponent2D
&Capture)
const
;
80
81
/// Force a rescan on the next Refresh.
82
void
MarkDirty
() {
bDirty
=
true
; }
83
84
int32
GetCachedActorCount
()
const
{
return
CachedActors
.Num(); }
85
86
private
:
87
88
void
Rescan(UWorld *World,
const
UCarlaEpisode
*Episode);
89
90
TSet<Label>
ShowOnlyTags
;
91
TSet<Label>
ShadowCatcherTags
;
92
TSet<uint32>
ActorIds
;
93
94
TArray<TWeakObjectPtr<AActor>>
CachedActors
;
95
int32
LastActorCount
= -1;
96
bool
bDirty
=
true
;
97
};
ObjectLabel.h
AActor
UCarlaEpisode
A simulation episode.
Definition
CarlaEpisode.h:45
USceneCaptureComponent2D
disable-ue4-macros.h
enable-ue4-macros.h
carla::rpc::CityObjectLabel
CityObjectLabel
Definition
ObjectLabel.h:16
FCarlaShowOnlyFilter
Show-only ("render layer") filter shared by every scene-capture camera.
Definition
ShowOnlyFilter.h:49
FCarlaShowOnlyFilter::CachedActors
TArray< TWeakObjectPtr< AActor > > CachedActors
Definition
ShowOnlyFilter.h:94
FCarlaShowOnlyFilter::GetCachedActorCount
int32 GetCachedActorCount() const
Definition
ShowOnlyFilter.h:84
FCarlaShowOnlyFilter::GetShowOnlyTags
const TSet< Label > & GetShowOnlyTags() const
Definition
ShowOnlyFilter.h:68
FCarlaShowOnlyFilter::SetShowOnlyTags
void SetShowOnlyTags(const FString &CommaSeparated)
Definition
ShowOnlyFilter.cpp:61
FCarlaShowOnlyFilter::ShadowCatcherTags
TSet< Label > ShadowCatcherTags
Definition
ShowOnlyFilter.h:91
FCarlaShowOnlyFilter::GetShowOnlyActorIds
const TSet< uint32 > & GetShowOnlyActorIds() const
Definition
ShowOnlyFilter.h:70
FCarlaShowOnlyFilter::LastActorCount
int32 LastActorCount
Definition
ShowOnlyFilter.h:95
FCarlaShowOnlyFilter::GetShadowCatcherTags
const TSet< Label > & GetShadowCatcherTags() const
Definition
ShowOnlyFilter.h:69
FCarlaShowOnlyFilter::ShowOnlyTags
TSet< Label > ShowOnlyTags
Definition
ShowOnlyFilter.h:90
FCarlaShowOnlyFilter::SetShadowCatcherTags
void SetShadowCatcherTags(const FString &CommaSeparated)
Definition
ShowOnlyFilter.cpp:69
FCarlaShowOnlyFilter::bDirty
bool bDirty
Definition
ShowOnlyFilter.h:96
FCarlaShowOnlyFilter::Label
carla::rpc::CityObjectLabel Label
Definition
ShowOnlyFilter.h:50
FCarlaShowOnlyFilter::ParseLabels
static bool ParseLabels(const FString &CommaSeparated, TSet< Label > &OutLabels, FString &OutUnknown)
Parse a comma separated list of label names into OutLabels using the tagger's own name mapping.
Definition
ShowOnlyFilter.cpp:20
FCarlaShowOnlyFilter::SetShowOnlyActorIds
void SetShowOnlyActorIds(const FString &CommaSeparated)
Definition
ShowOnlyFilter.cpp:77
FCarlaShowOnlyFilter::ActorIds
TSet< uint32 > ActorIds
Definition
ShowOnlyFilter.h:92
FCarlaShowOnlyFilter::IsEnabled
bool IsEnabled() const
Definition
ShowOnlyFilter.h:63
FCarlaShowOnlyFilter::MarkDirty
void MarkDirty()
Force a rescan on the next Refresh.
Definition
ShowOnlyFilter.h:82
Generated by
1.18.0