Better air simulation?

  • JasonS
    8th Oct 2021 Member 0 Permalink

    I have two requests/suggestions.

     

    1. Would it be possible to add a setting to adjust the resolution of the air simulation? I understand that doubling the resolution of the air simulation would increase the CPU load 8 fold (because it will also have to perform two air simulation steps per frame in order to make the air behave the same way), so that's why it would be an adjustable setting. I think the options could be 4 pixels (which is what it is currently), 2 pixels (x8 CPU load) and 1 pixel (x64 CPU load, very slow but very accurate). The pixels here are how wide each "air pixel" is in terms of normal pixels. The size of a wall block could be the size of an air pixel, so more accurate air simulation would also enable smoother walls as a side effect.

     

    2. Can the air simulation algorithm be switched out for something else or otherwise improved (with a setting to revert it back to original algorithm, similar to the heat simulation added in version 34)? Perhaps something like the lattice Boltzmann algorithm or some such. My main reason for this is that the current air simulation, while reasonably accurate, is not without flaws. For example, pressure waves damp themselves out for no reason with shorter wavelengths damping much quicker. The newer simulation could instead preserve wave energy (or at least not damp so fast). In order to keep every box from turning into a resonant cavity, there could also be a slider to adjust the damping factor so that it can be anywhere from undamped to very damped (with current simulation being somewhere between those two extremes). If the algorithm also happens to amplify certain waves when undamped, then rather than capping how far the slider can go you can instead let it go all the way to undamped and let the spontaneous amplification be a feature.

     

    If these suggestions are added, then not only will it be simply a nice improvement to the air simulation but it can also allow the players to use TPT as a wave simulator. This will allow players to make things like diffraction gratings, Fresnel zone plates, resonating cavities, whistles, flutes, and much more.

  • Roberttherobot
    14th Oct 2021 Member 0 Permalink

    I agree, the air simulation needs updating or a new mode, theres also the problem of gravity affecting the air simulation even when gravity is turned off, you cant get a flame like you'd really get in space because theres a bias toward going up.

  • LBPHacker
    15th Oct 2021 Developer 0 Permalink
    The first suggestion falls under the category of adjusting compile time constants at runtime. This has been requested many times before, targeting simulation size as a whole rather than air resolution, and the answer is the same: the performance gain from those constants being compile time constants and thus the compiler being able to generate different code with them is not marginal, and including two versions of the simulation would yield very difficult to maintain code. This leaves maybe changing the one simulation we have to a new air resolution, but this is a step we can't imagine taking with 10 years of CELL = 4 saves on our back. The disadvantages simply outweigh the advantages here.

    The second suggestion falls under the category of replacing the algorithm behind an important core mechanic with another, more realistic one. There is no reason to not consider these, but they are of extremely low priority because the game is not meant to be realistic. Also, like the air resolution suggestion, this one also suffers from the need to provide backwards compatibility. Unlike that suggestion, if someone were to clean the air code up sufficiently that it provided a clean interface for any algorithm to be plugged in, it might be possible to implement such that you could switch between the two algorithms. This is not something we can pull off with the limited time we can allocate to developing TPT, but PRs are welcome (preferably following discussion in #powder-dev@irc.libera.chat).

    @Roberttherobot (View Post)
    That is an annoying issue that we're aware of. Nobody has gotten to it yet though >_>
  • JasonS
    18th Oct 2021 Member 0 Permalink

    Thanks for the response. I was hoping it wouldn't be too much of a problem to implement, but it looks like that's not the case. Maybe some year or other I can try implementing it myself and making a pull request, but I don't think that's gonna happen any time soon.

  • thecodeadd
    19th Oct 2021 Member 0 Permalink

    @LBPHacker (View Post)

     Somebody did though, The Powder Toy - The Realistic Physics Mod

    functions as expected.

    Edited once by thecodeadd. Last: 19th Oct 2021
  • LBPHacker
    19th Oct 2021 Developer 0 Permalink
    Nope, that's a different issue.
  • thecodeadd
    19th Oct 2021 Member 0 Permalink

    @LBPHacker (View Post)

    ok but it still fixes the gravity issue?