Added: Initial world generation tool
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "LandscapeSubsystem.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Materials/MaterialInterface.h"
|
||||
#include "RenderingThread.h"
|
||||
|
||||
ALandscape* ULandscapeAuthoringLibrary::CreateLandscapeFromHeightmap(UWorld* World, const FString& HeightmapFile,
|
||||
const TArray<FLandscapeAuthoringWeightmap>& Weightmaps, UMaterialInterface* Material,
|
||||
@@ -130,6 +131,21 @@ ALandscape* ULandscapeAuthoringLibrary::CreateLandscapeFromHeightmap(UWorld* Wor
|
||||
}
|
||||
}
|
||||
|
||||
// Edit layers are always on, and the render heightmaps and weightmaps are produced from the imported layer
|
||||
// data by the edit-layer merge, which normally runs on the editor tick. A commandlet never ticks, so without
|
||||
// this the saved level has the imported collision heights but flat, empty render textures, and the landscape
|
||||
// is invisible from below. The editor's own import does the same full update before saving.
|
||||
Landscape->ForceLayersFullUpdate();
|
||||
for (int32 Attempt = 0; Attempt < 500 && !Landscape->IsUpToDate(); ++Attempt)
|
||||
{
|
||||
Landscape->TickLayers(1.0f / 30.0f);
|
||||
FlushRenderingCommands();
|
||||
}
|
||||
if (!Landscape->IsUpToDate())
|
||||
{
|
||||
UE_LOG(LogSaltyEditor, Warning, TEXT("CreateLandscapeFromHeightmap: the edit-layer update did not finish; render heightmaps may be stale"));
|
||||
}
|
||||
|
||||
UE_LOG(LogSaltyEditor, Log, TEXT("CreateLandscapeFromHeightmap: %ux%u vertices, %dx%d components of %d quads, scale (%g, %g, %g), %d paint layers"),
|
||||
RequiredResolution.Width, RequiredResolution.Height, ComponentCount.X, ComponentCount.Y, QuadsPerComponent, Scale.X, Scale.Y, Scale.Z, LayerInfos.Num());
|
||||
return Landscape;
|
||||
|
||||
@@ -17,7 +17,8 @@ public class SaltyEditor : ModuleRules
|
||||
PrivateDependencyModuleNames.AddRange(new string[] {
|
||||
"UnrealEd",
|
||||
"Landscape",
|
||||
"LandscapeEditor" // FLandscapeImportHelper reads the heightmap and weightmap files
|
||||
"LandscapeEditor", // FLandscapeImportHelper reads the heightmap and weightmap files
|
||||
"RenderCore" // FlushRenderingCommands while the edit-layer merge is driven by hand
|
||||
});
|
||||
|
||||
PublicIncludePaths.Add(ModuleDirectory);
|
||||
|
||||
Reference in New Issue
Block a user