2.5d flood-filling finite water

Ok, so here’s an idea for finite water that just might work:

Whenever a block of water wants to flow (ie there’s air next to or below it), I do a 2.5d flood fill (or possibly more more efficient) to find the highest surface block the furthest away from that block.

The search works like this:
1) Look one block up. If it’s water, move up and goto 1.
2) Iterate over all blocks on this plane.
2a) If the block is an infinite water source (spring, ocean), never store any results for this altitude or lower.
2b) If a block is a surface block, and we’re on the highest surface level found so far, save its location if it’s further away from the original block than our previous best.
2c) If it’s NOT a surface block, it’s a waterfall leading up to another surface level. Branch to step 1.

Once the tomost connected layer has been found and it’s higher up than the block that wants to spread, check if there’s any furthermost located water block on that layer (ie there isn’t an infinite source of water on that level). If there is, remove that block. In either case, spread the water.

Any educated guesses on how well this will work?

posted 14 years ago