Ambient heat (disabled by default)
This commit is contained in:
parent
3d600c6955
commit
c003fee63e
@ -21,10 +21,14 @@ extern float cb_pv[YRES/CELL][XRES/CELL], cb_opv[YRES/CELL][XRES/CELL];
|
|||||||
|
|
||||||
extern float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
|
extern float fvx[YRES/CELL][XRES/CELL], fvy[YRES/CELL][XRES/CELL];
|
||||||
|
|
||||||
|
extern float hv[YRES/CELL][XRES/CELL], ohv[YRES/CELL][XRES/CELL]; // Ambient Heat
|
||||||
|
|
||||||
extern float kernel[9];
|
extern float kernel[9];
|
||||||
|
|
||||||
void make_kernel(void);
|
void make_kernel(void);
|
||||||
|
|
||||||
|
void update_airh(void);
|
||||||
|
|
||||||
void update_grav(void);
|
void update_grav(void);
|
||||||
|
|
||||||
void update_air(void);
|
void update_air(void);
|
||||||
|
@ -79,6 +79,7 @@ extern unsigned char ZSIZE;
|
|||||||
#define SQUARE_BRUSH 1
|
#define SQUARE_BRUSH 1
|
||||||
#define BRUSH_NUM 2
|
#define BRUSH_NUM 2
|
||||||
|
|
||||||
|
//#define LUACONSOLE
|
||||||
//#define PYCONSOLE
|
//#define PYCONSOLE
|
||||||
//#define PYEXT
|
//#define PYEXT
|
||||||
//no longer needed
|
//no longer needed
|
||||||
@ -126,6 +127,7 @@ extern int legacy_enable;
|
|||||||
extern int ngrav_enable; //Newtonian gravity
|
extern int ngrav_enable; //Newtonian gravity
|
||||||
extern int sound_enable;
|
extern int sound_enable;
|
||||||
extern int kiosk_enable;
|
extern int kiosk_enable;
|
||||||
|
extern int aheat_enable;
|
||||||
extern int decorations_enable;
|
extern int decorations_enable;
|
||||||
|
|
||||||
extern int sys_pause;
|
extern int sys_pause;
|
||||||
|
51
src/air.c
51
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 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
|
void make_kernel(void) //used for velocity
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -38,6 +40,55 @@ void make_kernel(void) //used for velocity
|
|||||||
for (i=-1; i<2; i++)
|
for (i=-1; i<2; i++)
|
||||||
kernel[(i+1)+3*(j+1)] *= s;
|
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)
|
void update_grav(void)
|
||||||
{
|
{
|
||||||
int x, y, i, j, changed = 0;
|
int x, y, i, j, changed = 0;
|
||||||
|
@ -1234,8 +1234,17 @@ void draw_air(pixel *vid)
|
|||||||
else if (cmode == CM_VEL)
|
else if (cmode == CM_VEL)
|
||||||
{
|
{
|
||||||
c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
||||||
clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green
|
clamp_flt(pv[y][x], 0.0f, 8.0f),//pressure adds green
|
||||||
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
||||||
|
}
|
||||||
|
else if (cmode == CM_HEAT && aheat_enable)
|
||||||
|
{
|
||||||
|
float ttemp = hv[y][x]+(-MIN_TEMP);
|
||||||
|
int caddress = restrict_flt((int)( restrict_flt(ttemp, 0.0f, MAX_TEMP+(-MIN_TEMP)) / ((MAX_TEMP+(-MIN_TEMP))/1024) ) *3, 0.0f, (1024.0f*3)-3);
|
||||||
|
c = PIXRGB((unsigned char)color_data[caddress], (unsigned char)color_data[caddress+1], (unsigned char)color_data[caddress+2]);
|
||||||
|
//c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),//vx adds red
|
||||||
|
// clamp_flt(hv[y][x], 0.0f, 1600.0f),//heat adds green
|
||||||
|
// clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));//vy adds blue
|
||||||
}
|
}
|
||||||
else if (cmode == CM_CRACK)
|
else if (cmode == CM_CRACK)
|
||||||
{
|
{
|
||||||
|
@ -176,6 +176,7 @@ int sys_pause = 0;
|
|||||||
int sys_shortcuts = 1;
|
int sys_shortcuts = 1;
|
||||||
int legacy_enable = 0; //Used to disable new features such as heat, will be set by save.
|
int legacy_enable = 0; //Used to disable new features such as heat, will be set by save.
|
||||||
int ngrav_enable = 0; //Newtonian gravity, will be set by save
|
int ngrav_enable = 0; //Newtonian gravity, will be set by save
|
||||||
|
int aheat_enable; //Ambient heat
|
||||||
int decorations_enable = 1;
|
int decorations_enable = 1;
|
||||||
int death = 0, framerender = 0;
|
int death = 0, framerender = 0;
|
||||||
int amd = 1;
|
int amd = 1;
|
||||||
@ -1747,11 +1748,13 @@ int main(int argc, char *argv[])
|
|||||||
if (!sys_pause||framerender) //only update air if not paused
|
if (!sys_pause||framerender) //only update air if not paused
|
||||||
{
|
{
|
||||||
update_air();
|
update_air();
|
||||||
|
if(aheat_enable)
|
||||||
|
update_airh();
|
||||||
}
|
}
|
||||||
#ifdef OpenGL
|
#ifdef OpenGL
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
#else
|
#else
|
||||||
if (cmode==CM_VEL || cmode==CM_PRESS || cmode==CM_CRACK)//air only gets drawn in these modes
|
if (cmode==CM_VEL || cmode==CM_PRESS || cmode==CM_CRACK || (cmode==CM_HEAT && aheat_enable))//air only gets drawn in these modes
|
||||||
{
|
{
|
||||||
draw_air(vid_buf);
|
draw_air(vid_buf);
|
||||||
}
|
}
|
||||||
@ -2277,6 +2280,8 @@ int main(int argc, char *argv[])
|
|||||||
VINE_MODE = !VINE_MODE;
|
VINE_MODE = !VINE_MODE;
|
||||||
if (sdl_key==SDLK_SPACE)
|
if (sdl_key==SDLK_SPACE)
|
||||||
sys_pause = !sys_pause;
|
sys_pause = !sys_pause;
|
||||||
|
if (sdl_key=='u')
|
||||||
|
aheat_enable = !aheat_enable;
|
||||||
if (sdl_key=='h')
|
if (sdl_key=='h')
|
||||||
hud_enable = !hud_enable;
|
hud_enable = !hud_enable;
|
||||||
if (sdl_key=='p')
|
if (sdl_key=='p')
|
||||||
|
13
src/powder.c
13
src/powder.c
@ -1614,6 +1614,19 @@ void update_particles_i(pixel *vid, int start, int inc)
|
|||||||
h_count = 0;
|
h_count = 0;
|
||||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250))
|
if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250))
|
||||||
{
|
{
|
||||||
|
if (aheat_enable)
|
||||||
|
{
|
||||||
|
if (hv[y/CELL][x/CELL] < parts[i].temp)
|
||||||
|
{
|
||||||
|
hv[y/CELL][x/CELL] = hv[y/CELL][x/CELL] + parts[i].temp*0.04;
|
||||||
|
parts[i].temp = parts[i].temp - hv[y/CELL][x/CELL]*0.04;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hv[y/CELL][x/CELL] = hv[y/CELL][x/CELL] - parts[i].temp*0.04;
|
||||||
|
parts[i].temp = parts[i].temp + hv[y/CELL][x/CELL]*0.04;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (j=0; j<8; j++)
|
for (j=0; j<8; j++)
|
||||||
{
|
{
|
||||||
surround_hconduct[j] = i;
|
surround_hconduct[j] = i;
|
||||||
|
Loading…
Reference in New Issue
Block a user