Using spline components with or in place of landscape splines

I am wondering if there is a way to get the landscape spline section to read spline components for adjusting the terrain height. If not then I’m assuming that I can generate a terrain spine via C++ to follow the same path of the root spline component?

Edit:
Tried this, only updates LOD of the terrain…

/**/
 void ACityPathBuilder::UpdateCollision(ULandscapeHeightfieldCollisionComponent* InComponent, uint16 *InSource)
 {
     uint16 *Dest = (uint16*)InComponent->CollisionHeightData.Lock(LOCK_READ_WRITE);
 
     for (int i = 0; i < InComponent->CollisionHeightData.GetElementCount(); i++, InSource++, Dest++)
         *Dest = *InSource;
 
     InComponent->CollisionHeightData.Unlock();
 }
 void ACityPathBuilder::UpdateTexture(UTexture2D *InTexture, uint16 *InSource,int32 size)
 {
     for (int m = 0; m < InTexture->PlatformData->Mips.Num(); m++)
     {
         FTexture2DMipMap& Mip = InTexture->PlatformData->Mips[m];
         int32 sz = Mip.BulkData.GetBulkDataSize();
 
         UE_LOG(LogTemp, Log, TEXT("terrainSize: %d"), sz);
         void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
         FMemory::Memcpy(Data, InSource, sz);
         Mip.BulkData.Unlock();
     }
     InTexture->UpdateResource();
 }
 
 
 void GenerateHeights(int32 row, int32 col, int Value, uint16 *Heights)
 {
     for (int32 i = 0; i < row*col; i++)
     {
         Heights[i] = Value;
     }
 }
 void ACityPathBuilder::CreateTerrain()
 {
     // Generate 8x8 array with height 65000
     uint16 Heights[512*512];
     uint16 * pHeight = Heights;
     UE_LOG(LogTemp, Log, TEXT("CreateTerrain1"));
     GenerateHeights(512 , 512, 1000, Heights);
 
     UE_LOG(LogTemp, Log, TEXT("CreateTerrain2"));
     if (pHeight == nullptr)return;
     UE_LOG(LogTemp, Log, TEXT("CreateTerrain3"));
     for (TActorIterator<ALandscape> ActorItr(GetWorld()); ActorItr; ++ActorItr)
     {
         TArray<ULandscapeHeightfieldCollisionComponent*> Components = ActorItr->CollisionComponents;
         for (int c = 0; c < ActorItr->LandscapeComponents.Num(); c++)
         {
             ULandscapeComponent * temp = (ULandscapeComponent*)ActorItr->LandscapeComponents[c];
             UTexture2D * currTexture = nullptr;
             if (temp != nullptr){
                 currTexture= temp->HeightmapTexture;
             }
             if (currTexture != nullptr){
                 UpdateTexture(currTexture, pHeight, 512* 512);
             }
         }
     }
 }

I’ve also tried adding ULandscapeSplinesComponent but I can not figure out how to add any Controlpoints are Segments. Any ideas?

All attempts to spawn a Controlpoint or segment ended in a crash:

	TerrainSpline->ControlPoints.Add(GetWorld()->SpawnActor< ULandscapeSplineControlPoint >());//NewObject<ULandscapeSplineControlPoint>());//
	TerrainSpline->ControlPoints.Add(GetWorld()->SpawnActor< ULandscapeSplineControlPoint >());//NewObject<ULandscapeSplineControlPoint>()); //

	TerrainSpline->Segments.Add(GetWorld()->SpawnActor< ULandscapeSplineSegment >());//NewObject<ULandscapeSplineSegment>());//
	TerrainSpline->Segments.Add(GetWorld()->SpawnActor< ULandscapeSplineSegment >());//NewObject<ULandscapeSplineSegment>());//
	if (TerrainSpline->ControlPoints[0] != NULL){
		TerrainSpline->ControlPoints[0]->UpdateSplinePoints();
		TerrainSpline->Segments[0]->UpdateSplinePoints();
		TerrainSpline->ControlPoints[1]->UpdateSplinePoints();
		TerrainSpline->Segments[1]->UpdateSplinePoints();
	}

Also:

	TArray<ULandscapeSplineControlPoint*> temp = TerrainSpline->ControlPoints;
	ULandscapeSplineControlPoint * point = ObjectInitializer.CreateDefaultSubobject<ULandscapeSplineControlPoint>(this, TEXT("P0"));
	temp.Add(point);

I dont get it NewObject,NewNamedObject,ConstructObject none of these can make a ULandscapeSplineControlPoint. Awe these restricted or something?

Hey guys,

In 4.8 there will be a Blueprint function called “Editor Apply Spline” that lets you flatten landscape using blueprint created splines. You can specify a layer to paint as well which is very handy. I started messing around with an automatic river blueprint that builds a spline to fit the terrain and then carves out a flat section and a channel for the water.

This requires two spline apply operations, one for the flattening, one for the channel (which is built from a copy of the spline with Z offset). The nodes look like this:

To apply the splines to the landscape uses Blutilities. These are accessed via the details panel of the blueprint under blutilities:

39476-flatten.jpg

Blutilities let the editor call event graph code which is how this works. Unfortunately these edits are destructive and undo does not work with them yet so make sure to save often when trying this stuff.

Please note to others, It seems that you can only access this via blueprint using it via c++ throws a linker error:

Hopefully it will be available in c++ in the full release but maybe not :frowning:

I will find out about this and get back to you.