From 70c9979cce111f474ca68f4f1791fba0eddc63ca Mon Sep 17 00:00:00 2001 From: Daniel J. Ramirez Date: Thu, 28 Jul 2016 14:37:52 -0500 Subject: 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 --- tools/editor/plugins/spatial_editor_plugin.cpp | 59 ++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'tools/editor/plugins/spatial_editor_plugin.cpp') diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index a70df7869..95106d2c8 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 &selection = editor_selection->get_selected_node_list(); - - for(List::Element *E=selection.front();E;E=E->next()) { - - Spatial *sp = E->get()->cast_to(); - if (!sp) - continue; + focus_selection(); - SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(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 &selection = editor_selection->get_selected_node_list(); + + for(List::Element *E=selection.front();E;E=E->next()) { + + Spatial *sp = E->get()->cast_to(); + if (!sp) + continue; + + SpatialEditorSelectedItem *se=editor_selection->get_node_editor_data(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; -- cgit v1.2.3-70-g09d2