summaryrefslogtreecommitdiffstats
path: root/src/BoundingBox.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-01-22 19:55:46 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-01-22 20:16:27 +0100
commit439b3304f4c82448b0e1585f8641503691212cac (patch)
tree706035da78a49c971f6d3bf3d812582581ce93a4 /src/BoundingBox.cpp
parentMerge pull request #2894 from LogicParrot/spider (diff)
downloadcuberite-439b3304f4c82448b0e1585f8641503691212cac.tar
cuberite-439b3304f4c82448b0e1585f8641503691212cac.tar.gz
cuberite-439b3304f4c82448b0e1585f8641503691212cac.tar.bz2
cuberite-439b3304f4c82448b0e1585f8641503691212cac.tar.lz
cuberite-439b3304f4c82448b0e1585f8641503691212cac.tar.xz
cuberite-439b3304f4c82448b0e1585f8641503691212cac.tar.zst
cuberite-439b3304f4c82448b0e1585f8641503691212cac.zip
Diffstat (limited to 'src/BoundingBox.cpp')
-rw-r--r--src/BoundingBox.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp
index 64e3c02d2..8e3bb29a9 100644
--- a/src/BoundingBox.cpp
+++ b/src/BoundingBox.cpp
@@ -37,7 +37,7 @@ public:
} ;
bool Results[] = {true, true, true, false, true, false};
double LineCoeffs[] = {2, 0.25, 0.5, 0, 0.25, 0};
-
+
for (size_t i = 0; i < ARRAYCOUNT(LineDefs) / 2; i++)
{
double LineCoeff;
@@ -106,6 +106,16 @@ cBoundingBox::cBoundingBox(const Vector3d & a_Pos, double a_Radius, double a_Hei
+cBoundingBox::cBoundingBox(const Vector3d & a_Pos, double a_CubeLength) :
+ m_Min(a_Pos.x - a_CubeLength / 2, a_Pos.y - a_CubeLength / 2, a_Pos.z - a_CubeLength / 2),
+ m_Max(a_Pos.x + a_CubeLength / 2, a_Pos.y + a_CubeLength / 2, a_Pos.z + a_CubeLength / 2)
+{
+}
+
+
+
+
+
cBoundingBox::cBoundingBox(const cBoundingBox & a_Orig) :
m_Min(a_Orig.m_Min),
m_Max(a_Orig.m_Max)
@@ -269,10 +279,10 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d &
a_Face = BLOCK_FACE_NONE; // No faces hit
return true;
}
-
+
eBlockFace Face = BLOCK_FACE_NONE;
double Coeff = Vector3d::NO_INTERSECTION;
-
+
// Check each individual bbox face for intersection with the line, remember the one with the lowest coeff
double c = a_Line1.LineCoeffToXYPlane(a_Line2, a_Min.z);
if ((c >= 0) && (c < Coeff) && IsInside(a_Min, a_Max, a_Line1 + (a_Line2 - a_Line1) * c))
@@ -310,13 +320,13 @@ bool cBoundingBox::CalcLineIntersection(const Vector3d & a_Min, const Vector3d &
Face = (a_Line1.x > a_Line2.x) ? BLOCK_FACE_XP : BLOCK_FACE_XM;
Coeff = c;
}
-
+
if (Coeff >= Vector3d::NO_INTERSECTION)
{
// There has been no intersection
return false;
}
-
+
a_LineCoeff = Coeff;
a_Face = Face;
return true;