MeteorMgr.cpp   MeteorMgr.cpp 
skipping to change at line 42 skipping to change at line 42
#include <QSettings> #include <QSettings>
const double MeteorMgr::zhrToWsr = 1.6667f / 3600.f; const double MeteorMgr::zhrToWsr = 1.6667f / 3600.f;
MeteorMgr::MeteorMgr(int zhr, int maxv ) MeteorMgr::MeteorMgr(int zhr, int maxv )
: ZHR(zhr) : ZHR(zhr)
, maxVelocity(maxv) , maxVelocity(maxv)
, flagShow(true) , flagShow(true)
{ {
setObjectName("MeteorMgr"); setObjectName("MeteorMgr");
qsrand (QDateTime::currentMSecsSinceEpoch());
} }
MeteorMgr::~MeteorMgr() MeteorMgr::~MeteorMgr()
{ {
std::vector<Meteor*>::iterator iter; std::vector<Meteor*>::iterator iter;
for(iter = active.begin(); iter != active.end(); ++iter) for(iter = active.begin(); iter != active.end(); ++iter)
{ {
delete *iter; delete *iter;
} }
active.clear(); active.clear();
skipping to change at line 92 skipping to change at line 93
return ZHR; return ZHR;
} }
void MeteorMgr::setMaxVelocity(int maxv) void MeteorMgr::setMaxVelocity(int maxv)
{ {
maxVelocity = maxv; maxVelocity = maxv;
} }
void MeteorMgr::update(double deltaTime) void MeteorMgr::update(double deltaTime)
{ {
#ifdef _MSC_BUILD
return;
#endif
if (!flagShow) if (!flagShow)
{ {
return; return;
} }
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
double tspeed = core->getTimeRate()*86400; // sky seconds per actua l second double tspeed = core->getTimeRate()*86400; // sky seconds per actua l second
if (!tspeed) { // is paused? if (!tspeed) { // is paused?
return; // freeze meteors at the current position return; // freeze meteors at the current position
skipping to change at line 117 skipping to change at line 115
deltaTime*=1000; deltaTime*=1000;
// if stellarium has been suspended, don't create // if stellarium has been suspended, don't create
// huge number of meteors to make up for lost time! // huge number of meteors to make up for lost time!
if (deltaTime > 500) if (deltaTime > 500)
{ {
deltaTime = 500; deltaTime = 500;
} }
// step through and update all active meteors // step through and update all active meteors
std::vector<Meteor*>::iterator iter; std::vector<Meteor*>::iterator iter;
for (iter = active.begin(); iter != active.end(); ++iter) for (iter = active.begin(); iter != active.end(); )
{ {
if (!(*iter)->update(deltaTime)) if (!(*iter)->update(deltaTime))
{ {
delete *iter; delete *iter;
iter = active.erase(iter); iter = active.erase(iter);
iter--; // important! }
else
{
++iter;
} }
} }
// only makes sense given lifetimes of meteors to draw when timeSpee d is realtime // only makes sense given lifetimes of meteors to draw when timeSpee d is realtime
// otherwise high overhead of large numbers of meteors // otherwise high overhead of large numbers of meteors
if (tspeed<0 || fabs(tspeed)>1.) if (tspeed<0 || fabs(tspeed)>1.)
{ {
// don't start any more meteors // don't start any more meteors
return; return;
} }
skipping to change at line 145 skipping to change at line 146
// determine average meteors per frame needing to be created // determine average meteors per frame needing to be created
int mpf = (int)((double)ZHR*zhrToWsr*deltaTime/1000.0 + 0.5); int mpf = (int)((double)ZHR*zhrToWsr*deltaTime/1000.0 + 0.5);
if (mpf<1) if (mpf<1)
{ {
mpf = 1; mpf = 1;
} }
for (int i=0; i<mpf; ++i) for (int i=0; i<mpf; ++i)
{ {
// start new meteor based on ZHR time probability // start new meteor based on ZHR time probability
double prob = ((double)rand())/RAND_MAX; double prob = ((double)qrand())/RAND_MAX;
if (ZHR>0 && prob<((double)ZHR*zhrToWsr*deltaTime/1000.0/(do uble)mpf)) if (ZHR>0 && prob<((double)ZHR*zhrToWsr*deltaTime/1000.0/(do uble)mpf))
{ {
Meteor *m = new Meteor(core, maxVelocity); Meteor *m = new Meteor(core, maxVelocity);
active.push_back(m); active.push_back(m);
} }
} }
} }
void MeteorMgr::draw(StelCore* core) void MeteorMgr::draw(StelCore* core)
{ {
 End of changes. 5 change blocks. 
6 lines changed or deleted 7 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/