X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Faabb.hh;fp=src%2FMoof%2FAabb.hh;h=64e8968be114d72268808c65ae3630ac69a24582;hp=d3229bc23f1939f5eea2d68b2a4dc80bf17844c7;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/Moof/Aabb.hh b/src/moof/aabb.hh similarity index 64% rename from src/Moof/Aabb.hh rename to src/moof/aabb.hh index d3229bc..64e8968 100644 --- a/src/Moof/Aabb.hh +++ b/src/moof/aabb.hh @@ -12,61 +12,62 @@ #ifndef _MOOF_AABB_HH_ #define _MOOF_AABB_HH_ -#include -#include -#include -#include -#include +/** + * \file aabb.hh + * Axis-aligned Bounding Box + */ -#include // FIXME this file is quite broken -#include -#include +#include +#include +#include +#include +#include +#include // FIXME: this file is quite broken +#include +#include -namespace Mf { +namespace moof { -class Script; +class script; -/** - * Axis-aligned Bounding Box - */ template -struct Aabb : public Cullable, public Drawable, public Shape +struct aabb : public cullable, public drawable, public shape { - typedef cml::vector< Scalar, cml::fixed > Vector; + typedef moof::vector< scalar, fixed > vector; - Vector min; - Vector max; + vector min; + vector max; - Aabb() {} + aabb() {} - Aabb(const Vector& a, const Vector& b) + aabb(const vector& a, const vector& b) { init(a, b); } - Aabb(Scalar x1, Scalar y1, Scalar x2, Scalar y2) + aabb(scalar x1, scalar y1, scalar x2, scalar y2) { - Vector a(x1, y1); - Vector b(x2, y2); + vector a(x1, y1); + vector b(x2, y2); init(a, b); } - Aabb(Scalar x1, Scalar y1, Scalar z1, Scalar x2, Scalar y2, Scalar z2) + aabb(scalar x1, scalar y1, scalar z1, scalar x2, scalar y2, scalar z2) { - Vector a(x1, y1, z1); - Vector b(x2, y2, z2); + vector a(x1, y1, z1); + vector b(x2, y2, z2); init(a, b); } - void init(const Vector2& a, const Vector2& b) + void init(const vector2& a, const vector2& b) { if (a[0] < b[0]) { @@ -90,7 +91,7 @@ struct Aabb : public Cullable, public Drawable, public Shape } } - void init(const Vector3& a, const Vector3& b) + void init(const vector3& a, const vector3& b) { if (a[0] < b[0]) { @@ -125,38 +126,38 @@ struct Aabb : public Cullable, public Drawable, public Shape } - Vector getCenter() const + vector center() const { return (min + max) / 2.0; } - Plane getPlaneXY() const + plane xy_plane() const { - Plane plane; - plane.normal = Vector3(0.0, 0.0, 1.0); - plane.d = cml::dot(-plane.normal, getCenter()); + plane plane; + plane.normal = vector3(0.0, 0.0, 1.0); + plane.d = dot(-plane.normal, center()); return plane; } - Plane getPlaneXZ() const + plane xz_plane() const { - Plane plane; - plane.normal = Vector3(0.0, 1.0, 0.0); - plane.d = cml::dot(-plane.normal, getCenter()); + plane plane; + plane.normal = vector3(0.0, 1.0, 0.0); + plane.d = dot(-plane.normal, center()); return plane; } - Plane getPlaneYZ() const + plane yz_plane() const { - Plane plane; - plane.normal = Vector3(1.0, 0.0, 0.0); - plane.d = cml::dot(-plane.normal, getCenter()); + plane plane; + plane.normal = vector3(1.0, 0.0, 0.0); + plane.d = dot(-plane.normal, center()); return plane; } - void getCorners(Vector2 corners[4]) const + void get_corners(vector2 corners[4]) const { corners[0][0] = min[0]; corners[0][1] = min[1]; corners[1][0] = max[0]; corners[1][1] = min[1]; @@ -164,7 +165,7 @@ struct Aabb : public Cullable, public Drawable, public Shape corners[3][0] = min[0]; corners[3][1] = max[1]; } - void getCorners(Vector3 corners[8]) const + void get_corners(vector3 corners[8]) const { corners[0][0] = min[0]; corners[0][1] = min[1]; @@ -193,7 +194,7 @@ struct Aabb : public Cullable, public Drawable, public Shape } - void encloseVertices(const Vector vertices[], unsigned count) + void enclose_vertices(const vector vertices[], unsigned count) { min.zero(); max.zero(); @@ -206,24 +207,24 @@ struct Aabb : public Cullable, public Drawable, public Shape } - void draw(Scalar alpha = 0.0) const + void draw(scalar alpha = 0.0) const { glRect(min[0], min[1], max[0], max[1]); } - bool isVisible(const Frustum& frustum) const + bool is_visible(const frustum& frustum) const { return true; } }; -void importAabbClass(Script& script); +void import_aabb_class(script& script); template <> -inline void Aabb<3>::draw(Scalar alpha) const +inline void aabb<3>::draw(scalar alpha) const { - Scalar vertices[] = {min[0], min[1], min[2], + scalar vertices[] = {min[0], min[1], min[2], min[0], max[1], min[2], max[0], max[1], min[2], max[0], min[1], min[2], @@ -244,7 +245,7 @@ inline void Aabb<3>::draw(Scalar alpha) const glVertexPointer(3, GL_SCALAR, 0, vertices); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - Texture::resetBind(); + texture::reset_binding(); glDrawElements(GL_QUADS, sizeof(indices), GL_UNSIGNED_BYTE, indices); @@ -256,18 +257,18 @@ inline void Aabb<3>::draw(Scalar alpha) const } template <> -inline bool Aabb<3>::isVisible(const Frustum& frustum) const +inline bool aabb<3>::is_visible(const frustum& frustum) const { return frustum.contains(*this); } -typedef Aabb<2> Aabb2; -typedef Aabb2 Rectangle; -typedef Aabb<3> Aabb3; +typedef aabb<2> aabb2; +typedef aabb2 rectangle; +typedef aabb<3> aabb3; -} // namespace Mf +} // namespace moof #endif // _MOOF_AABB_HH_