ID:154374
 
I've been toying with an idea for an upcoming game of mine that (as a small part of play) models water flow and pressure as it moves through chambers. It's a side-scroller, so the water has depth, and pressure is modeled based on depth.

At the moment, it actually looks quite beautiful... even splashing, sloshing, and seeking its own level, no matter how complex the chamber shapes. I have one more detail to work out regarding apparent volume decrease due to pressure, but I'm getting there.

I was just wondering who else might have worked on something similar, and have a little input on something technical (regarding the above problem). I'd be willing to give you a glimpse at the project, if you think you might have some useful information to help perfect this. Lexy, I remember you had water in Miner League, but I don't know how detailed your modeling was.

/mob/skysaw
Actually, I was planning something to the effect of this in Maeva. Then again, I plan a lot of things. Its not on the top of my priority list currently, but I hope to impliment something of the like. My water is handled as an area though which will may create some problems, I supposed I'll burn that bridge when I get to it though, anyways, thats my input.

DerDragon, me.
I worked on (although did not necessarily work out) all of those things in my liquid physics module... unfortunately, math and physics are not my strong point, and due to what I can only characterize as rounding errors, whenever I tried a complex fluid code, I ended up with water that either slightly decreased or increased each time it moved, and the whole code consumed a lot of processing time.

I'm working on two new models, a combination of which will probably form the fluid module for my new version of ML. The first is ludicrously simple: water is a dense object that acts as non-dense to objs and mobs, and it uses a pathfinding procedure to continually move "down."

The second method involves a fluidbody data object, with properties such as volume, mass, and highpoint. (If there's tiles in the fluid below the highpoint, with room to expand above, mass will redistribute to bring them up.)

Rather than having immersion in one fluid tile cause its volume to increase, and pass that along to nearby fluid tiles, which pass it along to nearby fluid tiles in an eventually processing-intensive chain reaction, it'll simply call tile.fluidbody.displace() and handle everything at once. I had an insanely complicated "telegraph" procedure for communicating the high and low points of a volume of liquid before... this method is a jillion times more efficient.
In response to LexyBitch (#2)
Interesting stuff, thanks for the response.

My model uses a seperate water object for each square that has any water at all. Each water object knows only about itself and its neighbors in four directions. Density is calculated figuring in depth, so water can push up as well as down, if it the pressure builds up. This lets it push up through channels if necessary, and the end result is that it seeks its own level.

Everything is working beautifully, and it does not take as much processing power as you might expect. I have zero water loss, but there is a perception of loss due to high pressure. This is the only thing I'm not happy about. I have the solution in my head, but so far have had trouble coding it so that it actually works.

I may put up a little demo soon... it's just too cool not to share. The coolest thing is that the water sloshes and splashes a bit, and I didn't even code that in on purpose... it's just the end result of the pressure model I wrote.