Bounds check before interpolation to find walls

This commit is contained in:
jacksonmj 2014-01-26 10:16:42 +00:00
parent 09e7418aae
commit cf503a29f4

View File

@ -235,17 +235,9 @@ void Air::update_air(void)
dp += pv[y][x]*f;
}
if (dx*advDistanceMult<=1.0f && dy*advDistanceMult<=1.0f)
{
tx = x - dx*advDistanceMult;
ty = y - dy*advDistanceMult;
}
else if (bmap_blockair[y][x])
{
tx = x;
ty = y;
}
else
tx = x - dx*advDistanceMult;
ty = y - dy*advDistanceMult;
if ((dx*advDistanceMult>1.0f || dy*advDistanceMult>1.0f) && (tx>=2 && tx<XRES/CELL-2 && ty>=2 && ty<YRES/CELL-2))
{
// Trying to take velocity from far away, check whether there is an intervening wall. Step from current position to desired source location, looking for walls, with either the x or y step size being 1 cell
if (abs(dx)>abs(dy))
@ -284,8 +276,8 @@ void Air::update_air(void)
j = (int)ty;
tx -= i;
ty -= j;
if (i>=2 && i<XRES/CELL-3 &&
j>=2 && j<YRES/CELL-3)
if (!bmap_blockair[y][x] && i>=2 && i<=XRES/CELL-3 &&
j>=2 && j<=YRES/CELL-3)
{
dx *= 1.0f - AIR_VADV;
dy *= 1.0f - AIR_VADV;