MeteorMgr.cpp   MeteorMgr.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <functional> #include <functional>
#include <cstdlib> #include <cstdlib>
#include <QSettings> #include <QSettings>
#include "Projector.hpp" #include "StelProjector.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "MeteorMgr.hpp" #include "MeteorMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "Meteor.hpp" #include "Meteor.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp"
MeteorMgr::MeteorMgr(int zhr, int maxv ) : flagShow(true) MeteorMgr::MeteorMgr(int zhr, int maxv ) : flagShow(true)
{ {
setObjectName("MeteorMgr"); setObjectName("MeteorMgr");
ZHR = zhr; ZHR = zhr;
maxVelocity = maxv; maxVelocity = maxv;
// calculate factor for meteor creation rate per second since visibl e area ZHR is for // calculate factor for meteor creation rate per second since visibl e area ZHR is for
// estimated visible radius of 458km // estimated visible radius of 458km
skipping to change at line 94 skipping to change at line 95
{ {
maxVelocity = maxv; maxVelocity = maxv;
} }
void MeteorMgr::update(double deltaTime) void MeteorMgr::update(double deltaTime)
{ {
if (!flagShow) if (!flagShow)
return; return;
deltaTime*=1000; deltaTime*=1000;
Projector * proj = StelApp::getInstance().getCore()->getProjection() StelNavigator * nav = StelApp::getInstance().getCore()->getNavigator
; ();
Navigator * nav = StelApp::getInstance().getCore()->getNavigation();
ToneReproducer * eye = StelApp::getInstance().getCore()->getToneRepr
oducer();
// step through and update all active meteors // step through and update all active meteors
int n =0; int n =0;
for(std::vector<Meteor*>::iterator iter = active.begin(); iter != ac tive.end(); ++iter) for(std::vector<Meteor*>::iterator iter = active.begin(); iter != ac tive.end(); ++iter)
{ {
n++; n++;
//qDebug("Meteor %d update\n", ++n); //qDebug("Meteor %d update\n", ++n);
if( !( (*iter)->update(deltaTime) ) ) if( !( (*iter)->update(deltaTime) ) )
{ {
// remove dead meteor // remove dead meteor
// qDebug("Meteor \tdied\n"); // qDebug("Meteor \tdied\n");
delete *iter; delete *iter;
active.erase(iter); active.erase(iter);
iter--; // important! iter--; // important!
} }
} }
// 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
double tspeed = nav->getTimeSpeed() *86400; // sky seconds per actu al second double tspeed = nav->getTimeRate() *86400; // sky seconds per actua l second
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;
} }
/* /*
// debug - one at a time // debug - one at a time
if(active.begin() == active.end() ) { if(active.begin() == active.end() ) {
Meteor *m = new Meteor(projection, navigation, maxVelocity); Meteor *m = new Meteor(projection, navigation, maxVelocity);
skipping to change at line 151 skipping to change at line 150
if( mpf < 1 ) mpf = 1; if( mpf < 1 ) mpf = 1;
int mlaunch = 0; int mlaunch = 0;
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()/((double)RAND_MAX+1); double prob = (double)rand()/((double)RAND_MAX+1);
if( ZHR > 0 && prob < ((double)ZHR*zhrToWsr*(double)deltaTim e/1000.0f/(double)mpf) ) if( ZHR > 0 && prob < ((double)ZHR*zhrToWsr*(double)deltaTim e/1000.0f/(double)mpf) )
{ {
Meteor *m = new Meteor(proj, nav, eye, maxVelocity); Meteor *m = new Meteor(StelApp::getInstance().getCor e(), maxVelocity);
active.push_back(m); active.push_back(m);
mlaunch++; mlaunch++;
} }
} }
// qDebug("mpf: %d\tm launched: %d\t(mps: %f)\t%d\n", mpf, mlaunch, ZHR*zhrToWsr, deltaTime); // qDebug("mpf: %d\tm launched: %d\t(mps: %f)\t%d\n", mpf, mlaunch, ZHR*zhrToWsr, deltaTime);
} }
void MeteorMgr::draw(StelCore* core) void MeteorMgr::draw(StelCore* core)
{ {
if (!flagShow) if (!flagShow)
return; return;
LandscapeMgr* landmgr = (LandscapeMgr*)StelApp::getInstance().getMod uleMgr().getModule("LandscapeMgr"); LandscapeMgr* landmgr = (LandscapeMgr*)StelApp::getInstance().getMod uleMgr().getModule("LandscapeMgr");
if (landmgr->getFlagAtmosphere() && landmgr->getLuminance()>5) if (landmgr->getFlagAtmosphere() && landmgr->getLuminance()>5)
return; return;
core->getProjection()->setCurrentFrame(Projector::FrameLocal); StelPainter sPainter(core->getProjection(StelCore::FrameAltAz));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D); // much dimmer without this glDisable(GL_TEXTURE_2D); // much dimmer without this
// step through and draw all active meteors // step through and draw all active meteors
for (std::vector<Meteor*>::iterator iter = active.begin(); iter != a ctive.end(); ++iter) for (std::vector<Meteor*>::iterator iter = active.begin(); iter != a ctive.end(); ++iter)
{ {
(*iter)->draw(core->getProjection(), core->getNavigation()); (*iter)->draw(core, sPainter);
} }
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
 End of changes. 8 change blocks. 
12 lines changed or deleted 9 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/