Collision on dynamic ground

The problem here is that, in order to check the heightfield, I have to project my mouse position on the heightfield to have a x,y coord and then the height of the point … So the only way I see is this one which gives me the 3 coords at the same time.
Do you have an idea about how you would do ?