diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 1110e74156..0c5f4cf255 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2406,9 +2406,9 @@ int Simulation::do_move(int i, int x, int y, float nxf, float nyf) bool x_ok = (nx >= CELL && nx < XRES-CELL); bool y_ok = (ny >= CELL && ny < YRES-CELL); if (!x_ok) - nxf = remainder_p(nxf-CELL, XRES-CELL*2.0f)+CELL-.5f; + nxf = remainder_p(nxf-CELL+.5f, XRES-CELL*2.0f)+CELL-.5f; if (!y_ok) - nyf = remainder_p(nyf-CELL, YRES-CELL*2.0f)+CELL-.5f; + nyf = remainder_p(nyf-CELL+.5f, YRES-CELL*2.0f)+CELL-.5f; nx = (int)(nxf+0.5f); ny = (int)(nyf+0.5f); @@ -4079,9 +4079,9 @@ void Simulation::UpdateParticles(int start, int end) bool x_ok = (fin_x >= CELL && fin_x < XRES-CELL); bool y_ok = (fin_y >= CELL && fin_y < YRES-CELL); if (!x_ok) - fin_xf = remainder_p(fin_xf-CELL, XRES-CELL*2.0f)+CELL-.5f; + fin_xf = remainder_p(fin_xf-CELL+.5f, XRES-CELL*2.0f)+CELL-.5f; if (!y_ok) - fin_yf = remainder_p(fin_yf-CELL, YRES-CELL*2.0f)+CELL-.5f; + 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); } @@ -4132,12 +4132,12 @@ void Simulation::UpdateParticles(int start, int end) int oldnx = nx, oldny = ny; if (!x_ok) { - parts[i].x = remainder_p(parts[i].x-CELL, XRES-CELL*2.0f)+CELL-.5f; + parts[i].x = remainder_p(parts[i].x-CELL+.5f, XRES-CELL*2.0f)+CELL-.5f; nx = (int)((float)parts[i].x+0.5f); } if (!y_ok) { - parts[i].y = remainder_p(parts[i].y-CELL, YRES-CELL*2.0f)+CELL-.5f; + parts[i].y = remainder_p(parts[i].y-CELL+.5f, YRES-CELL*2.0f)+CELL-.5f; ny = (int)((float)parts[i].y+0.5f); }