pioneerspacesim/pioneer — pull request #1423 by johnbartholomew (2012-08-08 14:43:51+00:00)
Title: Clamp planetary mass value into range representable by `fixed`

Fixes #854, based on testing with [Brianetta's test system](https://gist.github.com/1499081).

The hang was an infinite loop in `TerrainBody::render`, which was a symptom of nan values creeping into the system. That nan was being generated as a result of a systembody having a negative mass, which was produced by the fixed-point planetary mass computation in `MakePlanetsAround` overflowing.

It would be a good idea to add some more comprehensive asserts to other fixed-point calculations to check for range problems (possibly put asserts in the `fixed` implementation itself). If this is merged before I get round to that, it would be good to add a TODO issue for it.