X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGSphere.hxx;h=e4fcb096a7e576a53ca1cfe69d867cf6b695a542;hb=914d3e6a2b323cf9f186cbef2aef7865ea07b309;hp=da0c641a310775366d3c0f6e25984b93c9f4f3fc;hpb=a89b9f6158d5bfbad0e9ff0f7822a1f3a5d1893f;p=simgear.git diff --git a/simgear/math/SGSphere.hxx b/simgear/math/SGSphere.hxx index da0c641a..e4fcb096 100644 --- a/simgear/math/SGSphere.hxx +++ b/simgear/math/SGSphere.hxx @@ -25,7 +25,6 @@ public: #ifdef __GNUC__ // Avoid "_center not initialized" warnings. -# pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wuninitialized" #endif @@ -49,7 +48,7 @@ public: #ifdef __GNUC__ // Restore warning settings. -# pragma GCC diagnostic pop +# pragma GCC diagnostic warning "-Wuninitialized" #endif const SGVec3& getCenter() const @@ -73,6 +72,18 @@ public: void clear() { _radius = -1; } + /// Return true if this is inside sphere + bool inside(const SGSphere& sphere) const + { + if (empty()) + return false; + if (sphere.empty()) + return false; + + T dist = sphere.getRadius() - getRadius(); + return distSqr(getCenter(), sphere.getCenter()) <= dist*dist; + } + void expandBy(const SGVec3& v) { if (empty()) {