do a container raycast, get the first brick it touches, do some math based on the brick.getWorldBox() function and figure out if the vector would be within the bounds of the top of the surface at the height that that surface is at.
For a terrain object type (why are you using this), if it finds some terrain you already know the vector has touched the top surface