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

Remove OrthographicProjection.scale (adopted) #15075

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

richchurcher
Copy link
Contributor

@richchurcher richchurcher commented Sep 7, 2024

Objective

Hello! I am adopting #11022 to resolve conflicts with main. tldr: this removes scale in favour of scaling_mode. Please see the original PR for explanation/discussion.

Also relates to #2580.

Migration Guide

Replace all uses of scale with scaling_mode, keeping in mind that scale is (was) a multiplier. For example, replace

    scale: 2.0,
    scaling_mode: ScalingMode::FixedHorizontal(4.0),

with

    scaling_mode: ScalingMode::FixedHorizontal(8.0),

@richchurcher
Copy link
Contributor Author

Just workin' through the CI failures now...

@@ -176,6 +177,6 @@ fn fit_canvas(
let h_scale = event.width / RES_WIDTH as f32;
let v_scale = event.height / RES_HEIGHT as f32;
let mut projection = projections.single_mut();
projection.scale = 1. / h_scale.min(v_scale).round();
projection.scaling_mode = ScalingMode::WindowSize(h_scale.min(v_scale).round());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this appears to produce the same behaviour as the existing example, though if there's a simpler method I haven't seen that's great too!

@richchurcher
Copy link
Contributor Author

...and now I know -p ci example-check is a thing!

@richchurcher richchurcher changed the title Remove OrthographicProjection.scale Remove OrthographicProjection.scale (adopted) Sep 7, 2024
@IQuick143 IQuick143 added A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Sep 7, 2024
Copy link
Contributor

github-actions bot commented Sep 7, 2024

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

Comment on lines -376 to -379
/// Note: scaling can be set by [`scaling_mode`](Self::scaling_mode) as well.
/// This parameter scales on top of that.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it pretty easy to scale multiple variants of ScalingMode since you can just modify a single f32. Are we at all concerned about hurting ergonomics?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not particularly; projects will only need to handle this once, and the majority of projects will have a single scaling mode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also run into a few people now who miss the existence of ScalingMode because of scale, leading them to ask questions. In this way, I think it's hurting them by not just making them think up front about how the camera should be configured.

@tychedelia tychedelia added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 8, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 9, 2024
@alice-i-cecile
Copy link
Member

@richchurcher let me know when merge conflicts are resolved and I'll get this in for you :)

github-merge-queue bot pushed a commit that referenced this pull request Sep 9, 2024
# Objective

Add examples for zooming (and orbiting) orthographic and perspective
cameras.

I'm pretty green with 3D, so please treat with suspicion! I note that
if/when #15075 is merged, `.scale` will go away so this example uses
`.scaling_mode`.

Closes #2580

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
@richchurcher
Copy link
Contributor Author

@alice-i-cecile I think we should be good now!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 9, 2024
Merged via the queue into bevyengine:main with commit f326705 Sep 9, 2024
26 checks passed
@richchurcher richchurcher deleted the orth-proj-scale branch September 9, 2024 22:57
github-merge-queue bot pushed a commit that referenced this pull request Sep 9, 2024
# Objective

Add examples for zooming (and orbiting) orthographic and perspective
cameras.

I'm pretty green with 3D, so please treat with suspicion! I note that
if/when #15075 is merged, `.scale` will go away so this example uses
`.scaling_mode`.

Closes #2580
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants