diff options
author | madmaxoft <github@xoft.cz> | 2014-03-09 22:02:08 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-03-09 22:02:08 +0100 |
commit | dacb6cef1d6d2942f01d15186d8a12b30d39a385 (patch) | |
tree | b375994b74fbbcf2d64f615d0d1da31db6556e7b | |
parent | ChunkDef: Replaced enums with static const ints. (diff) | |
download | cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar.gz cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar.bz2 cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar.lz cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar.xz cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.tar.zst cuberite-dacb6cef1d6d2942f01d15186d8a12b30d39a385.zip |
-rw-r--r-- | src/Cuboid.cpp | 6 | ||||
-rw-r--r-- | src/Cuboid.h | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp index dc8df8500..2400c64f3 100644 --- a/src/Cuboid.cpp +++ b/src/Cuboid.cpp @@ -72,6 +72,9 @@ int cCuboid::GetVolume(void) const bool cCuboid::DoesIntersect(const cCuboid & a_Other) const { + ASSERT(IsSorted()); + ASSERT(a_Other.IsSorted()); + // In order for cuboids to intersect, each of their coord intervals need to intersect return ( DoIntervalsIntersect(p1.x, p2.x, a_Other.p1.x, a_Other.p2.x) && @@ -86,6 +89,9 @@ bool cCuboid::DoesIntersect(const cCuboid & a_Other) const bool cCuboid::IsCompletelyInside(const cCuboid & a_Outer) const { + ASSERT(IsSorted()); + ASSERT(a_Outer.IsSorted()); + return ( (p1.x >= a_Outer.p1.x) && (p2.x <= a_Outer.p2.x) && diff --git a/src/Cuboid.h b/src/Cuboid.h index 50a69b853..b95517f69 100644 --- a/src/Cuboid.h +++ b/src/Cuboid.h @@ -34,7 +34,8 @@ public: Works on unsorted cuboids, too. */ int GetVolume(void) const; - /** Returns true if the cuboids have at least one voxel in common. Both coords are considered inclusive. */ + /** Returns true if the cuboids have at least one voxel in common. Both coords are considered inclusive. + Assumes both cuboids are sorted. */ bool DoesIntersect(const cCuboid & a_Other) const; bool IsInside(const Vector3i & v) const @@ -64,7 +65,8 @@ public: ); } - /** Returns true if this cuboid is completely inside the specifie cuboid (in all 6 coords) */ + /** Returns true if this cuboid is completely inside the specifie cuboid (in all 6 coords). + Assumes both cuboids are sorted. */ bool IsCompletelyInside(const cCuboid & a_Outer) const; /** Moves the cuboid by the specified offsets in each direction */ @@ -72,7 +74,7 @@ public: /** Expands the cuboid by the specified amount in each direction. Works on unsorted cuboids as well. - Note that this function doesn't check for underflows. */ + Note that this function doesn't check for underflows when using negative amounts. */ void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); /** Clamps both X coords to the specified range. Works on unsorted cuboids, too. */ |