mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-18 15:23:26 +00:00
clarified interfaces
This commit is contained in:
@@ -318,22 +318,22 @@ int main()
|
||||
glfwPollEvents();
|
||||
omath::Vector3<float> move_dir;
|
||||
if (glfwGetKey(window, GLFW_KEY_W))
|
||||
move_dir += camera.get_forward();
|
||||
move_dir += camera.get_abs_forward();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_A))
|
||||
move_dir -= camera.get_right();
|
||||
move_dir -= camera.get_abs_right();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_S))
|
||||
move_dir -= camera.get_forward();
|
||||
move_dir -= camera.get_abs_forward();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_D))
|
||||
move_dir += camera.get_right();
|
||||
move_dir += camera.get_abs_right();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_SPACE))
|
||||
move_dir += camera.get_up();
|
||||
move_dir += camera.get_abs_up();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL))
|
||||
move_dir -= camera.get_up();
|
||||
move_dir -= camera.get_abs_up();
|
||||
|
||||
|
||||
auto delta = glfwGetTime() - old_mouse_time;
|
||||
|
||||
@@ -127,9 +127,6 @@ namespace omath::projection
|
||||
Vector3<float> get_forward() const noexcept
|
||||
{
|
||||
const auto& view_matrix = get_view_matrix();
|
||||
|
||||
if constexpr (axes.inverted_forward)
|
||||
return -Vector3<float>{view_matrix[2, 0], view_matrix[2, 1], view_matrix[2, 2]};
|
||||
return {view_matrix[2, 0], view_matrix[2, 1], view_matrix[2, 2]};
|
||||
}
|
||||
|
||||
@@ -137,8 +134,6 @@ namespace omath::projection
|
||||
Vector3<float> get_right() const noexcept
|
||||
{
|
||||
const auto& view_matrix = get_view_matrix();
|
||||
if constexpr (axes.inverted_right)
|
||||
return -Vector3<float>{view_matrix[0, 0], view_matrix[0, 1], view_matrix[0, 2]};
|
||||
return {view_matrix[0, 0], view_matrix[0, 1], view_matrix[0, 2]};
|
||||
}
|
||||
|
||||
@@ -148,6 +143,27 @@ namespace omath::projection
|
||||
const auto& view_matrix = get_view_matrix();
|
||||
return {view_matrix[1, 0], view_matrix[1, 1], view_matrix[1, 2]};
|
||||
}
|
||||
[[nodiscard]]
|
||||
Vector3<float> get_abs_forward() const noexcept
|
||||
{
|
||||
if constexpr (axes.inverted_forward)
|
||||
return -get_forward();
|
||||
return get_forward();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> get_abs_right() const noexcept
|
||||
{
|
||||
if constexpr (axes.inverted_right)
|
||||
return -get_right();
|
||||
return get_right();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Vector3<float> get_abs_up() const noexcept
|
||||
{
|
||||
return get_up();
|
||||
}
|
||||
|
||||
[[nodiscard]] const Mat4X4Type& get_view_projection_matrix() const noexcept
|
||||
{
|
||||
|
||||
@@ -793,9 +793,9 @@ TEST(UnitTestProjection, SourceEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::source_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::source_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::source_engine::k_abs_forward.y, k_eps);
|
||||
@@ -815,9 +815,9 @@ TEST(UnitTestProjection, UnityEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::unity_engine::Camera({}, {}, {1280.f, 720.f},
|
||||
omath::projection::FieldOfView::from_degrees(60.f), 0.03f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::unity_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::unity_engine::k_abs_forward.y, k_eps);
|
||||
@@ -837,9 +837,9 @@ TEST(UnitTestProjection, OpenGLEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::opengl_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::opengl_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::opengl_engine::k_abs_forward.y, k_eps);
|
||||
@@ -859,9 +859,9 @@ TEST(UnitTestProjection, UnrealEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::unreal_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::unreal_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::unreal_engine::k_abs_forward.y, k_eps);
|
||||
@@ -881,9 +881,9 @@ TEST(UnitTestProjection, FrostbiteEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::frostbite_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::frostbite_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::frostbite_engine::k_abs_forward.y, k_eps);
|
||||
@@ -903,9 +903,9 @@ TEST(UnitTestProjection, CryEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::cry_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::cry_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::cry_engine::k_abs_forward.y, k_eps);
|
||||
@@ -925,9 +925,9 @@ TEST(UnitTestProjection, IWEngine_ZeroAngles_BasisVectors)
|
||||
constexpr float k_eps = 1e-5f;
|
||||
const auto cam = omath::iw_engine::Camera({}, {}, {1920.f, 1080.f},
|
||||
omath::projection::FieldOfView::from_degrees(90.f), 0.01f, 1000.f);
|
||||
const auto fwd = cam.get_forward();
|
||||
const auto right = cam.get_right();
|
||||
const auto up = cam.get_up();
|
||||
const auto fwd = cam.get_abs_forward();
|
||||
const auto right = cam.get_abs_right();
|
||||
const auto up = cam.get_abs_up();
|
||||
|
||||
EXPECT_NEAR(fwd.x, omath::iw_engine::k_abs_forward.x, k_eps);
|
||||
EXPECT_NEAR(fwd.y, omath::iw_engine::k_abs_forward.y, k_eps);
|
||||
|
||||
Reference in New Issue
Block a user