X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fsphere.hh;h=75c5808a476cfe5d4e4256f52f76bbd4d691c149;hp=cf1bba772316057ca7e625ab0f1b99ed976151f1;hb=574af38ed616d1adfa5e6ce35f67cda1f707f89d;hpb=6c9943707d4f33035830eba0587a61a34eaecbc2 diff --git a/src/moof/sphere.hh b/src/moof/sphere.hh index cf1bba7..75c5808 100644 --- a/src/moof/sphere.hh +++ b/src/moof/sphere.hh @@ -1,13 +1,11 @@ -/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +/*] Copyright (c) 2009-2011, Charles McGarvey [***************************** **] All rights reserved. * -* vi:ts=4 sw=4 tw=75 -* * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * -**************************************************************************/ +*****************************************************************************/ #ifndef _MOOF_SPHERE_HH_ #define _MOOF_SPHERE_HH_ @@ -41,14 +39,12 @@ struct sphere : public cullable, public drawable, public shape vector point; scalar radius; - sphere() {} sphere(const vector& p, scalar r) : point(p), radius(r) {} - void init(const vector& p, scalar r) { point = p; @@ -78,7 +74,6 @@ struct sphere : public cullable, public drawable, public shape return true; } - bool intersect(const sphere& sphere, contact& hit) const { vector n = sphere.point - point; @@ -110,7 +105,7 @@ struct sphere : public cullable, public drawable, public shape // a ray inside the sphere will not intersect on its way out bool intersect(const ray& ray, - typename moof::ray::contact& hit) const + typename moof::ray::contact& hit) const { vector b = point - ray.point; scalar z = dot(b, ray.direction); @@ -134,15 +129,19 @@ struct sphere : public cullable, public drawable, public shape } }; +typedef sphere<2> circle; +typedef sphere<2> sphere2; +typedef sphere<3> sphere3; + template <> -inline bool sphere<3>::is_visible(const frustum& frustum) const +inline bool sphere3::is_visible(const frustum& frustum) const { return frustum.contains(*this); } template <> -inline void sphere<2>::draw(scalar alpha) const +inline void sphere2::draw(scalar alpha) const { GLUquadricObj* sphereObj = gluNewQuadric(); gluQuadricDrawStyle(sphereObj, GLU_LINE); @@ -158,7 +157,7 @@ inline void sphere<2>::draw(scalar alpha) const } template <> -inline void sphere<3>::draw(scalar alpha) const +inline void sphere3::draw(scalar alpha) const { GLUquadricObj* sphereObj = gluNewQuadric(); gluQuadricDrawStyle(sphereObj, GLU_LINE); @@ -181,11 +180,6 @@ inline bool checkCollision(const sphere& a, const sphere& b) } -typedef sphere<2> sphere2; -typedef sphere2 circle; -typedef sphere<3> sphere3; - - } // namespace moof #endif // _MOOF_SPHERE_HH_