diff options
| author | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-07 18:12:54 (GMT) |
|---|---|---|
| committer | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-07 18:15:36 (GMT) |
| commit | fa1868314c1d48de9000c45dc8bcde36d92472cb (patch) | |
| tree | 578ee5d73223a2489ffd1dcf7f949bc1c460b941 /src | |
| parent | cb02bdfe214ceeb28795fa34ac0cee7ad30c658c (diff) | |
| download | powder-fa1868314c1d48de9000c45dc8bcde36d92472cb.zip powder-fa1868314c1d48de9000c45dc8bcde36d92472cb.tar.gz | |
Shrink GOL wrapping code. GSPEED now works.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 1 | ||||
| -rw-r--r-- | src/powder.c | 56 |
2 files changed, 10 insertions, 47 deletions
@@ -1113,6 +1113,7 @@ int main(int argc, char *argv[]) void *load_data=NULL; pixel *load_img=NULL;//, *fbi_img=NULL; int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0; + GSPEED = 1; #ifdef MT numCores = core_count(); diff --git a/src/powder.c b/src/powder.c index 4aa1063..999cd20 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1230,14 +1230,15 @@ void update_particles_i(pixel *vid, int start, int inc) } } } + CGOL++; if (ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation { + CGOL=0; + ISGOL=0; int createdsomething = 0; - for (nx=4; nx<XRES-4; nx++) - for (ny=4; ny<YRES-4; ny++) + for (nx=CELL; nx<XRES-CELL; nx++) + for (ny=CELL; ny<YRES-CELL; ny++) { - CGOL=0; - ISGOL=0; r = pmap[ny][nx]; if ((r>>8)>=NPART || !r) { @@ -1252,47 +1253,13 @@ void update_particles_i(pixel *vid, int start, int inc) for ( nnx=-1; nnx<2; nnx++) for ( nny=-1; nny<2; nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check { - if (ny+nny<4&&nx+nnx<4) {//any way to make wrapping code smaller? - gol2[XRES-5][YRES-5][golnum] ++; - gol2[XRES-5][YRES-5][0] ++; - } - else if (ny+nny<4&&nx+nnx>=XRES-4) { - gol2[4][YRES-5][golnum] ++; - gol2[4][YRES-5][0] ++; - } - else if (ny+nny>=YRES-4&&nx+nnx<4) { - gol2[XRES-5][4][golnum] ++; - gol2[XRES-5][4][0] ++; - } - else if (nx+nnx<4) { - gol2[XRES-5][ny+nny][golnum] ++; - gol2[XRES-5][ny+nny][0] ++; - } - else if (ny+nny<4) { - gol2[nx+nnx][YRES-5][golnum] ++; - gol2[nx+nnx][YRES-5][0] ++; - } - else if (ny+nny>=YRES-4&&nx+nnx>=XRES-4) { - gol2[4][4][golnum] ++; - gol2[4][4][0] ++; - } - else if (ny+nny>=YRES-4) { - gol2[nx+nnx][4][golnum] ++; - gol2[nx+nnx][4][0] ++; - } - else if (nx+nnx>=XRES-4) { - gol2[4][ny+nny][golnum] ++; - gol2[4][ny+nny][0] ++; - } - else { - gol2[nx+nnx][ny+nny][golnum] ++; - gol2[nx+nnx][ny+nny][0] ++; - } + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++; + gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++; } } } - for (nx=4; nx<XRES-4; nx++) - for (ny=4; ny<YRES-4; ny++) + for (nx=CELL; nx<XRES-CELL; nx++) + for (ny=CELL; ny<YRES-CELL; ny++) { int neighbors = gol2[nx][ny][0]; if (neighbors==0) @@ -1315,11 +1282,6 @@ void update_particles_i(pixel *vid, int start, int inc) if (createdsomething) GENERATION ++; } - //if(ISWIRE==1) - //{ - // CGOL = 0; - // ISWIRE = 0; - //} if (ISWIRE==1) { for ( q = 0; q<99; q++) |
