pioneerspacesim/pioneer — pull request #3297 by fluffyfreak (2014-12-31 10:23:56+00:00)
Title: *WIP* - Bundle Collision with SGM file

# Description:
We have an optimised & preprocessed file format called SGM that was written by Luomu but, for some reason, we don't ship SGM files in with the main distribution. Part of that reason was that it helped loading times a lot but not as much as it could have due to the collision mesh generation being excluded from it.

With the merging of #3099 giving us 3 very complex new space stations and very complex collision meshes I've tried to add support for serialising and deserialising the collision meshes into our SGM format.

# Loading times:
A quick comparison, please note that this is done on my laptop with a 512GiB SSD so there's little variation due to disk access, but possibly some due to thermal throttling/behaviour.

## SGM Load times:
I did 3 runs and the times were
* Loading took: 19467.036626 milliseconds
* Loading took: 20026.478004 milliseconds
* Loading took: 19888.185336 milliseconds
For an average of **~19,793.9** milliseconds.

## Standard Load times:
Once again but with no SGM files.
* Loading took: 117843.126233 milliseconds
* Loading took: 119204.148816 milliseconds
* Loading took: 118303.561635 milliseconds
For an average of **~118,450.3** milliseconds

## Result:
This means that using SGM files with the collision mesh data results in the game loading to the intro screen **~5.98** times faster.

# At the Command line:
**WARNING**: The SGM files this creates will be chosen in preference to the original data in future so you might miss updates to files. Best to delete all of these SGM files after experimenting with this **WARNING**

To recreate the SGM files you just need to build the ModelCompiler, this should be shipped with the binaries versions, or you can build it yourself. It's built alongside Pioneer.
Simply go to the Pioneer folder where ModelCompiler & Pioneer reside, open a prompt / terminal and enter something like: `modelcompiler -b inplace`
That will create an SGM file for every model in the game and place it next to it's `.model` file.

# WIP:
I have hacked this up whilst slightly off my face with a serious cold. Code review, indeed approach review would be appreciated.
[ ] Is it worth compressing the SGM2 format files? Does it improve loading times or make them worse?
[ ] Can the BVHTree class be serialised or is it better to store more data `m_aabbs` for serialisation like I am?

Andy