huge improvement

This commit is contained in:
2024-12-01 03:51:40 +03:00
parent f8e7faa570
commit 46b4eb9151
17 changed files with 297 additions and 254 deletions

View File

@@ -17,6 +17,7 @@ add_executable(unit-tests
general/UnitTestLineTrace.cpp
general/UnitTestAngles.cpp
general/UnitTestViewAngles.cpp
general/UnitTestAngle.cpp
engines/UnitTestOpenGL.cpp
engines/UnitTestUnityEngine.cpp
@@ -24,6 +25,6 @@ add_executable(unit-tests
)
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath glm)
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath)
gtest_discover_tests(unit-tests)

View File

@@ -7,17 +7,17 @@
#include <print>
#include <omath/engines/OpenGL.hpp>
#include <omath/engines/Source.hpp>
#include <glm/glm.hpp>
// #include <glm/glm.hpp>
#include "glm/ext/matrix_clip_space.hpp"
#include "glm/ext/matrix_transform.hpp"
// #include "glm/ext/matrix_clip_space.hpp"
// #include "glm/ext/matrix_transform.hpp"
TEST(UnitTestOpenGL, Projection)
{
const auto proj_glm = glm::perspective(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
const auto proj_glm2 = glm::perspectiveLH_NO(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
/*const auto proj_glm = glm::perspective(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
// const auto proj_glm2 = glm::perspectiveLH_NO(glm::radians(90.f), 16.f / 9.f, 0.1f, 1000.f);
// const auto proj_omath = omath::Mat<4, 4, float, omath::MatStoreType::COLUMN_MAJOR>((const float*)&proj_glm);
// EXPECT_EQ(omath::opengl::PerspectiveProjectionMatrix(90, 16.f / 9.f, 0.1f, 1000.f), proj_omath);
@@ -34,7 +34,7 @@ TEST(UnitTestOpenGL, Projection)
//auto ndc_omath = proj_omath * cords_omath;
// ndc_omath /= ndc_omath.At(3, 0);
*/
}
TEST(UnitTestOpenGL, Projection2)
{

View File

@@ -1,3 +1,29 @@
//
// Created by Orange on 11/27/2024.
// Created by Orange on 11/23/2024.
//
#include <gtest/gtest.h>
#include <omath/engines/Source.hpp>
TEST(UnitTestSourceEngine, ForwardVector)
{
const auto forward = omath::source::ForwardVector({});
EXPECT_EQ(forward, omath::source::kAbsForward);
}
TEST(UnitTestSourceEngine, RightVector)
{
const auto right = omath::source::RightVector({});
EXPECT_EQ(right, omath::source::kAbsRight);
}
TEST(UnitTestSourceEngine, UpVector)
{
const auto up = omath::source::UpVector({});
EXPECT_EQ(up, omath::source::kAbsUp);
}

View File

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

View File

@@ -4,16 +4,15 @@
#include <complex>
#include <gtest/gtest.h>
#include <omath/Matrix.hpp>
#include <print>
#include <omath/engines/Source.hpp>
#include <omath/projection/Camera.hpp>
#include <print>
TEST(UnitTestProjection, Projection)
{
const omath::projection::Camera camera({0.f, 0.f, 0.f}, {0, 0.f, 0.f} , {1920.f, 1080.f}, 110.f, 0.375f, 5000.f, 1.335f);
auto x = omath::Angle<float, 0.f, 180.f, omath::AngleFlags::Clamped>::FromDegrees(90.f);
auto cam = omath::source::CreateCamera({-10, 0, 0}, omath::source::ViewAngles{}, {1920.f, 1080.f}, x, 0.1f, 1000.f);
const auto projected = camera.WorldToScreen({5000, 0, 0});
EXPECT_TRUE(projected.has_value());
EXPECT_EQ(projected->z, 1.f);
const auto projected = cam.WorldToScreen({10, 0, 0});
std::print("{} {} {}", projected->x, projected->y, projected->z);
}