mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-26 01:23:27 +00:00
updated for unreal
This commit is contained in:
@@ -499,10 +499,11 @@ TEST(NDCDepthRangeTests, CryEngine_BothDepthRanges)
|
||||
// ── Verify Z mapping for ZERO_TO_ONE across all engines ─────────────────────
|
||||
|
||||
// Helper: projects a point at given z through a left-handed projection matrix and returns NDC z
|
||||
static float project_z_lh(const Mat<4, 4>& proj, float z)
|
||||
template<class Type = float, MatStoreType Store = MatStoreType::ROW_MAJOR>
|
||||
static float project_z_lh(const Mat<4, 4, Type, Store>& proj, float z)
|
||||
{
|
||||
auto clip = proj * mat_column_from_vector<float>({0, 0, z});
|
||||
return clip.at(2, 0) / clip.at(3, 0);
|
||||
auto clip = proj * mat_column_from_vector<Type, Store>({0, 0, static_cast<Type>(z)});
|
||||
return static_cast<float>(clip.at(2, 0) / clip.at(3, 0));
|
||||
}
|
||||
|
||||
TEST(NDCDepthRangeTests, Source_ZeroToOne_ZRange)
|
||||
|
||||
@@ -111,7 +111,7 @@ TEST(unit_test_unreal_engine, CameraSetAndGetOrigin)
|
||||
{
|
||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
|
||||
|
||||
EXPECT_EQ(cam.get_origin(), omath::Vector3<float>{});
|
||||
EXPECT_EQ(cam.get_origin(), omath::Vector3<double>{});
|
||||
cam.set_field_of_view(omath::projection::FieldOfView::from_degrees(50.f));
|
||||
|
||||
EXPECT_EQ(cam.get_field_of_view().as_degrees(), 50.f);
|
||||
@@ -129,7 +129,7 @@ TEST(unit_test_unreal_engine, loook_at_random_all_axis)
|
||||
std::size_t failed_points = 0;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
||||
const auto position_to_look = omath::Vector3<double>{dist(gen), dist(gen), dist(gen)};
|
||||
|
||||
if (cam.get_origin().distance_to(position_to_look) < 10)
|
||||
continue;
|
||||
@@ -151,7 +151,7 @@ TEST(unit_test_unreal_engine, loook_at_random_all_axis)
|
||||
TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
||||
{
|
||||
std::mt19937 gen(std::random_device{}()); // Seed with a non-deterministic source
|
||||
std::uniform_real_distribution<float> dist(-1000.f, 1000.f);
|
||||
std::uniform_real_distribution<double> dist(-1000.f, 1000.f);
|
||||
|
||||
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
|
||||
auto cam = omath::unreal_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.001f, 10000.f);
|
||||
@@ -159,7 +159,7 @@ TEST(unit_test_unreal_engine, loook_at_random_x_axis)
|
||||
std::size_t failed_points = 0;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
const auto position_to_look = omath::Vector3<float>{dist(gen), dist(gen), dist(gen)};
|
||||
const auto position_to_look = omath::Vector3<double>{dist(gen), dist(gen), dist(gen)};
|
||||
|
||||
if (cam.get_origin().distance_to(position_to_look) < 10)
|
||||
continue;
|
||||
@@ -190,7 +190,7 @@ TEST(unit_test_unreal_engine, loook_at_random_y_axis)
|
||||
std::size_t failed_points = 0;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
const auto position_to_look = omath::Vector3<float>{0.f, dist(gen), 0.f};
|
||||
const auto position_to_look = omath::Vector3<double>{0.f, dist(gen), 0.f};
|
||||
|
||||
if (cam.get_origin().distance_to(position_to_look) < 10)
|
||||
continue;
|
||||
@@ -221,7 +221,7 @@ TEST(unit_test_unreal_engine, loook_at_random_z_axis)
|
||||
std::size_t failed_points = 0;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
const auto position_to_look = omath::Vector3<float>{0.f, 0.f, dist(gen)};
|
||||
const auto position_to_look = omath::Vector3<double>{0.f, 0.f, dist(gen)};
|
||||
|
||||
if (cam.get_origin().distance_to(position_to_look) < 10)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user