From: Thomas Debesse Date: Tue, 21 Jun 2022 02:52:21 +0000 (+0200) Subject: Merge commit '1a0075a3f03af095ee32ded7f101cac79267f906' into master-merge X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=e8ee23459b69f28cb9c0e013665db80b836a0d9b;hp=2f3014d79f98abd19b003327ed7852e8246e0a1e;p=xonotic%2Fnetradiant.git Merge commit '1a0075a3f03af095ee32ded7f101cac79267f906' into master-merge --- diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 6bae24c7..33316edc 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1650,10 +1650,6 @@ void CamWnd::BenchMark(){ } -void fill_view_camera_menu( ui::Menu menu ){ - create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" ); -} - void GlobalCamera_ResetAngles(){ CamWnd& camwnd = *g_camwnd; Vector3 angles; @@ -1963,8 +1959,8 @@ void CamWnd_Construct(){ GlobalCommands_insert( "DownFloor", makeCallbackF(Camera_ChangeFloorDown), Accelerator( GDK_KEY_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", makeCallbackF(GlobalCamera_LookThroughSelected) ); - GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) ); +// GlobalCommands_insert( "LookThroughSelected", makeCallbackF(GlobalCamera_LookThroughSelected) ); +// GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) ); if ( g_pGameDescription->mGameType == "doom3" ) { GlobalCommands_insert( "TogglePreview", makeCallbackF(CamWnd_TogglePreview), Accelerator( GDK_KEY_F3 ) ); diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 9ed6d242..4bb85080 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -39,7 +39,6 @@ void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ); void GlobalCamera_setCamWnd( CamWnd& camwnd ); -void fill_view_camera_menu( ui::Menu menu ); void CamWnd_constructToolbar( ui::Toolbar toolbar ); void CamWnd_registerShortcuts(); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index acc56f61..ec650edf 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2124,20 +2124,6 @@ ui::MenuItem create_edit_menu(){ return edit_menu_item; } -void fill_view_xy_top_menu( ui::Menu menu ){ - create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); -} - - -void fill_view_yz_side_menu( ui::Menu menu ){ - create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); -} - - -void fill_view_xz_front_menu( ui::Menu menu ){ - create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); -} - ui::Widget g_toggle_z_item{ui::null}; ui::Widget g_toggle_console_item{ui::null}; @@ -2153,13 +2139,13 @@ ui::MenuItem 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" ); } @@ -2189,9 +2175,10 @@ ui::MenuItem 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 ); { @@ -2202,10 +2189,13 @@ ui::MenuItem 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 e5128ae7..63ef5973 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -366,7 +366,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 ), @@ -829,7 +829,8 @@ gboolean xywnd_expose( ui::Widget 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(); } } @@ -2058,47 +2059,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 ) { @@ -2537,7 +2597,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 ); @@ -2634,7 +2697,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(); @@ -2645,54 +2708,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 ); } @@ -2705,6 +2745,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 071f132c..36a5f1cb 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -139,6 +139,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 );