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

Add Camera3D preview in Inspector #90778

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Conversation

timothyqiu
Copy link
Member

@timothyqiu timothyqiu commented Apr 17, 2024

An alternate solution for godotengine/godot-proposals#1017

Peek.2024-04-17.09-53.mp4

The main problem to solve is that cameras can't be transformed (inside the 3D viewport) when in preview mode. Turning split viewports on and off for a temporary operation is tedious.

Previewing in the inspector is almost the same as using picture-in-picture. But keeps UI the same as other texture previews.

@JekSun97
Copy link
Contributor

We've been waiting for this PR, and it's finally here! :)

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

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

Really cool approach to enable viewing a camera preview without splitting the viewport.

editor/plugins/camera_3d_editor_plugin.cpp Outdated Show resolved Hide resolved
}

bool EditorInspectorPluginCamera3DPreview::can_handle(Object *p_object) {
return Object::cast_to<Camera3D>(p_object) != nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to collapse the preview or toggle it on and off?
For example, I might be editing on mobile and don't want the performance overhead of rendering an additional camera at its full resolution.
Or, perhaps I know what I want to edit and wish to reduce visual noise on the inspector so I can more easily find other properties.

Copy link
Member

Choose a reason for hiding this comment

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

This should be handled in TexturePreview code.

editor/plugins/camera_3d_editor_plugin.cpp Show resolved Hide resolved
@akien-mga
Copy link
Member

I think one use case covered by the picture-in-picture approach as implemented in https://twitter.com/anthonyec/status/1747254280518865349 is that you can pin the preview, and do operations on other nodes in the tree.

With the preview in the inspector, aren't we limited to seeing it only when the Camera3D is selected in the scene tree?

@timothyqiu
Copy link
Member Author

With the preview in the inspector, aren't we limited to seeing it only when the Camera3D is selected in the scene tree?

Yeah, that's the limitation. Feature wise, I think it's the same as spliting the viewport and checking "Preview".

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of master 557f63d), it works as expected in all rendering methods.

I'd like to be able to resize the preview vertically (so it can be made larger/smaller depending on dock width), but this isn't essential for a first iteration of the feature.

@passivestar
Copy link
Contributor

passivestar commented Oct 6, 2024

Tested (didn't rebase), works mostly as expected

There's a small problem when the camera is first selected the preview isn't immediately rendered and it needs something to happen that refreshes the UI (I assume):

pv.mp4

Instead of using preview in the viewport I usually use Align Transform With View on cameras, but the inspector preview could be convenient to quickly check the frame with the camera FOV

Btw speaking of Align Transform With View it needs to have the default shortcut fixed: #94026

@JekSun97
Copy link
Contributor

I think we can try to add this to 4.4 dev, for general testing

@Repiteo Repiteo modified the milestones: 4.x, 4.4 Nov 22, 2024
@Repiteo Repiteo merged commit 30ab612 into godotengine:master Nov 27, 2024
16 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 27, 2024

Thanks!

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.

8 participants