X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSphere.hh;h=319a3ae24a32b5a36b5d130134fc5bfca5e915aa;hp=7f7a76373dfd7f0d228f33c9c36379c25a57959c;hb=c9e20ac06383b20ceb5404c9237e319c2e90d157;hpb=25aefe01ef7dbdb603c51411e04b0d6a6107684f diff --git a/src/Moof/Sphere.hh b/src/Moof/Sphere.hh index 7f7a763..319a3ae 100644 --- a/src/Moof/Sphere.hh +++ b/src/Moof/Sphere.hh @@ -62,6 +62,12 @@ struct Sphere : public Cullable, public Drawable radius = r; } + void init(const Vector3& p, const Vector3& o) + { + point = p; + radius = (o - p).length(); + } + void encloseVertices(const Vector3 vertices[], unsigned count); void draw(Scalar alpha = 0.0) const; @@ -69,6 +75,13 @@ struct Sphere : public Cullable, public Drawable }; +inline bool checkCollision(const Sphere& a, const Sphere& b) +{ + Scalar d = (a.point - b.point).length(); + return d < (a.radius + b.radius); +} + + } // namespace Mf #endif // _MOOF_SPHERE_HH_