refactored tests

This commit is contained in:
2024-11-27 19:36:28 +03:00
parent 480d11dbc0
commit 6a9a51b39c
19 changed files with 55 additions and 26 deletions

View File

@@ -12,13 +12,25 @@ namespace omath::opengl
constexpr Vector3 kAbsRight = {1, 0, 0}; constexpr Vector3 kAbsRight = {1, 0, 0};
constexpr Vector3 kAbsForward = {0, 0, -1}; constexpr Vector3 kAbsForward = {0, 0, -1};
template<class Type> requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix()
{
template<class Type = float>
requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> ViewMatrix(const Vector3& forward,
const Vector3& right,
const Vector3& up,
const Vector3& cam_origin)
{
return
{
{right.x, up.x, -forward.x, 0},
{right.y, up.y, -forward.y, 0},
{right.z, up.z, -forward.z, 0},
{-cam_origin.x, -cam_origin.y, -cam_origin.z, 1},
};
} }
template<class Type> requires std::is_floating_point_v<Type> || std::is_integral_v<Type> template<class Type>
requires std::is_floating_point_v<Type> || std::is_integral_v<Type>
[[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix( [[nodiscard]] Mat<4, 4, Type, MatStoreType::COLUMN_MAJOR> PerspectiveProjectionMatrix(
const float fieldOfView, const Type& aspectRatio, const Type& near, const Type& far) const float fieldOfView, const Type& aspectRatio, const Type& near, const Type& far)
{ {

View File

@@ -2,7 +2,8 @@
// Created by Orange on 11/24/2024. // Created by Orange on 11/24/2024.
// //
#pragma once #pragma once
#include "omath/Vector3.hpp"
#include "omath/Mat.hpp"
namespace omath::source namespace omath::source
{ {

View File

@@ -0,0 +1,12 @@
//
// Created by Orange on 11/27/2024.
//
#pragma once
#include <omath/Vector3.hpp>
namespace omath::unity
{
};

View File

@@ -7,7 +7,6 @@
#include <expected> #include <expected>
#include <omath/Vector3.hpp> #include <omath/Vector3.hpp>
#include <omath/Mat.hpp> #include <omath/Mat.hpp>
#include <string_view>
#include "ErrorCodes.hpp" #include "ErrorCodes.hpp"

View File

@@ -3,10 +3,6 @@
// //
#include "omath/projection/Camera.hpp" #include "omath/projection/Camera.hpp"
#include <complex>
#include "omath/Angles.hpp"
namespace omath::projection namespace omath::projection
{ {

View File

@@ -5,17 +5,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
include(GoogleTest) include(GoogleTest)
add_executable(unit-tests add_executable(unit-tests
UnitTestPrediction.cpp general/UnitTestPrediction.cpp
UnitTestMatrix.cpp general/UnitTestMatrix.cpp
UnitTestMat.cpp general/UnitTestMat.cpp
UnitTestAstar.cpp general/UnitTestAstar.cpp
UnitTestProjection.cpp general/UnitTestProjection.cpp
UnitTestVector3.cpp general/UnitTestVector3.cpp
UnitTestVector2.cpp general/UnitTestVector2.cpp
UnitTestColor.cpp general/UnitTestColor.cpp
UnitTestVector4.cpp general/UnitTestVector4.cpp
UnitTestLineTrace.cpp general/UnitTestLineTrace.cpp
UnitTestOpenGL.cpp
engines/UnitTestOpenGL.cpp
engines/UnitTestUnityEngine.cpp
engines/UnitTestSourceEngine.cpp
) )
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm) target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm)

View File

@@ -38,11 +38,11 @@ TEST(UnitTestOpenGL, Projection)
} }
TEST(UnitTestOpenGL, Projection2) TEST(UnitTestOpenGL, Projection2)
{ {
const auto orient = omath::Mat<>::OrientationMat(omath::opengl::kAbsForward, omath::opengl::kAbsRight, omath::opengl::kAbsUp); const auto orient = omath::opengl::ViewMatrix(omath::opengl::kAbsForward, -omath::opengl::kAbsRight, omath::opengl::kAbsUp, {});
const omath::Mat<4, 1> cords_omath = const omath::Mat<4, 1,float, omath::MatStoreType::COLUMN_MAJOR> cords_omath =
{ {
{0}, {0}, {10}, {1} {0}, {0}, {-10}, {1}
}; };
std::cout << (orient.Transposed() * cords_omath).ToString(); std::cout << (orient * cords_omath).ToString();
} }

View File

@@ -0,0 +1,3 @@
//
// Created by Orange on 11/27/2024.
//

View File

@@ -0,0 +1,3 @@
//
// Created by Orange on 11/27/2024.
//