Index: deepskyobj.h =================================================================== --- deepskyobj.h (revision 4460) +++ deepskyobj.h (working copy) @@ -48,9 +48,19 @@ Quatf getOrientation() const; void setOrientation(const Quatf&); - float getRadius() const; - void setRadius(float); + /*! Return the radius of a bounding sphere large enough to contain the object. + * For correct rendering, all of the geometry must fit within this sphere radius. + * DSO subclasses an alternate radius that more closely matches the conventional + * astronomical definition for the size of the object (e.g. mu25 isophote radius.) + */ + virtual float getBoundingSphereRadius() const { return radius; } + /*! Return the radius of the object. This radius will be displayed in the UI and + * should match the conventional astronomical definition of the object size. + */ + float getRadius() const { return radius; } + void setRadius(float r); + float getAbsoluteMagnitude() const; void setAbsoluteMagnitude(float); Index: deepskyobj.cpp =================================================================== --- deepskyobj.cpp (revision 4460) +++ deepskyobj.cpp (working copy) @@ -68,11 +68,6 @@ orientation = q; } -float DeepSkyObject::getRadius() const -{ - return radius; -} - void DeepSkyObject::setRadius(float r) { radius = r; Index: globular.h =================================================================== --- globular.h (revision 4460) +++ globular.h (working copy) @@ -47,7 +47,9 @@ void setConcentration(const float); float getConcentration() const; float getHalfMassRadius(float c, float r_c); - + + virtual float getBoundingSphereRadius() const { return tidalRadius; } + virtual bool pick(const Ray3d& ray, double& distanceToPicker, double& cosAngleToBoundCenter) const; @@ -67,13 +69,17 @@ virtual unsigned int getRenderMask() const; virtual unsigned int getLabelMask() const; virtual const char* getObjTypeName() const; - - public: + private: + void recomputeTidalRadius(); + + private: float detail; std::string* customTmpName; GlobularForm* form; - float r_c, c; + float r_c; + float c; + float tidalRadius; }; #endif // _GLOBULAR_H_ Index: globular.cpp =================================================================== --- globular.cpp (revision 4460) +++ globular.cpp (working copy) @@ -144,8 +144,10 @@ customTmpName (NULL), form (NULL), r_c (R_c_ref), - c (C_ref) + c (C_ref), + tidalRadius(0.0f) { + recomputeTidalRadius(); } const char* Globular::getType() const @@ -193,6 +195,7 @@ void Globular::setCoreRadius(float coreRadius) { r_c = coreRadius; + recomputeTidalRadius(); } float Globular::getHalfMassRadius(float c, float r_c) @@ -206,6 +209,7 @@ { return c; } + void Globular::setConcentration(float conc) { int cslot; @@ -216,8 +220,11 @@ //account for the actual c values via 8 bins only, for saving time cslot = (int)floor((conc - 0.5)/0.35 + 0.5); form = globularForms[cslot]; + + recomputeTidalRadius(); } + size_t Globular::getDescription(char* buf, size_t bufLength) const { return snprintf(buf, bufLength, _("Globular (core radius: %4.2f', King concentration: %4.2f)"), r_c, c); @@ -263,6 +270,11 @@ } bool Globular::load(AssociativeArray* params, const string& resPath) { + // Load the basic DSO parameters first + bool ok = DeepSkyObject::load(params, resPath); + if (!ok) + return false; + if(params->getNumber("Detail", detail)) setDetail((float) detail); @@ -275,8 +287,8 @@ if(params->getNumber("KingConcentration", c)) setConcentration(c); - - return DeepSkyObject::load(params, resPath); + + return true; } @@ -305,7 +317,7 @@ float minimumFeatureSize = 0.5f * pixelSize * distanceToDSO; - float size0 = 2 * getRadius(); // mu25 isophote radius + float size0 = 2 * getRadius(); // mu25 isophote radius DiskSizeInPixels = size0 / minimumFeatureSize; @@ -548,6 +560,17 @@ } } + +// Compute the tidal radius in light years +void +Globular::recomputeTidalRadius() +{ + // Convert the core radius from arcminutes to light years + float coreRadiusLy = std::tan(degToRad(r_c / 60.0)) * (float) getPosition().distanceFromOrigin(); + tidalRadius = coreRadiusLy * std::pow(10.0f, c); +} + + GlobularForm* buildGlobularForms(float c) { GBlob b; Index: render.cpp =================================================================== --- render.cpp (revision 4460) +++ render.cpp (working copy) @@ -9813,7 +9813,8 @@ if ((renderFlags & dso->getRenderMask()) && dso->isVisible()) { - double dsoRadius = dso->getRadius(); + double dsoRadius = dso->getBoundingSphereRadius(); + if (frustum.testSphere(center, dsoRadius) != Frustum::Outside) { // display looks satisfactory for 0.2 < brightness < O(1.0) Index: dsooctree.cpp =================================================================== --- dsooctree.cpp (revision 4460) +++ dsooctree.cpp (working copy) @@ -27,7 +27,7 @@ bool dsoStraddlesNodesPredicate(const Point3d& cellCenterPos, DeepSkyObject* const & _dso, const float) { //checks if this dso's radius straddles child nodes - float dsoRadius = _dso->getRadius(); + float dsoRadius = _dso->getBoundingSphereRadius(); Point3d dsoPos = _dso->getPosition(); @@ -104,7 +104,7 @@ float absMag = _obj->getAbsoluteMagnitude(); if (absMag < dimmest) { - double distance = obsPosition.distanceTo(_obj->getPosition()) - _obj->getRadius(); + double distance = obsPosition.distanceTo(_obj->getPosition()) - _obj->getBoundingSphereRadius(); float appMag = (float) ((distance >= 32.6167) ? astro::absToAppMag((double) absMag, distance) : absMag); if ( appMag < limitingFactor) @@ -156,7 +156,7 @@ if (obsPosition.distanceToSquared(_obj->getPosition()) < radiusSquared) // { float absMag = _obj->getAbsoluteMagnitude(); - double distance = obsPosition.distanceTo(_obj->getPosition()) - _obj->getRadius(); + double distance = obsPosition.distanceTo(_obj->getPosition()) - _obj->getBoundingSphereRadius(); processor.process(_obj, distance, absMag); }