From 5919cefa85db406f1777df2231f20d78fde73c44 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 27 May 2011 14:44:56 +0100 Subject: [PATCH] Decorations are per particle TODO: remove references to the decorations buffer --- includes/powder.h | 1 + src/graphics.c | 26 +++++++++++++++++--------- src/interface.c | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index e5fafc1c4..155805663 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -329,6 +329,7 @@ struct particle int flags; int tmp; int tmp2; + int dcolour; }; typedef struct particle particle; diff --git a/src/graphics.c b/src/graphics.c index 7b9b0ea29..39764b1c8 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2946,6 +2946,7 @@ void draw_parts(pixel *vid) blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); } + blendpixel(vid, nx, ny, (parts[i].dcolour>>16)&0xFF, (parts[i].dcolour>>8)&0xFF, (parts[i].dcolour)&0xFF, (parts[i].dcolour>>24)&0xFF); } #endif } @@ -3126,29 +3127,36 @@ void draw_walls(pixel *vid) void draw_decorations(pixel *vid_buf,pixel *decorations) { - int i,r,g,b; + /*int i,r,g,b; for (i=0; i<(XRES+BARSIZE)*YRES; i++) { - r = PIXR(decorations[i]); - g = PIXG(decorations[i]); - b = PIXB(decorations[i]); + r = (decorations[i]&0xFF0000)>>16; + g = (decorations[i]&0x00FF00)>>8; + b = decorations[i]&0x0000FF; if (r>0 || g>0 || b>0) vid_buf[i] = PIXRGB(r,g,b); - } + }*/ } void create_decorations(pixel *decorations,int x, int y, int rx, int ry, int r, int g, int b) { - int i,j; + int i,j,rp; if (rx==0 && ry==0) { - decorations[(y)*(XRES+BARSIZE)+(x)] = PIXRGB(r, g, b); + rp = pmap[y][x]; + if ((rp>>8)>=NPART || !rp) + return; + parts[rp>>8].dcolour = ((255<<24)|(r<<16)|(g<<8)|b);//decorations[(y)*(XRES+BARSIZE)+(x)] = PIXRGB(r, g, b); return; } for (j=-ry; j<=ry; j++) for (i=-rx; i<=rx; i++) if(y+j>=0 && x+i>=0 && x+i>8)>=NPART || !rp) + continue; + parts[rp>>8].dcolour = ((255<<24)|(r<<16)|(g<<8)|b); + } } void line_decorations(pixel *decorations,int x1, int y1, int x2, int y2, int rx, int ry, int r, int g, int b) { diff --git a/src/interface.c b/src/interface.c index 9d1020794..b4c2d58f8 100644 --- a/src/interface.c +++ b/src/interface.c @@ -4326,7 +4326,7 @@ unsigned int decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy, my /= sdl_scale; memcpy(vid_buf,old_buf,(XRES+BARSIZE)*(YRES+MENUSIZE)*PIXELSIZE); - draw_decorations(vid_buf,decorations); + draw_parts(vid_buf);//draw_decorations(vid_buf,decorations); //ui_edit_process(mx, my, b, &box_R); //ui_edit_process(mx, my, b, &box_G); //ui_edit_process(mx, my, b, &box_B);