CARLA
Loading...
Searching...
No Matches
CarlaActorFactory.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
12
13#include <util/ue-header-guard-begin.h>
14#include "Containers/Array.h"
15#include "GameFramework/Actor.h"
16#include <util/ue-header-guard-end.h>
17
18#include "CarlaActorFactory.generated.h"
19
20/// Base class for Carla actor factories.
21UCLASS(Abstract)
22class CARLA_API ACarlaActorFactory : public AActor
23{
24 GENERATED_BODY()
25
26public:
27
28 ACarlaActorFactory(const FObjectInitializer& ObjectInitializer)
29 : Super(ObjectInitializer)
30 {
31 PrimaryActorTick.bCanEverTick = false;
32 }
33
34 /// Retrieve the list of actor definitions that this class is able to spawn.
35 virtual TArray<FActorDefinition> GetDefinitions() {
36 unimplemented();
37 return {};
38 }
39
40 /// Spawn an actor based on @a ActorDescription and @a Transform.
41 ///
42 /// @pre ActorDescription is expected to be derived from one of the
43 /// definitions retrieved with GetDefinitions.
45 const FTransform &SpawnAtTransform,
46 const FActorDescription &ActorDescription) {
47 unimplemented();
48 return {};
49 }
50
51 /// Drop every cached definition, parameter and loaded asset that refers to
52 /// content under @a MountPoint ("/<Pack>/"), so a content pack can be
53 /// unmounted; the dropped blueprints are gone until the next episode.
54 virtual void ReleaseContentPack(const FString &MountPoint) {}
55
56 /// True when the definition's class or any attribute/variation value
57 /// points at content under @a MountPoint.
58 static bool DefinitionReferencesPath(const FActorDefinition &Definition, const FString &MountPoint)
59 {
60 const UClass *Class = Definition.Class.Get();
61 if (IsValid(Class) && Class->GetPathName().StartsWith(MountPoint))
62 {
63 return true;
64 }
65 for (const FActorAttribute &Attribute : Definition.Attributes)
66 {
67 if (Attribute.Value.StartsWith(MountPoint))
68 {
69 return true;
70 }
71 }
72 for (const FActorVariation &Variation : Definition.Variations)
73 {
74 for (const FString &Value : Variation.RecommendedValues)
75 {
76 if (Value.StartsWith(MountPoint))
77 {
78 return true;
79 }
80 }
81 }
82 return false;
83 }
84};
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
Base class for Carla actor factories.
ACarlaActorFactory(const FObjectInitializer &ObjectInitializer)
virtual TArray< FActorDefinition > GetDefinitions()
Retrieve the list of actor definitions that this class is able to spawn.
virtual FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription)
Spawn an actor based on ActorDescription and Transform.
virtual void ReleaseContentPack(const FString &MountPoint)
Drop every cached definition, parameter and loaded asset that refers to content under MountPoint ("/<...
static bool DefinitionReferencesPath(const FActorDefinition &Definition, const FString &MountPoint)
True when the definition's class or any attribute/variation value points at content under MountPoint.
An actor attribute, may be an intrinsic (non-modifiable) attribute of the actor or an user-defined ac...
A definition of a Carla Actor with all the variation and attributes.
TArray< FActorVariation > Variations
Variations represent variables the user can modify to generate variations of the actor.
TArray< FActorAttribute > Attributes
Attributes represent non-modifiable properties of the actor that might help the user identifying and ...
TSubclassOf< AActor > Class
Class of the actor to be spawned (Optional).
A description of a Carla Actor with all its variation.
Result of an actor spawn function.