12#include <util/ue-header-guard-begin.h>
13#include "Components/PrimitiveComponent.h"
14#include "Components/SceneCaptureComponent2D.h"
15#include "Engine/World.h"
16#include "EngineUtils.h"
17#include "GameFramework/Actor.h"
18#include <util/ue-header-guard-end.h>
21 const FString &CommaSeparated,
22 TSet<Label> &OutLabels,
27 TArray<FString> Tokens;
28 CommaSeparated.ParseIntoArray(Tokens, TEXT(
","),
true);
29 bool bAllKnown =
true;
30 for (FString &Token : Tokens)
32 Token.TrimStartAndEndInline();
41 if (Parsed == Label::None)
44 OutUnknown += (OutUnknown.IsEmpty() ? TEXT(
"") : TEXT(
",")) + Token;
47 OutLabels.Add(Parsed);
54 if (!Unknown.IsEmpty())
56 UE_LOG(LogCarla, Warning,
57 TEXT(
"%s: unknown semantic label(s) \"%s\" ignored"), Attribute, *Unknown);
80 TArray<FString> Tokens;
81 CommaSeparated.ParseIntoArray(Tokens, TEXT(
","),
true);
82 for (FString &Token : Tokens)
84 Token.TrimStartAndEndInline();
89 if (Token.IsNumeric())
91 ActorIds.Add(
static_cast<uint32
>(FCString::Atoi64(*Token)));
95 UE_LOG(LogCarla, Warning,
96 TEXT(
"show_only_actor_ids: \"%s\" is not an actor id, ignored"), *Token);
108 const int32 ActorCount = World->GetActorCount();
119 const double Start = FPlatformTime::Seconds();
125 if (Wanted.Num() > 0)
127 TInlineComponentArray<UPrimitiveComponent *> Primitives;
128 for (TActorIterator<AActor> It(World); It; ++It)
136 Actor->GetComponents<UPrimitiveComponent>(Primitives);
137 for (UPrimitiveComponent *Primitive : Primitives)
139 if (Primitive !=
nullptr &&
149 if (
ActorIds.Num() > 0 && Episode !=
nullptr)
167 UE_LOG(LogCarla, Verbose,
168 TEXT(
"ShowOnlyFilter: %d actor(s) selected out of %d in %.2f ms"),
170 (FPlatformTime::Seconds() - Start) * 1000.0);
177 if (Capture.PrimitiveRenderMode == ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList)
179 Capture.PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_RenderScenePrimitives;
180 Capture.ShowOnlyActors.Reset();
181 Capture.ClearShowOnlyComponents();
185 Capture.PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList;
189 if (
AActor *Actor = Weak.Get())
191 Capture.ShowOnlyActors.Add(Actor);
static void ShowOnlyFilter_WarnUnknown(const TCHAR *Attribute, const FString &Unknown)
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
static crp::CityObjectLabel GetTagOfTaggedComponent(const UPrimitiveComponent &Component)
Retrieve the tag of an already tagged component.
static crp::CityObjectLabel GetTagFromString(FString Tag)
Transform a string into a CityObjectLabel.
A registry of all the Carla actors.
FCarlaActor * FindCarlaActor(IdType Id)
A view over an actor and its properties.
const FActorRegistry & GetActorRegistry() const
TArray< TWeakObjectPtr< AActor > > CachedActors
void Refresh(UWorld *World, const UCarlaEpisode *Episode)
Rebuild the cached actor list if the world changed since the last call.
void SetShowOnlyTags(const FString &CommaSeparated)
TSet< Label > ShadowCatcherTags
TSet< Label > ShowOnlyTags
void SetShadowCatcherTags(const FString &CommaSeparated)
void Rescan(UWorld *World, const UCarlaEpisode *Episode)
void ApplyTo(USceneCaptureComponent2D &Capture) const
Push the current list into Capture (or restore full-scene rendering when the filter is disabled).
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.
void SetShowOnlyActorIds(const FString &CommaSeparated)