Help with water

Blitz3D Forums/Blitz3D Programming/Help with water

MusicianKool(Posted 2011) [#1]
Well I'm trying to make a 2d fluid simulation around a single point.
all I have right now is basically a gravity simulation with very poor collision reaction for anything resembling water. everything is based oh circles so it should be somewhat easier to do. any help or tips would be appreciated.

code


Last edited 2011


MusicianKool(Posted 2011) [#2]
I need help with conservation of momentum for circular objects such as pool.


MusicianKool(Posted 2011) [#3]
Well now I need help optimizing the code so I can use more then 200 without slowing down. still a little fun to play with.


right mouse moves center circle to mouse's position
left mouse slows things down a lot.


Last edited 2011


Serpent(Posted 2011) [#4]
I'll look into this a bit more later (I tried doing something like this before and failed miserably...) but you can do all of the collision stuff with nothing but vectors.
For instance, to get NX and NY you just have to divide the X and Y distances (c2\X - c\X) by the actual distance.
Also, I'd check if the masses are equal and if so leave out that part of the calculations.
Probably the biggest time killer is collision detection. There are a few things that can be changed here:
- Checking for collisions can be faster if you don't bother square rooting the distance. You can just square the collision distance instead, which should be faster.
- I'm not sure if powers are optimised when compiling, but it might help to replace the ' ^2 's with a multiplication.
- At the moment, each particle is checked against every other particle for collisions. This could be improved by checking only the particles afterwards, almost halving the number of collision checks.

Last edited 2011


SLotman(Posted 2011) [#5]
This speeds it up a little:



I can go up to 600 here :)


Serpent(Posted 2011) [#6]
A few things seem to be broken though...


Serpent(Posted 2011) [#7]
Some optimisation, works with up to 800 on my PC:



MusicianKool(Posted 2011) [#8]
This is very good Thank you!