Velocity limit, to prevent NaNs

This commit is contained in:
jacksonmj 2014-03-27 00:34:40 +00:00
parent 2e6b4242d6
commit 20cbcf8ad9
2 changed files with 7 additions and 0 deletions

View File

@ -130,6 +130,7 @@
#define CELL 4
#define ISTP (CELL/2)
#define CFDS (4.0f/CELL)
#define SIM_MAXVELOCITY 1e4f
//Air constants
#define AIR_TSTEPP 0.3f

View File

@ -4199,6 +4199,12 @@ killed:
}
else
{
if (mv > SIM_MAXVELOCITY)
{
parts[i].vx *= SIM_MAXVELOCITY/mv;
parts[i].vy *= SIM_MAXVELOCITY/mv;
mv = SIM_MAXVELOCITY;
}
// interpolate to see if there is anything in the way
dx = parts[i].vx*ISTP/mv;
dy = parts[i].vy*ISTP/mv;