1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Merge pull request #85437 from lawnjelly/lod_scene_side

[3.x] Discrete Level of Detail
This commit is contained in:
Rémi Verschelde
2024-03-08 17:53:58 +01:00
30 changed files with 713 additions and 134 deletions

View File

@@ -36,6 +36,7 @@
#include "editor/node_dock.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "scene/3d/lod_manager.h"
#include "scene/gui/label.h"
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
@@ -162,7 +163,7 @@ void SceneTreeEditor::_toggle_visible(Node *p_node) {
}
}
void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_disable_visibility) {
if (!p_node) {
return;
}
@@ -405,9 +406,9 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
bool v = p_node->call("is_visible");
if (v) {
item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, p_disable_visibility, TTR("Toggle Visibility"));
} else {
item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility"));
item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, p_disable_visibility, TTR("Toggle Visibility"));
}
if (!p_node->is_connected("visibility_changed", this, "_node_visibility_changed")) {
@@ -437,8 +438,12 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
item->set_as_cursor(0);
}
// In some cases we want to disable visibility control by the user
// for automatically visibility-controlled children.
bool disable_visibility = p_node->is_class("LOD") && LODManager::is_enabled();
for (int i = 0; i < p_node->get_child_count(); i++) {
_add_nodes(p_node->get_child(i), item);
_add_nodes(p_node->get_child(i), item, disable_visibility);
}
if (valid_types.size()) {