diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-06-26 23:50:25 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-06-26 23:52:12 (GMT) |
| commit | 3a946efdfdf6bfc83540e7b4ce980acd3f6ae9b5 (patch) | |
| tree | 1b4aa94c598f72a23a3e8a49447db1338c57a91c /src | |
| parent | 8de602d467915a79854b211e1ea9cf6fc5c9e452 (diff) | |
| download | powder-3a946efdfdf6bfc83540e7b4ce980acd3f6ae9b5.zip powder-3a946efdfdf6bfc83540e7b4ce980acd3f6ae9b5.tar.gz | |
Lightning direction affected by Newtonian gravity
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/ligh.c | 2 | ||||
| -rw-r--r-- | src/powder.c | 39 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/elements/ligh.c b/src/elements/ligh.c index 146ba1f..a17954f 100644 --- a/src/elements/ligh.c +++ b/src/elements/ligh.c @@ -127,7 +127,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) * * life - "thickness" of lighting (but anyway one pixel) * - * tmp - angle of lighting + * tmp - angle of lighting, measured in degrees anticlockwise from the positive x direction * */ int r,rx,ry, multipler, powderful; diff --git a/src/powder.c b/src/powder.c index 889a5f6..8c1280b 100644 --- a/src/powder.c +++ b/src/powder.c @@ -947,24 +947,6 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a }*/ switch (t) { - case PT_LIGH: - if (p==-2) - { - switch (gravityMode) - { - default: - case 0: - parts[i].tmp= 270+rand()%40-20; - break; - case 1: - parts[i].tmp = rand()%360; - break; - case 2: - parts[i].tmp = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90; - } - parts[i].tmp2 = 4; - } - break; case PT_SOAP: parts[i].tmp = -1; parts[i].tmp2 = -1; @@ -1175,6 +1157,27 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].tmp2 = 4;//tail parts[i].life = 5; } + if (t==PT_LIGH) + { + float gx, gy, gsize; + if (p!=-2) + { + parts[i].life=30; + parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting + } + get_gravity_field(x, y, 1.0f, 1.0f, &gx, &gy); + gsize = gx*gx+gy*gy; + if (gsize<0.0016f) + { + float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) + gsize = sqrtf(gsize); + // randomness in weak gravity fields (more randomness with weaker fields) + gx += cosf(angle)*(0.04f-gsize); + gy += sinf(angle)*(0.04f-gsize); + } + parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360; + parts[i].tmp2 = 4; + } } //and finally set the pmap/photon maps to the newly created particle if (ptypes[t].properties & TYPE_ENERGY) |
