I already have c++ code to import a heightmap file and create a world partition landscape. In 5.3 the new worldpartion sizes where added so you can create/import very large landscape such as size 15,301. When you have a very large size UE creates Regions as well as streaming proxies. How do I tell UE to create Regions in my c++ code?
My import code:
void UEditorLandscapeLibrary::ImportHeightmap(FString FilePath, FString LandscapeName,
FString FileName, const int Width,
const int Height, const int WorldPartitionGridSize)
{
FilePath += + "\\" + FileName;
int NewLandscape_QuadsPerSection;
int NewLandscape_SectionsPerComponent;
FIntPoint NewLandscape_ComponentCount;
FLandscapeImportHelper::ChooseBestComponentSizeForImport(Width, Height, NewLandscape_QuadsPerSection, NewLandscape_SectionsPerComponent, NewLandscape_ComponentCount);
const int32 ComponentCountX = NewLandscape_ComponentCount.X;
const int32 ComponentCountY = NewLandscape_ComponentCount.Y;
const int32 QuadsPerComponent = NewLandscape_SectionsPerComponent * NewLandscape_QuadsPerSection;
const int32 SizeX = ComponentCountX * QuadsPerComponent + 1;
const int32 SizeY = ComponentCountY * QuadsPerComponent + 1;
ALandscape* Landscape = GEditor->GetEditorWorldContext().World()->SpawnActor<ALandscape>();
Landscape->bCanHaveLayersContent = true;
const auto ActualPath = FilePath.IsEmpty() ? Landscape->ReimportHeightmapFilePath : FilePath;
if (ActualPath.IsEmpty())
return;
//Read png file to height array
TArray<uint16> RawData;
ReadHeightmapFile(RawData, *ActualPath, Width, Height);
// Setup heightmap for landscape
TMap<FGuid, TArray<uint16>> HeightmapDataPerLayers;
TMap<FGuid, TArray<FLandscapeImportLayerInfo>> MaterialLayerDataPerLayer;
// Generate LandscapeActor from heightmap
HeightmapDataPerLayers.Add(FGuid(), RawData);
MaterialLayerDataPerLayer.Add(FGuid(), TArray<FLandscapeImportLayerInfo>());
Landscape->Import(FGuid::NewGuid(), 0, 0, SizeX - 1, SizeY - 1,
NewLandscape_SectionsPerComponent, NewLandscape_QuadsPerSection, HeightmapDataPerLayers,
*ActualPath, MaterialLayerDataPerLayer, ELandscapeImportAlphamapType::Layered);
ULandscapeInfo* LandscapeInfo = Landscape->GetLandscapeInfo();
Landscape->SetActorLocation(FVector(0, 0, 100));
Landscape->SetActorScale3D(FVector(100, 100, 100));
Landscape->SetActorLabel(LandscapeName);
LandscapeInfo->UpdateLayerInfoMap(Landscape);
UE_LOG(LogStreaming, Warning, TEXT("GridSize: %d"), WorldPartitionGridSize);
if (WorldPartitionGridSize > 0)
{
//Setup World partition streaming proxies
GEditor->GetEditorWorldContext().World()->GetSubsystem<ULandscapeSubsystem>()->ChangeGridSize(LandscapeInfo, WorldPartitionGridSize);
}
}
So this line
//Setup World partition streaming proxies
GEditor->GetEditorWorldContext().World()->GetSubsystem<ULandscapeSubsystem>()->ChangeGridSize(LandscapeInfo, WorldPartitionGridSize);
This allows me to easily specify the landscape should be a world partition and import it with streaming proxies. Is there a one liner like this where I can specify region and number of regions to make UE import the landscape using Regions?