Limited water simulation

The performance is quite good, but I’m testing with a relatively small and low-res plane. I do intend to send the values to a texture later on when it works.

If I understand correctly, as I’m still wrapping my head around it, dispersion results in the waves dissipating over time, so they eventually disappear. In my code, there’s already a damping factor. If I decrease that value, the waves do dissipate (disperse, am I correct?) much faster. However, then when I “add” water by increasing the water level of cells, the infinity problem also happens much faster. I double-checked my code with the original source, and there are no typos. It appears to be caused by the border cells, as they reflect the waves back, but then they won’t stop. I’ll keep experimenting a little with the border cells to see if that could be the problem.

This code selects a random cell and adds a value to it (set in the editor).



void AWaterSurface::CreateSource()
{
	int DesiredX = (int)(FMath::FRandRange(1, SurfaceVertices + 1));
	int DesiredY = (int)(FMath::FRandRange(1, SurfaceVertices + 1));

	H[IX(DesiredX, DesiredY)] += SourceStrength;
}