miscellaneous cleanup
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 17 Sep 2009 03:54:12 +0000 (21:54 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 17 Sep 2009 03:54:12 +0000 (21:54 -0600)
src/Moof/Aabb.cc
src/Moof/Frustum.cc
src/Moof/Frustum.hh
src/Moof/Octree.cc
src/Moof/Plane.cc
src/Moof/Plane.hh
src/Moof/Sphere.cc
src/Moof/Sphere.hh

index 1fb382f7fab7069bd8e1b8378f5d42a4daa6ce78..842d9d8a51b3fbfec7b8d1bd9f62ecf950bb1ea8 100644 (file)
@@ -140,7 +140,7 @@ void Aabb::draw(Scalar alpha) const
 
 bool Aabb::isVisible(const Camera& cam) const
 {
-       return cam.getFrustum().containsAabb(*this);
+       return cam.getFrustum().contains(*this);
 }
 
 
index dddbde09110476a42324ca9fbf2d5197efa1601f..51705f2eba7ebe53b458f2b99a8ad1c01204b1b1 100644 (file)
@@ -60,7 +60,7 @@ void Frustum::init(const Matrix4& modelview, Scalar fovy, Scalar aspect,
        init(modelview, projection);
 }
 
-Frustum::Collision Frustum::containsAabb(const Aabb& aabb) const
+Frustum::Collision Frustum::contains(const Aabb& aabb) const
 {
        Vector3 corners[8];
        int nTotalInside = 0;
@@ -73,7 +73,7 @@ Frustum::Collision Frustum::containsAabb(const Aabb& aabb) const
 
                for (int j = 0; j < 8; ++j)
                {
-                       if (planes_[i].intersectsPoint(corners[j]) ==
+                       if (planes_[i].intersects(corners[j]) ==
                                        Plane::NEGATIVE)
                        {
                                --nInside;
@@ -89,11 +89,11 @@ Frustum::Collision Frustum::containsAabb(const Aabb& aabb) const
 }
 
 
-Frustum::Collision Frustum::containsSphere(const Sphere& sphere) const
+Frustum::Collision Frustum::contains(const Sphere& sphere) const
 {
        for (int i = 0; i < 6; ++i)
        {
-               Plane::Halfspace halfspace = planes_[i].intersectsSphere(sphere);
+               Plane::Halfspace halfspace = planes_[i].intersects(sphere);
                
                if (halfspace == Plane::NEGATIVE)       return OUTSIDE;
                else if (halfspace == Plane::INTERSECT) return INTERSECT;
index 4154f1492cc98316ea72cd82b0c894359dac0010..0d08831911f721a9d2ed9f5b6a4ad4ec42cffdfb 100644 (file)
@@ -66,8 +66,8 @@ public:
        void init(const Matrix4& modelview, Scalar fovy, Scalar aspect,
                        Scalar abutting, Scalar distant);
 
-       Collision containsAabb(const Aabb& aabb) const;
-       Collision containsSphere(const Sphere& sphere) const;
+       Collision contains(const Aabb& aabb) const;
+       Collision contains(const Sphere& sphere) const;
 };
 
 
index bd1b410a6faa17cbc837df55527646b54c5232fb..9bb04e81d56e887882c2a59d152cdbcb012c2610 100644 (file)
@@ -72,28 +72,28 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                goto done;
        }
 
-       halfspace = xy.intersectsSphere(entity->getSphere());
+       halfspace = xy.intersects(entity->getSphere());
        if (halfspace == Plane::INTERSECT)
        {
-               halfspace = xy.intersectsAabb(entity->getAabb());
+               halfspace = xy.intersects(entity->getAabb());
        }
 
        if (halfspace == Plane::POSITIVE)
        {
                Plane xz = node->getAabb().getPlaneXZ();
-               halfspace = xz.intersectsSphere(entity->getSphere());
+               halfspace = xz.intersects(entity->getSphere());
                if (halfspace == Plane::INTERSECT)
                {
-                       halfspace = xz.intersectsAabb(entity->getAabb());
+                       halfspace = xz.intersects(entity->getAabb());
                }
 
                if (halfspace == Plane::POSITIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -108,10 +108,10 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                else if (halfspace == Plane::NEGATIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -127,19 +127,19 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
        else if (halfspace == Plane::NEGATIVE)
        {
                Plane xz = node->getAabb().getPlaneXZ();
-               halfspace = xz.intersectsSphere(entity->getSphere());
+               halfspace = xz.intersects(entity->getSphere());
                if (halfspace == Plane::INTERSECT)
                {
-                       halfspace = xz.intersectsAabb(entity->getAabb());
+                       halfspace = xz.intersects(entity->getAabb());
                }
 
                if (halfspace == Plane::POSITIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -154,10 +154,10 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                else if (halfspace == Plane::NEGATIVE)
                {
                        Plane yz = node->getAabb().getPlaneYZ();
-                       halfspace = yz.intersectsSphere(entity->getSphere());
+                       halfspace = yz.intersects(entity->getSphere());
                        if (halfspace == Plane::INTERSECT)
                        {
-                               halfspace = yz.intersectsAabb(entity->getAabb());
+                               halfspace = yz.intersects(entity->getAabb());
                        }
 
                        if (halfspace == Plane::POSITIVE)
@@ -244,11 +244,11 @@ void Octree::drawIfVisible(Scalar alpha, const Camera& cam, OctreeNodeP node)
 
        // try to cull by sphere
        Frustum::Collision collision =
-               cam.getFrustum().containsSphere(node->getSphere());
+               cam.getFrustum().contains(node->getSphere());
        if (collision == Frustum::OUTSIDE) return;
 
        // try to cull by aabb
-       collision = cam.getFrustum().containsAabb(node->getAabb());
+       collision = cam.getFrustum().contains(node->getAabb());
        if (collision == Frustum::OUTSIDE) return;
 
 
index 975ef13c52194990ba54e712c0d3138fa56f5d03..539093438c6114da07e440f60bb3c94e94f75ec2 100644 (file)
@@ -34,7 +34,7 @@
 namespace Mf {
 
 
-Plane::Halfspace Plane::intersectsAabb(const Aabb& aabb) const
+Plane::Halfspace Plane::intersects(const Aabb& aabb) const
 {
        Vector3 corners[8];
        int nPositive = 8;
@@ -43,7 +43,7 @@ Plane::Halfspace Plane::intersectsAabb(const Aabb& aabb) const
 
        for (int i = 0; i < 8; ++i)
        {
-               if (intersectsPoint(corners[i]) == NEGATIVE)
+               if (intersects(corners[i]) == NEGATIVE)
                {
                        --nPositive;
                }
@@ -54,7 +54,7 @@ Plane::Halfspace Plane::intersectsAabb(const Aabb& aabb) const
        else                     return INTERSECT;
 }
 
-Plane::Halfspace Plane::intersectsSphere(const Sphere& sphere) const
+Plane::Halfspace Plane::intersects(const Sphere& sphere) const
 {
        Scalar distance = getDistanceToPoint(sphere.point);
 
index 248a3128161afe0cadbdde10fa781d6b3e89c405..4739bb825406d5599d853ea0e39671d387e8041e 100644 (file)
@@ -39,6 +39,11 @@ class Aabb;
 class Sphere;
 
 
+/*
+ * A plane in 3-space defined by the equation Ax + By + Cz = D, where [A, B, C]
+ * is normal to the plane.
+ */
+
 struct Plane
 {
        Vector3 normal;
@@ -60,6 +65,8 @@ struct Plane
                d(scalar) {}
 
 
+       /* Causes the normal of the plane to become normalized.  The scalar may also
+        * be changed to keep the equation true. */
        void normalize()
        {
                Scalar mag = normal.length();
@@ -68,12 +75,15 @@ struct Plane
                d /= mag;
        }
 
+       /**
+        * Determine the shortest distance between a point and the plane. */
+
        inline Scalar getDistanceToPoint(const Vector3& point) const
        {
                return cml::dot(point, normal) + d;
        }
 
-       inline Halfspace intersectsPoint(const Vector3& point) const
+       inline Halfspace intersects(const Vector3& point) const
        {
                Scalar distance = getDistanceToPoint(point);
 
@@ -82,8 +92,8 @@ struct Plane
                else                        return POSITIVE;
        }
 
-       Halfspace intersectsAabb(const Aabb& aabb) const;
-       Halfspace intersectsSphere(const Sphere& sphere) const;
+       Halfspace intersects(const Aabb& aabb) const;
+       Halfspace intersects(const Sphere& sphere) const;
 };
 
 
index 352d58d503b419ec5cb7d77b5d0e9e30f0047f98..d8d089dec0adb0b28235b4ab0449132def0183d0 100644 (file)
@@ -26,9 +26,9 @@
 
 *******************************************************************************/
 
-#include <Moof/Camera.hh>
-#include <Moof/OpenGL.hh>
-#include <Moof/Sphere.hh>
+#include "Camera.hh"
+#include "OpenGL.hh"
+#include "Sphere.hh"
 
 
 namespace Mf {
@@ -36,16 +36,17 @@ namespace Mf {
 
 void Sphere::encloseVertices(const Vector3 vertices[], unsigned count)
 {
+       // TODO
 }
 
 void Sphere::draw(Scalar alpha) const
 {
-
+       // TODO
 }
 
 bool Sphere::isVisible(const Camera& cam) const
 {
-       return cam.getFrustum().containsSphere(*this);
+       return cam.getFrustum().contains(*this);
 }
 
 
index b20ca741748f076e648328593ffd8484be57367a..8a9d5e6e0008418ccc9e4885a87d5ad38ffd27e3 100644 (file)
@@ -38,7 +38,7 @@ namespace Mf {
 
 
 /**
- * Axis-aligned Bounding Box
+ * A round object.
  */
 
 struct Sphere : public Cullable, public Drawable
This page took 0.034773 seconds and 4 git commands to generate.