How can I access the landscape heightmap from Blueprint?

I’ve got a user request for a tool to create a terrain-following mesh using the spline tool, but, rather than following the terrain as a ribbon the geometry would be a closed polyline (or closed spline) : effectively a ‘fill’ to the spline in the same way a road spline is a ‘stroke’

To make this work I’d need to be able to sample the underlying terrain, either the mesh version or the heightmap version. If I had the same sample frequency as the underlying terrain then creating the offset mesh is pretty easy; Raycasts will let me find the terrain at a given point - but I don’t know how to make sure those points are lined up with the sample points of the terrain.

So, how do I proceed? I’d prefer to do it all via BP but I could do it in C++ if there were no other way.

The easiest way is to inverse transform your points by the landscape’s local-to-world so you are working in the landscape’s local space. Landscape-space is set up so each integer coordinate is a landscape vertex, which makes it lovely to work with. You can then transform back into world space to do your raycasts.

Alternatively, (if you’re in the editor) there are various classes for reading the landscape data directly, but these don’t function at runtime.

This sounds great, thanks! So i’m just going to grab the matrix of the landscape object, transform into it, and when I’m done transform back out?