Particle groups
#74
I can do that after 0.5.0. Should we add the group to the particleDetail struct, or would you prefer some other data structure?
Need to keep in mind backwards compatibility. Some thoughts:
- Changing the
particleDetailstruct will cause all previous saved simulations to be corrupt. We can fix this by making Gravit- automatically "upgrade" saved simulations, or
- automatically detect which version of Gravit was used to save, then load the simulation differently
- We can create another save file used for saving groups, but 4 files per simulation is starting to be excessive
- The other option is to dismiss any idea of upgrading saved simulations, but it might make some users unhappy.
I like the idea of upgrading saved simulations. Maybe this can be done whenever someone loads the simulation?
There's another aspect to this where we should start keeping a version number within the simulation for future upgrades to the file formats.
I think the saveInfo struct can have a version number added to it. We can detect if the save is from a previous version by the size of the file being 20 bytes (5 ints) and the new version which should add an int version at the start, making it 24 bytes.
versioning and auto-upgrading sounds good; I was also thinking about extending saveInfo, because we should include view.zoom, view.rot, and possibly other data (state.g) that is neecessary to restore the view and simulation state.
The .info file is really small, so maybe we should directly go for XML with this file.
XML would probably be a bad choice for the other two files (.particles, .particledetail), because the size may "explode" when we write all the binary data to an ASCII format.
(back to the main topic) If we have particle groups, we could even exploit this to stabilize a simulation after spawning:
- spawn stuff
- for all groups, compute the total mass, and the center-off-mass
- run a "dummy" simulation step, to compute accelerations on each body
- now correct all particle velocities to enforce a stable orbit around the groups center-of-mass. (formula to compute a stable orbit velocity: http://en.wikipedia.org/wiki/Elliptic_orbit)