Skip to content

Commit

Permalink
Accounting for FOV in orbit_camera::calculate_lateral_speed
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesugb committed Jun 3, 2023
1 parent 3383bb2 commit 587c713
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(avk_toolkit_Sources
auto_vk_toolkit/src/orca_scene.cpp
auto_vk_toolkit/src/quadratic_uniform_b_spline.cpp
auto_vk_toolkit/src/quake_camera.cpp
auto_vk_toolkit/src/orbit_camera.cpp
auto_vk_toolkit/src/swapchain_resized_event.cpp
auto_vk_toolkit/src/transform.cpp
auto_vk_toolkit/src/timer_globals.cpp
Expand Down
10 changes: 5 additions & 5 deletions auto_vk_toolkit/src/orbit_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace avk
* ((input().key_down(key_code::left_control) || input().key_down(key_code::right_control)) ? mSlowMultiplier : 1.f);

const auto t
= down(*this) * static_cast<float>(deltaCursor.y) * latSpeed.x
= down(*this) * static_cast<float>(deltaCursor.y) * latSpeed.y
+ right(*this) * static_cast<float>(deltaCursor.x) * latSpeed.x;
translate(*this, t);
}
Expand Down Expand Up @@ -116,9 +116,9 @@ namespace avk
{
const auto* wnd = context().main_window();
auto resi = nullptr != wnd ? wnd->resolution() : glm::uvec2{1920, 1080};
mLateralSpeed = glm::vec2{
(mPivotDistance / (static_cast<float>(resi.x) * 2.f)) / near_plane_distance(),
(mPivotDistance / (static_cast<float>(resi.y) * 2.f)) / near_plane_distance()
};
mLateralSpeed = glm::vec2{ // This v accounts for different FOVs
mPivotDistance / static_cast<float>(resi.x) / (near_plane_distance() * -projection_matrix()[1][1]),
mPivotDistance / static_cast<float>(resi.x) / (near_plane_distance() * -projection_matrix()[1][1])
}; // No idea why there ^ must .x for both axes. *shrug*
}
}

0 comments on commit 587c713

Please sign in to comment.