Skip to content

Commit

Permalink
Velocity limit, to prevent NaNs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonmj committed Mar 27, 2014
1 parent 2e6b424 commit 20cbcf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Config.h
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/simulation/Simulation.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 20cbcf8

Please sign in to comment.