diff --git a/radiant/map.cpp b/radiant/map.cpp index f4ed3006..3afeae2d 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -2154,7 +2154,7 @@ void SelectBrush( int entitynum, int brushnum ){ Selectable* selectable = Instance_getSelectable( *instance ); ASSERT_MESSAGE( selectable != 0, "SelectBrush: path not selectable" ); selectable->setSelected( true ); - g_pParentWnd->GetXYWnd()->PositionView( instance->worldAABB().origin ); + g_pParentWnd->GetXYWnd()->SetOrigin( instance->worldAABB().origin ); } } diff --git a/radiant/points.cpp b/radiant/points.cpp index 7daa7ae6..eb6c987b 100644 --- a/radiant/points.cpp +++ b/radiant/points.cpp @@ -196,7 +196,6 @@ void Pointfile_Next( void ){ CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); Camera_setOrigin( camwnd, *i ); g_pParentWnd->ActiveXY()->SetOrigin( *i ); - g_pParentWnd->ActiveXY()->queueDraw(); { Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) ); Vector3 angles( Camera_getAngles( camwnd ) ); @@ -222,7 +221,6 @@ void Pointfile_Prev( void ){ CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); Camera_setOrigin( camwnd, *i ); g_pParentWnd->ActiveXY()->SetOrigin( *i ); - g_pParentWnd->ActiveXY()->queueDraw(); { Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) ); Vector3 angles( Camera_getAngles( camwnd ) ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 99ba6d34..51e37bab 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -263,10 +263,10 @@ void XYWnd::ZoomOut(){ } void XYWnd::ZoomInWithMouse( int pointx, int pointy ){ - float old_scale = Scale(); + const float old_scale = Scale(); ZoomIn(); - if ( g_xywindow_globals.m_bZoomInToPointer ) { - float scale_diff = 1.0 / old_scale - 1.0 / Scale(); + if ( g_xywindow_globals.m_bZoomInToPointer && old_scale != Scale() ) { + const float scale_diff = 1.0 / old_scale - 1.0 / Scale(); int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim2 = ( m_viewType == XY ) ? 1 : 2; Vector3 origin = GetOrigin(); @@ -776,17 +776,20 @@ const Vector3& XYWnd::GetOrigin() const { } void XYWnd::SetOrigin( const Vector3& origin ){ - m_vOrigin = origin; + for( std::size_t i = 0; i < 3; ++i ) + m_vOrigin[i] = std::min( g_MaxWorldCoord, std::max( g_MinWorldCoord, origin[i] ) ); updateModelview(); + XYWnd_Update( *this ); } void XYWnd::Scroll( int x, int y ){ int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim2 = ( m_viewType == XY ) ? 1 : 2; + m_vOrigin[nDim1] += x / m_fScale; m_vOrigin[nDim2] += y / m_fScale; - updateModelview(); - queueDraw(); + + SetOrigin( m_vOrigin ); } FBO* XYWnd::fbo_get(){ @@ -1146,19 +1149,6 @@ void XYWnd::Zoom_End(){ g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut ); } -// makes sure the selected brush or camera is in view -void XYWnd::PositionView( const Vector3& position ){ - int nDim1 = ( m_viewType == YZ ) ? 1 : 0; - int nDim2 = ( m_viewType == XY ) ? 1 : 2; - - m_vOrigin[nDim1] = position[nDim1]; - m_vOrigin[nDim2] = position[nDim2]; - - updateModelview(); - - XYWnd_Update( *this ); -} - void XYWnd::SetViewType( VIEWTYPE viewType ){ m_viewType = viewType; updateModelview(); @@ -2384,13 +2374,13 @@ inline AABB GetCenterBbox(){ } void XYWnd_Centralize( XYWnd* xywnd ){ - xywnd->PositionView( GetCenterBbox().origin ); + xywnd->SetOrigin( GetCenterBbox().origin ); } void XY_Centralize(){ const Vector3 position( GetCenterBbox().origin ); g_pParentWnd->forEachXYWnd( [&position]( XYWnd* xywnd ){ - xywnd->PositionView( position ); + xywnd->SetOrigin( position ); } ); } diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 21a3211f..95608341 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -116,7 +116,6 @@ static void recaptureStates(){ captureStates(); } -void PositionView( const Vector3& position ); const Vector3& GetOrigin() const; void SetOrigin( const Vector3& origin ); void Scroll( int x, int y );