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

Improve editor state initialization #75563

Merged
merged 1 commit into from
Apr 3, 2023
Merged

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Apr 1, 2023

When opening some scene for the first time, the current editor state was leaking into the new scene. This PR ensures that editors call clear() when the scene has no stored state.

It also implements clear() for 2D editor, which resets position and zoom. If fixes an issue where opening some scene could lead to the scene being out of view.

Before

godot.windows.editor.dev.x86_64_aDSn0UJCwk.mp4

After

godot.windows.editor.dev.x86_64_4eurctyyP9.mp4

(other 2D state elements are handled by #74682)

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 1, 2023

I also changed the default view offset. Previously it was some arbitrary value, now it's centered in the viewport. I pushed it in separate commit for now, because not sure if it's a wanted change.

@akien-mga
Copy link
Member

akien-mga commented Apr 3, 2023

I also changed the default view offset. Previously it was some arbitrary value, now it's centered in the viewport. I pushed it in separate commit for now, because not sure if it's a wanted change.

The underlying idea for the arbitrary offset is that in 2D, your scene "area" will often range from (0, 0) to a point in the (X+, Y+) quadrant.

For example the main scene's root viewport / camera:

image

image

On the other hand it's true that for props/characters/etc., you'd typically have them centered on the origin, in which case the default offset isn't the best:

image

But it's hard to find a balance that fits both types of scenes IMO.

I think it used to be centered in some earlier versions of Godot (2.x maybe?), and I always had to scroll, as the default scroll would basically have the left and top halves of the viewport empty.

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 3, 2023

I'll revert that change for now and we'll see if it's really a problem.

@akien-mga akien-mga merged commit 5fbbe3b into godotengine:master Apr 3, 2023
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the sanity branch April 3, 2023 15:26
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.0.3.

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

Successfully merging this pull request may close these issues.

3 participants