invalidate gravity map if walls changed, fixes http://tpt.io/~1223463

This commit is contained in:
mniip 2013-12-22 11:41:19 +04:00
parent bc84326ca2
commit 4eab5c4ce3
2 changed files with 5 additions and 1 deletions

View File

@ -55,6 +55,7 @@ void Gravity::gravity_init()
gravx = (float *)calloc((XRES/CELL)*(YRES/CELL), sizeof(float));
gravp = (float *)calloc((XRES/CELL)*(YRES/CELL), sizeof(float));
gravmask = (unsigned int *)calloc((XRES/CELL)*(YRES/CELL), sizeof(unsigned));
obmap = (unsigned char (*)[XRES/CELL])calloc((XRES/CELL)*(YRES/CELL), sizeof(unsigned char));
}
void Gravity::gravity_cleanup()
@ -291,7 +292,7 @@ void Gravity::update_grav()
break;
for (x=0; x<XRES/CELL; x++)
{
if(th_ogravmap[y*(XRES/CELL)+x]!=th_gravmap[y*(XRES/CELL)+x]){
if(th_ogravmap[y*(XRES/CELL)+x] != th_gravmap[y*(XRES/CELL)+x] || bmap[y][x] != obmap[y][x]){
changed = 1;
break;
}
@ -348,6 +349,7 @@ void Gravity::update_grav()
th_gravchanged = 0;
}
memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memcpy(obmap, bmap, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned char));
}
#else
@ -407,6 +409,7 @@ void Gravity::update_grav(void)
}
fin:
memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memcpy(obmap, bmap, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned char));
}
#endif

View File

@ -74,6 +74,7 @@ public:
float *gravy;
float *gravx;
unsigned char (*bmap)[XRES/CELL];
unsigned char (*obmap)[XRES/CELL];
int ngrav_enable;
void grav_mask_r(int x, int y, char checkmap[YRES/CELL][XRES/CELL], char shape[YRES/CELL][XRES/CELL], char *shapeout);
void mask_free(mask_el *c_mask_el);