From 8c656b548647f8a413e27c264193da483404de54 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Fri, 27 Jul 2018 21:12:04 +0200 Subject: [PATCH] Add the tagger to the new game mode --- .../Carla/Game/TheNewCarlaGameModeBase.cpp | 18 ++++++++++++++++++ .../Carla/Game/TheNewCarlaGameModeBase.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.cpp index ee4eb9f5b..56b2dd44e 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.cpp @@ -7,6 +7,9 @@ #include "Carla.h" #include "Carla/Game/TheNewCarlaGameModeBase.h" +#include "Game/Tagger.h" +#include "Game/TaggerDelegate.h" + ATheNewCarlaGameModeBase::ATheNewCarlaGameModeBase(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { @@ -15,6 +18,8 @@ ATheNewCarlaGameModeBase::ATheNewCarlaGameModeBase(const FObjectInitializer& Obj bAllowTickBeforeBeginPlay = false; Episode = CreateDefaultSubobject(TEXT("Episode")); + + TaggerDelegate = CreateDefaultSubobject(TEXT("TaggerDelegate")); } void ATheNewCarlaGameModeBase::InitGame( @@ -32,6 +37,13 @@ void ATheNewCarlaGameModeBase::InitGame( GameInstance != nullptr, TEXT("GameInstance is not a UCarlaGameInstance, did you forget to set it in the project settings?")); + if (TaggerDelegate != nullptr) { + check(GetWorld() != nullptr); + TaggerDelegate->RegisterSpawnHandler(GetWorld()); + } else { + UE_LOG(LogCarla, Error, TEXT("Missing TaggerDelegate!")); + } + SpawnActorFactories(); } @@ -39,6 +51,12 @@ void ATheNewCarlaGameModeBase::BeginPlay() { Super::BeginPlay(); + if (true) { /// @todo If semantic segmentation enabled. + check(GetWorld() != nullptr); + ATagger::TagActorsInLevel(*GetWorld(), true); + TaggerDelegate->SetSemanticSegmentationEnabled(); + } + GameInstance->NotifyBeginEpisode(*Episode); } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.h index 553981c81..237543b7f 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/TheNewCarlaGameModeBase.h @@ -14,6 +14,8 @@ #include "TheNewCarlaGameModeBase.generated.h" +class UTaggerDelegate; + /// Base class for the CARLA Game Mode. UCLASS(HideCategories=(ActorTick)) class CARLA_API ATheNewCarlaGameModeBase : public AGameModeBase @@ -41,6 +43,9 @@ private: UPROPERTY() UCarlaGameInstance *GameInstance = nullptr; + UPROPERTY() + UTaggerDelegate *TaggerDelegate = nullptr; + UPROPERTY() UCarlaEpisode *Episode = nullptr;