#include #include "air.h" #include "powder.h" #include "defines.h" float kernel[9]; float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL]; float vy[YRES/CELL][XRES/CELL], ovy[YRES/CELL][XRES/CELL]; float pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL]; float cb_vx[YRES/CELL][XRES/CELL], cb_ovx[YRES/CELL][XRES/CELL]; float cb_vy[YRES/CELL][XRES/CELL], cb_ovy[YRES/CELL][XRES/CELL]; float cb_pv[YRES/CELL][XRES/CELL], cb_opv[YRES/CELL][XRES/CELL]; float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL]; void make_kernel(void) { int i, j; float s = 0.0f; for(j=-1; j<2; j++) for(i=-1; i<2; i++) { kernel[(i+1)+3*(j+1)] = expf(-2.0f*(i*i+j*j)); s += kernel[(i+1)+3*(j+1)]; } s = 1.0f / s; for(j=-1; j<2; j++) for(i=-1; i<2; i++) kernel[(i+1)+3*(j+1)] *= s; } void update_air(void) { int x, y, i, j; float dp, dx, dy, f, tx, ty; for(y=1; y0 && y+j0 && x+i=2 && i=2 && j 256.0f) dp = 256.0f; if(dp < -256.0f) dp = -256.0f; if(dx > 256.0f) dx = 256.0f; if(dx < -256.0f) dx = -256.0f; if(dy > 256.0f) dy = 256.0f; if(dy < -256.0f) dy = -256.0f; ovx[y][x] = dx; ovy[y][x] = dy; opv[y][x] = dp; } memcpy(vx, ovx, sizeof(vx)); memcpy(vy, ovy, sizeof(vy)); memcpy(pv, opv, sizeof(pv)); }