Add the tagger to the new game mode

This commit is contained in:
nsubiron 2018-07-27 21:12:04 +02:00
parent 3bd383a46d
commit 8c656b5486
2 changed files with 23 additions and 0 deletions

View File

@ -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<UCarlaEpisode>(TEXT("Episode"));
TaggerDelegate = CreateDefaultSubobject<UTaggerDelegate>(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);
}

View File

@ -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;