CARLA
UtilActorFactory.cpp
Go to the documentation of this file.
1 // Copyright (c) 2023 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 #include "UtilActorFactory.h"
8 
10 #include "Carla/Util/EmptyActor.h"
12 
13 TArray<FActorDefinition> AUtilActorFactory::GetDefinitions()
14 {
15  using ABFL = UActorBlueprintFunctionLibrary;
16  auto StaticMeshDefinition = ABFL::MakeGenericDefinition(
17  TEXT("util"),
18  TEXT("actor"),
19  TEXT("empty"));
20  StaticMeshDefinition.Class = AEmptyActor::StaticClass();
21 
22  return { StaticMeshDefinition };
23 }
24 
26  const FTransform &SpawnAtTransform,
27  const FActorDescription &ActorDescription)
28 {
29  using ABFL = UActorBlueprintFunctionLibrary;
30  auto *World = GetWorld();
31  if (World == nullptr)
32  {
33  UE_LOG(LogCarla, Error, TEXT
34  ("AUtilActorFactory: cannot spawn mesh into an empty world."));
35  return {};
36  }
37 
38  FActorSpawnParameters SpawnParameters;
39  SpawnParameters.SpawnCollisionHandlingOverride =
40  ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
41 
42  auto *StaticMeshActor = World->SpawnActor<AEmptyActor>(
43  ActorDescription.Class, SpawnAtTransform, SpawnParameters);
44 
45  return FActorSpawnResult(StaticMeshActor);
46 }
TArray< FActorDefinition > GetDefinitions() final
Retrieve the definitions of the static mesh actor.
TSubclassOf< AActor > Class
Class of the actor to be spawned.
A description of a Carla Actor with all its variation.
FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) final
Spawn an actor based on ActorDescription and Transform.
Result of an actor spawn function.