How to determine if atmosphere is escaping from a voxel(block based) vesselAuthor:
While on the forums of star-made the issue of having an atmosphere in a ship that could escape came up.
At this point the creators have not implemented anything of the sort and as I recently told one of the moderators I would no longer offer solutions for free.
The solution to this is relatively easy if you do a few things. The first is the ships in this game are made out of blocks. That actually makes it simpler. The primary solution is to use a path finding algorithm such as "Best first search" to find out if the atmosphere can make it out.
It would require millions of checks if we checked from each block to try and get outside all the time.
To make the task easy we will define when we need to make a check only if an airlock with the outside opens or to a room without atmosphere and if damage occurs that penetrates the ship to an atmosphere filled compartment.
To further make this simpler we create an atmospheric emitter or Oxygen output block or anything else one might choose to call it. You then measure from the emission point to the first outside block it comes to. We can simplify that by specifying the blocks outside the air lock that opens or the first block where a hull breach occurs internally.
To make that task simpler we create a bounding box around rooms and halls that are to be filled with atmosphere. They could be user defined or defined by the game engine. This way to determine breach points we can simply test when damage happens does it break the bounding box if so we know where the breach happens.
This means all testing can be reduced to just when a door opens or closes when hull damage actually reaches inner compartments not just every time damage happens.
To further reduce processor load after a breach has been created it is only again test after an airlock is closed or the hull damage is reset and repairs deemed complete. This can be done by taking the Atmosphere emitter offline and when repairs are complete the user can put it back online.
If you want a rough estimate of the atmosphere. Being exchange simply use the opening size to determine how many blocks of air that can pass through it in a given time to work you calculation. No need to over complicate it. After all you need to test is if the atmosphere empties out or balances with another space.
Performance can be further improved by giving each room's bounding box information as to what other rooms are directly connected. Then best first search can be done on a room to room basis vs block basis and only doors need to be checked for open or closed in between. This cuts the path search to a minute fraction of the block length search.
(C) George Hayes You can make use of this method so long as you give full credit to George Hayes with providing the method. Credit will be display on any packaging or credits to any product making use of the method. If you provide this method to another party or entity they must be made aware of the copyright restrictions and also provide the credit as listed above.