|
CARLA
|
Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of all the actors spawned. More...
#include <ActorDispatcher.h>
Inheritance diagram for UActorDispatcher:Public Types | |
| using | SpawnFunctionType = TFunction< FActorSpawnResult(const FTransform &, const FActorDescription &)> |
Public Member Functions | |
| void | Bind (ACarlaActorFactory &ActorFactory) |
| Bind all the definitions of ActorFactory to its spawn function. | |
| void | Bind (FActorDefinition Definition, SpawnFunctionType SpawnFunction) |
| Bind a definition to a spawn function. | |
| void | BindNewDefinitions (ACarlaActorFactory &ActorFactory) |
| Bind the definitions of ActorFactory that are not bound yet. | |
| bool | DestroyActor (FCarlaActor::IdType ActorId) |
| Destroys an actor, properly removing it from the registry. | |
| const TArray< FActorDefinition > & | GetActorDefinitions () const |
| FActorRegistry & | GetActorRegistry () |
| const FActorRegistry & | GetActorRegistry () const |
| void | PutActorToSleep (FCarlaActor::IdType Id, UCarlaEpisode *CarlaEpisode) |
| FCarlaActor * | RegisterActor (AActor &Actor, FActorDescription ActorDescription, FActorRegistry::IdType DesiredId=0) |
| Register an actor that was not created using "SpawnActor" function but that should be kept in the registry. | |
| void | ReleaseContentPack (const FString &MountPoint) |
| Forget the classes of every definition that refers to content under MountPoint (a content pack being unmounted). | |
| AActor * | ReSpawnActor (const FTransform &Transform, FActorDescription ActorDescription) |
| ReSpawns an actor based on ActorDescription at Transform. | |
| TPair< EActorSpawnResultStatus, FCarlaActor * > | SpawnActor (const FTransform &Transform, FActorDescription ActorDescription, FCarlaActor::IdType DesiredId=0) |
| Spawns an actor based on ActorDescription at Transform. | |
| void | WakeActorUp (FCarlaActor::IdType Id, UCarlaEpisode *CarlaEpisode) |
Private Member Functions | |
| void | OnActorDestroyed (AActor *Actor) |
Private Attributes | |
| TMap< FString, TSubclassOf< AActor > > | Classes |
| TArray< FActorDefinition > | Definitions |
| UPROPERTY so the garbage collector clears the class references when a content pack's classes are destroyed; a plain array kept dangling TSubclassOf pointers that ReleaseContentPack then dereferenced. | |
| FActorRegistry | Registry |
| TArray< SpawnFunctionType > | SpawnFunctions |
Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of all the actors spawned.
Definition at line 26 of file ActorDispatcher.h.
| using UActorDispatcher::SpawnFunctionType = TFunction<FActorSpawnResult(const FTransform &, const FActorDescription &)> |
Definition at line 32 of file ActorDispatcher.h.
| void UActorDispatcher::Bind | ( | ACarlaActorFactory & | ActorFactory | ) |
Bind all the definitions of ActorFactory to its spawn function.
Definition at line 78 of file ActorDispatcher.cpp.
References Bind(), ACarlaActorFactory::GetDefinitions(), and ACarlaActorFactory::SpawnActor().
| void UActorDispatcher::Bind | ( | FActorDefinition | Definition, |
| SpawnFunctionType | SpawnFunction | ||
| ) |
Bind a definition to a spawn function.
When SpawnActor is called with a matching description Functor is called.
Definition at line 26 of file ActorDispatcher.cpp.
References UActorBlueprintFunctionLibrary::CheckActorDefinition(), FActorDefinition::Class, Classes, Definitions, FActorDefinition::Id, SpawnFunctions, and FActorDefinition::UId.
Referenced by Bind(), and BindNewDefinitions().
| void UActorDispatcher::BindNewDefinitions | ( | ACarlaActorFactory & | ActorFactory | ) |
Bind the definitions of ActorFactory that are not bound yet.
Definitions are normally bound once, when the episode registers its factories. A content pack mounted later brings new catalog entries, and its blueprints must become available without waiting for a world load.
Definition at line 62 of file ActorDispatcher.cpp.
References Bind(), Definitions, ACarlaActorFactory::GetDefinitions(), FActorDefinition::Id, and ACarlaActorFactory::SpawnActor().
| bool UActorDispatcher::DestroyActor | ( | FCarlaActor::IdType | ActorId | ) |
Destroys an actor, properly removing it from the registry.
Return true if the Actor is destroyed or already marked for destruction, false if indestructible or nullptr.
Definition at line 176 of file ActorDispatcher.cpp.
References FActorRegistry::Deregister(), FActorInfo::Description, FActorRegistry::FindCarlaActor(), FCarlaActor::GetActor(), FCarlaActor::GetActorInfo(), FActorDescription::Id, Registry, and Success.
|
inline |
Definition at line 96 of file ActorDispatcher.h.
|
inline |
Definition at line 106 of file ActorDispatcher.h.
|
inline |
Definition at line 101 of file ActorDispatcher.h.
Referenced by UCarlaEpisode::SerializeActorWithPrimaryIds().
|
private |
Definition at line 335 of file ActorDispatcher.cpp.
References FFrameData::AddEvent(), UCarlaEpisode::bIsPrimaryServer, FActorRegistry::Deregister(), FActorRegistry::FindCarlaActor(), FCarlaActor::GetActorId(), UCarlaEpisode::GetFrameData(), carla::ros2::ROS2::GetInstance(), FCarlaActor::IsActive(), and Registry.
Referenced by RegisterActor().
| void UActorDispatcher::PutActorToSleep | ( | FCarlaActor::IdType | Id, |
| UCarlaEpisode * | CarlaEpisode | ||
| ) |
Definition at line 325 of file ActorDispatcher.cpp.
References FActorRegistry::PutActorToSleep(), and Registry.
| FCarlaActor * UActorDispatcher::RegisterActor | ( | AActor & | Actor, |
| FActorDescription | ActorDescription, | ||
| FActorRegistry::IdType | DesiredId = 0 |
||
| ) |
Register an actor that was not created using "SpawnActor" function but that should be kept in the registry.
Definition at line 221 of file ActorDispatcher.cpp.
References ActorROS2Handler::FlattenSteeringCurve(), FCarlaActor::GetActorId(), carla::ros2::ROS2::GetInstance(), FActorDescription::Id, OnActorDestroyed(), FActorRegistry::Register(), Registry, and FActorDescription::Variations.
Referenced by UCarlaEpisode::InitializeAtBeginPlay(), and SpawnActor().
| void UActorDispatcher::ReleaseContentPack | ( | const FString & | MountPoint | ) |
Forget the classes of every definition that refers to content under MountPoint (a content pack being unmounted).
Slots are kept so UIds stay valid; spawning such a definition fails until the next episode.
Definition at line 41 of file ActorDispatcher.cpp.
References Classes, ACarlaActorFactory::DefinitionReferencesPath(), Definitions, and FActorDefinition::Id.
| AActor * UActorDispatcher::ReSpawnActor | ( | const FTransform & | Transform, |
| FActorDescription | ActorDescription | ||
| ) |
ReSpawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor. Used to respawn dormant actors.
Definition at line 138 of file ActorDispatcher.cpp.
References FActorSpawnResult::Actor, FActorDescription::Class, Classes, FActorDescription::Id, SpawnFunctions, FActorSpawnResult::Status, and FActorDescription::UId.
| TPair< EActorSpawnResultStatus, FCarlaActor * > UActorDispatcher::SpawnActor | ( | const FTransform & | Transform, |
| FActorDescription | ActorDescription, | ||
| FCarlaActor::IdType | DesiredId = 0 |
||
| ) |
Spawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor.
Definition at line 88 of file ActorDispatcher.cpp.
References FActorSpawnResult::Actor, FActorDescription::Class, Classes, FActorDescription::Id, FActorSpawnResult::IsValid(), RegisterActor(), SpawnFunctions, FActorSpawnResult::Status, ATagger::TagActor(), and FActorDescription::UId.
Referenced by UCarlaEpisode::SpawnActorWithInfo().
| void UActorDispatcher::WakeActorUp | ( | FCarlaActor::IdType | Id, |
| UCarlaEpisode * | CarlaEpisode | ||
| ) |
Definition at line 330 of file ActorDispatcher.cpp.
References Registry, and FActorRegistry::WakeActorUp().
|
private |
Definition at line 125 of file ActorDispatcher.h.
Referenced by Bind(), ReleaseContentPack(), ReSpawnActor(), and SpawnActor().
|
private |
UPROPERTY so the garbage collector clears the class references when a content pack's classes are destroyed; a plain array kept dangling TSubclassOf pointers that ReleaseContentPack then dereferenced.
Definition at line 120 of file ActorDispatcher.h.
Referenced by Bind(), BindNewDefinitions(), and ReleaseContentPack().
|
private |
Definition at line 127 of file ActorDispatcher.h.
Referenced by DestroyActor(), OnActorDestroyed(), PutActorToSleep(), RegisterActor(), and WakeActorUp().
|
private |
Definition at line 122 of file ActorDispatcher.h.
Referenced by Bind(), ReSpawnActor(), and SpawnActor().