X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FAabb.hh;h=457d198495e9a358fd40e304b3236730e501af57;hp=b43e194784df06c96892f11d8b7129fe8fef4587;hb=f72400af4fa3e7b54dab154b5a2b6503a6f9af18;hpb=29e3d45f7bbbf31eadf793c41ff2b3d9c47b7539 diff --git a/src/Moof/Aabb.hh b/src/Moof/Aabb.hh index b43e194..457d198 100644 --- a/src/Moof/Aabb.hh +++ b/src/Moof/Aabb.hh @@ -29,8 +29,10 @@ #ifndef _MOOF_AABB_HH_ #define _MOOF_AABB_HH_ +#include #include #include +#include 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; @@ -103,7 +105,38 @@ struct Aabb : public Drawable (min[2] + max[2]) / 2.0); } - void draw(Scalar alpha) const; + void getOctant(Aabb& octant, int num) const; + + inline Plane getPlaneXY() const + { + Plane plane; + plane.normal = Vector3(0.0, 0.0, 1.0); + plane.d = cml::dot(-plane.normal, getCenter()); + return plane; + } + + inline Plane getPlaneXZ() const + { + Plane plane; + plane.normal = Vector3(0.0, 1.0, 0.0); + plane.d = cml::dot(-plane.normal, getCenter()); + return plane; + } + + inline 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 Camera& cam) const; };