diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-25 17:21:25 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-25 17:21:25 (GMT) |
| commit | 5337f917368985b1163dfe7369d7aa7d507d1ead (patch) | |
| tree | 1008ae354da78c5067039393265af08d85c99663 /src/simulation/Simulation.cpp | |
| parent | 55c870c5180c20df0936865331a3483b228a449a (diff) | |
| download | powder-5337f917368985b1163dfe7369d7aa7d507d1ead.zip powder-5337f917368985b1163dfe7369d7aa7d507d1ead.tar.gz | |
TPT: Lightning direction affected by Newtonian gravity 3a946efdfd
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index d0b42bc..596a226 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2660,24 +2660,6 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat } 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(float( x-XCNTR), float(y-YCNTR))*(180.0f/M_PI)+90; - } - parts[i].tmp2 = 4; - } - break; case PT_SOAP: parts[i].tmp = -1; parts[i].tmp2 = -1; @@ -2876,6 +2858,27 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat 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 + } + GetGravityField(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; + } break; } //and finally set the pmap/photon maps to the newly created particle |
