Skip to content

Add a dedicated editor for Camera2D limits #104190

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

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Mar 15, 2025

This improves #101427 by replacing default rect edit with a dedicated editor (and also fixes multiple Camera2DEditor bugs). The main benefit is that camera is no longer selected when clicking within it's limit rectangle.
In a separate commit I added functionality for overriding 2D editor's cursor, which makes the editor much more friendly.

SMIOycIWKf.mp4

We could apply it to other existing editors, e.g. CollisionShape2D editor.

Closes #105077
Fixes #107409

@arkology
Copy link
Contributor

Limit rect will reduce itself after moving it for a while.

godot.windows.editor.x86_64_Kox7Zfedi7.mp4

@KoBeWi
Copy link
Member Author

KoBeWi commented Mar 19, 2025

set_limit_rect() and get_limit_rect() use Rect2, while the limits are int 🤦‍♂️
At least they are not exposed, so I can change it.

Fixed.

@KoBeWi KoBeWi force-pushed the edit_your_limits branch 2 times, most recently from 4778d06 to a9b9b89 Compare March 19, 2025 14:48
@arkology
Copy link
Contributor

Confirm that PR fixes both issues mentioned in #101427 (comment).

Some suggestions:

  • Allow limit rect corners selection to enable diagonal resizing.
  • Allow selecting nodes inside limit rect in "Select Mode". With this it will be possible to select nodes (including camera itself) as expected and to move limit rect. But maybe it may cause any kind of problems and is not worth it.

godot windows editor x86_64_h5BYdbxLIw

@KoBeWi
Copy link
Member Author

KoBeWi commented Mar 20, 2025

Allow selecting nodes inside limit rect in "Select Mode". With this it will be possible to select nodes (including camera itself) as expected and to move limit rect. But maybe it may cause any kind of problems and is not worth it.

It's not (easily) possible to move both limit rect and other nodes, because they are handled by 2 different editors.

@arkology
Copy link
Contributor

arkology commented Mar 20, 2025

Sorry, I didn't mean to move both limit rect and other nodes at the same time.
About selecting already selected camera to move camera itself while hovering over its position - got it.
As you can see from gif above, when camera2d is selected and mouse is inside limit rect it blocks selection of other nodes (but it still shows panel with nodes at this position on hover , CollisionShape2D in my case).

@KoBeWi
Copy link
Member Author

KoBeWi commented Mar 24, 2025

Well the problem is the same as mentioned. I'd need Camera2D editor to check for nodes under cursor, because it's handled by the 2D editor and other editors don't have access to that information. Although selecting might interfere with dragging if you click something by accident. And another thing are nodes selectable as rectangle instead of point; they can cover a bigger portion of camera's limit rect, making accidental selection even easier.

I could accept motion events to (possibly) fix the issue with hover labels, but not sure if it's a good idea.

@beicause
Copy link
Contributor

beicause commented May 11, 2025

What is the status of this PR? I still got crash when reloading a scene with Camera2D in master branch, and also this issue #105077.

Copy link
Contributor

@kitbdev kitbdev left a comment

Choose a reason for hiding this comment

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

When the limit rect is enabled, it defaults to a high value for each so you cannot see the limits. There is no background color for it either, so it is not visibile in the 2d editor until the limits are changed. This is fine and you may not want to set all 4 to be in visible range. The issue is clicking inside of the limit rect it only moves it and other nodes cannot be selected, which by default will be everything in your scene.
So, I think the limits should only be movable from the edges, its fine to only allow moving the limits individually IMO. Diagonal dragging would help too. This way we can just return false in gui_input and allow other nodes to be selected.

Changing the limits in the inspector when typing or using the up down arrows doesn't update the limits in the 2d editor until it is redrawn.

Edit: Also this fixes #107409

@KoBeWi KoBeWi force-pushed the edit_your_limits branch from 896f140 to 1d697cf Compare June 12, 2025 11:55
@KoBeWi KoBeWi force-pushed the edit_your_limits branch from 1d697cf to efbc5aa Compare June 12, 2025 12:00
@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 12, 2025

Fixed limits not redrawing from the inspector.

I commented out center dragging, I plan to revisit it later. I think it would be fine to allow it if any limit edge is visible in the viewport. That would require more changes, so I'll improve it in a follow-up. Same with corner dragging.

@akien-mga akien-mga merged commit 9ef04f8 into godotengine:master Jun 12, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the edit_your_limits branch June 12, 2025 23:43
@Lazy-Rabbit-2001
Copy link
Contributor

Thanks for hard working :D

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