]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Radiant:
authorGarux <garux@mail.ru>
Wed, 2 Aug 2017 06:22:10 +0000 (09:22 +0300)
committerGarux <garux@mail.ru>
Wed, 2 Aug 2017 06:22:10 +0000 (09:22 +0300)
binds...
* Tab in freelook: smooth turn around selected, while focusing on one

misc...
* activate key_press_handler before special_key_press_handler to allow CameraFree* commands, bound to special (gtk: !accelerator_is_valid) keys
* update workzone on partial deselecting too (was updating only on adding to selection)

libs/gtkutil/accelerator.cpp
radiant/camwindow.cpp
radiant/select.cpp

index 5e01456c648c16839fee61650fbb0d53ea815234..596c187871bd440e073be17f088e90c8a591531b 100644 (file)
@@ -522,10 +522,10 @@ void global_accel_connect_window( GtkWindow* window ){
        unsigned int override_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( override_global_accelerators ), 0 );
        g_object_set_data( G_OBJECT( window ), "override_handler", gint_to_pointer( override_handler ) );
 
+       GlobalPressedKeys_connect( window );
+
        unsigned int special_key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_special_accelerators );
        g_object_set_data( G_OBJECT( window ), "special_key_press_handler", gint_to_pointer( special_key_press_handler ) );
-
-       GlobalPressedKeys_connect( window );
 #else
        unsigned int key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_keydown_accelerators );
        unsigned int key_release_handler = g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( accelerator_key_event ), &g_keyup_accelerators );
index 99210352c42485a3e7a710d920e7a05555b07f4e..a5ac588596dba2ceda86f53280eab5e7d4f58a90 100644 (file)
@@ -371,7 +371,10 @@ const unsigned int MOVE_UP = 1 << 6;
 const unsigned int MOVE_DOWN = 1 << 7;
 const unsigned int MOVE_PITCHUP = 1 << 8;
 const unsigned int MOVE_PITCHDOWN = 1 << 9;
-const unsigned int MOVE_ALL = MOVE_FORWARD | MOVE_BACK | MOVE_ROTRIGHT | MOVE_ROTLEFT | MOVE_STRAFERIGHT | MOVE_STRAFELEFT | MOVE_UP | MOVE_DOWN | MOVE_PITCHUP | MOVE_PITCHDOWN;
+const unsigned int MOVE_FOCUS = 1 << 10;
+const unsigned int MOVE_ALL = MOVE_FORWARD | MOVE_BACK | MOVE_ROTRIGHT | MOVE_ROTLEFT | MOVE_STRAFERIGHT | MOVE_STRAFELEFT | MOVE_UP | MOVE_DOWN | MOVE_PITCHUP | MOVE_PITCHDOWN | MOVE_FOCUS;
+
+Vector3 Camera_getFocusPos( camera_t& camera );
 
 void Cam_KeyControl( camera_t& camera, float dtime ){
        // Update angles
@@ -416,6 +419,9 @@ void Cam_KeyControl( camera_t& camera, float dtime ){
        if ( camera.movementflags & MOVE_DOWN ) {
                vector3_add( camera.origin, vector3_scaled( g_vector3_axis_z, -dtime * g_camwindow_globals_private.m_nMoveSpeed ) );
        }
+       if ( camera.movementflags & MOVE_FOCUS ) {
+               camera.origin = Camera_getFocusPos( camera );
+       }
 
        Camera_updateModelview( camera );
 }
@@ -519,6 +525,12 @@ void Camera_PitchDown_KeyUp( camera_t& camera ){
        Camera_clearMovementFlags( camera, MOVE_PITCHDOWN );
 }
 
+void Camera_Focus_KeyDown( camera_t& camera ){
+       Camera_setMovementFlags( camera, MOVE_FOCUS );
+}
+void Camera_Focus_KeyUp( camera_t& camera ){
+       Camera_clearMovementFlags( camera, MOVE_FOCUS );
+}
 
 typedef ReferenceCaller<camera_t, &Camera_MoveForward_KeyDown> FreeMoveCameraMoveForwardKeyDownCaller;
 typedef ReferenceCaller<camera_t, &Camera_MoveForward_KeyUp> FreeMoveCameraMoveForwardKeyUpCaller;
@@ -533,6 +545,8 @@ typedef ReferenceCaller<camera_t, &Camera_MoveUp_KeyUp> FreeMoveCameraMoveUpKeyU
 typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyDown> FreeMoveCameraMoveDownKeyDownCaller;
 typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyUp> FreeMoveCameraMoveDownKeyUpCaller;
 
+typedef ReferenceCaller<camera_t, &Camera_Focus_KeyDown> FreeMoveCameraFocusKeyDownCaller;
+typedef ReferenceCaller<camera_t, &Camera_Focus_KeyUp> FreeMoveCameraFocusKeyUpCaller;
 
 #define SPEED_MOVE 32
 #define SPEED_TURN 22.5
@@ -1040,6 +1054,11 @@ void CamWnd_registerCommands( CamWnd& camwnd ){
                                                        FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
                                                        );
 
+       GlobalKeyEvents_insert( "CameraFreeFocus", accelerator_null(),
+                                                       FreeMoveCameraFocusKeyDownCaller( camwnd.getCamera() ),
+                                                       FreeMoveCameraFocusKeyUpCaller( camwnd.getCamera() )
+                                                       );
+
        GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
        GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
        GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
@@ -1188,6 +1207,8 @@ void CamWnd_Add_Handlers_FreeMove( CamWnd& camwnd ){
 
        KeyEvent_connect( "CameraFreeMoveUp" );
        KeyEvent_connect( "CameraFreeMoveDown" );
+
+       KeyEvent_connect( "CameraFreeFocus" );
 }
 
 void CamWnd_Remove_Handlers_FreeMove( CamWnd& camwnd ){
@@ -1204,6 +1225,8 @@ void CamWnd_Remove_Handlers_FreeMove( CamWnd& camwnd ){
        KeyEvent_disconnect( "CameraFreeMoveUp" );
        KeyEvent_disconnect( "CameraFreeMoveDown" );
 
+       KeyEvent_disconnect( "CameraFreeFocus" );
+
        g_signal_handler_disconnect( G_OBJECT( camwnd.m_gl_widget ), camwnd.m_selection_button_press_handler );
        g_signal_handler_disconnect( G_OBJECT( camwnd.m_gl_widget ), camwnd.m_selection_button_release_handler );
        g_signal_handler_disconnect( G_OBJECT( camwnd.m_gl_widget ), camwnd.m_selection_motion_handler );
@@ -1693,23 +1716,22 @@ void GlobalCamera_ResetAngles(){
 
 #include "select.h"
 
-void GlobalCamera_FocusOnSelected(){
-       CamWnd& camwnd = *g_camwnd;
-/*
-       Vector3 angles( Camera_getAngles( camwnd ) );
+Vector3 Camera_getFocusPos( camera_t& camera ){
+       Vector3 camorigin( Camera_getOrigin( camera ) );
+       AABB aabb( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
+       View& view = *( camera.m_view );
+#if 0
+       Vector3 angles( Camera_getAngles( camera ) );
        Vector3 radangles( degrees_to_radians( angles[0] ), degrees_to_radians( angles[1] ), degrees_to_radians( angles[2] ) );
        Vector3 viewvector;
        viewvector[0] = cos( radangles[1] ) * cos( radangles[0] );
        viewvector[1] = sin( radangles[1] ) * cos( radangles[0] );
        viewvector[2] = sin( radangles[0] );
-*/
-       Vector3 camorigin( Camera_getOrigin( camwnd ) );
-
-       AABB aabb( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
-
-       View& view = *( camwnd.getCamera().m_view );
-
+#elif 0
        Vector3 viewvector( -view.GetModelview()[2], -view.GetModelview()[6], -view.GetModelview()[10] );
+#elif 1
+       Vector3 viewvector( -camera.vpn );
+#endif
 
        Plane3 frustumPlanes[4];
        frustumPlanes[0] = plane3_translated( view.getFrustum().left, camorigin - aabb.origin );
@@ -1734,14 +1756,11 @@ void GlobalCamera_FocusOnSelected(){
                        }
                }
        }
-/*
-       globalOutputStream() << viewvector << "\n";
-       globalOutputStream() << view.GetModelview()[0] << " " << view.GetModelview()[1] << " " << view.GetModelview()[2] << " " << view.GetModelview()[3] << "\n"
-        << view.GetModelview()[4] << " " << view.GetModelview()[5] << " " << view.GetModelview()[6] << " " << view.GetModelview()[7] << "\n"
-         << view.GetModelview()[8] << " " << view.GetModelview()[9] << " " << view.GetModelview()[10] << " " << view.GetModelview()[11] << "\n"
-          << view.GetModelview()[12] << " " << view.GetModelview()[13] << " " << view.GetModelview()[14] << " " << view.GetModelview()[15] << "\n";
-*/
-       Camera_setOrigin( camwnd, aabb.origin - viewvector * offset );
+       return ( aabb.origin - viewvector * offset );
+}
+
+void GlobalCamera_FocusOnSelected(){
+       Camera_setOrigin( *g_camwnd, Camera_getFocusPos( g_camwnd->getCamera() ) );
 }
 
 void Camera_ChangeFloorUp(){
@@ -2053,6 +2072,8 @@ void CamWnd_Construct(){
        GlobalShortcuts_insert( "CameraFreeMoveUp", accelerator_null() );
        GlobalShortcuts_insert( "CameraFreeMoveDown", accelerator_null() );
 
+       GlobalShortcuts_insert( "CameraFreeFocus", Accelerator( GDK_Tab ) );
+
        GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
 
        GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
index 651397ea10377afd7e7c75ca0b963559a98a25e6..7a85f59dfd7d8727e924b41e9d2d490e4cc22fa1 100644 (file)
@@ -450,9 +450,9 @@ void UpdateWorkzone_ForSelection(){
 
 // update the workzone to the current selection
 void UpdateWorkzone_ForSelectionChanged( const Selectable& selectable ){
-       if ( selectable.isSelected() ) {
+       //if ( selectable.isSelected() ) {
                UpdateWorkzone_ForSelection();
-       }
+       //}
 }
 
 void Select_SetShader( const char* shader ){