changed code style

This commit is contained in:
2025-05-03 20:31:59 +03:00
parent be3fae63b8
commit df6d75e554
70 changed files with 1258 additions and 1312 deletions

View File

@@ -9,69 +9,69 @@
TEST(UnitTestUnityEngine, ForwardVector)
{
const auto forward = omath::unity_engine::ForwardVector({});
const auto forward = omath::unity_engine::forward_vector({});
EXPECT_EQ(forward, omath::unity_engine::kAbsForward);
EXPECT_EQ(forward, omath::unity_engine::k_abs_forward);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationYaw)
{
omath::unity_engine::ViewAngles angles;
angles.yaw = omath::unity_engine::YawAngle::FromDegrees(90.f);
angles.yaw = omath::unity_engine::YawAngle::from_degrees(90.f);
const auto forward = omath::unity_engine::ForwardVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
const auto forward = omath::unity_engine::forward_vector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::k_abs_right.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::k_abs_right.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::k_abs_right.z, 0.00001f);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationPitch)
{
omath::unity_engine::ViewAngles angles;
angles.pitch = omath::unity_engine::PitchAngle::FromDegrees(-90.f);
angles.pitch = omath::unity_engine::PitchAngle::from_degrees(-90.f);
const auto forward = omath::unity_engine::ForwardVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsUp.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsUp.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsUp.z, 0.00001f);
const auto forward = omath::unity_engine::forward_vector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::k_abs_up.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::k_abs_up.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::k_abs_up.z, 0.00001f);
}
TEST(UnitTestUnityEngine, ForwardVectorRotationRoll)
{
omath::unity_engine::ViewAngles angles;
angles.roll = omath::unity_engine::RollAngle::FromDegrees(-90.f);
angles.roll = omath::unity_engine::RollAngle::from_degrees(-90.f);
const auto forward = omath::unity_engine::UpVector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
const auto forward = omath::unity_engine::up_vector(angles);
EXPECT_NEAR(forward.x, omath::unity_engine::k_abs_right.x, 0.00001f);
EXPECT_NEAR(forward.y, omath::unity_engine::k_abs_right.y, 0.00001f);
EXPECT_NEAR(forward.z, omath::unity_engine::k_abs_right.z, 0.00001f);
}
TEST(UnitTestUnityEngine, RightVector)
{
const auto right = omath::unity_engine::RightVector({});
const auto right = omath::unity_engine::right_vector({});
EXPECT_EQ(right, omath::unity_engine::kAbsRight);
EXPECT_EQ(right, omath::unity_engine::k_abs_right);
}
TEST(UnitTestUnityEngine, UpVector)
{
const auto up = omath::unity_engine::UpVector({});
EXPECT_EQ(up, omath::unity_engine::kAbsUp);
const auto up = omath::unity_engine::up_vector({});
EXPECT_EQ(up, omath::unity_engine::k_abs_up);
}
TEST(UnitTestUnityEngine, ProjectTargetMovedFromCamera)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(60.f);
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.01f, 1000.f);
for (float distance = 0.02f; distance < 100.f; distance += 0.01f)
{
const auto projected = cam.WorldToScreen({0, 0, distance});
const auto projected = cam.world_to_screen({0, 0, distance});
EXPECT_TRUE(projected.has_value());
@@ -84,30 +84,30 @@ TEST(UnitTestUnityEngine, ProjectTargetMovedFromCamera)
}
TEST(UnitTestUnityEngine, Project)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(60.f);
constexpr auto fov = omath::projection::FieldOfView::from_degrees(60.f);
const auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1280.f, 720.f}, fov, 0.03f, 1000.f);
const auto proj = cam.WorldToScreen({5.f, 3, 10.f});
const auto proj = cam.world_to_screen({5.f, 3, 10.f});
std::println("{} {}", proj->x, proj->y);
}
TEST(UnitTestUnityEngine, CameraSetAndGetFov)
{
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
constexpr auto fov = omath::projection::FieldOfView::from_degrees(90.f);
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, fov, 0.01f, 1000.f);
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 90.f);
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
EXPECT_EQ(cam.get_field_of_view().as_degrees(), 90.f);
cam.set_field_of_view(omath::projection::FieldOfView::from_degrees(50.f));
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
EXPECT_EQ(cam.get_field_of_view().as_degrees(), 50.f);
}
TEST(UnitTestUnityEngine, CameraSetAndGetOrigin)
{
auto cam = omath::unity_engine::Camera({0, 0, 0}, {}, {1920.f, 1080.f}, {}, 0.01f, 1000.f);
EXPECT_EQ(cam.GetOrigin(), omath::Vector3<float>{});
cam.SetFieldOfView(omath::projection::FieldOfView::FromDegrees(50.f));
EXPECT_EQ(cam.get_origin(), omath::Vector3<float>{});
cam.set_field_of_view(omath::projection::FieldOfView::from_degrees(50.f));
EXPECT_EQ(cam.GetFieldOfView().AsDegrees(), 50.f);
EXPECT_EQ(cam.get_field_of_view().as_degrees(), 50.f);
}