fix emp flash, better live parts rendering in (render_ui &) deco editor

This commit is contained in:
Jacob1 2012-05-23 19:45:16 -04:00
parent 2656bcec2b
commit 0799c2e09d
6 changed files with 137 additions and 163 deletions

View File

@ -195,6 +195,10 @@ void blend_line(pixel *vid, int x1, int y1, int x2, int y2, int r, int g, int b,
void render_parts(pixel *vid); void render_parts(pixel *vid);
void render_before(pixel *part_vbuf);
void render_after(pixel *part_vbuf, pixel *vid_buf);
#ifdef OGLR #ifdef OGLR
void draw_parts_fbo(); void draw_parts_fbo();
#endif #endif

View File

@ -65,6 +65,5 @@
#define DISPLAY_AIR 0x0000000F #define DISPLAY_AIR 0x0000000F
#define DISPLAY_WARP 0x00000010 #define DISPLAY_WARP 0x00000010
#define DISPLAY_PERS 0x00000020 #define DISPLAY_PERS 0x00000020
#define DISPLAY_EFFE 0x00000040
#endif #endif

View File

@ -1693,7 +1693,7 @@ void draw_other(pixel *vid) // EMP effect
if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2; if (emp_decor>0 && !sys_pause) emp_decor-=emp_decor/25+2;
if (emp_decor>40) emp_decor=40; if (emp_decor>40) emp_decor=40;
if (emp_decor<0) emp_decor = 0; if (emp_decor<0) emp_decor = 0;
if (!(display_mode & DISPLAY_EFFE)) // no in nothing mode if (!(render_mode & EFFECT)) // not in nothing mode
return; return;
if (emp_decor>0) if (emp_decor>0)
{ {
@ -2869,10 +2869,82 @@ void draw_parts_fbo()
} }
#endif #endif
// draw the graphics that appear before update_particles is called
void render_before(pixel *part_vbuf)
{
#ifdef OGLR
if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
clearScreen(0.01f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
else //clear screen every frame
{
clearScreen(1.0f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
}
#else
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
}
else //clear screen every frame
{
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
if(ngrav_enable && drawgrav_enable)
draw_grav(part_vbuf);
draw_walls(part_vbuf);
}
int persist_counter = 0;
// draw the graphics that appear after update_particles is called
void render_after(pixel *part_vbuf, pixel *vid_buf)
{
render_parts(part_vbuf); //draw particles
draw_other(part_vbuf);
//if(su == WL_GRAV+100)
// draw_grav_zones(part_vbuf);
if (vid_buf && (display_mode & DISPLAY_PERS))
{
if (!persist_counter)
{
dim_copy_pers(pers_bg, vid_buf);
}
else
{
memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
persist_counter = (persist_counter+1) % 3;
}
#ifndef OGLR
if (render_mode & FIREMODE)
render_fire(part_vbuf);
#endif
render_signs(part_vbuf);
#ifndef OGLR
if(vid_buf && ngrav_enable && (display_mode & DISPLAY_WARP))
render_gravlensing(part_vbuf, vid_buf);
#endif
}
void draw_walls(pixel *vid) void draw_walls(pixel *vid)
{ {
int x, y, i, j, cr, cg, cb; int x, y, i, j, cr, cg, cb, nx, ny, t;
unsigned char wt; unsigned char wt;
float lx, ly;
pixel pc; pixel pc;
pixel gc; pixel gc;
for (y=0; y<YRES/CELL; y++) for (y=0; y<YRES/CELL; y++)
@ -3058,6 +3130,30 @@ void draw_walls(pixel *vid)
} }
} }
// draw streamlines
for (y=0; y<YRES/CELL; y++)
for (x=0; x<XRES/CELL; x++)
if (bmap[y][x]==WL_STREAM)
{
lx = x*CELL + CELL*0.5f;
ly = y*CELL + CELL*0.5f;
for (t=0; t<1024; t++)
{
nx = (int)(lx+0.5f);
ny = (int)(ly+0.5f);
if (nx<0 || nx>=XRES || ny<0 || ny>=YRES)
break;
addpixel(vid, nx, ny, 255, 255, 255, 64);
i = nx/CELL;
j = ny/CELL;
lx += vx[j][i]*0.125f;
ly += vy[j][i]*0.125f;
if (bmap[j][i]==WL_STREAM && i!=x && j!=y)
break;
}
drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
}
} }
void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int click, int tool) void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int click, int tool)

View File

@ -5441,7 +5441,8 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
b = mouse_get_state(&mx, &my); b = mouse_get_state(&mx, &my);
memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE);
render_parts(vid_buf); render_before(vid_buf);
render_after(vid_buf, NULL);
ui_edit_process(mx, my, b, &box_R); ui_edit_process(mx, my, b, &box_R);
ui_edit_process(mx, my, b, &box_G); ui_edit_process(mx, my, b, &box_G);
ui_edit_process(mx, my, b, &box_B); ui_edit_process(mx, my, b, &box_B);
@ -6466,10 +6467,10 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
int render_optionicons[] = {0xE1, 0xDF, 0x9B, 0xC4, 0xBF, 0xDB}; int render_optionicons[] = {0xE1, 0xDF, 0x9B, 0xC4, 0xBF, 0xDB};
char * render_desc[] = {"Effects", "Glow", "Fire", "Blur", "Blob", "Basic"}; char * render_desc[] = {"Effects", "Glow", "Fire", "Blur", "Blob", "Basic"};
int display_optioncount = 7; int display_optioncount = 6;
int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS, DISPLAY_EFFE}; int display_options[] = {DISPLAY_AIRC, DISPLAY_AIRP, DISPLAY_AIRV, DISPLAY_AIRH, DISPLAY_WARP, DISPLAY_PERS};
int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A, -1}; int display_optionicons[] = {0xD4, 0x99, 0x98, 0xBE, 0xDE, 0x9A};
char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent", "Effects"}; char * display_desc[] = {"Air: Cracker", "Air: Pressure", "Air: Velocity", "Air: Heat", "Warp effect", "Persistent"};
int colour_optioncount = 4; int colour_optioncount = 4;
int colour_options[] = {COLOUR_BASC, COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD}; int colour_options[] = {COLOUR_BASC, COLOUR_LIFE, COLOUR_HEAT, COLOUR_GRAD};
@ -6558,63 +6559,24 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
b = mouse_get_state(&mx, &my); b = mouse_get_state(&mx, &my);
memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE); memcpy(vid_buf, o_vid_buf, ((YRES+MENUSIZE) * (XRES+BARSIZE)) * PIXELSIZE);
#ifdef OGLR
if(ngrav_enable && display_mode & DISPLAY_WARP) part_vbuf = vid_buf;
#else
if(ngrav_enable && (display_mode & DISPLAY_WARP))
{ {
part_vbuf = part_vbuf_store; part_vbuf = part_vbuf_store;
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
} else { } else {
part_vbuf = vid_buf; part_vbuf = vid_buf;
} }
#ifdef OGLR
if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
clearScreen(0.01f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
else //clear screen every frame
{
clearScreen(1.0f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
}
#else
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
}
else //clear screen every frame
{
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
if(ngrav_enable && drawgrav_enable)
draw_grav(vid_buf);
draw_walls(part_vbuf);
render_parts(part_vbuf);
draw_other(part_vbuf);
#ifndef OGLR
if (render_mode & FIREMODE)
render_fire(part_vbuf);
#endif
render_signs(part_vbuf);
#ifndef OGLR
if(ngrav_enable && display_mode & DISPLAY_WARP)
render_gravlensing(part_vbuf, vid_buf);
#endif #endif
render_before(part_vbuf);
render_after(part_vbuf, vid_buf);
quickoptions_menu(vid_buf, b, bq, mx, my);
for (i=0; i<SC_TOTAL; i++)//draw all the menu sections
{
draw_menu(vid_buf, i, active_menu);
}
draw_svf_ui(vid_buf, sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)); draw_svf_ui(vid_buf, sdl_mod & (KMOD_LCTRL|KMOD_RCTRL));
clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4); clearrect(vid_buf, xcoord-2, ycoord-2, xsize+4, ysize+4);

View File

@ -755,7 +755,7 @@ int main(int argc, char *argv[])
void *http_ver_check, *http_session_check = NULL; void *http_ver_check, *http_session_check = NULL;
char *ver_data=NULL, *check_data=NULL, *tmp; char *ver_data=NULL, *check_data=NULL, *tmp;
//char console_error[255] = ""; //char console_error[255] = "";
int result, i, j, bq, bc = 0, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, buildnum, is_beta = 0, old_ver_len, new_message_len=0; int result, i, j, bq, bc = 0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, buildnum, is_beta = 0, old_ver_len, new_message_len=0;
#ifdef INTERNAL #ifdef INTERNAL
int vs = 0; int vs = 0;
#endif #endif
@ -1002,54 +1002,12 @@ int main(int argc, char *argv[])
update_airh(); update_airh();
} }
#ifdef OGLR
part_vbuf = vid_buf;
#else
if(ngrav_enable && display_mode & DISPLAY_WARP)
{
part_vbuf = part_vbuf_store;
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
} else {
part_vbuf = vid_buf;
}
#endif
if(gravwl_timeout) if(gravwl_timeout)
{ {
if(gravwl_timeout==1) if(gravwl_timeout==1)
gravity_mask(); gravity_mask();
gravwl_timeout--; gravwl_timeout--;
} }
#ifdef OGLR
if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
clearScreen(0.01f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
else //clear screen every frame
{
clearScreen(1.0f);
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
}
#else
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
{
draw_air(part_vbuf);
}
else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
{
memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
}
else //clear screen every frame
{
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
//Can't be too sure (Limit the cursor size) //Can't be too sure (Limit the cursor size)
if (bsx>1180) if (bsx>1180)
@ -1067,10 +1025,19 @@ int main(int argc, char *argv[])
sandcolour_b = sandcolour_r = sandcolour_g = (int)(20.0f*sin((float)sandcolour_frame*(M_PI/180.0f))); sandcolour_b = sandcolour_r = sandcolour_g = (int)(20.0f*sin((float)sandcolour_frame*(M_PI/180.0f)));
sandcolour_frame++; sandcolour_frame++;
sandcolour_frame%=360; sandcolour_frame%=360;
if(ngrav_enable && drawgrav_enable) #ifdef OGLR
draw_grav(vid_buf); part_vbuf = vid_buf;
draw_walls(part_vbuf); #else
if(ngrav_enable && (display_mode & DISPLAY_WARP))
{
part_vbuf = part_vbuf_store;
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
} else {
part_vbuf = vid_buf;
}
#endif
render_before(part_vbuf);
if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME))
{ {
@ -1099,8 +1066,9 @@ int main(int argc, char *argv[])
#endif #endif
} }
render_parts(part_vbuf); //draw particles render_after(part_vbuf, vid_buf);
draw_other(part_vbuf); if(su == WL_GRAV+100)
draw_grav_zones(part_vbuf);
if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME)) if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME))
{ {
@ -1118,9 +1086,6 @@ int main(int argc, char *argv[])
debug_perf_istart %= DEBUG_PERF_FRAMECOUNT; debug_perf_istart %= DEBUG_PERF_FRAMECOUNT;
} }
if(sl == WL_GRAV+100 || sr == WL_GRAV+100)
draw_grav_zones(part_vbuf);
gravity_update_async(); //Check for updated velocity maps from gravity thread gravity_update_async(); //Check for updated velocity maps from gravity thread
if (!sys_pause||framerender) //Only update if not paused if (!sys_pause||framerender) //Only update if not paused
memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap
@ -1130,31 +1095,6 @@ int main(int argc, char *argv[])
sys_pause = 1; sys_pause = 1;
} }
if (display_mode & DISPLAY_PERS)
{
if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames
{
dim_copy_pers(pers_bg, vid_buf);
}
else
{
memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
fire_fc = (fire_fc+1) % 3;
}
#ifndef OGLR
if (render_mode & FIREMODE)
render_fire(part_vbuf);
#endif
render_signs(part_vbuf);
#ifndef OGLR
if(ngrav_enable && display_mode & DISPLAY_WARP)
render_gravlensing(part_vbuf, vid_buf);
#endif
memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas
clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES);
@ -2822,7 +2762,6 @@ int main(int argc, char *argv[])
#endif #endif
} }
//execute python step hook
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE); sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
//Setting an element for the stick man //Setting an element for the stick man

View File

@ -2730,8 +2730,7 @@ movedone:
int parts_lastActiveIndex = NPART-1; int parts_lastActiveIndex = NPART-1;
void update_particles(pixel *vid)//doesn't update the particles themselves, but some other things void update_particles(pixel *vid)//doesn't update the particles themselves, but some other things
{ {
int i, j, x, y, t, nx, ny, r, cr,cg,cb, l = -1; int i, x, y, t;
float lx, ly;
int lastPartUsed = 0; int lastPartUsed = 0;
int lastPartUnused = -1; int lastPartUnused = -1;
#ifdef MT #ifdef MT
@ -2792,31 +2791,6 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but
} }
update_particles_i(vid, 0, 1); update_particles_i(vid, 0, 1);
// this should probably be elsewhere
for (y=0; y<YRES/CELL; y++)
for (x=0; x<XRES/CELL; x++)
if (bmap[y][x]==WL_STREAM)
{
lx = x*CELL + CELL*0.5f;
ly = y*CELL + CELL*0.5f;
for (t=0; t<1024; t++)
{
nx = (int)(lx+0.5f);
ny = (int)(ly+0.5f);
if (nx<0 || nx>=XRES || ny<0 || ny>=YRES)
break;
addpixel(vid, nx, ny, 255, 255, 255, 64);
i = nx/CELL;
j = ny/CELL;
lx += vx[j][i]*0.125f;
ly += vy[j][i]*0.125f;
if (bmap[j][i]==WL_STREAM && i!=x && j!=y)
break;
}
drawtext(vid, x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
}
} }
void clear_area(int area_x, int area_y, int area_w, int area_h) void clear_area(int area_x, int area_y, int area_w, int area_h)