Original Post
Hi there. I have a small problem regarding wave physics. I've taken this algorithm : which is basically an update algo for a water wave. Now I've been told that water waves and explosion waves are relatively the same. The thing is, does anyone know how to prevent the waves from bouncing off the edges? I found this algo from a site that I can't remember and that guy who used it got it from the Programming Gems book. So, anyone have any ideas? Thanks a lot!
void CWave::update()
{
float n;
float temp;
float one_over_dampf = 1.0f / DampingFactor;
int h;
register int v;
//Skip the edges to allow area sampling
for(h = 1; h < mHorizontalSize; ++h)
{
for(v = 1; v < mVerticalSize; ++v)
{
n = ( mWave2[v - 1][h ] +
mWave2[v + 1][h ] +
mWave2[v ][h - 1] +
mWave2[v ][h + 1]) * 0.5f - mWave[v][h];
n -= n * one_over_dampf;
mWave[v][h] = n;
}
}
//wave=wave2
for(h = 0; h <= mHorizontalSize; ++h)
{
for(v = 0; v <= mVerticalSize; ++v)
{
temp = mWave2[v][h];
mWave2[v][h] = mWave[v][h];
mWave[v][h] = temp;
}
}
}