From: Garux Date: Wed, 2 Aug 2017 06:08:43 +0000 (+0300) Subject: Radiant: X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=de5fcea3362fe1e6cb68ccfab792469a993da215;p=xonotic%2Fnetradiant.git Radiant: binds... * ctrl+tab (nextview cmd) = center on selected in 4 views layout misc... * quick method of rendering camera icon (w/o rerendering the scene) = great speedup for camera moves * fix: center on selected cmd works in floating views layout * projections are switchable in floating views layout * defaulted 'mark active view by outline' --- diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 624b53fb..1b36589b 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1640,10 +1640,6 @@ void CamWnd::BenchMark(){ } -void fill_view_camera_menu( GtkMenu* menu ){ - create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" ); -} - void GlobalCamera_ResetAngles(){ CamWnd& camwnd = *g_camwnd; Vector3 angles; @@ -1924,8 +1920,8 @@ void CamWnd_Construct(){ GlobalCommands_insert( "DownFloor", FreeCaller(), Accelerator( GDK_Next ) ); GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "LookThroughSelected", FreeCaller() ); - GlobalCommands_insert( "LookThroughCamera", FreeCaller() ); +// GlobalCommands_insert( "LookThroughSelected", FreeCaller() ); +// GlobalCommands_insert( "LookThroughCamera", FreeCaller() ); if ( g_pGameDescription->mGameType == "doom3" ) { GlobalCommands_insert( "TogglePreview", FreeCaller(), Accelerator( GDK_F3 ) ); diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 1101d431..c40c8fb0 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -41,8 +41,6 @@ void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); -typedef struct _GtkMenu GtkMenu; -void fill_view_camera_menu( GtkMenu* menu ); typedef struct _GtkToolbar GtkToolbar; void CamWnd_constructToolbar( GtkToolbar* toolbar ); void CamWnd_registerShortcuts(); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index e7f951e8..233a9133 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1897,20 +1897,6 @@ GtkMenuItem* create_edit_menu(){ return edit_menu_item; } -void fill_view_xy_top_menu( GtkMenu* menu ){ - create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); -} - - -void fill_view_yz_side_menu( GtkMenu* menu ){ - create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); -} - - -void fill_view_xz_front_menu( GtkMenu* menu ){ - create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); -} - GtkWidget* g_toggle_z_item = 0; GtkWidget* g_toggle_console_item = 0; @@ -1926,13 +1912,13 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } if ( style == MainFrame::eFloating ) { - fill_view_camera_menu( menu ); - fill_view_xy_top_menu( menu ); - fill_view_yz_side_menu( menu ); - fill_view_xz_front_menu( menu ); + create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" ); + create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); + create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); + create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); } if ( style == MainFrame::eFloating || style == MainFrame::eSplit ) { - create_menu_item_with_mnemonic( menu, "Console View", "ToggleConsole" ); + create_menu_item_with_mnemonic( menu, "Console", "ToggleConsole" ); create_menu_item_with_mnemonic( menu, "Texture Browser", "ToggleTextures" ); create_menu_item_with_mnemonic( menu, "Entity Inspector", "ToggleEntityInspector" ); } @@ -1959,9 +1945,10 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ menu_separator( camera_menu ); create_menu_item_with_mnemonic( camera_menu, "Next leak spot", "NextLeakSpot" ); create_menu_item_with_mnemonic( camera_menu, "Previous leak spot", "PrevLeakSpot" ); - menu_separator( camera_menu ); - create_menu_item_with_mnemonic( camera_menu, "Look Through Selected", "LookThroughSelected" ); - create_menu_item_with_mnemonic( camera_menu, "Look Through Camera", "LookThroughCamera" ); + //cameramodel is not implemented in instances, thus useless +// menu_separator( camera_menu ); +// create_menu_item_with_mnemonic( camera_menu, "Look Through Selected", "LookThroughSelected" ); +// create_menu_item_with_mnemonic( camera_menu, "Look Through Camera", "LookThroughCamera" ); } menu_separator( menu ); { @@ -1972,10 +1959,13 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) { create_menu_item_with_mnemonic( orthographic_menu, "_Next (XY, YZ, XY)", "NextView" ); create_menu_item_with_mnemonic( orthographic_menu, "XY (Top)", "ViewTop" ); - create_menu_item_with_mnemonic( orthographic_menu, "YZ", "ViewSide" ); - create_menu_item_with_mnemonic( orthographic_menu, "XZ", "ViewFront" ); + create_menu_item_with_mnemonic( orthographic_menu, "XZ (Front)", "ViewFront" ); + create_menu_item_with_mnemonic( orthographic_menu, "YZ (Side)", "ViewSide" ); menu_separator( orthographic_menu ); } + else{ + create_menu_item_with_mnemonic( orthographic_menu, "Center on Selected", "NextView" ); + } create_menu_item_with_mnemonic( orthographic_menu, "Center on Selected", "CenterXYView" ); menu_separator( orthographic_menu ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index dc046af5..3e454e2d 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -361,7 +361,7 @@ struct xywindow_globals_private_t show_names( false ), show_coordinates( false ), show_angles( true ), - show_outline( false ), + show_outline( true ), show_axis( true ), d_show_work( false ), @@ -820,7 +820,8 @@ gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){ void XYWnd_CameraMoved( XYWnd& xywnd ){ if ( g_xywindow_globals_private.m_bCamXYUpdate ) { - XYWnd_Update( xywnd ); + //XYWnd_Update( xywnd ); + xywnd.UpdateCameraIcon(); } } @@ -2034,47 +2035,106 @@ void XYWnd::XY_DrawBlockGrid(){ } void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){ - float x, y, fov, box; - double a; - - fov = 48 / m_fScale; - box = 16 / m_fScale; + Cam.fov = 48 / m_fScale; + Cam.box = 16 / m_fScale; if ( m_viewType == XY ) { - x = origin[0]; - y = origin[1]; - a = degrees_to_radians( angles[CAMERA_YAW] ); + Cam.x = origin[0]; + Cam.y = origin[1]; + Cam.a = degrees_to_radians( angles[CAMERA_YAW] ); } else if ( m_viewType == YZ ) { - x = origin[1]; - y = origin[2]; - a = degrees_to_radians( angles[CAMERA_PITCH] ); + Cam.x = origin[1]; + Cam.y = origin[2]; + Cam.a = degrees_to_radians( angles[CAMERA_PITCH] ); } else { - x = origin[0]; - y = origin[2]; - a = degrees_to_radians( angles[CAMERA_PITCH] ); + Cam.x = origin[0]; + Cam.y = origin[2]; + Cam.a = degrees_to_radians( angles[CAMERA_PITCH] ); } - glColor3f( 0.0, 0.0, 1.0 ); + //glColor3f( 0.0, 0.0, 1.0 ); + glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_LINE_STRIP ); - glVertex3f( x - box,y,0 ); - glVertex3f( x,y + ( box / 2 ),0 ); - glVertex3f( x + box,y,0 ); - glVertex3f( x,y - ( box / 2 ),0 ); - glVertex3f( x - box,y,0 ); - glVertex3f( x + box,y,0 ); + glVertex3f( Cam.x - Cam.box,Cam.y,0 ); + glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 ); + glVertex3f( Cam.x + Cam.box,Cam.y,0 ); + glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 ); + glVertex3f( Cam.x - Cam.box,Cam.y,0 ); + glVertex3f( Cam.x + Cam.box,Cam.y,0 ); glEnd(); glBegin( GL_LINE_STRIP ); - glVertex3f( x + static_cast( fov * cos( a + c_pi / 4 ) ), y + static_cast( fov * sin( a + c_pi / 4 ) ), 0 ); - glVertex3f( x, y, 0 ); - glVertex3f( x + static_cast( fov * cos( a - c_pi / 4 ) ), y + static_cast( fov * sin( a - c_pi / 4 ) ), 0 ); + glVertex3f( Cam.x + static_cast( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 ); + glVertex3f( Cam.x, Cam.y, 0 ); + glVertex3f( Cam.x + static_cast( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 ); glEnd(); } +void XYWnd::UpdateCameraIcon( void ){ + if ( glwidget_make_current( m_gl_widget ) != FALSE ) { + if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { + GlobalOpenGL_debugAssertNoErrors(); + glDrawBuffer( GL_FRONT ); + { + // clear + glViewport( 0, 0, m_nWidth, m_nHeight ); + // set up viewpoint + glMatrixMode( GL_PROJECTION ); + glLoadMatrixf( reinterpret_cast( &m_projection ) ); + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glScalef( m_fScale, m_fScale, 1 ); + int nDim1 = ( m_viewType == YZ ) ? 1 : 0; + int nDim2 = ( m_viewType == XY ) ? 1 : 2; + glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 ); + + glDisable( GL_LINE_STIPPLE ); + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); + glDisableClientState( GL_NORMAL_ARRAY ); + glDisableClientState( GL_COLOR_ARRAY ); + glDisable( GL_TEXTURE_2D ); + glDisable( GL_LIGHTING ); + glDisable( GL_COLOR_MATERIAL ); + glDisable( GL_DEPTH_TEST ); + glDisable( GL_TEXTURE_1D ); + + glEnable( GL_BLEND ); + glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); + + //glColor3f( 0.0, 0.0, 1.0 ); + glColor3f( 1.0, 1.0, 1.0 ); + glBegin( GL_LINE_STRIP ); + glVertex3f( Cam.x - Cam.box,Cam.y,0 ); + glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 ); + glVertex3f( Cam.x + Cam.box,Cam.y,0 ); + glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 ); + glVertex3f( Cam.x - Cam.box,Cam.y,0 ); + glVertex3f( Cam.x + Cam.box,Cam.y,0 ); + glEnd(); + + glBegin( GL_LINE_STRIP ); + glVertex3f( Cam.x + static_cast( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 ); + glVertex3f( Cam.x, Cam.y, 0 ); + glVertex3f( Cam.x + static_cast( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 ); + glEnd(); + + XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) ); + + glDisable( GL_BLEND ); + } + + glDrawBuffer( GL_BACK ); + GlobalOpenGL_debugAssertNoErrors(); + glwidget_make_current( m_gl_widget ); + } + } +} + float Betwixt( float f1, float f2 ){ if ( f1 > f2 ) { @@ -2509,7 +2569,10 @@ void XYWnd::XY_Draw(){ glScalef( m_fScale, m_fScale, 1 ); glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 ); + glEnable( GL_BLEND ); + glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) ); + glDisable( GL_BLEND ); Feedback_draw2D( m_viewType ); @@ -2606,7 +2669,7 @@ void XY_Split_Focus(){ } void XY_Focus(){ - if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) { + if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) { // cannot do this in a split window // do something else that the user may want here XY_Split_Focus(); @@ -2617,54 +2680,31 @@ void XY_Focus(){ XYWnd_Focus( xywnd ); } -void XY_Top(){ - if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) { +void XY_TopFrontSide( VIEWTYPE viewtype ){ + if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) { // cannot do this in a split window // do something else that the user may want here XY_Split_Focus(); return; } - - XYWnd* xywnd = g_pParentWnd->GetXYWnd(); - xywnd->SetViewType( XY ); + XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd(); + xywnd->SetViewType( viewtype ); XYWnd_Focus( xywnd ); } -void XY_Side(){ - if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) { - // cannot do this in a split window - // do something else that the user may want here - XY_Split_Focus(); - return; - } +void XY_Top(){ + XY_TopFrontSide( XY ); +} - XYWnd* xywnd = g_pParentWnd->GetXYWnd(); - xywnd->SetViewType( XZ ); - XYWnd_Focus( xywnd ); +void XY_Side(){ + XY_TopFrontSide( XZ ); } void XY_Front(){ - if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) { - // cannot do this in a split window - // do something else that the user may want here - XY_Split_Focus(); - return; - } - - XYWnd* xywnd = g_pParentWnd->GetXYWnd(); - xywnd->SetViewType( YZ ); - XYWnd_Focus( xywnd ); + XY_TopFrontSide( YZ ); } -void XY_Next(){ - if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) { - // cannot do this in a split window - // do something else that the user may want here - XY_Split_Focus(); - return; - } - - XYWnd* xywnd = g_pParentWnd->GetXYWnd(); +void XY_NextView( XYWnd* xywnd ){ if ( xywnd->GetViewType() == XY ) { xywnd->SetViewType( XZ ); } @@ -2677,6 +2717,17 @@ void XY_Next(){ XYWnd_Focus( xywnd ); } +void XY_Next(){ + if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) { + // cannot do this in a split window + // do something else that the user may want here + XY_Split_Focus(); + return; + } + XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd(); + XY_NextView( xywnd ); +} + void XY_Zoom100(){ if ( g_pParentWnd->GetXYWnd() ) { g_pParentWnd->GetXYWnd()->SetScale( 1 ); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 3d913484..1d978b95 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -138,6 +138,14 @@ void SetActive( bool b ){ bool Active(){ return m_bActive; }; +struct camera_icon_t +{ + float x, y, fov, box; + double a; +}; +camera_icon_t Cam; +void UpdateCameraIcon(); + void Clipper_OnLButtonDown( int x, int y ); void Clipper_OnLButtonUp( int x, int y );