X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FAabb.hh;h=0f7bbb9ff74fa2495e6b6582f2515c3b99f7cef2;hp=f51531a49d49db13e1fd3f87b77510c59ed747c4;hb=7e898e8ec0ff716e2fc722b883a626a6c346f107;hpb=493ddb59a8620b49dfa0ff62ce93395ebfd02e86 diff --git a/src/Moof/Aabb.hh b/src/Moof/Aabb.hh index f51531a..0f7bbb9 100644 --- a/src/Moof/Aabb.hh +++ b/src/Moof/Aabb.hh @@ -32,6 +32,7 @@ #include #include #include +#include namespace Mf { @@ -63,7 +64,7 @@ struct Aabb : public Cullable, 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]) { @@ -97,15 +98,45 @@ struct Aabb : public Cullable, 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 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 Camera& cam) const; + bool isVisible(const Frustum& frustum) const; };