Reason behind this line of code?

  • majca
    20th May 2019 Member 1 Permalink

    Hello,


    I was doing some experiments with the pressure system and noticed this line of code (air.cpp:193):

    pv[y][x] *= AIR_PLOSS;
    

    Does anyone know the reason for this?

     

    Majca

  • jacob1
    20th May 2019 Developer 0 Permalink
    Every frame, pressure decreases slightly. That's why if you have a solid box surrounded by walls, the pressure still goes down over time. This line of code does that for enclosed boxes.
  • majca
    20th May 2019 Member 0 Permalink

    I'm not sure I understand what you mean. I'm confused.

     

    Whitout that line of code, pressure works as one might expect it to work (i.e. equalized pressure in the room, whatever the shape of that room is).

    At the opposite, with that line of code enabled, I cannot have the expected behavior from the pressure.

     

    Majca

    Edited once by majca. Last: 20th May 2019
  • jacob1
    20th May 2019 Developer 1 Permalink
    I don't know why the decision was made. But it's always worked like that. Pressure decreases slightly every frame. There is no way around it.
  • majca
    20th May 2019 Member 0 Permalink

    Well, as I mentioned, there is: I simply commented that line of code and everything seems to be working fine. No pressure loss.

     

    But I guess this line of code exists for a reason I'm not aware of, hence my question.

  • phox
    22nd May 2019 Member 0 Permalink

    a 10x10 ttan square with 256 pressure after a minute will have around 230 pressure, not too hard to understand

  • Sylvi
    22nd May 2019 Moderator 0 Permalink
    @phox (View Post)
    They're asking *why* the code exists. The reason of why we even added pressure decay, not what the code does

    As far as I can deduce from asking around, the reason may have been for numeric stability.
    Edited once by Lockheedmartin. Last: 22nd May 2019
  • majca
    22nd May 2019 Member 0 Permalink

    @phox (View Post)

    As Lockheedmartin said it, the question was about the why, not the what. That being said, you should not presume what is too hard or not for others to understand... Know that you are a genius compare to some... as well as the opposite ;).

     

    @Lockheedmartin (View Post)

    Considering I disabled the decay, I'll keep that potential instability in mind.

    Thanks for the info.

     

     

  • phox
    22nd May 2019 Member 0 Permalink

    sorry for my reply i wasn't trying to sound pretentious :P