Ray to terrain

Hi,

given the x and the y location I have to find the z looking for the intersection with a “terrain” object, quite complex, in game engine.

Is the function mathutils.geometry.intersect_ray_tri the only utility?
Should I loop all the faces?

I have looked the documentation around and a huge number of examples are looping and another good percent deals with problems that can be solved in other ways, not applicable here.

Thank you for any suggestion or advice,
Rickyx

That solved the problem: