diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 20:45:42 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 20:45:42 +0100 |
commit | a633c45e8e714b91783b3625c1ec98c62302292d (patch) | |
tree | fbf60bef53bb2f7fa35de13eb7f3f5d7ba350ff1 /source/Cuboid.h | |
parent | ListenThread now reports the protocol used (IPv4 - IPv6) in its error messages (diff) | |
download | cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar.gz cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar.bz2 cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar.lz cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar.xz cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.tar.zst cuberite-a633c45e8e714b91783b3625c1ec98c62302292d.zip |
Diffstat (limited to 'source/Cuboid.h')
-rw-r--r-- | source/Cuboid.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/Cuboid.h b/source/Cuboid.h index 4032b66fb..4b0a76a34 100644 --- a/source/Cuboid.h +++ b/source/Cuboid.h @@ -18,12 +18,17 @@ public: 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) {} + cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {} + cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {} 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; } + + /// Returns true if the cuboids have at least one voxel in common. Both coords are considered inclusive. + bool DoesIntersect(const cCuboid & a_Other) const; bool IsInside(const Vector3i & v) const { @@ -34,6 +39,15 @@ public: ); } + bool IsInside(int a_X, int a_Y, int a_Z) const + { + return ( + (a_X >= p1.x) && (a_X <= p2.x) && + (a_Y >= p1.y) && (a_Y <= p2.y) && + (a_Z >= p1.z) && (a_Z <= p2.z) + ); + } + bool IsInside( const Vector3d & v ) const { return ( @@ -42,6 +56,9 @@ public: (v.z >= p1.z) && (v.z <= p2.z) ); } + + /// Moves the cuboid by the specified offsets in each direction + void Move(int a_OfsX, int a_OfsY, int a_OfsZ); } ; // tolua_end |