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)); gravx = (float *)calloc((XRES/CELL)*(YRES/CELL), sizeof(float));
gravp = (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)); 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() void Gravity::gravity_cleanup()
@ -291,7 +292,7 @@ void Gravity::update_grav()
break; break;
for (x=0; x<XRES/CELL; x++) 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; changed = 1;
break; break;
} }
@ -348,6 +349,7 @@ void Gravity::update_grav()
th_gravchanged = 0; th_gravchanged = 0;
} }
memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float)); memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memcpy(obmap, bmap, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned char));
} }
#else #else
@ -407,6 +409,7 @@ void Gravity::update_grav(void)
} }
fin: fin:
memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float)); memcpy(th_ogravmap, th_gravmap, (XRES/CELL)*(YRES/CELL)*sizeof(float));
memcpy(obmap, bmap, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned char));
} }
#endif #endif

View File

@ -74,6 +74,7 @@ public:
float *gravy; float *gravy;
float *gravx; float *gravx;
unsigned char (*bmap)[XRES/CELL]; unsigned char (*bmap)[XRES/CELL];
unsigned char (*obmap)[XRES/CELL];
int ngrav_enable; 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 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); void mask_free(mask_el *c_mask_el);