Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would say the proper solution is to add another grid for the second derivative, this time matching the original grid. That is

grid 0: water height in each cell

grid 1: water flow at each edge (first derivative)

grid 2: water acceleration in each cell (second derivative)

So each grid is the dual of the previous one and stores its derivative. In fact I don't think you even need to store edge data as a special case, just corner data and work purely with dual grids. You can derive the edge flow by taking the sum of the flow at the two corners of the edge. So you update the fluid height based on flow, then you update acceleration based on how much fluid mass flowed into the cell with what velocity, then you update the flow based on acceleration and current fluid height. I don't really know fluid dynamics, but looking at it purely from a numerical simulation standpoint, it sounds about right. It would also let you have diagonal flow.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: