Merge pull request #88584 from ryevdokimov/hide_grid_per_viewport

Add ability to hide grid per viewport
This commit is contained in:
Rémi Verschelde 2024-02-23 22:19:01 +01:00
commit fd788d7df9
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 17 additions and 2 deletions

View file

@ -3445,7 +3445,8 @@ void Node3DEditorViewport::_menu_option(int p_option) {
int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
uint32_t layers = ((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + index)) | (1 << GIZMO_GRID_LAYER) | (1 << MISC_TOOL_LAYER);
uint32_t layers = camera->get_cull_mask();
layers &= ~(1 << GIZMO_EDIT_LAYER);
if (current) {
layers |= (1 << GIZMO_EDIT_LAYER);
}
@ -3469,7 +3470,18 @@ void Node3DEditorViewport::_menu_option(int p_option) {
int idx = view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME);
bool current = view_menu->get_popup()->is_item_checked(idx);
view_menu->get_popup()->set_item_checked(idx, !current);
} break;
case VIEW_GRID: {
int idx = view_menu->get_popup()->get_item_index(VIEW_GRID);
bool current = view_menu->get_popup()->is_item_checked(idx);
current = !current;
uint32_t layers = camera->get_cull_mask();
layers &= ~(1 << GIZMO_GRID_LAYER);
if (current) {
layers |= (1 << GIZMO_GRID_LAYER);
}
camera->set_cull_mask(layers);
view_menu->get_popup()->set_item_checked(idx, current);
} break;
case VIEW_DISPLAY_NORMAL:
case VIEW_DISPLAY_WIREFRAME:
@ -5142,6 +5154,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_grid_lines", TTR("View Grid")), VIEW_GRID);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_information", TTR("View Information")), VIEW_INFORMATION);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View Frame Time")), VIEW_FRAME_TIME);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true);
@ -5151,6 +5164,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_doppler", TTR("Enable Doppler")), VIEW_AUDIO_DOPPLER);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS), true);
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GRID), true);
view_menu->get_popup()->add_separator();
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_cinematic_preview", TTR("Cinematic Preview")), VIEW_CINEMATIC_PREVIEW);

View file

@ -124,6 +124,7 @@ class Node3DEditorViewport : public Control {
VIEW_AUDIO_LISTENER,
VIEW_AUDIO_DOPPLER,
VIEW_GIZMOS,
VIEW_GRID,
VIEW_INFORMATION,
VIEW_FRAME_TIME,