Cell-Based Liquid Simulation: Local pressure model?

I'm attempting to add semi-realistic water into my tile-based, 2D platformer. The water must act somewhat lifelike, with a pressure model that runs entirely local. (IE. Can only use data from cells near it) This model is needed because of the nature of my game, where you cannot be certain that the data you need isn't inside an area that isn't in memory.

I've tried one method so far, but I could not refine it enough to work with my constraints.

For that model, each cell would be slightly compressible, depending on the amount of water in the above cell. When a cell's water content was larger than the normal capacity, the cell would try to expand upwards. This created a fairly nice simulation, abeit slow (Not lag; Changes in the water were taking a while to propagate.), at times. When I tried to implement this into my engine, I found that my limitations lacked the precision required for it to work. I can provide a more indepth explanation or a link to the original concept if you wish.

My constraints:

  • Only 256 discrete values for water level. (No floating point variables :( ) -- EDIT. Floats are fine.
  • Fixed grid size.
  • 2D Only.
  • U-Bend Configurations must work.

The language that I'm using is C#, but I can probably take other languages and translate it to C#.

The question is, can anyone give me a pressure model for water, following my constraints as closely as possible?

11
задан Steffan Donal 27 May 2011 в 21:08
поделиться