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

Camera Overhaul #1881

Closed

Conversation

DragonMoffon
Copy link
Contributor

@DragonMoffon DragonMoffon commented Aug 15, 2023

There are a few issues with the current camera system in arcade. Mainly it only supports a 2D orthographic camera with limited zoom and rotation functionality. This refactor aims to create a new system that allows users to easily make fully 3D orthographic or perspective cameras which are easy to use and create custom functionality for.

The refactor aims to be mostly backwards-compatible with the previously implemented SImpleCamera and Camera.

The refactor includes:
A ViewData PoD that holds all of the information needed to make a view matrix and set the viewport.
Two ProjectionData PoDs hold the data for making either an orthographic or projection matrix.

The Projection Protocol to link the ProjectionData PoDs together (may be removed as it is unnecessary)
The Projector Protocol defines any object that provides the Use, Activate, and get_map_coordinates (may be renamed) methods.
The Camera Protocol defines an object which holds both a ViewData PoD and a ProjectionProtocol Object.

The OrthographicCamera class uses the ViewData and OrthographicProjectionData PoDs to provide an easy way to create and use an orthographic projection matrix, but it alone does not provide ways of controlling the camera.
The PersepctiveCamera class is the same as the OrthographicCamera class, except it uses the PerspectiveProjectionData PoD.

It provides a backwards-compatible SimpleCamera class implementation with the same methods.
The Camera2D class provides a simple interface to control nearly every camera aspect and will be what 99% of arcade users will need. It does not provide animations or any other similar logic but provides easy properties and methods for setting the different variables that are used by the camera. The only clamps on control are lack of access to the forward vector and only accepting 2D vectors.

The DefaultProjector class is provided to have a base camera only to be used internally by Arcade. This class is designed to be used as the default "current_camera". This is because of a significant bug currently plaguing Arcade. If the user has never used a Camera and they try to use a camera as a context manager, the current camera will be equal to None and cause a crash.

See Issue #1853 for more details

DragonMoffon and others added 30 commits June 10, 2023 12:45
…nds, and Scenes.

See the
#Possible Scene Improvements
#Cameras
topics in the arcade-dev forum on the Python Arcade discord server.
…s, and started the Camera2DController, and SimpleCamera classes.

See the
#Possible Scene Improvements
#Cameras
topics in the arcade-dev forum on the Python Arcade discord server for more info.
…. Created basic Perspective and Orthographic Cameras.

See the
#Possible Scene Improvements
#Cameras
topics in the arcade-dev forum on the Python Arcade discord server for more info.
…This has been fixed and applied to both of the base cameras. Added a new get map coordinates function (open to change). Placed framework for backwards compatible simple camera.

See the
#Possible Scene Improvements
#Cameras
topics in the arcade-dev forum on the Python Arcade discord server for more info.
Finished Simple Camera. Is backwards compatible with current Simple Camera implementation.
Cleaning up PR to only include camera refactor
Moved experimental code into new "cinematic" folder within arcade.

Also made the default camera in arcade the "DefaultCamera" class. and made it's type be "Projector"
Created files for unit tests, and wrote a few.

Started work on Camera2D (replacement for simple camera)
The basics for Camera2D have been provided with full doc strings. Other helper methods may be added in the future.
Fixed `mypy`, `pyright`, `ruff` errors.

Also added __all__ property to every file
for a better importing experience.

NOTE arcade/camera.py is still there, and it does not match the current system so the code-inspection still complains. Will resolve later.
This included deleting `arcade/camera.py`, and fixing the ui and sections to use either the Default Ortho Projector.

NOTE I removed a quick index to the `camera.rst`. That will need to be fixed.

Hey look I linted before pushing for once!
Made a few function controllers which are mega simple.

Also changed name from arcade.cinematic to arcade.camera.

Also moved the controllers to arcade.camera.controllers.
when I changed the file name it didn't update any imports tsk tsk.
Have not setup camera documentation so removing old ref.

DO NOT PULL PR UNTIL FIXED.
NOTE this is a quick fix. It removed shaking from two examples. CANNOT BE PULLED IN WHILE THIS IS UNRESOLVED.

Weirdly the linters didn't pick up on these errors
DragonMoffon and others added 6 commits August 7, 2023 03:04
setup lerp, quadratic, cubic, b-spline

Contemplating how to do spline controller
Removed Splines
Made Isometric Controller
Fixed small issue with facing direction
doing temp rendering test so don't mind `log.png`
Added 'nother default glsl shader. Also cleaned up some linting.
@DragonMoffon
Copy link
Contributor Author

DragonMoffon commented Aug 15, 2023

@cspotcode Sorry you're going to have to add me as an assignee again.

DragonMoffon and others added 4 commits August 18, 2023 05:19
commit 7d56d39
Author: DragonMoffon <happydog.aja@gmail.com>
Date:   Fri Aug 18 05:16:55 2023 +1200

    Created a camera shake class

    Created a camera shake class. It isn't exactly like the shake provided before so people might what to have a review.
NOTE: The doc strings aren't useless. The code just is. Going to completely change the class.
@cspotcode cspotcode linked an issue Aug 19, 2023 that may be closed by this pull request
35 tasks
@pushfoo
Copy link
Member

pushfoo commented Sep 6, 2023

Are you ok with me making PRs into this branch at some point?

@DragonMoffon
Copy link
Contributor Author

@pushfoo go right ahead

@pushfoo
Copy link
Member

pushfoo commented Sep 9, 2023

I'll do so as time allows. Don't worry about overwriting my changes. I'll try to keep them to technical information only and will do more final grammar / formatting at a later point.

I'm also wondering if we should try to break this thing into chunks. I'm not sure how to do that yet, but it would make merging and reviewing it easier if we could.

@pushfoo
Copy link
Member

pushfoo commented Sep 11, 2023

@DragonMoffon would it be a good idea to mark this as WIP for now?

@DragonMoffon
Copy link
Contributor Author

@pushfoo Id rather we took the unstable stuff out and put that into WIP. I really want the core work pulled so people can test it in actual use cases.

@DragonMoffon
Copy link
Contributor Author

I'm splitting the PR so the stable work can be pulled. Will make into another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete Camera Overhaul
2 participants