summaryrefslogtreecommitdiff
path: root/src/simulation/Simulation.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-25 16:44:29 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-25 16:44:29 (GMT)
commite36bc8e4aeaf26b87d81f4e8df6c82c242256db9 (patch)
tree777b2d175915ca5e710d4638d60fe2b0ee52948e /src/simulation/Simulation.cpp
parent811c2cb26bdce4975c23c4c47d61471726dbab0d (diff)
downloadpowder-e36bc8e4aeaf26b87d81f4e8df6c82c242256db9.zip
powder-e36bc8e4aeaf26b87d81f4e8df6c82c242256db9.tar.gz
TPT: Gravity modes and Newtonian gravity for fireworks 31ce22f122
Diffstat (limited to 'src/simulation/Simulation.cpp')
-rw-r--r--src/simulation/Simulation.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 9a347e8..9117fd0 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -2875,6 +2875,28 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
return i;
}
+void Simulation::GetGravityField(int x, int y, float particleGrav, float newtonGrav, float & pGravX, float & pGravY)
+{
+ pGravX = newtonGrav*gravx[(y/CELL)*(XRES/CELL)+(x/CELL)];
+ pGravY = newtonGrav*gravy[(y/CELL)*(XRES/CELL)+(x/CELL)];
+ switch (gravityMode)
+ {
+ default:
+ case 0: //normal, vertical gravity
+ pGravY += particleGrav;
+ break;
+ case 1: //no gravity
+ break;
+ case 2: //radial gravity
+ if (x-XCNTR != 0 || y-YCNTR != 0)
+ {
+ float pGravMult = particleGrav/sqrtf((x-XCNTR)*(x-XCNTR) + (y-YCNTR)*(y-YCNTR));
+ pGravX -= pGravMult * (float)(x - XCNTR);
+ pGravY -= pGravMult * (float)(y - YCNTR);
+ }
+ }
+}
+
void Simulation::create_gain_photon(int pp)//photons from PHOT going through GLOW
{
float xx, yy;