MeteorMgr.cpp   MeteorMgr.cpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 <QtOpenGL>
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelNavigator.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" #include "StelPainter.hpp"
skipping to change at line 98 skipping to change at line 99
void MeteorMgr::update(double deltaTime) void MeteorMgr::update(double deltaTime)
{ {
if (!flagShow) if (!flagShow)
return; return;
deltaTime*=1000; deltaTime*=1000;
StelNavigator * nav = StelApp::getInstance().getCore()->getNavigator (); StelNavigator * nav = StelApp::getInstance().getCore()->getNavigator ();
// step through and update all active meteors // step through and update all active meteors
int n =0; for (std::vector<Meteor*>::iterator iter = active.begin(); iter != a
for(std::vector<Meteor*>::iterator iter = active.begin(); iter != ac ctive.end(); ++iter)
tive.end(); ++iter)
{ {
n++; if (!(*iter)->update(deltaTime))
//qDebug("Meteor %d update\n", ++n);
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->getTimeRate() *86400; // sky seconds per actua double tspeed = nav->getTimeRate()*86400; // sky seconds per actual
l second 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
if(active.begin() == active.end() ) {
Meteor *m = new Meteor(projection, navigation, maxVelocity);
active.push_back(m);
}
*/
// if stellarium has been suspended, don't create huge number of met eors to // if stellarium has been suspended, don't create huge number of met eors to
// make up for lost time! // make up for lost time!
if( deltaTime > 500 ) if (deltaTime > 500)
{ {
deltaTime = 500; deltaTime = 500;
} }
// determine average meteors per frame needing to be created // determine average meteors per frame needing to be created
int mpf = (int)((double)ZHR*zhrToWsr*(double)deltaTime/1000.0f + 0.5 int mpf = (int)((double)ZHR*zhrToWsr*deltaTime/1000.0 + 0.5);
); if (mpf<1)
if( mpf < 1 ) 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())/RAND_MAX;
if( ZHR > 0 && prob < ((double)ZHR*zhrToWsr*(double)deltaTim if (ZHR>0 && prob<((double)ZHR*zhrToWsr*deltaTime/1000.0/(do
e/1000.0f/(double)mpf) ) uble)mpf) )
{ {
Meteor *m = new Meteor(StelApp::getInstance().getCor e(), 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;
StelPainter sPainter(core->getProjection(StelCore::FrameAltAz)); 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 sPainter.setShadeModel(StelPainter::ShadeModelSmooth);
// 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, sPainter); (*iter)->draw(core, sPainter);
} }
glEnable(GL_TEXTURE_2D);
} }
 End of changes. 14 change blocks. 
31 lines changed or deleted 16 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/