diff options
author | Mattes D <github@xoft.cz> | 2014-02-05 21:26:12 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-02-05 21:26:12 +0100 |
commit | 24dfe7f9cc91ce550860a6c3366e0b57a54f2f97 (patch) | |
tree | 083f1f2c428b689912f7ef381e57a9164b921cbd /src | |
parent | Merge pull request #649 from mc-server/GroupsPermissions (diff) | |
parent | Change Output to stderr (diff) | |
download | cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar.gz cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar.bz2 cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar.lz cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar.xz cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.tar.zst cuberite-24dfe7f9cc91ce550860a6c3366e0b57a54f2f97.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/BoundingBox.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index 86d4546c7..47b135688 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -1,4 +1,3 @@ - // BoundingBox.cpp // Implements the cBoundingBox class representing an axis-aligned bounding box with floatingpoint coords @@ -11,7 +10,7 @@ -#if 0 +#if SELF_TEST /// A simple self-test that is executed on program start, used to verify bbox functionality class SelfTest @@ -30,20 +29,39 @@ public: Vector3d(1.999, 0, 1.5), Vector3d(1.999, 4, 1.5), // Should intersect at 0.25, face 0 (YM) Vector3d(2.001, 0, 1.5), Vector3d(2.001, 4, 1.5), // Should not intersect } ; + 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; - char Face; + eBlockFace Face; Vector3d Line1 = LineDefs[2 * i]; Vector3d Line2 = LineDefs[2 * i + 1]; bool res = cBoundingBox::CalcLineIntersection(Min, Max, Line1, Line2, LineCoeff, Face); - printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", - Line1.x, Line1.y, Line1.z, - Line2.x, Line2.y, Line2.z, - res ? 1 : 0, LineCoeff, Face - ); + if (res != Results[i]) + { + fprintf(stderr,"LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + Line1.x, Line1.y, Line1.z, + Line2.x, Line2.y, Line2.z, + res ? 1 : 0, LineCoeff, Face + ); + abort(); + } + if (res) + { + if (LineCoeff != LineCoeffs[i]) + { + fprintf(stderr,"LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + Line1.x, Line1.y, Line1.z, + Line2.x, Line2.y, Line2.z, + res ? 1 : 0, LineCoeff, Face + ); + abort(); + } + } } // for i - LineDefs[] - printf("BoundingBox selftest complete."); + fprintf(stderr,"BoundingBox selftest complete."); } } Test; |