Prevent ambient heat going through walls
Still doesn't conserve energy, it might disappear when blown towards a wall, but it will no longer go through the wall.
This commit is contained in:
parent
06cb98f705
commit
ccb88b6b3b
24
src/air.c
24
src/air.c
@ -10,6 +10,7 @@ float vx[YRES/CELL][XRES/CELL], ovx[YRES/CELL][XRES/CELL];
|
|||||||
float vy[YRES/CELL][XRES/CELL], ovy[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 pv[YRES/CELL][XRES/CELL], opv[YRES/CELL][XRES/CELL];
|
||||||
unsigned char bmap_blockair[YRES/CELL][XRES/CELL];
|
unsigned char bmap_blockair[YRES/CELL][XRES/CELL];
|
||||||
|
unsigned char bmap_blockairh[YRES/CELL][XRES/CELL];
|
||||||
|
|
||||||
float cb_vx[YRES/CELL][XRES/CELL];
|
float cb_vx[YRES/CELL][XRES/CELL];
|
||||||
float cb_vy[YRES/CELL][XRES/CELL];
|
float cb_vy[YRES/CELL][XRES/CELL];
|
||||||
@ -38,7 +39,12 @@ void make_kernel(void) //used for velocity
|
|||||||
void update_airh(void)
|
void update_airh(void)
|
||||||
{
|
{
|
||||||
int x, y, i, j;
|
int x, y, i, j;
|
||||||
float dh, dx, dy, f, tx, ty;
|
float odh, dh, dx, dy, f, tx, ty;
|
||||||
|
for (y=0; y<YRES/CELL; y++)
|
||||||
|
for (x=0; x<XRES/CELL; x++)
|
||||||
|
{
|
||||||
|
bmap_blockairh[y][x] = (bmap[y][x]==WL_WALL || bmap[y][x]==WL_WALLELEC || bmap[y][x]==WL_GRAV || (bmap[y][x]==WL_EWALL && !emap[y][x]));
|
||||||
|
}
|
||||||
for (i=0; i<YRES/CELL; i++) //reduces pressure/velocity on the edges every frame
|
for (i=0; i<YRES/CELL; i++) //reduces pressure/velocity on the edges every frame
|
||||||
{
|
{
|
||||||
hv[i][0] = 295.15f;
|
hv[i][0] = 295.15f;
|
||||||
@ -68,11 +74,8 @@ void update_airh(void)
|
|||||||
{
|
{
|
||||||
if (y+j>0 && y+j<YRES/CELL-2 &&
|
if (y+j>0 && y+j<YRES/CELL-2 &&
|
||||||
x+i>0 && x+i<XRES/CELL-2 &&
|
x+i>0 && x+i<XRES/CELL-2 &&
|
||||||
bmap[y+j][x+i]!=WL_WALL &&
|
!bmap_blockairh[y+j][x+i])
|
||||||
bmap[y+j][x+i]!=WL_WALLELEC &&
|
{
|
||||||
bmap[y+j][x+i]!=WL_GRAV &&
|
|
||||||
(bmap[y+j][x+i]!=WL_EWALL || emap[y+j][x+i]))
|
|
||||||
{
|
|
||||||
f = kernel[i+1+(j+1)*3];
|
f = kernel[i+1+(j+1)*3];
|
||||||
dh += hv[y+j][x+i]*f;
|
dh += hv[y+j][x+i]*f;
|
||||||
dx += vx[y+j][x+i]*f;
|
dx += vx[y+j][x+i]*f;
|
||||||
@ -95,11 +98,12 @@ void update_airh(void)
|
|||||||
ty -= j;
|
ty -= j;
|
||||||
if (i>=2 && i<XRES/CELL-3 && j>=2 && j<YRES/CELL-3)
|
if (i>=2 && i<XRES/CELL-3 && j>=2 && j<YRES/CELL-3)
|
||||||
{
|
{
|
||||||
|
odh = dh;
|
||||||
dh *= 1.0f - AIR_VADV;
|
dh *= 1.0f - AIR_VADV;
|
||||||
dh += AIR_VADV*(1.0f-tx)*(1.0f-ty)*hv[j][i];
|
dh += AIR_VADV*(1.0f-tx)*(1.0f-ty)*(bmap_blockairh[j][i] ? odh : hv[j][i]);
|
||||||
dh += AIR_VADV*tx*(1.0f-ty)*hv[j][i+1];
|
dh += AIR_VADV*tx*(1.0f-ty)*(bmap_blockairh[j][i+1] ? odh : hv[j][i+1]);
|
||||||
dh += AIR_VADV*(1.0f-tx)*ty*hv[j+1][i];
|
dh += AIR_VADV*(1.0f-tx)*ty*(bmap_blockairh[j+1][i] ? odh : hv[j+1][i]);
|
||||||
dh += AIR_VADV*tx*ty*hv[j+1][i+1];
|
dh += AIR_VADV*tx*ty*(bmap_blockairh[j+1][i+1] ? odh : hv[j+1][i+1]);
|
||||||
}
|
}
|
||||||
if(!gravityMode){ //Vertical gravity only for the time being
|
if(!gravityMode){ //Vertical gravity only for the time being
|
||||||
float airdiff = dh-hv[y][x];
|
float airdiff = dh-hv[y][x];
|
||||||
|
Reference in New Issue
Block a user