Show a message when trying to zoom farther than the limit
(cherry picked from commit b8f66d58b6
)
This commit is contained in:
parent
c4f941114c
commit
9b928cbd9e
2 changed files with 19 additions and 0 deletions
|
@ -2220,6 +2220,12 @@ void SpatialEditorViewport::scale_cursor_distance(real_t scale) {
|
|||
cursor.distance = CLAMP(cursor.distance * scale, min_distance, max_distance);
|
||||
}
|
||||
|
||||
if (cursor.distance == max_distance || cursor.distance == min_distance) {
|
||||
zoom_failed_attempts_count++;
|
||||
} else {
|
||||
zoom_failed_attempts_count = 0;
|
||||
}
|
||||
|
||||
zoom_indicator_delay = ZOOM_FREELOOK_INDICATOR_DELAY_S;
|
||||
surface->update();
|
||||
}
|
||||
|
@ -2371,6 +2377,7 @@ void SpatialEditorViewport::_notification(int p_what) {
|
|||
zoom_indicator_delay -= delta;
|
||||
if (zoom_indicator_delay <= 0) {
|
||||
surface->update();
|
||||
zoom_limit_label->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2732,6 +2739,7 @@ void SpatialEditorViewport::_draw() {
|
|||
|
||||
} else {
|
||||
// Show zoom
|
||||
zoom_limit_label->set_visible(zoom_failed_attempts_count > 15);
|
||||
|
||||
real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
|
||||
real_t max_distance = MIN(camera->get_zfar() / 2, ZOOM_FREELOOK_MAX);
|
||||
|
@ -4004,6 +4012,15 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
|
|||
locked_label->set_text(TTR("View Rotation Locked"));
|
||||
locked_label->hide();
|
||||
|
||||
zoom_limit_label = memnew(Label);
|
||||
zoom_limit_label->set_anchors_and_margins_preset(LayoutPreset::PRESET_BOTTOM_LEFT);
|
||||
zoom_limit_label->set_margin(Margin::MARGIN_TOP, -28 * EDSCALE);
|
||||
zoom_limit_label->set_text(TTR("To zoom further, change the camera's clipping planes (View -> Settings...)"));
|
||||
zoom_limit_label->set_name("ZoomLimitMessageLabel");
|
||||
zoom_limit_label->add_color_override("font_color", Color(1, 1, 1, 1));
|
||||
zoom_limit_label->hide();
|
||||
surface->add_child(zoom_limit_label);
|
||||
|
||||
top_right_vbox = memnew(VBoxContainer);
|
||||
top_right_vbox->set_anchors_and_margins_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE);
|
||||
top_right_vbox->set_h_grow_direction(GROW_DIRECTION_BEGIN);
|
||||
|
|
|
@ -272,6 +272,7 @@ private:
|
|||
Label *info_label;
|
||||
Label *cinema_label;
|
||||
Label *locked_label;
|
||||
Label *zoom_limit_label;
|
||||
|
||||
VBoxContainer *top_right_vbox;
|
||||
ViewportRotationControl *rotation_control;
|
||||
|
@ -394,6 +395,7 @@ private:
|
|||
void scale_freelook_speed(real_t scale);
|
||||
|
||||
real_t zoom_indicator_delay;
|
||||
int zoom_failed_attempts_count = 0;
|
||||
|
||||
RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[4], scale_gizmo_instance[3], scale_plane_gizmo_instance[3];
|
||||
|
||||
|
|
Loading…
Reference in a new issue