fix really fast particles moving through EHOLE

This commit is contained in:
jacob1 2015-10-15 00:26:01 -04:00
parent bb455ea893
commit 7fcc056cb6
2 changed files with 9 additions and 1 deletions

View File

@ -4056,6 +4056,9 @@ killed:
dy = parts[i].vy*ISTP/mv; dy = parts[i].vy*ISTP/mv;
fin_xf = parts[i].x; fin_xf = parts[i].x;
fin_yf = parts[i].y; 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) while (1)
{ {
mv -= ISTP; mv -= ISTP;
@ -4092,7 +4095,7 @@ killed:
//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) //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 //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); 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 // found an obstacle
clear_xf = fin_xf-dx; clear_xf = fin_xf-dx;

View File

@ -207,6 +207,11 @@ public:
void clear_sim(); void clear_sim();
Simulation(); Simulation();
~Simulation(); ~Simulation();
bool InBounds(int x, int y)
{
return (x>=0 && y>=0 && x<XRES && y<YRES);
}
}; };
#endif /* SIMULATION_H */ #endif /* SIMULATION_H */