Skip to content

Commit

Permalink
Remove unneeded copy and cast in "camera.cpp"
Browse files Browse the repository at this point in the history
A leftover copy of the `Sizef` variable `m_screen_size` was left in.
Additionally, an unneeded `static_cast<float>` was removed, since `m_screen_size` only contains `float` values.
  • Loading branch information
Vankata453 committed Sep 2, 2023
1 parent ff4dbe3 commit eee2cf8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/object/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Camera::keep_in_bounds(Vector& translation_)
if (m_mode == Mode::MANUAL)
{
// Determines the difference between normal and scaled translation.
const Vector scale_factor = (Sizef(m_screen_size).as_vector() * (get_current_scale() - 1.f)) / 2.f;
const Vector scale_factor = (m_screen_size.as_vector() * (get_current_scale() - 1.f)) / 2.f;

// Keep the translation's scaled position in sector bounds.
translation_.x = math::clamp(translation_.x + scale_factor.x, 0.0f, width - m_screen_size.width);
Expand Down Expand Up @@ -549,7 +549,7 @@ Camera::update_scroll_normal(float dt_sec)
target_y = player.m_last_ground_y + player.get_bbox().get_height();
else
target_y = player.get_bbox().get_bottom();
target_y -= static_cast<float>(m_screen_size.height) * config_.target_y;
target_y -= m_screen_size.height * config_.target_y;

// delta_y is the distance we'd have to travel to directly reach target_y.
float delta_y = m_cached_translation.y - target_y;
Expand Down

0 comments on commit eee2cf8

Please sign in to comment.