From 69d28bd7b0cb497f1db7423cfbfd4c98b3473f9c Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 24 Sep 2016 10:07:53 -0400 Subject: [PATCH] Fix crash with really high speed photons, a check is needed here too --- src/simulation/Simulation.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index a625ba9fc..d25c0ed4d 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -4111,6 +4111,15 @@ killed: // nothing found fin_xf = parts[i].x + parts[i].vx; fin_yf = parts[i].y + parts[i].vy; + if (edgeMode == 2) + { + bool x_ok = (fin_xf >= CELL-.5f && fin_xf < XRES-CELL-.5f); + bool y_ok = (fin_yf >= CELL-.5f && fin_yf < YRES-CELL-.5f); + if (!x_ok) + fin_xf = remainder_p(fin_xf-CELL+.5f, XRES-CELL*2.0f)+CELL-.5f; + if (!y_ok) + fin_yf = remainder_p(fin_yf-CELL+.5f, YRES-CELL*2.0f)+CELL-.5f; + } fin_x = (int)(fin_xf+0.5f); fin_y = (int)(fin_yf+0.5f); clear_xf = fin_xf-dx;