Permalink
Browse files

fix really fast particles moving through EHOLE

  • Loading branch information...
jacob1 committed Oct 15, 2015
1 parent bb455ea commit 7fcc056cb6b5229b7d6aa4d3bcce7c37e2401791
Showing with 9 additions and 1 deletion.
  1. +4 −1 src/simulation/Simulation.cpp
  2. +5 −0 src/simulation/Simulation.h
@@ -4056,6 +4056,9 @@ void Simulation::UpdateParticles(int start, int end)
dy = parts[i].vy*ISTP/mv;
fin_xf = parts[i].x;
fin_yf = parts[i].y;
fin_x = (int)(fin_xf+0.5f);
fin_y = (int)(fin_yf+0.5f);
bool closedEholeStart = this->InBounds(fin_x, fin_y) && (bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL]);
while (1)
{
mv -= ISTP;
@@ -4092,7 +4095,7 @@ void Simulation::UpdateParticles(int start, int end)
//block if particle can't move (0), or some special cases where it returns 1 (can_move = 3 but returns 1 meaning particle will be eaten)
//also photons are still blocked (slowed down) by any particle (even ones it can move through), and absorb wall also blocks particles
int eval = eval_move(t, fin_x, fin_y, NULL);
if (!eval || (can_move[t][pmap[fin_y][fin_x]&0xFF] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL)
if (!eval || (can_move[t][pmap[fin_y][fin_x]&0xFF] == 3 && eval == 1) || (t == PT_PHOT && pmap[fin_y][fin_x]) || bmap[fin_y/CELL][fin_x/CELL]==WL_DESTROYALL || closedEholeStart!=(bmap[fin_y/CELL][fin_x/CELL] == WL_EHOLE && !emap[fin_y/CELL][fin_x/CELL]))
{
// found an obstacle
clear_xf = fin_xf-dx;
@@ -207,6 +207,11 @@ class Simulation
void clear_sim();
Simulation();
~Simulation();
bool InBounds(int x, int y)
{
return (x>=0 && y>=0 && x<XRES && y<YRES);
}
};
#endif /* SIMULATION_H */

0 comments on commit 7fcc056

Please sign in to comment.