Theres been two big questions on my mind for a long time now about game dev and the time is going to come very soon where im going to need how to do this, because i've thought long and hard about it but i just can't fathom of any way to do it.


Say you have a level or a terrain, it could be for a shooter, or a racer just about anything and its not flat it has angles and hills infact it was as far from flat as anything could possibly be (well actually if it were a racer u'd want some kind of flatness) how could done calculate the depth of the tarrain at any giving location so you would not fall through the floor when you have a mash with what is most likely going to to be 500,000+ polygons.
And how would one calculate it if say you had two floors in a building that could be accessed how would you know when to fall and when to stop.

This seems to me like a fundemental in any givin 3d game, but i wouldn't even know where to begin