ID:2921322
 
I'm working on a Noita-like combination of sidescroller with 'Powder Game' style particles and physics where things like water, sand, and lava will fall under gravity and can flow. After a month of coding and optimizing, it runs pretty well even in a large map where every pixel on the map is an icon_size=1 atom.

One of things I want to tackle that Powder Game never accurately simulated is hydrostatic pressure of liquids. For instance, in the picture below on the *left*: if you make a U-shaped tube with water on one side it will just flow sideways and the two sides of the U-tube don't level out. The water on both sides of the U-tube should level out like on the *right*. Dwarf Fortress does this correctly.



I'm stuck on trying to figure out a low-resource approach for getting the two liquid levels to balance out using the cellular automata approach that drives a Powder Game.

My first attempt was trying to iterate through all water particles, group them into lists of neighboring water particles (to isolate individual bodies of water), and then iterating through each body of water's particles' positions versus center of mass to determine which water particles should be forced upward. It worked okay but was resource intensive and not very robust for cases like when different bodies of water suddenly connected or were split apart.
I don't know the specifics of your implementation, but you could possibly use a datum that carries a reference to a group of particles and determines the ideal height of them, then somehow repositions them in order to achieve the ideal height in all circumstances. This generalized approach might not properly factor in an enclosed space, where air pressure would prevent the fluid from rising any higher.

Again, just a thought after a quick read-through. Hope it helps maybe get the juices flowing.
The way Dwarf Fortress accomplishes this in a cheap manner is to cheat and literally teleport the water from the top of the tall side to the top of the shorter side.
The way Dwarf Fortress accomplishes this in a cheap manner is to cheat and literally teleport the water from the top of the tall side to the top of the shorter side.

I thought about suggesting that, as it's the cheapest way to go about it, but in a powder game, usually you want some kind of preservation of fluid kind, and that means handling actual flow.

Login to reply.