Yeah, does look a lot like the Gish demos. Though the source is not Gish, they are probably basing their stuff on similar methods - I should post a link to the demos I based this on, so check out http://kotsoft.googlepages.com/physicsdemos
(there's a bunch of other cool stuff there, too, and don't miss his game at http://pollutedplanet.googlepages.com/p ... lanet.html
). Also see http://www.fun-motion.com/forums/showthread.php?t=1191
, a thread about Polluted Planet. From that thread, it's clear that the method is SPH, so I don't think there should be any rights issues here, as I'm implementing it from scratch (in the demo the only bits that I pulled from that code are the custom broadphase and the SPH kernels, and we aren't ultimately going to use the broadphase anyways, since Box2d already has one).
How does the performance for this kind of a simulation scale, in terms of the number of particles? I'd be pretty impressed if it was O(n^2) or under..
Performance of the fluid solver itself is O(N*K) where K is the number of neighbor particles, which should usually be a small constant. The neighbor-finding relies on the broadphase, so once I integrate it with Box2d it should inherit Box2d's broadphase timing (I forget what that is exactly, maybe amortized O(N)?). Definitely less than O(N^2), though.
Oh, and can you make at least one object with a low enough density so that it'll float? I wonder how realistic the buoyancy effects are and how that behavior scales with the particle number/density.
Yeah, at some point I'll put up a demo of this - it's not perfect, because things can get stuck under the surface even if they would otherwise float, but it works okay. This is one area where it would be ideal to have a separate buoyancy solver, so you'd rarely be relying on the SPH stuff for floating.
Also, I hate to sound like a nit-picker (cause this is so awesome) but when the bomb object (the circle) is in a corner, and the fluid is being poured over it, it starts to spin counter-clockwise. Also when I tried dragged it into a wall with the mouse joint, the static bodies all disappeared, and it bugged out majorly.
Yeah, the bugging out is due to a divide by zero that I forgot to check for, my bad. The spinning stuff I still need to track down, I've noticed that as well.