summaryrefslogtreecommitdiffstats
path: root/src/Cuboid.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-11 20:33:26 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-11 20:33:26 +0100
commit80d7c88e007c6dd3af629aad7a01fbf911a00d67 (patch)
treef60467bca973ef34b355b53e2d0dbb5554f71ad7 /src/Cuboid.cpp
parentMerge branch 'master' into Werror (diff)
parentMerge pull request #791 from mc-server/PieceGenerator (diff)
downloadcuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar.gz
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar.bz2
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar.lz
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar.xz
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.tar.zst
cuberite-80d7c88e007c6dd3af629aad7a01fbf911a00d67.zip
Diffstat (limited to 'src/Cuboid.cpp')
-rw-r--r--src/Cuboid.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Cuboid.cpp b/src/Cuboid.cpp
index 782837b23..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) &&
@@ -197,3 +203,37 @@ bool cCuboid::IsSorted(void) const
+
+void cCuboid::Engulf(const Vector3i & a_Point)
+{
+ if (a_Point.x < p1.x)
+ {
+ p1.x = a_Point.x;
+ }
+ else if (a_Point.x > p2.x)
+ {
+ p2.x = a_Point.x;
+ }
+
+ if (a_Point.y < p1.y)
+ {
+ p1.y = a_Point.y;
+ }
+ else if (a_Point.y > p2.y)
+ {
+ p2.y = a_Point.y;
+ }
+
+ if (a_Point.z < p1.z)
+ {
+ p1.z = a_Point.z;
+ }
+ else if (a_Point.z > p2.z)
+ {
+ p2.z = a_Point.z;
+ }
+}
+
+
+
+