CesiumGS / cesium-native

Apache License 2.0
402 stars 205 forks source link

Fix `SimplePlanarEllipsoidCurve` when one of the points has a negative height #830

Closed azrogers closed 5 months ago

azrogers commented 5 months ago

The SimplePlanarEllipsoidCurve used for flight paths currently doesn't work for paths where the source point is below the surface of the ellipsoid. It currently causes the calculated coordinates to be inverted, giving points on the other side of the earth. This is because the math in SimplePlanarEllipsoidCurve first scales the source and destination points to the surface of the ellipsoid, and then assumes that these surface points must be lower in elevation than the original points for the rest of the calculations. This meant that height wasn't calculated correctly, and crucially, _sourceDirection was calculated pointing the wrong direction, resulting in the inverted coordinates. I've fixed the math so that it should work the same when points are below the ellipsoid.

csciguy8 commented 5 months ago

Thanks @azrogers ! Code changes look reasonable and tested out some flights in cesium-unreal-samples.

If you could, just add a note about this in CHANGES.md, since it's a potentially user facing fix.

Other than that, looks ready for merge.

azrogers commented 5 months ago

@csciguy8 Updated CHANGES.md!