]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/xywindow.cpp
Merge commit '020d0244e4239b21dc804d630edff926386ea34f' into master-merge
[xonotic/netradiant.git] / radiant / xywindow.cpp
index db3802bd90e5d2b97fb983b5d7ba727ccbd0740b..e2a2d5069a0409b570bef23c484e0c034903eacc 100644 (file)
@@ -999,6 +999,18 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){
        }
 }
 
+void XYWnd::SetCustomPivotOrigin( int pointx, int pointy ){
+       Vector3 point;
+       XY_ToPoint( pointx, pointy, point );
+       VIEWTYPE viewtype = static_cast<VIEWTYPE>( GetViewType() );
+       const int nDim = ( viewtype == YZ ) ? 0 : ( ( viewtype == XZ ) ? 1 : 2 );
+       //vector3_snap( point, GetSnapGridSize() );
+       point[nDim] = 999999;
+
+       GlobalSelectionSystem().setCustomPivotOrigin( point );
+       SceneChangeNotify();
+}
+
 unsigned int MoveCamera_buttons(){
        return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
 }
@@ -1033,6 +1045,10 @@ void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
        }
 }
 
+unsigned int SetCustomPivotOrigin_buttons(){
+       return RAD_MBUTTON | RAD_SHIFT;
+}
+
 /*
    ==============
    NewBrushDrag
@@ -1236,7 +1252,9 @@ void XYWnd::Move_Begin(){
 
 void XYWnd::Move_End(){
        m_move_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_gl_widget );
+       /* NetRadiant did this instead:
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false ); */
+       g_xywnd_freezePointer.unfreeze_pointer( m_gl_widget, false );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut );
 }
 
@@ -1283,7 +1301,7 @@ void XYWnd::Zoom_Begin(){
 
 void XYWnd::Zoom_End(){
        m_zoom_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
 }
 
@@ -1344,6 +1362,9 @@ void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){
        else if ( buttons == OrientCamera_buttons() ) {
                XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
        }
+       else if ( buttons == SetCustomPivotOrigin_buttons() ) {
+               SetCustomPivotOrigin( x, y );
+       }
        else
        {
                m_window_observer->onMouseDown( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
@@ -1401,6 +1422,10 @@ void XYWnd::XY_MouseMoved( int x, int y, unsigned int buttons ){
                XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
        }
 
+       else if ( buttons == SetCustomPivotOrigin_buttons() ) {
+               SetCustomPivotOrigin( x, y );
+       }
+
        else
        {
                m_window_observer->onMouseMotion( WindowVector_forInteger( x, y ), modifiers_for_flags( buttons ) );
@@ -2188,8 +2213,8 @@ void XYWnd::updateProjection( bool reconstruct ){
        m_projection[15] = 1.0f;
 
        if (reconstruct) {
-               m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
-       }
+       m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
+}
 }
 
 // note: modelview matrix must have a uniform scale, otherwise strange things happen when rendering the rotation manipulator.
@@ -2250,7 +2275,7 @@ void XYWnd::updateModelview( bool reconstruct ){
        m_modelview[15] = 1;
 
        if (reconstruct) {
-               m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
+       m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
        }
 }