* prevent runouts of 2D views from grid area

This commit is contained in:
Garux 2019-08-23 14:40:45 +03:00
parent 154b5f3619
commit 446e1148a5
4 changed files with 12 additions and 25 deletions

View File

@ -2154,7 +2154,7 @@ void SelectBrush( int entitynum, int brushnum ){
Selectable* selectable = Instance_getSelectable( *instance ); Selectable* selectable = Instance_getSelectable( *instance );
ASSERT_MESSAGE( selectable != 0, "SelectBrush: path not selectable" ); ASSERT_MESSAGE( selectable != 0, "SelectBrush: path not selectable" );
selectable->setSelected( true ); selectable->setSelected( true );
g_pParentWnd->GetXYWnd()->PositionView( instance->worldAABB().origin ); g_pParentWnd->GetXYWnd()->SetOrigin( instance->worldAABB().origin );
} }
} }

View File

@ -196,7 +196,6 @@ void Pointfile_Next( void ){
CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); CamWnd& camwnd = *g_pParentWnd->GetCamWnd();
Camera_setOrigin( camwnd, *i ); Camera_setOrigin( camwnd, *i );
g_pParentWnd->ActiveXY()->SetOrigin( *i ); g_pParentWnd->ActiveXY()->SetOrigin( *i );
g_pParentWnd->ActiveXY()->queueDraw();
{ {
Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) ); Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) );
Vector3 angles( Camera_getAngles( camwnd ) ); Vector3 angles( Camera_getAngles( camwnd ) );
@ -222,7 +221,6 @@ void Pointfile_Prev( void ){
CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); CamWnd& camwnd = *g_pParentWnd->GetCamWnd();
Camera_setOrigin( camwnd, *i ); Camera_setOrigin( camwnd, *i );
g_pParentWnd->ActiveXY()->SetOrigin( *i ); g_pParentWnd->ActiveXY()->SetOrigin( *i );
g_pParentWnd->ActiveXY()->queueDraw();
{ {
Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) ); Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) );
Vector3 angles( Camera_getAngles( camwnd ) ); Vector3 angles( Camera_getAngles( camwnd ) );

View File

@ -263,10 +263,10 @@ void XYWnd::ZoomOut(){
} }
void XYWnd::ZoomInWithMouse( int pointx, int pointy ){ void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
float old_scale = Scale(); const float old_scale = Scale();
ZoomIn(); ZoomIn();
if ( g_xywindow_globals.m_bZoomInToPointer ) { if ( g_xywindow_globals.m_bZoomInToPointer && old_scale != Scale() ) {
float scale_diff = 1.0 / old_scale - 1.0 / Scale(); const float scale_diff = 1.0 / old_scale - 1.0 / Scale();
int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
int nDim2 = ( m_viewType == XY ) ? 1 : 2; int nDim2 = ( m_viewType == XY ) ? 1 : 2;
Vector3 origin = GetOrigin(); Vector3 origin = GetOrigin();
@ -776,17 +776,20 @@ const Vector3& XYWnd::GetOrigin() const {
} }
void XYWnd::SetOrigin( const Vector3& origin ){ 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(); updateModelview();
XYWnd_Update( *this );
} }
void XYWnd::Scroll( int x, int y ){ void XYWnd::Scroll( int x, int y ){
int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
int nDim2 = ( m_viewType == XY ) ? 1 : 2; int nDim2 = ( m_viewType == XY ) ? 1 : 2;
m_vOrigin[nDim1] += x / m_fScale; m_vOrigin[nDim1] += x / m_fScale;
m_vOrigin[nDim2] += y / m_fScale; m_vOrigin[nDim2] += y / m_fScale;
updateModelview();
queueDraw(); SetOrigin( m_vOrigin );
} }
FBO* XYWnd::fbo_get(){ FBO* XYWnd::fbo_get(){
@ -1146,19 +1149,6 @@ void XYWnd::Zoom_End(){
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut ); 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 ){ void XYWnd::SetViewType( VIEWTYPE viewType ){
m_viewType = viewType; m_viewType = viewType;
updateModelview(); updateModelview();
@ -2384,13 +2374,13 @@ inline AABB GetCenterBbox(){
} }
void XYWnd_Centralize( XYWnd* xywnd ){ void XYWnd_Centralize( XYWnd* xywnd ){
xywnd->PositionView( GetCenterBbox().origin ); xywnd->SetOrigin( GetCenterBbox().origin );
} }
void XY_Centralize(){ void XY_Centralize(){
const Vector3 position( GetCenterBbox().origin ); const Vector3 position( GetCenterBbox().origin );
g_pParentWnd->forEachXYWnd( [&position]( XYWnd* xywnd ){ g_pParentWnd->forEachXYWnd( [&position]( XYWnd* xywnd ){
xywnd->PositionView( position ); xywnd->SetOrigin( position );
} ); } );
} }

View File

@ -116,7 +116,6 @@ static void recaptureStates(){
captureStates(); captureStates();
} }
void PositionView( const Vector3& position );
const Vector3& GetOrigin() const; const Vector3& GetOrigin() const;
void SetOrigin( const Vector3& origin ); void SetOrigin( const Vector3& origin );
void Scroll( int x, int y ); void Scroll( int x, int y );