summaryrefslogtreecommitdiffstats
path: root/tools/editor/plugins/spatial_editor_plugin.cpp
diff options
context:
space:
mode:
authorDaniel J. Ramirez <djrmuv@gmail.com>2016-07-28 14:37:52 -0500
committerDaniel J. Ramirez <djrmuv@gmail.com>2016-08-27 17:15:49 -0500
commit70c9979cce111f474ca68f4f1791fba0eddc63ca (patch)
treeeb9cf19c0258a42e0c7e3bc7fc7d573b46576016 /tools/editor/plugins/spatial_editor_plugin.cpp
parent3cc08ab1f125820d78b9917998ff09f81b052918 (diff)
downloadredot-engine-70c9979cce111f474ca68f4f1791fba0eddc63ca.tar.gz
Double click on scene tree element to focus currently selected node
In 3D it will focus in the first viewport Enable double click for trees
Diffstat (limited to 'tools/editor/plugins/spatial_editor_plugin.cpp')
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp59
1 files changed, 33 insertions, 26 deletions
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index a70df78697..95106d2c81 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -1980,33 +1980,8 @@ void SpatialEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_CENTER_TO_SELECTION: {
- if (!get_selected_count())
- break;
-
- Vector3 center;
- int count=0;
-
- List<Node*> &selection = editor_selection->get_selected_node_list();
-
- for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
-
- Spatial *sp = E->get()->cast_to<Spatial>();
- if (!sp)
- continue;
+ focus_selection();
- SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
- if (!se)
- continue;
-
- center+=sp->get_global_transform().origin;
- count++;
- }
-
- if( count != 0 ) {
- center/=float(count);
- }
-
- cursor.pos=center;
} break;
case VIEW_ALIGN_SELECTION_WITH_VIEW: {
@@ -2323,6 +2298,38 @@ void SpatialEditorViewport::reset() {
_update_name();
}
+
+void SpatialEditorViewport::focus_selection() {
+ if (!get_selected_count())
+ return;
+
+ Vector3 center;
+ int count=0;
+
+ List<Node*> &selection = editor_selection->get_selected_node_list();
+
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+
+ Spatial *sp = E->get()->cast_to<Spatial>();
+ if (!sp)
+ continue;
+
+ SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp);
+ if (!se)
+ continue;
+
+ center+=sp->get_global_transform().origin;
+ count++;
+ }
+
+ if( count != 0 ) {
+ center/=float(count);
+ }
+
+ cursor.pos=center;
+}
+
+
SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) {
_edit.mode=TRANSFORM_NONE;