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/powder.c | |
| 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/powder.c')
| -rw-r--r-- | src/powder.c | 34 |
1 files changed, 18 insertions, 16 deletions
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; } |
