diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-22 20:52:49 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-01-22 20:52:49 +0100 |
commit | 7ba432b338ffa4c448de9d68d0f1b1e0024cd50a (patch) | |
tree | 706035da78a49c971f6d3bf3d812582581ce93a4 /src/BoundingBox.cpp | |
parent | Merge pull request #2894 from LogicParrot/spider (diff) | |
parent | Improved tamed wolf pack cooperation and projectile reactions (diff) | |
download | cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar.gz cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar.bz2 cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar.lz cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar.xz cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.tar.zst cuberite-7ba432b338ffa4c448de9d68d0f1b1e0024cd50a.zip |
Diffstat (limited to 'src/BoundingBox.cpp')
-rw-r--r-- | src/BoundingBox.cpp | 20 |
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; |