Added check to register objects

This commit is contained in:
doterop 2020-11-09 22:55:36 +01:00 committed by bernat
parent 42c4c15569
commit e83fd71040
2 changed files with 15 additions and 8 deletions

View File

@ -127,7 +127,7 @@ void ACarlaGameModeBase::BeginPlay()
Super::BeginPlay();
LoadMapLayer(GameInstance->GetCurrentMapLayer());
ReadyToRegisterObjects = true;
if (true) { /// @todo If semantic segmentation enabled.
check(GetWorld() != nullptr);
@ -163,8 +163,7 @@ void ACarlaGameModeBase::BeginPlay()
Recorder->GetReplayer()->CheckPlayAfterMapLoaded();
}
RegisterEnvironmentObject();
RegisterEnvironmentObjects();
}
void ACarlaGameModeBase::Tick(float DeltaSeconds)
@ -361,7 +360,7 @@ TArray<FBoundingBox> ACarlaGameModeBase::GetAllBBsOfLevel(uint8 TagQueried)
return BoundingBoxes;
}
void ACarlaGameModeBase::RegisterEnvironmentObject()
void ACarlaGameModeBase::RegisterEnvironmentObjects()
{
// Get all actors of the level
TArray<AActor*> FoundActors;
@ -392,8 +391,11 @@ void ACarlaGameModeBase::LoadMapLayer(int32 MapLayers)
}
// Register new actors and tag them
RegisterEnvironmentObject();
ATagger::TagActorsInLevel(*GetWorld(), true);
if(ReadyToRegisterObjects)
{
RegisterEnvironmentObjects();
ATagger::TagActorsInLevel(*GetWorld(), true);
}
}
@ -413,7 +415,10 @@ void ACarlaGameModeBase::UnLoadMapLayer(int32 MapLayers)
}
// Update stored registered objects (discarding the deleted objects)
RegisterEnvironmentObject();
if(ReadyToRegisterObjects)
{
RegisterEnvironmentObjects();
}
}
void ACarlaGameModeBase::ConvertMapLayerMaskToMapNames(int32 MapLayer, TArray<FName>& OutLevelNames)

View File

@ -91,7 +91,7 @@ private:
void ParseOpenDrive(const FString &MapName);
void RegisterEnvironmentObject();
void RegisterEnvironmentObjects();
void ConvertMapLayerMaskToMapNames(int32 MapLayer, TArray<FName>& OutLevelNames);
@ -130,4 +130,6 @@ private:
boost::optional<carla::road::Map> Map;
bool ReadyToRegisterObjects = false;
};