Height Field Fluids simulation

BlitzMax Forums/BlitzMax Programming/Height Field Fluids simulation

Hi

There is a whole system to easily simulating fluids in realtime from the Matthias Müller-Fischer paper : http://www.matthiasmueller.info/talks/GDC2008.pdf

I'm trying to implement this into my platform Box2d game "sandbox" but the routine just won't work as intended.

The best I can do is this
SuperStrict
SetGraphicsDriver GLMax2DDriver()
Graphics 640, 480, 0

Const m:Int = 126
Const damping:Float = 1.2

Local size:Float = 5

Local current:Float[m]
Local previous:Float[m]
Local result:Float[m]

While Not KeyHit(KEY_ESCAPE)
	Cls

	If KeyHit(KEY_SPACE) Then current[Rnd(1, m - 1)] = 200
	
	For Local x:Int = 1 To m - 2
	
		result[x] :+(current[x - 1] + current[x + 1] - previous[x] * 3) / 4
		result[x] :*damping

		SetColor 5 * Abs(previous[x]), 100, 100
		DrawRect(x * size, 300, size * 2, - 50 - previous[x])
	Next

	'This work
	For Local x:Int = 1 To m - 1
		previous[x] = current[x]
		current[x] = result[x]
	Next

'	Strange number occurs with this method :
'	previous = current[..]
'	current = result[..]

	Flip
'	Delay 100
Wend


This routine isn't exactly the same as described in the paper but if I try the same math then the simulation became really ugly.

Implementing the whole paper would be an excellent solution other than trying to write complicated buoyancy system.
Also it would probably well fit inside a box2d simulation.
But successfully realise the waves effect and faking buoyancy with water sensor is my first priority for this.

Does anybody is interested in this or could help me to fix what's not going well ?
Thanks