X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fsphere.hh;h=15a80314dc6afa3ce2518e067ac76ce3d2494d92;hp=dd4decec8d4224c16945467b820118a9ecdd4d4f;hb=HEAD;hpb=831f04d4bc19a390415ac0bbac4331c7a65509bc diff --git a/src/moof/sphere.hh b/src/moof/sphere.hh index dd4dece..15a8031 100644 --- a/src/moof/sphere.hh +++ b/src/moof/sphere.hh @@ -1,23 +1,15 @@ -/*] 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_ -/** - * \file sphere.hh - * A round shape like a circle or sphere. - * TODO: This class needs some work. - */ - #include #include #include @@ -27,6 +19,12 @@ #include +/** + * \file sphere.hh + * A round shape like a circle or sphere. + * TODO: This class needs some work. + */ + namespace moof { @@ -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; @@ -109,7 +104,8 @@ 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 ray::contact& hit) const + bool intersect(const ray& ray, + typename moof::ray::contact& hit) const { vector b = point - ray.point; scalar z = dot(b, ray.direction); @@ -133,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); @@ -157,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); @@ -180,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_