Check for NaN
Seems some setups are sensitive to this and others are not.
This commit is contained in:
parent
199941385f
commit
43c1ddc6b3
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
+-------------------------------------------------------------+
|
+-------------------------------------------------------------+
|
||||||
| OneLoneCoder Pixel Game Engine Extension |
|
| OneLoneCoder Pixel Game Engine Extension |
|
||||||
| Ray Cast World v1.0 |
|
| Ray Cast World v1.01 |
|
||||||
+-------------------------------------------------------------+
|
+-------------------------------------------------------------+
|
||||||
|
|
||||||
NOTE: UNDER ACTIVE DEVELOPMENT - THERE ARE BUGS/GLITCHES
|
NOTE: UNDER ACTIVE DEVELOPMENT - THERE ARE BUGS/GLITCHES
|
||||||
@ -310,10 +310,6 @@ void olc::rcw::Engine::Update(float fElapsedTime)
|
|||||||
olc::vi2d vAreaTL = { std::min(vCurrentCell.x, vTargetCell.x) - 1, std::min(vCurrentCell.y, vTargetCell.y) - 1 };
|
olc::vi2d vAreaTL = { std::min(vCurrentCell.x, vTargetCell.x) - 1, std::min(vCurrentCell.y, vTargetCell.y) - 1 };
|
||||||
olc::vi2d vAreaBR = { std::max(vCurrentCell.x, vTargetCell.x) + 1, std::max(vCurrentCell.y, vTargetCell.y) + 1 };
|
olc::vi2d vAreaBR = { std::max(vCurrentCell.x, vTargetCell.x) + 1, std::max(vCurrentCell.y, vTargetCell.y) + 1 };
|
||||||
|
|
||||||
bool bRecheck = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
bRecheck = false;
|
|
||||||
|
|
||||||
// Iterate through each cell in test area
|
// Iterate through each cell in test area
|
||||||
olc::vi2d vCell;
|
olc::vi2d vCell;
|
||||||
@ -338,6 +334,7 @@ void olc::rcw::Engine::Update(float fElapsedTime)
|
|||||||
// But modified to work :P
|
// But modified to work :P
|
||||||
olc::vf2d vRayToNearest = vNearestPoint - vPotentialPosition;
|
olc::vf2d vRayToNearest = vNearestPoint - vPotentialPosition;
|
||||||
float fOverlap = object->fRadius - vRayToNearest.mag();
|
float fOverlap = object->fRadius - vRayToNearest.mag();
|
||||||
|
if(std::isnan(fOverlap)) fOverlap = 0;// Thanks Dandistine!
|
||||||
|
|
||||||
// If overlap is positive, then a collision has occurred, so we displace backwards by the
|
// If overlap is positive, then a collision has occurred, so we displace backwards by the
|
||||||
// overlap amount. The potential position is then tested against other tiles in the area
|
// overlap amount. The potential position is then tested against other tiles in the area
|
||||||
@ -358,15 +355,11 @@ void olc::rcw::Engine::Update(float fElapsedTime)
|
|||||||
|
|
||||||
HandleObjectVsScenery(object, vCell.x, vCell.y, side, vNearestPoint.x - float(vCell.x), vNearestPoint.y - float(vCell.y));
|
HandleObjectVsScenery(object, vCell.x, vCell.y, side, vNearestPoint.x - float(vCell.x), vNearestPoint.y - float(vCell.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
bRecheck = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (bRecheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the objects new position to the allowed potential position
|
// Set the objects new position to the allowed potential position
|
||||||
object->pos = vPotentialPosition;
|
object->pos = vPotentialPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user