]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGSphere.hxx
math: Add integer valued vector types.
[simgear.git] / simgear / math / SGSphere.hxx
index da0c641a310775366d3c0f6e25984b93c9f4f3fc..e4fcb096a7e576a53ca1cfe69d867cf6b695a542 100644 (file)
@@ -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<T>& getCenter() const
@@ -73,6 +72,18 @@ public:
   void clear()
   { _radius = -1; }
 
+  /// Return true if this is inside sphere
+  bool inside(const SGSphere<T>& 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<T>& v)
   {
     if (empty()) {