Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boundaries for camera movement #1682

Open
4 tasks
heinezen opened this issue Aug 25, 2024 · 0 comments · May be fixed by #1691
Open
4 tasks

Boundaries for camera movement #1682

heinezen opened this issue Aug 25, 2024 · 0 comments · May be fixed by #1691
Labels
area: renderer Concerns our graphics renderer good first issue Suitable for newcomers hacktoberfest For newcomers from Hacktoberfest event improvement Enhancement of an existing component just do it You can start working on this, there should be nothing left to discuss lang: c++ Done in C++ code

Comments

@heinezen
Copy link
Member

heinezen commented Aug 25, 2024

Required Skills: C++

Difficulty: Medium

Currently, we let the camera move freely in the scene. This can result in the camera accidently moving away from the visible map terrain. It would be better if we could set the boundaries of the camera movement according to the current size of the map, so that the camera can't be moved outside of the play area. This should be implemented for the CameraManager and not for the camera class itself!

Tasks:

  • Add 4 boundary values using the float type to the CameraManager class. For testing purposes, you can hardcode these 4 positions at the start:
    • south west: 12.25f (min x axis coordinate)
    • south east: 32.25f (max x axis coordinate)
    • north west: 12.25f (max z axis corrdinate)
    • north east: -8.25f (min z axis coordinate)
  • Check if the camera position is within those boundaries when the camera is moved by the camera manager. If the camera is moved outside of the boundaries, the value should be clamped to the respective min and max values. You can use std::clamp for this purpose.
  • Set the camera boundaries during initialization of the camera manager (you may use hardcoded values).

    Note that the position the camera is at is different from the position the camera looks at! When we want to set boundaries, we usually want to set boundaries based on what the camera can look at. However this also means that we have to convert look-at coordinates to is-at (camera position) first. You can check how the camera dies this by checking out the Camera::look_at_scene(..) method.
  • (optional; Difficulty: High) Set the camera boundaries from the game simulation using the map size. This requires you to pass the map size across thread boundaries, so you need to understand the C++ thread model.

Further Reading

@heinezen heinezen added improvement Enhancement of an existing component area: renderer Concerns our graphics renderer lang: c++ Done in C++ code good first issue Suitable for newcomers just do it You can start working on this, there should be nothing left to discuss labels Aug 25, 2024
@heinezen heinezen added the hacktoberfest For newcomers from Hacktoberfest event label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: renderer Concerns our graphics renderer good first issue Suitable for newcomers hacktoberfest For newcomers from Hacktoberfest event improvement Enhancement of an existing component just do it You can start working on this, there should be nothing left to discuss lang: c++ Done in C++ code
Projects
Status: renderer
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant