Air heat simulation now knows about gravity mode. fixes #142

This commit is contained in:
Simon Robertshaw 2012-08-21 12:26:39 +01:00
parent e54eeae883
commit 4b8ebe4abd
3 changed files with 10 additions and 5 deletions

View File

@ -2,6 +2,7 @@
#include <algorithm> #include <algorithm>
#include "Config.h" #include "Config.h"
#include "Air.h" #include "Air.h"
#include "Simulation.h"
//#include <powder.h> //#include <powder.h>
//#include <defines.h> //#include <defines.h>
#include "Gravity.h" #include "Gravity.h"
@ -110,7 +111,7 @@ void Air::update_airh(void)
dh += AIR_VADV*(1.0f-tx)*ty*(bmap_blockairh[j+1][i] ? odh : hv[j+1][i]); dh += AIR_VADV*(1.0f-tx)*ty*(bmap_blockairh[j+1][i] ? odh : hv[j+1][i]);
dh += AIR_VADV*tx*ty*(bmap_blockairh[j+1][i+1] ? odh : hv[j+1][i+1]); dh += AIR_VADV*tx*ty*(bmap_blockairh[j+1][i+1] ? odh : hv[j+1][i+1]);
} }
//if(!gravityMode) TODO: GET REAL VALUE if(!sim.gravityMode)
{ //Vertical gravity only for the time being { //Vertical gravity only for the time being
float airdiff = hv[y-1][x]-hv[y][x]; float airdiff = hv[y-1][x]-hv[y][x];
if(airdiff>0 && !bmap_blockairh[y-1][x]) if(airdiff>0 && !bmap_blockairh[y-1][x])
@ -309,9 +310,12 @@ void Air::Invert()
} }
} }
Air::Air(): Air::Air(Simulation & simulation):
airMode(0) airMode(0),
sim(simulation)
{ {
//Simulation should do this. //Simulation should do this.
make_kernel(); make_kernel();
} }

View File

@ -7,6 +7,7 @@ class Simulation;
class Air class Air
{ {
public: public:
Simulation & sim;
int airMode; int airMode;
//Arrays from the simulation //Arrays from the simulation
unsigned char (*bmap)[XRES/CELL]; unsigned char (*bmap)[XRES/CELL];
@ -30,7 +31,7 @@ public:
void update_air(void); void update_air(void);
void Clear(); void Clear();
void Invert(); void Invert();
Air(); Air(Simulation & sim);
}; };
#endif #endif

View File

@ -4520,7 +4520,7 @@ Simulation::Simulation():
gravmap = grav->gravmap; gravmap = grav->gravmap;
//Create and attach air simulation //Create and attach air simulation
air = new Air(); air = new Air(*this);
//Give air sim references to our data //Give air sim references to our data
air->bmap = bmap; air->bmap = bmap;
air->emap = emap; air->emap = emap;