Skip to content

Commit

Permalink
fix really fast particles moving through EHOLE
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Oct 15, 2015
1 parent bb455ea commit 7fcc056
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/simulation/Simulation.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/simulation/Simulation.h
Expand Up @@ -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.