diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 21:50:32 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-29 21:50:32 +0100 |
commit | a3e4704b5417ae1ee68d369ec0648d1e88ae34dd (patch) | |
tree | 193d00f671335dc4a3004782ef240f429843cbd1 /source | |
parent | ChunkDesc: Cuboid-based manipulation (diff) | |
download | cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar.gz cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar.bz2 cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar.lz cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar.xz cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.tar.zst cuberite-a3e4704b5417ae1ee68d369ec0648d1e88ae34dd.zip |
Diffstat (limited to 'source')
-rw-r--r-- | source/Cuboid.cpp | 15 | ||||
-rw-r--r-- | source/Cuboid.h | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/source/Cuboid.cpp b/source/Cuboid.cpp index 54dd1f1a4..3b07bf23a 100644 --- a/source/Cuboid.cpp +++ b/source/Cuboid.cpp @@ -13,7 +13,7 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2) return ( ((a_Min1 >= a_Min2) && (a_Min1 <= a_Max2)) || // Start of first interval is within the second interval ((a_Max1 >= a_Min2) && (a_Max1 <= a_Max2)) || // End of first interval is within the second interval - ((a_Min2 >= a_Min2) && (a_Min2 <= a_Max2)) // Start of second interval is within the first interval + ((a_Min2 >= a_Min1) && (a_Min2 <= a_Max1)) // Start of second interval is within the first interval ); } @@ -72,3 +72,16 @@ void cCuboid::Move(int a_OfsX, int a_OfsY, int a_OfsZ) + +bool cCuboid::IsSorted(void) const +{ + return ( + (p1.x <= p2.x) && + (p1.y <= p2.y) && + (p1.z <= p2.z) + ); +} + + + + diff --git a/source/Cuboid.h b/source/Cuboid.h index 4b0a76a34..01a2b4ef0 100644 --- a/source/Cuboid.h +++ b/source/Cuboid.h @@ -60,6 +60,8 @@ public: /// Moves the cuboid by the specified offsets in each direction void Move(int a_OfsX, int a_OfsY, int a_OfsZ); + /// Returns true if the coords are properly sorted (lesser in p1, greater in p2) + bool IsSorted(void) const; } ; // tolua_end |