KSP-KOS/KOS — pull request #197 by Dunbaratu (2014-07-16 18:56:43+00:00)
Title: "Resolves" issue #194.

This issue was a lot more messy than it appeared on the surface.
At the moment the ground height is still different from alt:radar by a meter
or two, but I think that might be due to the floating point precision errors
in some of the API methods.

NOTE: IF you get a LATLNG of a position far away from the current active
vessel, such that in the area around that LATLNG the terrain polygon mesh
isn't loaded (i.e. it's more than 8000 or so meters away), then the distance
**cannot** be made more accurate than it is because it's based on the
ideal predicted ground altitude at that location rather than what it will
actually be when you get there. The game renders the ground polygons in
a way that only approximates the mathematical description of the terrain,
and once it renders the ground polygons then it's the actual ground polygons
that it made that decide the ground altitude, NOT the ideal predicted ground
altitude function. (Thus why if you save a game with a landed ship, and then
change the graphics terrain detail setting, and then reload to the ship
again, it might spawn under the ground and KSP has to fiddle around to move it
to the new ground position, which you can watch it doing.)

OTHER PROBLEMS ALSO FIXED:
When looking at the code I noticed other problems with what it was doing before that I fixed, which I've made commit notes for in the code lines.