summaryrefslogtreecommitdiff
path: root/src/air.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-06-01 19:18:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-06-01 19:18:19 (GMT)
commitc003fee63ee63d5bc5194349fe262db101c17e1f (patch)
treea5eb45fc8d1c49b0764ae6b9c4e9341162b0c7ef /src/air.c
parent3d600c69558b4b3e3f05b860531942f1ea2cd1c1 (diff)
downloadpowder-c003fee63ee63d5bc5194349fe262db101c17e1f.zip
powder-c003fee63ee63d5bc5194349fe262db101c17e1f.tar.gz
Ambient heat (disabled by default)
Diffstat (limited to 'src/air.c')
-rw-r--r--src/air.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/air.c b/src/air.c
index 76c6fee..63eaa49 100644
--- a/src/air.c
+++ b/src/air.c
@@ -23,6 +23,8 @@ float cb_pv[YRES/CELL][XRES/CELL], cb_opv[YRES/CELL][XRES/CELL];
float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
+float hv[YRES/CELL][XRES/CELL], ohv[YRES/CELL][XRES/CELL]; // For Ambient Heat
+
void make_kernel(void) //used for velocity
{
int i, j;
@@ -38,6 +40,55 @@ void make_kernel(void) //used for velocity
for (i=-1; i<2; i++)
kernel[(i+1)+3*(j+1)] *= s;
}
+void update_airh(void)
+{
+ int x, y, i, j;
+ float dh, dp, f, tx, ty;
+ for (i=0; i<YRES/CELL; i++) //reduces pressure/velocity on the edges every frame
+ {
+ hv[i][0] = 295.15f;
+ hv[i][1] = 295.15f;
+ hv[i][XRES/CELL-3] = 295.15f;
+ hv[i][XRES/CELL-2] = 295.15f;
+ hv[i][XRES/CELL-1] = 295.15f;
+ }
+ for (i=0; i<XRES/CELL; i++) //reduces pressure/velocity on the edges every frame
+ {
+ hv[0][i] = 295.15f;
+ hv[1][i] = 295.15f;
+ hv[YRES/CELL-3][i] = 295.15f;
+ hv[YRES/CELL-2][i] = 295.15f;
+ hv[YRES/CELL-1][i] = 295.15f;
+ }
+ for (y=0; y<YRES/CELL; y++) //update velocity and pressure
+ for (x=0; x<XRES/CELL; x++)
+ {
+ dh = 0.0f;
+ for (j=-1; j<2; j++)
+ for (i=-1; i<2; i++)
+ if (y+j>0 && y+j<YRES/CELL-2 &&
+ x+i>0 && x+i<XRES/CELL-2 &&
+ bmap[y+j][x+i]!=WL_WALL &&
+ bmap[y+j][x+i]!=WL_WALLELEC &&
+ (bmap[y+j][x+i]!=WL_EWALL || emap[y+j][x+i]))
+ {
+ f = kernel[i+1+(j+1)*3];
+ dh += hv[y+j][x+i]*f;
+ }
+ else
+ {
+ f = kernel[i+1+(j+1)*3];
+ dh += hv[y][x]*f;
+ }
+ i = (int)tx;
+ j = (int)ty;
+ tx -= i;
+ ty -= j;
+ ohv[y][x] = dh;
+ }
+ memcpy(hv, ohv, sizeof(hv));
+}
+
void update_grav(void)
{
int x, y, i, j, changed = 0;