Permalink
Browse files

really fix the remainders in loop edge mode

  • Loading branch information...
jacob1 committed Mar 12, 2016
1 parent 0b0c736 commit 15068552b50d672ddbb433a1669e4fd3516e8ba8
Showing with 6 additions and 6 deletions.
  1. +6 −6 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);
}

0 comments on commit 1506855

Please sign in to comment.