From 0a5ae5505b95d3df995dce2cf829f2ec48b73605 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Fri, 16 Feb 2024 20:09:15 -0500 Subject: [PATCH] More test fiddling --- src/engine/constants.hpp | 2 +- src/engine/debug/drawers.cpp | 3 --- src/engine/model/BoundingBox.cpp | 4 ---- tests/src/BoundingBoxTest.cpp | 3 +++ tests/src/FrustumTesting.cpp | 7 ++++++ .../{RotationTests.cpp => TransformTests.cpp} | 6 ----- tests/src/gtest_printers.hpp | 22 +++++++++---------- 7 files changed, 21 insertions(+), 26 deletions(-) rename tests/src/{RotationTests.cpp => TransformTests.cpp} (96%) diff --git a/src/engine/constants.hpp b/src/engine/constants.hpp index f482d47..996e1fb 100644 --- a/src/engine/constants.hpp +++ b/src/engine/constants.hpp @@ -28,7 +28,7 @@ namespace fgl::engine::constants constexpr float DEFAULT_FLOAT { std::numeric_limits< float >::max() }; constexpr float NEAR_PLANE { 0.1f }; - constexpr float FAR_PLANE { 5.0f }; + constexpr float FAR_PLANE { 100.0f }; constexpr glm::vec3 CENTER { 0.0f, 0.0f, 0.0f }; } // namespace fgl::engine::constants diff --git a/src/engine/debug/drawers.cpp b/src/engine/debug/drawers.cpp index a4f943d..d8e6304 100644 --- a/src/engine/debug/drawers.cpp +++ b/src/engine/debug/drawers.cpp @@ -22,9 +22,6 @@ namespace fgl::engine::debug ZoneScoped; const ImVec2 window_size { windowSize() }; - world_point.z = -world_point.z; - world_point.x = -world_point.x; - return Coordinate< CoordinateSpace::Screen >( glm::project( static_cast< glm::vec3 >( world_point ), glm::mat4( 1.0f ), diff --git a/src/engine/model/BoundingBox.cpp b/src/engine/model/BoundingBox.cpp index 2902016..ac4c325 100644 --- a/src/engine/model/BoundingBox.cpp +++ b/src/engine/model/BoundingBox.cpp @@ -125,10 +125,6 @@ namespace fgl::engine const auto yp { xp_yp_zp.y }; const auto zp { xp_yp_zp.z }; - assert( xp > xn ); - assert( yp > yn ); - assert( zp > zn ); - //Top const glm::vec3 xn_yp_zp { xn, yp, zp }; // (- + +) const glm::vec3 xn_yp_zn { xn, yp, zn }; // (- + -) diff --git a/tests/src/BoundingBoxTest.cpp b/tests/src/BoundingBoxTest.cpp index a721a07..f93b522 100644 --- a/tests/src/BoundingBoxTest.cpp +++ b/tests/src/BoundingBoxTest.cpp @@ -10,6 +10,7 @@ using namespace fgl::engine; TEST_CASE( "BoundingBox", "[boundingbox]" ) { + SECTION( "Combine test" ) { std::vector< Coordinate< CoordinateSpace::Model > > model_points {}; @@ -50,6 +51,7 @@ TEST_CASE( "BoundingBox", "[boundingbox]" ) } } +#ifdef FGL_ENABLE_BENCHMARKS BENCHMARK( "Combine bounding box" ) { auto generatePoints = []() @@ -89,4 +91,5 @@ TEST_CASE( "BoundingBox", "[boundingbox]" ) return model_box; }; +#endif } diff --git a/tests/src/FrustumTesting.cpp b/tests/src/FrustumTesting.cpp index 325dc7e..f35de02 100644 --- a/tests/src/FrustumTesting.cpp +++ b/tests/src/FrustumTesting.cpp @@ -40,9 +40,16 @@ TEST_CASE( "Frustum", "[frustum][rotation][translation]" ) //Verify that during a translation the direction isn't changed REQUIRE( translated_backwards.near.direction() == base_frustum.near.direction() ); + const glm::vec3 target_near { ( constants::WORLD_FORWARD * constants::NEAR_PLANE ) + - constants::WORLD_FORWARD }; + const glm::vec3 target_far { ( constants::WORLD_FORWARD * constants::FAR_PLANE ) + - constants::WORLD_FORWARD }; + + REQUIRE( translated_backwards.near.getPosition() == glm::vec3 { target_near } ); REQUIRE( translated_backwards.near.direction() == constants::WORLD_FORWARD ); REQUIRE( translated_backwards.near.distance() == constants::NEAR_PLANE - 1.0f ); + REQUIRE( translated_backwards.far.getPosition() == target_far ); REQUIRE( translated_backwards.far.direction() == constants::WORLD_BACKWARD ); REQUIRE( translated_backwards.far.distance() == -( constants::FAR_PLANE - 1.0f ) ); // The distance for the far plane should be negative. Due to the fact diff --git a/tests/src/RotationTests.cpp b/tests/src/TransformTests.cpp similarity index 96% rename from tests/src/RotationTests.cpp rename to tests/src/TransformTests.cpp index cb90c41..e12895b 100644 --- a/tests/src/RotationTests.cpp +++ b/tests/src/TransformTests.cpp @@ -9,12 +9,6 @@ using namespace fgl::engine; -std::ostream& operator<<( std::ostream& os, const glm::vec3 vec ) -{ - os << "X: " << vec.x << " Y: " << vec.y << " Z: " << vec.z; - return os; -} - TEST_CASE( "Transform", "[transform][rotation][translation]" ) { TransformComponent component; diff --git a/tests/src/gtest_printers.hpp b/tests/src/gtest_printers.hpp index 4d08b29..eb2d247 100644 --- a/tests/src/gtest_printers.hpp +++ b/tests/src/gtest_printers.hpp @@ -4,19 +4,17 @@ #pragma once -namespace glm -{ - inline void PrintTo( const glm::vec3& vec, ::std::ostream* os ) - { - *os << "(" << vec.x << "," << vec.y << "," << vec.z << ")"; - } +#include -} // namespace glm +#define GLM_ENABLE_EXPERIMENTAL +#include -namespace fgl::engine +namespace Catch { - inline void PrintTo( const Vector& vec, ::std::ostream* os ) + template <> + struct StringMaker< const glm::vec3 > { - glm::PrintTo( static_cast< glm::vec3 >( vec ), os ); - } -} // namespace fgl::engine + static std::string convert( glm::vec3 const & val ) { return glm::to_string( val ); } + }; + +} // namespace Catch