mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-27 01:44:31 +02:00
Bounds check before interpolation to find walls
This commit is contained in:
@@ -235,17 +235,9 @@ void Air::update_air(void)
|
|||||||
dp += pv[y][x]*f;
|
dp += pv[y][x]*f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dx*advDistanceMult<=1.0f && dy*advDistanceMult<=1.0f)
|
tx = x - dx*advDistanceMult;
|
||||||
{
|
ty = y - dy*advDistanceMult;
|
||||||
tx = x - dx*advDistanceMult;
|
if ((dx*advDistanceMult>1.0f || dy*advDistanceMult>1.0f) && (tx>=2 && tx<XRES/CELL-2 && ty>=2 && ty<YRES/CELL-2))
|
||||||
ty = y - dy*advDistanceMult;
|
|
||||||
}
|
|
||||||
else if (bmap_blockair[y][x])
|
|
||||||
{
|
|
||||||
tx = x;
|
|
||||||
ty = y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// 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
|
// 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))
|
if (abs(dx)>abs(dy))
|
||||||
@@ -284,8 +276,8 @@ void Air::update_air(void)
|
|||||||
j = (int)ty;
|
j = (int)ty;
|
||||||
tx -= i;
|
tx -= i;
|
||||||
ty -= j;
|
ty -= j;
|
||||||
if (i>=2 && i<XRES/CELL-3 &&
|
if (!bmap_blockair[y][x] && i>=2 && i<=XRES/CELL-3 &&
|
||||||
j>=2 && j<YRES/CELL-3)
|
j>=2 && j<=YRES/CELL-3)
|
||||||
{
|
{
|
||||||
dx *= 1.0f - AIR_VADV;
|
dx *= 1.0f - AIR_VADV;
|
||||||
dy *= 1.0f - AIR_VADV;
|
dy *= 1.0f - AIR_VADV;
|
||||||
|
Reference in New Issue
Block a user