]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Aabb.hh
improved new vorbisfile compatibility
[chaz/yoink] / src / Moof / Aabb.hh
index b43e194784df06c96892f11d8b7129fe8fef4587..0f7bbb9ff74fa2495e6b6582f2515c3b99f7cef2 100644 (file)
 #ifndef _MOOF_AABB_HH_
 #define _MOOF_AABB_HH_
 
+#include <Moof/Cullable.hh>
 #include <Moof/Drawable.hh>
 #include <Moof/Math.hh>
+#include <Moof/Plane.hh>
 
 
 namespace Mf {
@@ -40,7 +42,7 @@ namespace Mf {
  * Axis-aligned Bounding Box
  */
 
-struct Aabb : public Drawable
+struct Aabb : public Cullable, public Drawable
 {
        Vector3 min;
        Vector3 max;
@@ -62,7 +64,7 @@ struct Aabb : public Drawable
                init(a, b);
        }
 
-       inline void init(const Vector3& a, const Vector3& b)
+       void init(const Vector3& a, const Vector3& b)
        {
                if (a[0] < b[0])
                {
@@ -96,14 +98,45 @@ struct Aabb : public Drawable
                }
        }
 
-       inline Vector3 getCenter() const
+       Vector3 getCenter() const
        {
                return Vector3((min[0] + max[0]) / 2.0,
                                           (min[1] + max[1]) / 2.0,
                                           (min[2] + max[2]) / 2.0);
        }
 
-       void draw(Scalar alpha) const;
+       void getOctant(Aabb& octant, int num) const;
+
+       Plane getPlaneXY() const
+       {
+               Plane plane;
+               plane.normal = Vector3(0.0, 0.0, 1.0);
+               plane.d = cml::dot(-plane.normal, getCenter());
+               return plane;
+       }
+
+       Plane getPlaneXZ() const
+       {
+               Plane plane;
+               plane.normal = Vector3(0.0, 1.0, 0.0);
+               plane.d = cml::dot(-plane.normal, getCenter());
+               return plane;
+       }
+
+       Plane getPlaneYZ() const
+       {
+               Plane plane;
+               plane.normal = Vector3(1.0, 0.0, 0.0);
+               plane.d = cml::dot(-plane.normal, getCenter());
+               return plane;
+       }
+
+       void getCorners(Vector3 corners[8]) const;
+
+       void encloseVertices(const Vector3 vertices[], unsigned count);
+
+       void draw(Scalar alpha = 0.0) const;
+       bool isVisible(const Frustum& frustum) const;
 };
 
 
This page took 0.018946 seconds and 4 git commands to generate.