Comet.cpp   Comet.cpp 
skipping to change at line 57 skipping to change at line 57
bool Comet::createTailTextureCoords=true; bool Comet::createTailTextureCoords=true;
StelTextureSP Comet::comaTexture; StelTextureSP Comet::comaTexture;
StelTextureSP Comet::tailTexture; StelTextureSP Comet::tailTexture;
QVector<float> Comet::tailTexCoordArr; // computed only once for all Comets . QVector<float> Comet::tailTexCoordArr; // computed only once for all Comets .
QVector<unsigned short> Comet::tailIndices; // computed only once for all C omets. QVector<unsigned short> Comet::tailIndices; // computed only once for all C omets.
Comet::Comet(const QString& englishName, Comet::Comet(const QString& englishName,
int flagLighting, int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
Vec3f color, Vec3f halocolor,
float albedo, float albedo,
const QString& atexMapName, const QString& atexMapName,
posFuncType coordFunc, posFuncType coordFunc,
void* auserDataPtr, void* auserDataPtr,
OsculatingFunctType *osculatingFunc, OsculatingFunctType *osculatingFunc,
bool acloseOrbit, bool acloseOrbit,
bool hidden, bool hidden,
const QString& pTypeStr, const QString& pTypeStr,
float dustTailWidthFact, float dustTailWidthFact,
float dustTailLengthFact, float dustTailLengthFact,
float dustTailBrightnessFact) float dustTailBrightnessFact)
: Planet (englishName, : Planet (englishName,
flagLighting, flagLighting,
radius, radius,
oblateness, oblateness,
color, halocolor,
albedo, albedo,
atexMapName, atexMapName,
"", "",
coordFunc, coordFunc,
auserDataPtr, auserDataPtr,
osculatingFunc, osculatingFunc,
acloseOrbit, acloseOrbit,
hidden, hidden,
false, //No atmosphere false, //No atmosphere
true, //halo true, //halo
pTypeStr), pTypeStr),
tailActive(false), tailActive(false),
tailBright(false), tailBright(false),
dustTailWidthFactor(dustTailWidthFact), dustTailWidthFactor(dustTailWidthFact),
dustTailLengthFactor(dustTailLengthFact), dustTailLengthFactor(dustTailLengthFact),
dustTailBrightnessFactor(dustTailBrightnessFact) dustTailBrightnessFactor(dustTailBrightnessFact)
{ {
texMapName = atexMapName; texMapName = atexMapName;
lastOrbitJD =0; lastOrbitJDE =0;
deltaJD = StelCore::JD_SECOND; deltaJDE = StelCore::JD_SECOND;
deltaJDtail=15.0*StelCore::JD_MINUTE; // update tail geometry every deltaJDEtail=15.0*StelCore::JD_MINUTE; // update tail geometry every
15 minutes only 15 minutes only
lastJDtail=0.0; lastJDEtail=0.0;
orbitCached = 0; orbitCached = 0;
closeOrbit = acloseOrbit; closeOrbit = acloseOrbit;
eclipticPos=Vec3d(0.,0.,0.); eclipticPos=Vec3d(0.,0.,0.);
rotLocalToParent = Mat4d::identity(); rotLocalToParent = Mat4d::identity();
texMap = StelApp::getInstance().getTextureManager().createTextureThr ead(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture: :StelTextureParams(true, GL_LINEAR, GL_REPEAT)); texMap = StelApp::getInstance().getTextureManager().createTextureThr ead(StelFileMgr::getInstallationDir()+"/textures/"+texMapName, StelTexture: :StelTextureParams(true, GL_LINEAR, GL_REPEAT));
tailFactors[0]=-1.0f; tailFactors[1]=-1.0f; // mark "invalid" tailFactors[0]=-1.0f; tailFactors[1]=-1.0f; // mark "invalid"
gastailVertexArr.clear(); gastailVertexArr.clear();
dusttailVertexArr.clear(); dusttailVertexArr.clear();
skipping to change at line 153 skipping to change at line 153
void Comet::translateName(const StelTranslator &translator) void Comet::translateName(const StelTranslator &translator)
{ {
nameI18 = translator.qtranslate(englishName); nameI18 = translator.qtranslate(englishName);
} }
QString Comet::getInfoString(const StelCore *core, const InfoStringGroup &f lags) const QString Comet::getInfoString(const StelCore *core, const InfoStringGroup &f lags) const
{ {
//Mostly copied from Planet::getInfoString(): //Mostly copied from Planet::getInfoString():
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
double az_app, alt_app;
StelUtils::rectToSphe(&az_app,&alt_app,getAltAzPosApparent(core));
Q_UNUSED(az_app);
if (flags&Name) if (flags&Name)
{ {
oss << "<h2>"; oss << "<h2>";
oss << getNameI18n(); // UI translation can differ from sky translation oss << getNameI18n(); // UI translation can differ from sky translation
oss.setRealNumberNotation(QTextStream::FixedNotation); oss.setRealNumberNotation(QTextStream::FixedNotation);
oss.setRealNumberPrecision(1); oss.setRealNumberPrecision(1);
if (sphereScale != 1.f) if (sphereScale != 1.f)
oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")"; oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")";
oss << "</h2>"; oss << "</h2>";
skipping to change at line 178 skipping to change at line 181
if (semiMajorAxis>0.0) if (semiMajorAxis>0.0)
{ {
// Parabolic and hyperbolic comets doesn't have semi -major axis of the orbit. We have comet with elliptic orbit. // Parabolic and hyperbolic comets doesn't have semi -major axis of the orbit. We have comet with elliptic orbit.
cometType = qc_("periodic", "type of comet"); cometType = qc_("periodic", "type of comet");
} }
oss << q_("Type: <b>%1</b> (%2)").arg(q_(getPlanetTypeString ())).arg(cometType) << "<br />"; oss << q_("Type: <b>%1</b> (%2)").arg(q_(getPlanetTypeString ())).arg(cometType) << "<br />";
} }
if (flags&Magnitude) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere() && (alt_app>-3. 0*M_PI/180.0)) // Don't show extincted magnitude much below horizon where m odel is meaningless.
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). arg(QString::number(getVMagnitude(core), 'f', 2), oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). arg(QString::number(getVMagnitude(core), 'f', 2),
QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) << "<br>";
else else
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>";
} }
if (flags&AbsoluteMagnitude) if (flags&AbsoluteMagnitude)
{ {
//TODO: Make sure absolute magnitude is a sane value //TODO: Make sure absolute magnitude is a sane value
//If the two parameter magnitude system is not use, don't di splay this //If the two parameter magnitude system is not use, don't di splay this
skipping to change at line 316 skipping to change at line 319
// with kappa typically 5..15. MPC provides Slope parameter. So we s hould expect to have slopeParameter (a word only used for minor planets!) f or our comets 2..6 // with kappa typically 5..15. MPC provides Slope parameter. So we s hould expect to have slopeParameter (a word only used for minor planets!) f or our comets 2..6
double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observ erCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance); double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observ erCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance);
return apparentMagnitude; return apparentMagnitude;
} }
void Comet::update(int deltaTime) void Comet::update(int deltaTime)
{ {
Planet::update(deltaTime); Planet::update(deltaTime);
// The rest used to be in computePosition(), but is better in update (). Unfortunately we need date (JD). // The rest deals with updating tail geometries and brightness
StelCore* core=StelApp::getInstance().getCore(); StelCore* core=StelApp::getInstance().getCore();
double date=core->getJDay(); double dateJDE=core->getJDE();
// The CometOrbit is in fact available in userDataPtr! // The CometOrbit is in fact available in userDataPtr!
CometOrbit* orbit=(CometOrbit*)userDataPtr; CometOrbit* orbit=(CometOrbit*)userDataPtr;
Q_ASSERT(orbit); Q_ASSERT(orbit);
if (!orbit->objectDateValid(core->getJDay())) return; // don't do an ything if out of useful date range. This allows having hundreds of comet el ements. if (!orbit->objectDateValid(dateJDE)) return; // don't do anything i f out of useful date range. This allows having hundreds of comet elements.
//GZ: I think we can make deltaJDtail adaptive, depending on distanc e to sun! For some reason though, this leads to a crash! //GZ: I think we can make deltaJDtail adaptive, depending on distanc e to sun! For some reason though, this leads to a crash!
//deltaJDtail=StelCore::JD_SECOND * qMax(1.0, qMin(eclipticPos.lengt h(), 20.0)); //deltaJDtail=StelCore::JD_SECOND * qMax(1.0, qMin(eclipticPos.lengt h(), 20.0));
if (fabs(lastJDtail-date)>deltaJDtail) if (fabs(lastJDEtail-dateJDE)>deltaJDEtail)
{ {
lastJDtail=date; lastJDEtail=dateJDE;
// The CometOrbit is in fact available in userDataPtr! // The CometOrbit is in fact available in userDataPtr!
CometOrbit* orbit=(CometOrbit*)userDataPtr; CometOrbit* orbit=(CometOrbit*)userDataPtr;
Q_ASSERT(orbit); Q_ASSERT(orbit);
if (!orbit->objectDateValid(date)) return; // out of useful date range. This should allow having hundreds of comet elements. if (!orbit->objectDateValid(dateJDE)) return; // out of usef ul date range. This should allow having hundreds of comet elements.
if (orbit->getUpdateTails()){ if (orbit->getUpdateTails()){
// Compute lengths and orientations from orbit objec t, but only if required. // Compute lengths and orientations from orbit objec t, but only if required.
tailFactors=getComaDiameterAndTailLengthAU(); tailFactors=getComaDiameterAndTailLengthAU();
// Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may lo ok better. // Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may lo ok better.
computeComa(1.0f*tailFactors[0]); // TBD: APPARENTLY NO SCALING? REMOVE 1.0 and note above. computeComa(1.0f*tailFactors[0]); // TBD: APPARENTLY NO SCALING? REMOVE 1.0 and note above.
tailActive = (tailFactors[1] > tailFactors[0]); // I nhibit tails drawing if too short. Would be nice to include geometric proje ction angle, but this is too costly. tailActive = (tailFactors[1] > tailFactors[0]); // I nhibit tails drawing if too short. Would be nice to include geometric proje ction angle, but this is too costly.
skipping to change at line 456 skipping to change at line 459
dusttailColorArr.append(dustColor*extinctionFactor * brightnessPerVertexFromHead); dusttailColorArr.append(dustColor*extinctionFactor * brightnessPerVertexFromHead);
brightnessPerVertexFromHead-=brightnessDecreasePerVe rtexFromHead; brightnessPerVertexFromHead-=brightnessDecreasePerVe rtexFromHead;
} }
} }
else // no atmosphere: set all vertices to same brightness. else // no atmosphere: set all vertices to same brightness.
{ {
gastailColorArr.fill(gasColor, gastailVertexArr.length()); gastailColorArr.fill(gasColor, gastailVertexArr.length());
dusttailColorArr.fill(dustColor, dusttailVertexArr.length()) ; dusttailColorArr.fill(dustColor, dusttailVertexArr.length()) ;
} }
//qDebug() << "Comet " << getEnglishName() << "JD: " << date << "ga sR" << gasColor[0] << " dustR" << dustColor[0]; //qDebug() << "Comet " << getEnglishName() << "JDE: " << date << "g asR" << gasColor[0] << " dustR" << dustColor[0];
} }
// Draw the Comet and all the related infos: name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended // Draw the Comet and all the related infos: name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended
void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNam eFont) void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNam eFont)
{ {
if (hidden) if (hidden)
return; return;
// Exclude drawing if user set a hard limit magnitude.
if (core->getSkyDrawer()->getFlagPlanetMagnitudeLimit() && (getVMagn
itude(core) > core->getSkyDrawer()->getCustomPlanetMagnitudeLimit()))
return;
if (getEnglishName() == core->getCurrentLocation().planetName) if (getEnglishName() == core->getCurrentLocation().planetName)
{ // Maybe even don't do that? E.g., draw tail while riding the come t? Decide later. { // Maybe even don't do that? E.g., draw tail while riding the come t? Decide later.
return; return;
} }
// This test seemed necessary for reasonable fps in case too many co met elements are loaded. // This test seemed necessary for reasonable fps in case too many co met elements are loaded.
// Problematic: Early-out here of course disables the wanted hint ci rcles for dim comets. // Problematic: Early-out here of course disables the wanted hint ci rcles for dim comets.
// The line makes hints for comets 5 magnitudes below sky limiting m agnitude visible. // The line makes hints for comets 5 magnitudes below sky limiting m agnitude visible.
// If comet is too faint to be seen, don't bother rendering. (Massiv e speedup if people have hundreds of comet elements!) // If comet is too faint to be seen, don't bother rendering. (Massiv e speedup if people have hundreds of comet elements!)
if ((getVMagnitude(core)-5.0f) > core->getSkyDrawer()->getLimitMagni tude()) if ((getVMagnitude(core)-5.0f) > core->getSkyDrawer()->getLimitMagni tude())
{ {
return; return;
} }
// The CometOrbit is in fact available in userDataPtr! // The CometOrbit is in fact available in userDataPtr!
CometOrbit* orbit=(CometOrbit*)userDataPtr; CometOrbit* orbit=(CometOrbit*)userDataPtr;
Q_ASSERT(orbit); Q_ASSERT(orbit);
if (!orbit->objectDateValid(core->getJDay())) return; // don't draw at all if out of useful date range. This allows having hundreds of comet el ements. if (!orbit->objectDateValid(core->getJDE())) return; // don't draw a t all if out of useful date range. This allows having hundreds of comet ele ments.
Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent; Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent;
// This removed totally the Planet shaking bug!!! // This removed totally the Planet shaking bug!!!
StelProjector::ModelViewTranformP transfo = core->getHeliocentricEcl ipticModelViewTransform(); StelProjector::ModelViewTranformP transfo = core->getHeliocentricEcl ipticModelViewTransform();
transfo->combine(mat); transfo->combine(mat);
// Compute the 2D position and check if in the screen // Compute the 2D position and check if in the screen
const StelProjectorP prj = core->getProjection(transfo); const StelProjectorP prj = core->getProjection(transfo);
float screenSz = getAngularSize(core)*M_PI/180.*prj->getPixelPerRadA tCenter(); float screenSz = getAngularSize(core)*M_PI/180.*prj->getPixelPerRadA tCenter();
float viewport_left = prj->getViewportPosX(); float viewport_left = prj->getViewportPosX();
 End of changes. 14 change blocks. 
16 lines changed or deleted 24 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/