From 6c3034acffc79f810d20cd04d14134c7ac2ada0e Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 13 Jun 2012 00:42:30 +0100 Subject: [PATCH] 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. --- src/air.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/air.c b/src/air.c index eb7f47ffc..17598836c 100644 --- a/src/air.c +++ b/src/air.c @@ -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;