Skip to content

Commit 2e4eb59

Browse files
Fix camera override when there is no camera in scene tree
1 parent 7b1ed52 commit 2e4eb59

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

scene/debugger/scene_debugger.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ void RuntimeNodeSelect::_root_window_input(const Ref<InputEvent> &p_event) {
13651365
}
13661366
} else if (node_select_type == NODE_TYPE_3D) {
13671367
#ifndef _3D_DISABLED
1368-
if (root->get_camera_3d() && _handle_3d_input(p_event)) {
1368+
if (_handle_3d_input(p_event)) {
13691369
return;
13701370
}
13711371
#endif // _3D_DISABLED
@@ -1865,10 +1865,6 @@ void RuntimeNodeSelect::_update_view_2d() {
18651865
void RuntimeNodeSelect::_find_3d_items_at_pos(const Point2 &p_pos, Vector<SelectResult> &r_items) {
18661866
Window *root = SceneTree::get_singleton()->get_root();
18671867
Camera3D *camera = root->get_viewport()->get_camera_3d();
1868-
if (!camera) {
1869-
return;
1870-
}
1871-
18721868
Vector3 ray, pos, to;
18731869
if (root->get_viewport()->is_camera_3d_override_enabled()) {
18741870
Viewport *vp = root->get_viewport();
@@ -2127,21 +2123,21 @@ Transform3D RuntimeNodeSelect::_get_cursor_transform() {
21272123
void RuntimeNodeSelect::_reset_camera_3d() {
21282124
camera_first_override = true;
21292125

2126+
cursor = Cursor();
21302127
Window *root = SceneTree::get_singleton()->get_root();
21312128
Camera3D *camera = root->get_camera_3d();
2132-
if (!camera) {
2133-
return;
2134-
}
2135-
2136-
cursor = Cursor();
2137-
Transform3D transform = camera->get_global_transform();
2138-
transform.translate_local(0, 0, -cursor.distance);
2139-
cursor.pos = transform.origin;
2129+
if (camera) {
2130+
Transform3D transform = camera->get_global_transform();
2131+
transform.translate_local(0, 0, -cursor.distance);
2132+
cursor.pos = transform.origin;
21402133

2141-
cursor.x_rot = -camera->get_global_rotation().x;
2142-
cursor.y_rot = -camera->get_global_rotation().y;
2134+
cursor.x_rot = -camera->get_global_rotation().x;
2135+
cursor.y_rot = -camera->get_global_rotation().y;
21432136

2144-
cursor.fov_scale = CLAMP(camera->get_fov() / CAMERA_BASE_FOV, CAMERA_MIN_FOV_SCALE, CAMERA_MAX_FOV_SCALE);
2137+
cursor.fov_scale = CLAMP(camera->get_fov() / CAMERA_BASE_FOV, CAMERA_MIN_FOV_SCALE, CAMERA_MAX_FOV_SCALE);
2138+
} else {
2139+
cursor.fov_scale = 1.0;
2140+
}
21452141

21462142
SceneTree::get_singleton()->get_root()->set_camera_3d_override_transform(_get_cursor_transform());
21472143
SceneTree::get_singleton()->get_root()->set_camera_3d_override_perspective(CAMERA_BASE_FOV * cursor.fov_scale, CAMERA_ZNEAR, CAMERA_ZFAR);

0 commit comments

Comments
 (0)