diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-02-07 20:31:57 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-02-07 20:31:57 +0000 |
| commit | dc70308cd8caebbab43067c6520f39476c2ae044 (patch) | |
| tree | 0067d643c9ebe80e36b5b48afbbcbcdbb250c16d | |
| parent | MathLib: added TraceLineThroughGrid function (diff) | |
| download | DiligentCore-dc70308cd8caebbab43067c6520f39476c2ae044.tar.gz DiligentCore-dc70308cd8caebbab43067c6520f39476c2ae044.zip | |
MathLib: added few more tests for TraceLineThroughGrid function
| -rw-r--r-- | Common/interface/AdvancedMath.hpp | 4 | ||||
| -rw-r--r-- | Tests/DiligentCoreTest/src/Common/MathLibTest.cpp | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Common/interface/AdvancedMath.hpp b/Common/interface/AdvancedMath.hpp index d67243b8..3b0685dd 100644 --- a/Common/interface/AdvancedMath.hpp +++ b/Common/interface/AdvancedMath.hpp @@ -554,13 +554,13 @@ inline float IntersectRayTriangle(const float3& V0, } -/// Traces a 2D line through the grid and enumerates all cells the line touches. +/// Traces a 2D line through the square cell grid and enumerates all cells the line touches. /// \tparam TCallback - Type of the callback function. /// \param f2Start - Line start point. /// \param f2Start - Line end point. /// \param i2GridSize - Grid dimensions. -/// \param Callback - Callback function that will be caleed with the argument of type Int2 +/// \param Callback - Callback function that will be caleed with the argument of type int2 /// for every cell visited. The function should return true to continue /// tracing and false otherwise. /// diff --git a/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp b/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp index d27c54fd..d5bbb46b 100644 --- a/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp +++ b/Tests/DiligentCoreTest/src/Common/MathLibTest.cpp @@ -1152,14 +1152,18 @@ TEST(Common_AdvancedMath, TraceLineThroughGrid) // Horizontal direction TestLineTrace(float2{0.f, 0.5f}, float2{2.f, 0.5f}, {int2{0, 0}, int2{1, 0}, int2{2, 0}}); TestLineTrace(float2{-10.f, 0.5f}, float2{2.f, 0.5f}, {int2{0, 0}, int2{1, 0}, int2{2, 0}}); + TestLineTrace(float2{2.f, 0.5f}, float2{-10.f, 0.5f}, {int2{2, 0}, int2{1, 0}, int2{0, 0}}); TestLineTrace(float2{8.f, 0.5f}, float2{10.f, 0.5f}, {int2{8, 0}, int2{9, 0}}); TestLineTrace(float2{8.f, 0.5f}, float2{20.f, 0.5f}, {int2{8, 0}, int2{9, 0}}); + TestLineTrace(float2{20.f, 0.5f}, float2{8.f, 0.5f}, {int2{9, 0}, int2{8, 0}}); // Vertical direction TestLineTrace(float2{0.5f, 0.f}, float2{0.5f, 2.f}, {int2{0, 0}, int2{0, 1}, int2{0, 2}}); TestLineTrace(float2{0.5f, -10.f}, float2{0.5f, 2.f}, {int2{0, 0}, int2{0, 1}, int2{0, 2}}); + TestLineTrace(float2{0.5f, 2.f}, float2{0.5f, -10.f}, {int2{0, 2}, int2{0, 1}, int2{0, 0}}); TestLineTrace(float2{0.5f, 8.f}, float2{0.5f, 10.f}, {int2{0, 8}, int2{0, 9}}); TestLineTrace(float2{0.5f, 8.f}, float2{0.5f, 20.f}, {int2{0, 8}, int2{0, 9}}); + TestLineTrace(float2{0.5f, 20.f}, float2{0.5f, 8.f}, {int2{0, 9}, int2{0, 8}}); // Sub-cell horizontal TestLineTrace(float2{5.85f, 5.5f}, float2{5.9f, 5.5f}, {int2{5, 5}}); |
