Make ambient heat convection work a bit better

Previously, it was comparing the temperature of the current cell to the
average of the cells around it (plus some advection affecting the
average, but that makes no difference if the air starts out stationary),
and basing the velocity change on this temperature difference.

If the cell below is hotter and the cell above is cooler, the air should
rise. But in this case, the average of surrounding cells tends to be
near the temperature of the current cell, so not much happens.

Just using the temperature difference between the current cell and the
cell above makes convection work a lot better.
This commit is contained in:
jacksonmj 2012-06-13 00:42:30 +01:00
parent 35d125cf53
commit 6c3034acff

View File

@ -118,10 +118,10 @@ void update_airh(void)
dh += AIR_VADV*(1.0f-tx)*ty*(bmap_blockairh[j+1][i] ? odh : hv[j+1][i]);
dh += AIR_VADV*tx*ty*(bmap_blockairh[j+1][i+1] ? odh : hv[j+1][i+1]);
}
pv[y][x] += (dh-hv[y][x])/5000.0f;
if(!gravityMode){ //Vertical gravity only for the time being
float airdiff = dh-hv[y][x];
pv[y][x] += airdiff/5000.0f;
if(airdiff>0)
float airdiff = hv[y-1][x]-hv[y][x];
if(airdiff>0 && !bmap_blockairh[y-1][x])
vy[y][x] -= airdiff/5000.0f;
}
ohv[y][x] = dh;