From 20cbcf8ad92af6c570b518990e03ee6ed9d41231 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 27 Mar 2014 00:34:40 +0000 Subject: [PATCH] Velocity limit, to prevent NaNs --- src/Config.h | 1 + src/simulation/Simulation.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/Config.h b/src/Config.h index 1346dc2ac..90252826c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 01d6c5c57..5f79a08d1 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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;