Quick 'n Dirty Verlet Fluids v0.1

Despite knowing its existence in other languages, I haven’t ever used labels and gotos in anything other than Assembly, ever.

[quote]This is the 2nd time I did that in over a decade. It stinks. Don’t do it.
[/quote]

I use it sometime in java rarely but… it can be very usefull in some special cases and can give cleaver code, I think that it is not so much unlogical to use it even in Java

Sure, it has its uses, just like:

`
static int guessWhat()
{
int a = 15;

  try
  {
     return --a - 100;
  }
  finally
  {
     return --a + 100;
  }

}
`

Who needs multiple return values anyway?

i used labels in my last game inside a for loop for my collision checking like so:

uniFor: for (total units) {
Unit u = getUnitAt(index)

 enemyFor: for (total enemies){
       Enemy e = getEnemyAt(index)
       
       if (u.collidesWith(e){
             continue uniFor;  //otherwise i could use break enemyFor
       }
 }

}

this is because when an unit collides with an enemy and attacks it, its useless to keep looking for more collissions

Anyways its not something that useful, and you gotta keep an eye not make it really complicated, coz this is all about structured programming, so not goTo nor many breaks/continue

winxp
core2duo E8200 2.66ghz
50 FPS

I rarely do as fermixx posted, but I name the label “outerLoop”.

On my i7 920 (4 cores, 8 threads) with a GTX 275 video card, if the raft is not colliding at all, about 85 to 90 fps. If the raft is deep in the water, about 75 fps. ~30% CPU utilization.

Interestingly, if you use the raft to block the outlet at the bottom, water molecules pop out of the top of the water like popcorn. :slight_smile:

The raft code is very inefficient, and the water<->raft code even more. It collides every drop in the boundingbox of the boundingsphere of the bounding box (it keeps getting bigger :))

Yeah, I mentioned the stability problems when drops are under high pressure. I might have to move towards grids, and drop the particle approach, to really get rid of that. Nice thing is grids is that their are embarrassingly parallel. Downside is that your are limited to a fixed shape and can’t have that much control over the actual collisions (there are none).