summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-04-08 10:09:42 (GMT)
committer Simon <simon@hardwired.org.uk>2011-04-08 10:09:42 (GMT)
commit767d73c5fc51647dcb5da4ed8349da2186c5060c (patch)
treee9cb3540858927af4887553068fd348a95195092 /src/powder.c
parent1bdf72be1a306ac07641211adb2ec1539e3d0a48 (diff)
downloadpowder-767d73c5fc51647dcb5da4ed8349da2186c5060c.zip
powder-767d73c5fc51647dcb5da4ed8349da2186c5060c.tar.gz
astyle
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/powder.c b/src/powder.c
index deacfed..00ea068 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -13,7 +13,7 @@ particle *parts;
particle *cb_parts;
int gravityMode = 0; // starts enabled in "vertical" mode...
-int airMode = 0;
+int airMode = 0;
unsigned char bmap[YRES/CELL][XRES/CELL];
@@ -79,7 +79,7 @@ int eval_move(int pt, int nx, int ny, unsigned *rr)
if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL)
return 1;
- if(pt==PT_SPRK)//spark shouldn't move
+ if (pt==PT_SPRK)//spark shouldn't move
return 0;
if (pt==PT_PHOT&&(
@@ -200,7 +200,7 @@ int try_move(int i, int x, int y, int nx, int ny)
}
return 1;
}
- //else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later
+ //else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later
if ((r&0xFF)==PT_VOID) //this is where void eats particles
{
@@ -702,8 +702,8 @@ inline int create_part(int p, int x, int y, int t)//the function for creating a
}
if (ptypes[t].properties&PROP_LIFE) {
int r;
- for(r = 0; r<NGOL; r++)
- if(t==goltype[r])
+ for (r = 0; r<NGOL; r++)
+ if (t==goltype[r])
parts[i].tmp = grule[r+1][9] - 1;
}
if (t==PT_DEUT)
@@ -1313,7 +1313,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for ( golnum=1; golnum<=NGOL; golnum++)
if (parts[r>>8].type==goltype[golnum-1])
{
- if(parts[r>>8].tmp == grule[golnum][9]-1) {
+ if (parts[r>>8].tmp == grule[golnum][9]-1) {
gol[nx][ny] = golnum;
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
@@ -1327,7 +1327,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
} else {
parts[r>>8].tmp --;
- if(parts[r>>8].tmp<=0)
+ if (parts[r>>8].tmp<=0)
parts[r>>8].type = PT_NONE;//using kill_part makes it not work
}
}
@@ -1337,25 +1337,25 @@ void update_particles_i(pixel *vid, int start, int inc)
{
r = pmap[ny][nx];
neighbors = gol2[nx][ny][0];
- if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !(r&0xFF)) || (r>>8)>=NPART)
+ if (neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !(r&0xFF)) || (r>>8)>=NPART)
continue;
for ( golnum = 1; golnum<=NGOL; golnum++)
+ {
+ goldelete = neighbors;
+ if (gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
{
- goldelete = neighbors;
- if (gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
- {
- if (create_part(-1,nx,ny,goltype[golnum-1]))
- createdsomething = 1;
- }
- else if (gol[nx][ny]==golnum&&(grule[golnum][goldelete-1]==0||grule[golnum][goldelete-1]==2))//subtract 1 because it counted itself
- {
- if(parts[r>>8].tmp==grule[golnum][9]-1)
- parts[r>>8].tmp --;
- }
- if (r && parts[r>>8].tmp<=0)
- parts[r>>8].type = PT_NONE;//using kill_part makes it not work
+ if (create_part(-1,nx,ny,goltype[golnum-1]))
+ createdsomething = 1;
+ }
+ else if (gol[nx][ny]==golnum&&(grule[golnum][goldelete-1]==0||grule[golnum][goldelete-1]==2))//subtract 1 because it counted itself
+ {
+ if (parts[r>>8].tmp==grule[golnum][9]-1)
+ parts[r>>8].tmp --;
}
- for( z = 0;z<=NGOL;z++)
+ if (r && parts[r>>8].tmp<=0)
+ parts[r>>8].type = PT_NONE;//using kill_part makes it not work
+ }
+ for ( z = 0; z<=NGOL; z++)
gol2[nx][ny][z] = 0;//this improves performance A LOT compared to the memset, i was getting ~23 more fps with this.
}
if (createdsomething)
@@ -1450,18 +1450,18 @@ void update_particles_i(pixel *vid, int start, int inc)
//Gravity mode by Moach
switch (gravityMode)
{
- default:
- case 0:
- pGravX = 0.0f;
- pGravY = ptypes[t].gravity;
- break;
- case 1:
- pGravX = pGravY = 0.0f;
- break;
- case 2:
- pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
- pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
- pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
+ default:
+ case 0:
+ pGravX = 0.0f;
+ pGravY = ptypes[t].gravity;
+ break;
+ case 1:
+ pGravX = pGravY = 0.0f;
+ break;
+ case 2:
+ pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
+ pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
+ pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
}
//velocity updates for the particle
parts[i].vx *= ptypes[t].loss;
@@ -2704,9 +2704,9 @@ int flood_parts(int x, int y, int c, int cm, int bm)
// fill span
for (x=x1; x<=x2; x++)
{
- if(cm==PT_INST&&co==PT_SPRK)
+ if (cm==PT_INST&&co==PT_SPRK)
{
- if(create_part(-1,x, y, co)==-1)
+ if (create_part(-1,x, y, co)==-1)
return 0;
}
else if (!create_parts(x, y, 0, 0, co))
@@ -2864,7 +2864,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for (i=-rx; i<=rx; i++)
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
{
- if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
+ if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
continue;
if (!REPLACE_MODE)
create_part(-2, x+i, y+j, c);
@@ -2910,7 +2910,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for (i=-rx; i<=rx; i++)
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
{
- if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
+ if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
continue;
if ((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
continue;
@@ -3026,7 +3026,7 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
cornerso[1] = v2d_new(w-1,0);
cornerso[2] = v2d_new(0,h-1);
cornerso[3] = v2d_new(w-1,h-1);
- for (i=0;i<4;i++)
+ for (i=0; i<4; i++)
{
tmp = m2d_multiply_v2d(transform,cornerso[i]);
if (i==0) ctl = cbr = tmp; // top left, bottom right corner
@@ -3073,8 +3073,8 @@ 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<YRES/CELL; y++)
+ for (x=0; x<XRES/CELL; x++)
{
pos = v2d_new(x*CELL+CELL*0.4f, y*CELL+CELL*0.4f);
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
@@ -3107,7 +3107,7 @@ inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblo
resblock1[1] = (block1&0x0000FF00)>>8;
resblock1[2] = (block1&0x00FF0000)>>16;
resblock1[3] = (block1&0xFF000000)>>24;
-
+
resblock2[0] = (block2&0x000000FF);
resblock2[1] = (block2&0x0000FF00)>>8;
resblock2[2] = (block2&0x00FF0000)>>16;
@@ -3122,17 +3122,17 @@ inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resb
{
int block1tmp = 0;
int block2tmp = 0;
-
+
block1tmp = (resblock1[0]&0xFF);
block1tmp |= (resblock1[1]&0xFF)<<8;
block1tmp |= (resblock1[2]&0xFF)<<16;
block1tmp |= (resblock1[3]&0xFF)<<24;
-
+
block2tmp = (resblock2[0]&0xFF);
block2tmp |= (resblock2[1]&0xFF)<<8;
block2tmp |= (resblock2[2]&0xFF)<<16;
block2tmp |= (resblock2[3]&0xFF)<<24;
-
+
*block1 = block1tmp;
*block2 = block2tmp;
}