diff --git a/src/core/modules/Planet.cpp b/src/core/modules/Planet.cpp index b589c506cace6..7b8352c198b64 100644 --- a/src/core/modules/Planet.cpp +++ b/src/core/modules/Planet.cpp @@ -3765,7 +3765,7 @@ float Planet::getVMagnitude(const StelCore* core, double eclipseFactor) const double Planet::getAngularRadius(const StelCore* core) const { const double rad = (rings ? rings->getSize() : equatorialRadius); - return std::atan2(rad*sphereScale,getJ2000EquatorialPos(core).norm()) * M_180_PI; + return std::asin(rad*sphereScale/getJ2000EquatorialPos(core).norm()) * M_180_PI; } diff --git a/src/core/modules/StarMgr.cpp b/src/core/modules/StarMgr.cpp index 74809851072b1..c9fbcc838ec1b 100644 --- a/src/core/modules/StarMgr.cpp +++ b/src/core/modules/StarMgr.cpp @@ -46,6 +46,7 @@ #include "StelUtils.hpp" #include "StelHealpix.hpp" #include "StelObject.hpp" +#include "SolarSystem.hpp" #include #include @@ -1371,6 +1372,20 @@ void StarMgr::draw(StelCore* core) // Prepare a table for storing precomputed RCMag for all ZoneArrays RCMag rcmag_table[RCMAG_TABLE_SIZE]; + + // Try to filter away stars hidden by the Moon! + bool filterMoon=false; + PlanetP moon = GETSTELMODULE(SolarSystem)->getMoon(); + Vec3d moonPos=moon->getJ2000EquatorialPos(core); + const double moonRadius = moon->getEquatorialRadius() * moon->getSphereScale(); + double angularSize = asin(moonRadius / moonPos.norm()); + moonPos.normalize(); + SphericalCap moonCap(moonPos, cos(angularSize)); + for (auto &cap : viewportCaps) + { + if (cap.intersects(moonCap)) + filterMoon=true; + } // Draw all the stars of all the selected zones for (const auto* z : std::as_const(gridLevels)) @@ -1418,11 +1433,11 @@ void StarMgr::draw(StelCore* core) diffPos = core->getParallaxDiff(core->getJDE()); } for (GeodesicSearchInsideIterator it1(*geodesic_search_result,z->level);(zone = it1.next()) >= 0;) - z->draw(&sPainter, zone, true, rcmag_table, limitMagIndex, core, maxMagStarName, names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames); + z->draw(&sPainter, zone, true, rcmag_table, limitMagIndex, core, maxMagStarName, names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames, filterMoon, moonCap); for (GeodesicSearchBorderIterator it1(*geodesic_search_result,z->level);(zone = it1.next()) >= 0;) - z->draw(&sPainter, zone, false, rcmag_table, limitMagIndex, core, maxMagStarName,names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames); + z->draw(&sPainter, zone, false, rcmag_table, limitMagIndex, core, maxMagStarName,names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames, filterMoon, moonCap); // always check the last zone because it is a global zone - z->draw(&sPainter, (20<<(z->level<<1)), false, rcmag_table, limitMagIndex, core, maxMagStarName, names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames); + z->draw(&sPainter, (20<<(z->level<<1)), false, rcmag_table, limitMagIndex, core, maxMagStarName, names_brightness, viewportCaps, withAberration, vel, withParallax, diffPos, currentSkycultureUsesCommonStarnames, filterMoon, moonCap); } exit_loop: diff --git a/src/core/modules/ZoneArray.cpp b/src/core/modules/ZoneArray.cpp index 2ba138ba9634c..cae634754968c 100644 --- a/src/core/modules/ZoneArray.cpp +++ b/src/core/modules/ZoneArray.cpp @@ -433,7 +433,8 @@ void SpecialZoneArray::draw(StelPainter* sPainter, int index, bool isInsid int limitMagIndex, StelCore* core, int maxMagStarName, float names_brightness, const QVector &boundingCaps, const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos, - const bool withCommonNameI18n) const + const bool withCommonNameI18n, + const bool filterMoon, SphericalCap moonCap) const { StelSkyDrawer* drawer = core->getSkyDrawer(); Vec3d v; @@ -543,6 +544,13 @@ void SpecialZoneArray::draw(StelPainter* sPainter, int index, bool isInsid continue; } + // If the star is covered by the Moon, don't draw (avoid displaying part of halo of occulted star!) + // TODO: This is a bad test. We should draw the moon into a stencil buffer and check that. + if (filterMoon) + { + if (moonCap.contains(v)) + continue; + } int extinctedMagIndex = magIndex; float twinkleFactor=1.0f; // allow height-dependent twinkle. if (withExtinction) diff --git a/src/core/modules/ZoneArray.hpp b/src/core/modules/ZoneArray.hpp index 972987cdaa8f8..e57567b3a7ee1 100644 --- a/src/core/modules/ZoneArray.hpp +++ b/src/core/modules/ZoneArray.hpp @@ -100,7 +100,7 @@ class ZoneArray virtual void searchWithin(const StelCore* core, int index, const SphericalRegionP region, const double withParallax, const Vec3d diffPos, const bool hipOnly, const float maxMag, QList &result) const = 0; - virtual StelObjectP searchGaiaID(int index, const StarId source_id, int& matched) const = 0; + virtual StelObjectP searchGaiaID(int index, const StarId source_id, int& matched) const = 0; virtual void searchGaiaIDepochPos(const StarId source_id, float dyrs, double & RA, double & DEC, @@ -114,7 +114,9 @@ class ZoneArray const RCMag* rcmag_table, int limitMagIndex, StelCore* core, int maxMagStarName, float names_brightness, const QVector& boundingCaps, - const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos, const bool withCommonNameI18n) const = 0; + const bool withAberration, const Vec3d vel, + const double withParallax, const Vec3d diffPos, const bool withCommonNameI18n, + const bool filterMoon, SphericalCap moonCap) const = 0; //! Get whether or not the catalog was successfully loaded. //! @return @c true if at least one zone was loaded, otherwise @c false @@ -187,7 +189,8 @@ class SpecialZoneArray : public ZoneArray const RCMag *rcmag_table, int limitMagIndex, StelCore* core, int maxMagStarName, float names_brightness, const QVector& boundingCaps, - const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos, const bool withCommonNameI18n) const override; + const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos, const bool withCommonNameI18n, + const bool filterMoon, SphericalCap moonCap) const override; void searchAround(const StelCore* core, int index, const Vec3d &v, const double withParallax, const Vec3d diffPos, double cosLimFov, QList &result) override;