diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 17:45:00 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 17:45:00 +0100 |
commit | d023589a192004ac20c18c40a73db1142364cde1 (patch) | |
tree | 478fdcf305ea0bcf129fedd4b00f5d23b195dfd7 /source/Cuboid.h | |
parent | BlockArea: Finished rotation and mirroring with meta. Implemented example meta handling for vines, stairs and torches. (diff) | |
download | cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar.gz cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar.bz2 cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar.lz cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar.xz cuberite-d023589a192004ac20c18c40a73db1142364cde1.tar.zst cuberite-d023589a192004ac20c18c40a73db1142364cde1.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Cuboid.h | 81 |
1 files changed, 46 insertions, 35 deletions
diff --git a/source/Cuboid.h b/source/Cuboid.h index 1002ff6b4..4032b66fb 100644 --- a/source/Cuboid.h +++ b/source/Cuboid.h @@ -1,40 +1,51 @@ + #pragma once #include "Vector3i.h" #include "Vector3d.h" -class cCuboid // tolua_export -{ // tolua_export -public: // tolua_export - cCuboid() {} // tolua_export - cCuboid( const cCuboid & a_Cuboid ) : p1( a_Cuboid.p1 ), p2( a_Cuboid.p2 ) {} // tolua_export - cCuboid( const Vector3i & a_p1, const Vector3i & a_p2 ) : p1( a_p1 ), p2( a_p2 ) {} // tolua_export - - - Vector3i p1, p2; // tolua_export - - void Sort(); // tolua_export - - bool IsInside( const Vector3i & v ) const // tolua_export - { // tolua_export - if( v.x >= p1.x && v.x <= p2.x - && v.y >= p1.y && v.y <= p2.y - && v.z >= p1.z && v.z <= p2.z ) - { - return true; - } - return false; - } // tolua_export - - bool IsInside( const Vector3d & v ) const // tolua_export - { // tolua_export - if( v.x >= p1.x && v.x <= p2.x - && v.y >= p1.y && v.y <= p2.y - && v.z >= p1.z && v.z <= p2.z ) - { - return true; - } - return false; - } // tolua_export - -}; // tolua_export + + + + +// tolua_begin +class cCuboid +{ +public: + // p1 is expected to have the smaller of the coords; Sort() swaps coords to match this + Vector3i p1, p2; + + cCuboid(void) {} + cCuboid(const cCuboid & a_Cuboid ) : p1(a_Cuboid.p1), p2(a_Cuboid.p2) {} + cCuboid(const Vector3i & a_p1, const Vector3i & a_p2) : p1(a_p1), p2(a_p2) {} + + void Sort(void); + + int DifX(void) const { return p2.x - p1.x; } + int DifY(void) const { return p2.y - p1.y; } + int DifZ(void) const { return p2.z - p1.z; } + + bool IsInside(const Vector3i & v) const + { + return ( + (v.x >= p1.x) && (v.x <= p2.x) && + (v.y >= p1.y) && (v.y <= p2.y) && + (v.z >= p1.z) && (v.z <= p2.z) + ); + } + + bool IsInside( const Vector3d & v ) const + { + return ( + (v.x >= p1.x) && (v.x <= p2.x) && + (v.y >= p1.y) && (v.y <= p2.y) && + (v.z >= p1.z) && (v.z <= p2.z) + ); + } + +} ; +// tolua_end + + + + |