#ifndef SGSphere_H
#define SGSphere_H
-#ifndef _MSC_VER
-# pragma GCC diagnostic ignored "-Wuninitialized" SGSphere();
-#endif
template<typename T>
class SGSphere {
public:
+
+#ifdef __GNUC__
+// Avoid "_center not initialized" warnings.
+# pragma GCC diagnostic ignored "-Wuninitialized"
+#endif
+
SGSphere() :
/*
* Do not initialize _center to save unneeded initialization time.
_radius(sphere.getRadius())
{ }
+#ifdef __GNUC__
+ // Restore warning settings.
+# pragma GCC diagnostic warning "-Wuninitialized"
+#endif
+
const SGVec3<T>& getCenter() const
{ return _center; }
void setCenter(const SGVec3<T>& center)
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()) {