diff options
author | reduz <reduzio@gmail.com> | 2021-02-22 10:54:12 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2021-02-22 16:56:29 -0300 |
commit | d6a9cff8b7cbacec81a924c65a02736a5dba9b53 (patch) | |
tree | ac7397e7da9e73d13a8ecf001a47fe222fb60848 /scene/main | |
parent | 98c63389d1af95fa529b1baab057236fd9feeabb (diff) |
Add preview Sun and Environment
* Adds both a preview sun and preview environment to the 3D editor.
* They are valid as long as a DirectionalLight3D and WorldEnvironment are not in the scene.
* If any is added to the scene, the respective preview is disabled.
* Changed WorldEnvironment to better handle multiple node versions.
* Added a function in SceneTree to get the first node in a group.
* Fixed button minimum size to also consider font height if no text is there, this broke with the TextSever PR.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/scene_tree.cpp | 16 | ||||
-rw-r--r-- | scene/main/scene_tree.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 9f32c65f7b..b10e23ac07 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -956,6 +956,21 @@ bool SceneTree::has_group(const StringName &p_identifier) const { return group_map.has(p_identifier); } +Node *SceneTree::get_first_node_in_group(const StringName &p_group) { + Map<StringName, Group>::Element *E = group_map.find(p_group); + if (!E) { + return nullptr; //no group + } + + _update_group_order(E->get()); //update order just in case + + if (E->get().nodes.size() == 0) { + return nullptr; + } + + return E->get().nodes[0]; +} + void SceneTree::get_nodes_in_group(const StringName &p_group, List<Node *> *p_list) { Map<StringName, Group>::Element *E = group_map.find(p_group); if (!E) { @@ -1216,6 +1231,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("set_group", "group", "property", "value"), &SceneTree::set_group); ClassDB::bind_method(D_METHOD("get_nodes_in_group", "group"), &SceneTree::_get_nodes_in_group); + ClassDB::bind_method(D_METHOD("get_first_node_in_group", "group"), &SceneTree::get_first_node_in_group); ClassDB::bind_method(D_METHOD("set_current_scene", "child_node"), &SceneTree::set_current_scene); ClassDB::bind_method(D_METHOD("get_current_scene"), &SceneTree::get_current_scene); diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index f39780831f..c2280c747b 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -302,6 +302,7 @@ public: void queue_delete(Object *p_object); void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list); + Node *get_first_node_in_group(const StringName &p_group); bool has_group(const StringName &p_identifier) const; //void change_scene(const String& p_path); |