There are 8192 particles in this demo. The water has a bit (too much) viscosity, so it will form drops in the air. You can drag the raft around a bit with the mouse. It won't stay afloat for too long, because the water is flowing very rough. The demo tries to make use of multiple cores, but it still doesn't manage to use 100% of all 4 cores of my CPU. On my Q6600 I get 50fps, singlethreaded it gives me 25fps.

If you would tell me your FPS (in the titlebar) and your CPU type (and how many cores) it'd be nice!

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

no no no, and even if Applet + opengl may be worse wich I dont believe is true, webstart sucks even a direct link to an executable jar is better than webstart. NB: I have tested this demo cause it come from you and I wouldn't have if it was not from a known JGO member.

Wow, well, it seems like the algorithm still takes more advantage of the clockspeed than the amount of cores.

The turbulence is just a side effect if the integrator, not really hard work Another nice thing is that the current algorithm works in 3D too - I'd only have to change 1 line of code - basically assigning a z-value (instead of 0.0) to every drop and watch it go. I'm just not really into writing a 3D renderer in Java2D, and going to LWJGL is a bit out of scope of this probject.

The only problem with the current algorithm is that large liquid bodies tend to get unstable at the bottom, due to the massive stress and conflicting constraints. The problem is that I can't relax the collision response (or releasing tension of springs), because then the liquid becomes compressable, which causes 'global resonation' - the fluid falls in on itself, then explodes, in an infinte loop - besides that, real fluids are not compressible anyway, so relaxing is not how I should be solving the stress problem anyway. I already slightly hacked the verlet code to handle fluids differently from your average sphere/sphere collision, but there are still some drops shooting out like fireworks.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

traverse the grid, and for each cell[ x ][ y ] collide each drop with every drop in cell2[ x ][ y ], except itself

==> only this part is multi-threaded

clear all drops from both cell[ x ][ y ] and cell2[ x ][ y ]

The grid.cellSize is adjusted automatically (in steps of 10%), by measuring its own performance. It basically does some trial-and-error and after N iterations, approaches an optimum (hopefully not a local optimum) and kinda stays there. When the location of large sums of particles will change, it is likely that the grid will also converge to another optimal cellSize.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

Interesting, so how big is the grid, 1 cell per pixel? It appears that the droplets compress and end up in the same cell so I guess the cells are smaller than a pixel? How do you chuck the big boat in there which is obviously bigger than a cell?

The drops in cell[ x ][ y ] can only collide with the drops in cell2[ x ][ y ], so naturally, the cellSize must be greater than the dropRadius, because otherwise the potential colliders wouldn't be in cell2[ x ][ y ]. The current dropRadius is 2,75. Typically, the cellSize ends up at 12..16 pixels (on my CPU, in this scene), which basically means that in cell2[ x ][ y ], the drops are gathered that are found in a (12..16)*3 = 36..48 pixel square.

Regarding the boat, it is not interacting with the liquid grid (cells) directly. I calculate the bounding sphere (rendered as a grey circle) of the boat. Then I query the grid for all cells that intersect that bounding sphere. I sorta took a (slower) shortcut, by calculating the boundingbox of the boundingsphere (is too big, I know), calculated the minimal x,y and maximal x,y cell coordinates in the grid, corresponding with that boundingbox, then subtract -1,-1 cell from the minimum, and add 1,1 to the maximum cell (adding the neighbouring cells), and grab all drops in that rectangular group of cells. Then I collide (pure Verlet) all drops (basically spheres) with all spheres in the boat.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org