Skip to content

Commit

Permalink
Bounds check before interpolation to find walls
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonmj committed Jan 26, 2014
1 parent 09e7418 commit cf503a2
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/simulation/Air.cpp
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cf503a2

Please sign in to comment.