Permalink
Browse files

Velocity limit, to prevent NaNs

  • Loading branch information...
jacksonmj committed Mar 27, 2014
1 parent 2e6b424 commit 20cbcf8ad92af6c570b518990e03ee6ed9d41231
Showing with 7 additions and 0 deletions.
  1. +1 −0 src/Config.h
  2. +6 −0 src/simulation/Simulation.cpp
@@ -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
@@ -4199,6 +4199,12 @@ void Simulation::update_particles_i(int start, int inc)
}
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;

0 comments on commit 20cbcf8

Please sign in to comment.