diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2011-05-11 21:02:15 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-05-14 12:44:02 (GMT) |
| commit | 7fe99f32102429113c671615fc2c5cadb9c51e56 (patch) | |
| tree | a6b6fa9e9510b9e6ae9d3d838524dee9e1a9ef00 /src | |
| parent | cbfc73d8d60421c5d64a8cca0961c87bc33146d0 (diff) | |
| download | powder-7fe99f32102429113c671615fc2c5cadb9c51e56.zip powder-7fe99f32102429113c671615fc2c5cadb9c51e56.tar.gz | |
Pass decorations to saving functions (doesn't actually save yet)
Diffstat (limited to 'src')
| -rw-r--r-- | src/interface.c | 4 | ||||
| -rw-r--r-- | src/main.c | 24 | ||||
| -rw-r--r-- | src/powder.c | 34 |
3 files changed, 32 insertions, 30 deletions
diff --git a/src/interface.c b/src/interface.c index a3ee9bb..2383782 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3244,7 +3244,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date) if (queue_open) { if (info_ready && data_ready) { // Do Open! - status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); + status = parse_save(data, data_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); if (!status) { //if(svf_last) //free(svf_last); @@ -3765,7 +3765,7 @@ void execute_save(pixel *vid_buf) plens[0] = strlen(svf_name); uploadparts[1] = svf_description; plens[1] = strlen(svf_description); - uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts); + uploadparts[2] = build_save(plens+2, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts, decorations); uploadparts[3] = build_thumb(plens+3, 1); uploadparts[4] = (svf_publish==1)?"Public":"Private"; plens[4] = strlen((svf_publish==1)?"Public":"Private"); @@ -59,7 +59,7 @@ #include "pyconsole.h" #endif -pixel *vid_buf; +pixel *vid_buf, *decorations; #define NUM_SOUNDS 2 struct sample { @@ -317,7 +317,7 @@ void *build_thumb(int *size, int bzip2) } //the saving function -void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr) +void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, pixel *decorations) { unsigned char *d=calloc(1,3*(XRES/CELL)*(YRES/CELL)+(XRES*YRES)*11+MAXSIGNS*262), *c; int i,j,x,y,p=0,*m=calloc(XRES*YRES, sizeof(int)); @@ -490,7 +490,7 @@ void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRE return c; } -int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES]) +int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char bmap[YRES/CELL][XRES/CELL], float fvx[YRES/CELL][XRES/CELL], float fvy[YRES/CELL][XRES/CELL], sign signs[MAXSIGNS], void* partsptr, unsigned pmap[YRES][XRES], pixel *decorations) { unsigned char *d=NULL,*c=save; int q,i,j,k,x,y,p=0,*m=NULL, ver, pty, ty, legacy_beta=0; @@ -578,6 +578,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char } clear_sim(); } + clearrect(decorations, x0, y0, w, h); m = calloc(XRES*YRES, sizeof(int)); // make a catalog of free parts @@ -1031,7 +1032,7 @@ void stamp_save(int x, int y, int w, int h) FILE *f; int n; char fn[64], sn[16]; - void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts); + void *s=build_save(&n, x, y, w, h, bmap, fvx, fvy, signs, parts, decorations); #ifdef WIN32 _mkdir("stamps"); @@ -1305,8 +1306,7 @@ int main(int argc, char *argv[]) if(load_data && load_size){ int parsestate = 0; - //parsestate = parse_save(load_data, load_size, 1, 0, 0); - parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); + parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); for(i=0; i<30; i++){ memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); @@ -1377,7 +1377,7 @@ int main(int argc, char *argv[]) PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey; PyObject *tpt_console_obj; #endif - pixel *decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); + decorations = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); GSPEED = 1; @@ -1532,7 +1532,7 @@ int main(int argc, char *argv[]) if (file_data) { it=0; - parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap); + parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); } } @@ -2493,7 +2493,7 @@ int main(int argc, char *argv[]) if (load_y<0) load_y=0; if (bq==1 && !b) { - parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap); + parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap, decorations); free(load_data); free(load_img); load_mode = 0; @@ -2535,14 +2535,14 @@ int main(int argc, char *argv[]) { if (copy_mode==1)//CTRL-C, copy { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations); clipboard_ready = 1; save_mode = 0; copy_mode = 0; } else if (copy_mode==2)//CTRL-X, cut { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); + clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts, decorations); clipboard_ready = 1; save_mode = 0; copy_mode = 0; @@ -2669,7 +2669,7 @@ int main(int argc, char *argv[]) } if (x>=19 && x<=35 && svf_last && svf_open && !bq) { //int tpval = sys_pause; - parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); + parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap, decorations); //sys_pause = tpval; } if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) diff --git a/src/powder.c b/src/powder.c index c25e312..63527b2 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2542,11 +2542,14 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl float (*fvyo)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); float (*fvxn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); float (*fvyn)[XRES/CELL] = calloc((YRES/CELL)*(XRES/CELL), sizeof(float)); + pixel *decorationso = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); + pixel *decorationsn = calloc((XRES+BARSIZE)*YRES, PIXELSIZE); int i, x, y, nx, ny, w, h, nw, nh; + pixel px; vector2d pos, tmp, ctl, cbr; vector2d cornerso[4]; unsigned char *odatac = odata; - if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt)) + if (parse_save(odata, *size, 0, 0, 0, bmapo, fvxo, fvyo, signst, partst, pmapt, decorationso)) { free(bmapo); free(bmapn); @@ -2557,6 +2560,8 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl free(fvyo); free(fvxn); free(fvyn); + free(decorationso); + free(decorationsn); return odata; } w = odatac[6]*CELL; @@ -2613,26 +2618,21 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl partst[i].x = nx; partst[i].y = ny; } - for (y=0; y<YRES/CELL; y++) - for (x=0; x<XRES/CELL; x++) + for (y=0; y<h; y++) + for (x=0; x<w; x++) { - pos = v2d_new(x*CELL+CELL*0.4f, y*CELL+CELL*0.4f); + px = decorationso[y*(XRES+BARSIZE)+x]; + if (!PIXR(px) && !PIXG(px) && !PIXB(px)) + continue; + pos = v2d_new(x, y); pos = v2d_add(m2d_multiply_v2d(transform,pos),translate); - nx = pos.x/CELL; - ny = pos.y/CELL; + nx = floor(pos.x+0.5f); + ny = floor(pos.y+0.5f); if (nx<0 || nx>=nw || ny<0 || ny>=nh) continue; - if (bmapo[y][x]) - { - bmapn[ny][nx] = bmapo[y][x]; - if (bmapo[y][x]==WL_FAN) - { - fvxn[ny][nx] = fvxo[y][x]; - fvyn[ny][nx] = fvyo[y][x]; - } - } + decorationsn[ny*(XRES+BARSIZE)+nx] = px; } - ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst); + ndata = build_save(size,0,0,nw,nh,bmapn,fvxn,fvyn,signst,partst,decorationsn); free(bmapo); free(bmapn); free(partst); @@ -2642,6 +2642,8 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl free(fvyo); free(fvxn); free(fvyn); + free(decorationso); + free(decorationsn); return ndata; } |
