]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '6a7a6b309311c16138981200f4539770755c243a' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 03:59:45 +0000 (05:59 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 03:59:45 +0000 (05:59 +0200)
libs/gtkutil/xorrectangle.cpp
radiant/autosave.cpp
radiant/brush.h
radiant/brushmanip.cpp
radiant/camwindow.cpp
radiant/select.cpp
radiant/selection.cpp
radiant/texwindow.cpp
radiant/xywindow.cpp

index 99ff978b09e3576d35136f477f8771812f5b6255..3f519b09a4c9d6b32192a6e6dd29719b4604f896 100644 (file)
@@ -96,6 +96,7 @@ void XORRectangle::set(rectangle_t rectangle)
                                glVertex2f( rectangle.x, rectangle.y );
                                glEnd();
 
+                               glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
                                glDrawBuffer( GL_BACK );
                                GlobalOpenGL_debugAssertNoErrors();
                                //glwidget_swap_buffers( m_widget );
index 9921d4be4d9cd100e6b109cabab3b87fc3345f0c..59da27a40f7ddc368a3d064d2d380cef8e515e68 100644 (file)
@@ -106,7 +106,7 @@ void Map_Snapshot(){
  */
 
 bool g_AutoSave_Enabled = true;
-int m_AutoSave_Frequency = 5;
+int m_AutoSave_Frequency = 15;
 bool g_SnapShots_Enabled = false;
 
 namespace
index 1e5a8de855359d1413fafe72f0e0295e3d6eafa2..eb33f58547ac19a0ed6f9e551a773d336c817f81 100644 (file)
@@ -361,7 +361,8 @@ SavedState( const FaceShader& faceShader ){
 
 void exportState( FaceShader& faceShader ) const {
        faceShader.setShader( m_shader.c_str() );
-                       faceShader.m_flags = m_flags;
+       //faceShader.setFlags( m_flags );
+       faceShader.m_flags = m_flags;
 }
 };
 
index 4299ee80409e6ebab0a734aaea8521319ca454bf..426f90834c2950495dbce8ec5de99529f96349c6 100644 (file)
@@ -139,17 +139,22 @@ void Brush_ConstructPrism( Brush& brush, const AABB& bounds, std::size_t sides,
                double sv = sin( i * 3.14159265 * 2 / sides );
                double cv = cos( i * 3.14159265 * 2 / sides );
 
-               planepts[0][( axis + 1 ) % 3] = static_cast<float>( floor( mid[( axis + 1 ) % 3] + radius * cv + 0.5 ) );
-               planepts[0][( axis + 2 ) % 3] = static_cast<float>( floor( mid[( axis + 2 ) % 3] + radius * sv + 0.5 ) );
+//             planepts[0][( axis + 1 ) % 3] = static_cast<float>( floor( mid[( axis + 1 ) % 3] + radius * cv + 0.5 ) );
+//             planepts[0][( axis + 2 ) % 3] = static_cast<float>( floor( mid[( axis + 2 ) % 3] + radius * sv + 0.5 ) );
+               planepts[0][( axis + 1 ) % 3] = static_cast<float>( mid[( axis + 1 ) % 3] + radius * cv );
+               planepts[0][( axis + 2 ) % 3] = static_cast<float>( mid[( axis + 2 ) % 3] + radius * sv );
                planepts[0][axis] = mins[axis];
 
                planepts[1][( axis + 1 ) % 3] = planepts[0][( axis + 1 ) % 3];
                planepts[1][( axis + 2 ) % 3] = planepts[0][( axis + 2 ) % 3];
                planepts[1][axis] = maxs[axis];
 
-               planepts[2][( axis + 1 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 1 ) % 3] - radius * sv + 0.5 ) );
-               planepts[2][( axis + 2 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 2 ) % 3] + radius * cv + 0.5 ) );
+//             planepts[2][( axis + 1 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 1 ) % 3] - radius * sv + 0.5 ) );
+//             planepts[2][( axis + 2 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 2 ) % 3] + radius * cv + 0.5 ) );
+               planepts[2][( axis + 1 ) % 3] = static_cast<float>( planepts[0][( axis + 1 ) % 3] - radius * sv );
+               planepts[2][( axis + 2 ) % 3] = static_cast<float>( planepts[0][( axis + 2 ) % 3] + radius * cv );
                planepts[2][axis] = maxs[axis];
+               //globalOutputStream() << planepts[0] << "   " << planepts[2] << "  #" << i << "   sin " << sv << "  cos " << cv << "\n";
 
                brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
        }
@@ -190,16 +195,20 @@ void Brush_ConstructCone( Brush& brush, const AABB& bounds, std::size_t sides, c
                double sv = sin( i * 3.14159265 * 2 / sides );
                double cv = cos( i * 3.14159265 * 2 / sides );
 
-               planepts[0][0] = static_cast<float>( floor( mid[0] + radius * cv + 0.5 ) );
-               planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) );
+               planepts[0][0] = static_cast<float>( mid[0] + radius * cv );
+               planepts[0][1] = static_cast<float>( mid[1] + radius * sv );
+//             planepts[0][0] = static_cast<float>( floor( mid[0] + radius * cv + 0.5 ) );
+//             planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) );
                planepts[0][2] = mins[2];
 
                planepts[1][0] = mid[0];
                planepts[1][1] = mid[1];
                planepts[1][2] = maxs[2];
 
-               planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) );
-               planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) );
+               planepts[2][0] = static_cast<float>( planepts[0][0] - radius * sv );
+               planepts[2][1] = static_cast<float>( planepts[0][1] + radius * cv );
+//             planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) );
+//             planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) );
                planepts[2][2] = maxs[2];
 
                brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
index 97a30887531c586bdc7d36b4bb868c24d361fc8e..cba949715f54c5d3cecc65d8ba1cb3fc5ade595c 100644 (file)
@@ -913,101 +913,102 @@ void KeyEvent_disconnect( const char* name ){
 }
 
 void CamWnd_registerCommands( CamWnd& camwnd ){
-       GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_KEY_Up ),
+       GlobalKeyEvents_insert( "CameraForward", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_KEY_Down ),
+       GlobalKeyEvents_insert( "CameraBack", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_KEY_Left ),
+       GlobalKeyEvents_insert( "CameraLeft", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_KEY_Right ),
+       GlobalKeyEvents_insert( "CameraRight", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ),
+       GlobalKeyEvents_insert( "CameraStrafeRight", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ),
+       GlobalKeyEvents_insert( "CameraStrafeLeft", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraUp", Accelerator( 'D' ),
+       GlobalKeyEvents_insert( "CameraUp", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraDown", Accelerator( 'C' ),
+       GlobalKeyEvents_insert( "CameraDown", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraAngleDown", Accelerator( 'A' ),
-                                                       ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyUp>( camwnd.getCamera() )
-                                                       );
-       GlobalKeyEvents_insert( "CameraAngleUp", Accelerator( 'Z' ),
+       GlobalKeyEvents_insert( "CameraAngleUp", accelerator_null(),
                                                        ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
                                                        ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyUp>( camwnd.getCamera() )
                                                        );
+       GlobalKeyEvents_insert( "CameraAngleDown", accelerator_null(),
+                                                       ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyUp>( camwnd.getCamera() )
+                                                       );
 
-       GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ),
+
+       GlobalKeyEvents_insert( "CameraFreeMoveForward", accelerator_null(),
                                                        FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( GDK_KEY_Down ),
+       GlobalKeyEvents_insert( "CameraFreeMoveBack", accelerator_null(),
                                                        FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ),
+       GlobalKeyEvents_insert( "CameraFreeMoveLeft", accelerator_null(),
                                                        FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ),
+       GlobalKeyEvents_insert( "CameraFreeMoveRight", accelerator_null(),
                                                        FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
                                                        );
 
-       GlobalKeyEvents_insert( "CameraFreeMoveForward2", Accelerator( GDK_Up ),
+       GlobalKeyEvents_insert( "CameraFreeMoveForward2", accelerator_null(),
                                                        FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveBack2", Accelerator( GDK_Down ),
+       GlobalKeyEvents_insert( "CameraFreeMoveBack2", accelerator_null(),
                                                        FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ),
+       GlobalKeyEvents_insert( "CameraFreeMoveLeft2", accelerator_null(),
                                                        FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ),
+       GlobalKeyEvents_insert( "CameraFreeMoveRight2", accelerator_null(),
                                                        FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
                                                        );
 
-       GlobalKeyEvents_insert( "CameraFreeMoveUp", Accelerator( 'D' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveUp", accelerator_null(),
                                                        FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( 'C' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveDown", accelerator_null(),
                                                        FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
                                                        );
 
-       GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, void(), Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Up ) );
-       GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, void(), Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Down ) );
-       GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, void(), Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Left ) );
-       GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, void(), Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Right ) );
-       GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, void(), Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_period ) );
-       GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, void(), Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_comma ) );
+       GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, void(), Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, void(), Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, void(), Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, void(), Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, void(), Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, void(), Camera_MoveLeft_Discrete>( camwnd.getCamera() ) );
 
-       GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, void(), Camera_MoveUp_Discrete>( camwnd.getCamera() ), Accelerator( 'D' ) );
-       GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, void(), Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) );
-       GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, void(), Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) );
-       GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, void(), Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) );
+       GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, void(), Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, void(), Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, void(), Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
+       GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, void(), Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
 }
 
 void CamWnd_Move_Enable( CamWnd& camwnd ){
@@ -2039,6 +2040,9 @@ void CamWnd_Construct(){
        GlobalShortcuts_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ) );
        GlobalShortcuts_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ) );
 
+       GlobalShortcuts_insert( "CameraFreeMoveUp", accelerator_null() );
+       GlobalShortcuts_insert( "CameraFreeMoveDown", accelerator_null() );
+
        GlobalToggles_insert( "ShowStats", makeCallbackF(ShowStatsToggle), ToggleItem::AddCallbackCaller( g_show_stats ) );
 
        GlobalPreferenceSystem().registerPreference( "ShowStats", make_property_string( g_camwindow_globals_private.m_showStats ) );
index 22d0a963fc21269e6b09e988bfb3ac6f6eac6bb1..8e749542975c5d62dcab68f6f6784ab4a4dcc0cb 100644 (file)
@@ -1162,7 +1162,7 @@ void DoRotateDlg(){
                                }
                                {
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
-                                       auto spin = ui::SpinButton( adj, 1, 0 );
+                                       auto spin = ui::SpinButton( adj, 1, 1 );
                                        spin.show();
                     table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
                     spin.dimensions(64, -1);
@@ -1174,7 +1174,7 @@ void DoRotateDlg(){
                                }
                                {
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
-                                       auto spin = ui::SpinButton( adj, 1, 0 );
+                                       auto spin = ui::SpinButton( adj, 1, 1 );
                                        spin.show();
                     table.attach(spin, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
                     spin.dimensions(64, -1);
@@ -1184,7 +1184,7 @@ void DoRotateDlg(){
                                }
                                {
                                        auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
-                                       auto spin = ui::SpinButton( adj, 1, 0 );
+                                       auto spin = ui::SpinButton( adj, 1, 1 );
                                        spin.show();
                     table.attach(spin, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
                     spin.dimensions(64, -1);
index e8d16c95be6f031f7fb22d5144f4f545b5b21a9e..11e2337e0e63700348c4b790546f00f7d4291949 100644 (file)
@@ -194,7 +194,7 @@ class Manipulatable
 {
 public:
 virtual void Construct( const Matrix4& device2manip, const float x, const float y ) = 0;
-virtual void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ) = 0;
+virtual void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ) = 0;
 };
 
 void transform_local2object( Matrix4& object, const Matrix4& local, const Matrix4& local2object ){
@@ -223,12 +223,26 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
        point_on_sphere( m_start, device2manip, x, y );
        vector3_normalise( m_start );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        Vector3 current;
-
        point_on_sphere( current, device2manip, x, y );
-       vector3_normalise( current );
 
+       if( snap ){
+               Vector3 axis( 0, 0, 0 );
+               for( std::size_t i = 0; i < 3; ++i ){
+                       if( current[i] == 0.0f ){
+                               axis[i] = 1.0f;
+                               break;
+                       }
+               }
+               if( vector3_length_squared( axis ) != 0 ){
+                       constrain_to_axis( current, axis );
+                       m_rotatable.rotate( quaternion_for_axisangle( axis, float_snapped( angle_for_axis( m_start, current, axis ), static_cast<float>( c_pi / 12.0 ) ) ) );
+                       return;
+               }
+       }
+
+       vector3_normalise( current );
        m_rotatable.rotate( quaternion_for_unit_vectors( m_start, current ) );
 }
 };
@@ -247,12 +261,17 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
        constrain_to_axis( m_start, m_axis );
 }
 /// \brief Converts current position to a normalised vector orthogonal to axis.
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        Vector3 current;
        point_on_sphere( current, device2manip, x, y );
        constrain_to_axis( current, m_axis );
 
-       m_rotatable.rotate( quaternion_for_axisangle( m_axis, angle_for_axis( m_start, current, m_axis ) ) );
+       if( snap ){
+               m_rotatable.rotate( quaternion_for_axisangle( m_axis, float_snapped( angle_for_axis( m_start, current, m_axis ), static_cast<float>( c_pi / 12.0 ) ) ) );
+       }
+       else{
+               m_rotatable.rotate( quaternion_for_axisangle( m_axis, angle_for_axis( m_start, current, m_axis ) ) );
+       }
 }
 
 void SetAxis( const Vector3& axis ){
@@ -288,7 +307,7 @@ TranslateAxis( Translatable& translatable )
 void Construct( const Matrix4& device2manip, const float x, const float y ){
        point_on_axis( m_start, m_axis, device2manip, x, y );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        Vector3 current;
        point_on_axis( current, m_axis, device2manip, x, y );
        current = vector3_scaled( m_axis, distance_for_axis( m_start, current, m_axis ) );
@@ -316,11 +335,22 @@ TranslateFree( Translatable& translatable )
 void Construct( const Matrix4& device2manip, const float x, const float y ){
        point_on_plane( m_start, device2manip, x, y );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        Vector3 current;
        point_on_plane( current, device2manip, x, y );
        current = vector3_subtracted( current, m_start );
 
+       if( snap ){
+               for ( std::size_t i = 0; i < 3 ; ++i ){
+                       if( fabs( current[i] ) >= fabs( current[(i + 1) % 3] ) ){
+                               current[(i + 1) % 3] = 0.0f;
+                       }
+                       else{
+                               current[i] = 0.0f;
+                       }
+               }
+       }
+
        translation_local2object( current, current, manip2object );
        vector3_snap( current, GetSnapGridSize() );
 
@@ -329,7 +359,7 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 };
 
 void GetSelectionAABB( AABB& bounds );
-const Matrix4& ssGetPivot2World();
+const Matrix4& SelectionSystem_GetPivot2World();
 
 class Scalable
 {
@@ -357,14 +387,15 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 
        AABB aabb;
        GetSelectionAABB( aabb );
-       Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
-       m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+       Vector3 transform_origin = vector4_to_vector3( SelectionSystem_GetPivot2World().t() );
+       m_choosen_extent = Vector3(
+                                       std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
                                        std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
                                        std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
                                                        );
 
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        //globalOutputStream() << "manip2object: " << manip2object << "  device2manip: " << device2manip << "  x: " << x << "  y:" << y <<"\n";
        Vector3 current;
        point_on_axis( current, m_axis, device2manip, x, y );
@@ -373,8 +404,13 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
        translation_local2object( delta, delta, manip2object );
        vector3_snap( delta, GetSnapGridSize() );
 
-       Vector3 start( vector3_snapped( m_start, GetSnapGridSize() ) );
-       //globalOutputStream() << "start: " << start << "   delta: " << delta <<"\n";
+       Vector3 start( vector3_snapped( m_start, GetSnapGridSize() != 0.0f ? GetSnapGridSize() : 0.001f ) );
+       for ( std::size_t i = 0; i < 3 ; ++i ){ //prevent snapping to 0 with big gridsize
+               if( float_snapped( m_start[i], 0.001f ) != 0.0f && start[i] == 0.0f ){
+                       start[i] = GetSnapGridSize();
+               }
+       }
+       //globalOutputStream() << "m_start: " << m_start << "   start: " << start << "   delta: " << delta <<"\n";
        Vector3 scale(
                start[0] == 0 ? 1 : 1 + delta[0] / start[0],
                start[1] == 0 ? 1 : 1 + delta[1] / start[1],
@@ -382,11 +418,18 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
                );
 
        for( std::size_t i = 0; i < 3; i++ ){
-               if( m_choosen_extent[i] > 0.0625 ){ //epsilon to prevent too high scale for set of models, having really small extent, formed by origins
+               if( m_choosen_extent[i] > 0.0625f ){ //epsilon to prevent super high scale for set of models, having really small extent, formed by origins
                        scale[i] = ( m_choosen_extent[i] + delta[i] ) / m_choosen_extent[i];
                }
        }
-
+       if( snap ){
+               for( std::size_t i = 0; i < 3; i++ ){
+                       if( scale[i] == 1.0f ){
+                               scale[i] = vector3_dot( scale, m_axis );
+                       }
+               }
+       }
+       //globalOutputStream() << "scale: " << scale <<"\n";
        m_scalable.scale( scale );
 }
 
@@ -412,13 +455,14 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
 
        AABB aabb;
        GetSelectionAABB( aabb );
-       Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() );
-       m_choosen_extent = Vector3( std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
+       Vector3 transform_origin = vector4_to_vector3( SelectionSystem_GetPivot2World().t() );
+       m_choosen_extent = Vector3(
+                                       std::max( aabb.origin[0] + aabb.extents[0] - transform_origin[0], - aabb.origin[0] + aabb.extents[0] + transform_origin[0] ),
                                        std::max( aabb.origin[1] + aabb.extents[1] - transform_origin[1], - aabb.origin[1] + aabb.extents[1] + transform_origin[1] ),
                                        std::max( aabb.origin[2] + aabb.extents[2] - transform_origin[2], - aabb.origin[2] + aabb.extents[2] + transform_origin[2] )
                                                        );
 }
-void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y ){
+void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const float x, const float y, const bool snap ){
        Vector3 current;
        point_on_plane( current, device2manip, x, y );
        Vector3 delta = vector3_subtracted( current, m_start );
@@ -426,19 +470,41 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
        translation_local2object( delta, delta, manip2object );
        vector3_snap( delta, GetSnapGridSize() );
 
-       Vector3 start( vector3_snapped( m_start, GetSnapGridSize() ) );
+       Vector3 start( vector3_snapped( m_start, GetSnapGridSize() != 0.0f ? GetSnapGridSize() : 0.001f ) );
+       for ( std::size_t i = 0; i < 3 ; ++i ){ //prevent snapping to 0 with big gridsize
+               if( float_snapped( m_start[i], 0.001f ) != 0.0f && start[i] == 0.0f ){
+                       start[i] = GetSnapGridSize();
+               }
+       }
        Vector3 scale(
                start[0] == 0 ? 1 : 1 + delta[0] / start[0],
                start[1] == 0 ? 1 : 1 + delta[1] / start[1],
                start[2] == 0 ? 1 : 1 + delta[2] / start[2]
                );
 
+       //globalOutputStream() << "m_start: " << m_start << "   start: " << start << "   delta: " << delta <<"\n";
        for( std::size_t i = 0; i < 3; i++ ){
-               if( m_choosen_extent[i] > 0.0625 ){
+               if( m_choosen_extent[i] > 0.0625f ){
                        scale[i] = ( m_choosen_extent[i] + delta[i] ) / m_choosen_extent[i];
                }
        }
-
+       //globalOutputStream() << "pre snap scale: " << scale <<"\n";
+       if( snap ){
+               float bestscale = scale[0];
+               for( std::size_t i = 1; i < 3; i++ ){
+                       //if( fabs( 1.0f - fabs( scale[i] ) ) > fabs( 1.0f - fabs( bestscale ) ) ){
+                       if( fabs( scale[i] ) > fabs( bestscale ) && scale[i] != 1.0f ){ //harder to scale down with this, but glitchier with upper one
+                               bestscale = scale[i];
+                       }
+                       //globalOutputStream() << "bestscale: " << bestscale <<"\n";
+               }
+               for( std::size_t i = 0; i < 3; i++ ){
+                       if( start[i] != 0.0f ){ // !!!!check grid == 0 case
+                               scale[i] = ( scale[i] < 0.0f ) ? -fabs( bestscale ) : fabs( bestscale );
+                       }
+               }
+       }
+       //globalOutputStream() << "scale: " << scale <<"\n";
        m_scalable.scale( scale );
 }
 };
@@ -944,6 +1010,8 @@ RotateManipulator( Rotatable& rotatable, std::size_t segments, float radius ) :
 
        draw_circle( segments, radius * 1.15f, m_circle_screen.m_vertices.data(), RemapXYZ() );
        draw_circle( segments, radius, m_circle_sphere.m_vertices.data(), RemapXYZ() );
+
+       m_selectable_sphere.setSelected( true );
 }
 
 
@@ -3220,7 +3288,7 @@ void scaleSelected( const Vector3& scaling ){
        freezeTransforms();
 }
 
-void MoveSelected( const View& view, const float device_point[2] ){
+void MoveSelected( const View& view, const float device_point[2], bool snap ){
        if ( m_manipulator->isSelected() ) {
                if ( !m_undo_begun ) {
                        m_undo_begun = true;
@@ -3229,7 +3297,7 @@ void MoveSelected( const View& view, const float device_point[2] ){
 
                Matrix4 device2manip;
                ConstructDevice2Manip( device2manip, m_pivot2world_start, view.GetModelview(), view.GetProjection(), view.GetViewport() );
-               m_manipulator->GetManipulatable()->Transform( m_manip2pivot_start, device2manip, device_point[0], device_point[1] );
+               m_manipulator->GetManipulatable()->Transform( m_manip2pivot_start, device2manip, device_point[0], device_point[1], snap );
        }
 }
 
@@ -3621,11 +3689,6 @@ void RadiantSelectionSystem::ConstructPivot() const {
 }
 
 void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
-       /*if ( !m_pivotChanged || m_pivot_moving ) {
-               return;
-       }*/
-       //m_pivotChanged = false;
-
        if ( !nothingSelected() && ( m_manipulator_mode == eTranslate || m_manipulator_mode == eRotate || m_manipulator_mode == eScale ) ) {
                AABB bounds;
                if ( Mode() == eComponent ) {
@@ -3636,11 +3699,8 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
                        Scene_BoundsSelected( GlobalSceneGraph(), bounds );
                }
                //globalOutputStream() << point << "\n";
-               const float gridsize = GetSnapGridSize();
-               //const float bbox_epsilon = gridsize / 4.0;
-
                for( std::size_t i = 0; i < 3; i++ ){
-                       if( point[i] < 900000 ){
+                       if( point[i] < 900000.0f ){
                                float bestsnapDist = fabs( bounds.origin[i] - point[i] );
                                float bestsnapTo = bounds.origin[i];
                                float othersnapDist = fabs( bounds.origin[i] + bounds.extents[i] - point[i] );
@@ -3653,20 +3713,13 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
                                        bestsnapDist = othersnapDist;
                                        bestsnapTo = bounds.origin[i] - bounds.extents[i];
                                }
-                               othersnapDist = fabs( float_snapped( point[i], gridsize ) - point[i] );
+                               othersnapDist = fabs( float_snapped( point[i], GetSnapGridSize() ) - point[i] );
                                if( othersnapDist < bestsnapDist ){
                                        bestsnapDist = othersnapDist;
-                                       bestsnapTo = float_snapped( point[i], gridsize );
+                                       bestsnapTo = float_snapped( point[i], GetSnapGridSize() );
                                }
                                point[i] = bestsnapTo;
 
-/*                             if( float_equal_epsilon( point[i], bestsnapTo, bbox_epsilon ) ){
-                                       point[i] = bestsnapTo;
-                               }
-                               else{
-                                       point[i] = float_snapped( point[i], gridsize );
-                               }
-                               */
                                m_pivot2world[i + 12] = point[i]; //m_pivot2world.tx() .ty() .tz()
                        }
                }
@@ -3696,8 +3749,9 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
                default:
                        break;
                }
+
+               m_pivotIsCustom = true;
        }
-       m_pivotIsCustom = true;
 }
 
 void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const {
@@ -3716,7 +3770,7 @@ void GetSelectionAABB( AABB& bounds ){
        getSelectionSystem().getSelectionAABB( bounds );
 }
 
-const Matrix4& ssGetPivot2World(){
+const Matrix4& SelectionSystem_GetPivot2World(){
        return getSelectionSystem().GetPivot2World();
 }
 
@@ -3983,13 +4037,17 @@ class Manipulator_
 public:
 DeviceVector m_epsilon;
 const View* m_view;
+ModifierFlags m_state;
+
+Manipulator_() : m_state( c_modifierNone ){
+}
 
 bool mouseDown( DeviceVector position ){
        return getSelectionSystem().SelectManipulator( *m_view, &position[0], &m_epsilon[0] );
 }
 
 void mouseMoved( DeviceVector position ){
-       getSelectionSystem().MoveSelected( *m_view, &position[0] );
+       getSelectionSystem().MoveSelected( *m_view, &position[0], ( m_state & c_modifierShift ) == c_modifierShift );
 }
 typedef MemberCaller<Manipulator_, void(DeviceVector), &Manipulator_::mouseMoved> MouseMovedCaller;
 
@@ -3999,6 +4057,21 @@ void mouseUp( DeviceVector position ){
        g_mouseUpCallback.clear();
 }
 typedef MemberCaller<Manipulator_, void(DeviceVector), &Manipulator_::mouseUp> MouseUpCaller;
+
+void setState( ModifierFlags state ){
+       m_state = state;
+}
+
+ModifierFlags getState() const {
+       return m_state;
+}
+
+void modifierEnable( ModifierFlags type ){
+       setState( bitfield_enable( getState(), type ) );
+}
+void modifierDisable( ModifierFlags type ){
+       setState( bitfield_disable( getState(), type ) );
+}
 };
 
 void Scene_copyClosestTexture( SelectionTest& test );
@@ -4103,9 +4176,11 @@ void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierF
 }
 void onModifierDown( ModifierFlags type ){
        m_selector.modifierEnable( type );
+       m_manipulator.modifierEnable( type );
 }
 void onModifierUp( ModifierFlags type ){
        m_selector.modifierDisable( type );
+       m_manipulator.modifierDisable( type );
 }
 };
 
index 7670d20c61b08543aa4a4388c70aeb09bf854808..4068f27b551b7ebab1314e0361edb0d021ad5d3b 100644 (file)
@@ -337,6 +337,7 @@ bool m_move_started;
 int m_uniformTextureSize;
 int m_uniformTextureMinSize;
 
+bool m_hideNonShadersInCommon;
 // Return the display width of a texture in the texture browser
 void getTextureWH( qtexture_t* tex, int &W, int &H ){
                // Don't use uniform size
@@ -397,6 +398,7 @@ TextureBrowser() :
        m_tags( false ),
        m_uniformTextureSize( 160 ),
        m_uniformTextureMinSize( 48 ),
+       m_hideNonShadersInCommon( true ),
        m_move_started( false ){
 }
 };
@@ -535,7 +537,7 @@ bool TextureSearch_IsShown( const char* name ){
 }
 
 // if texture_showinuse jump over non in-use textures
-bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused ){
+bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused, bool hideNonShadersInCommon ){
        // filter missing shaders
        // ugly: filter on built-in fallback name after substitution
        if ( g_TextureBrowser_filterMissing ) {
@@ -582,6 +584,11 @@ bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bo
                return false;
        }
 
+       if( hideNonShadersInCommon && shader->IsDefault() && !shader->IsInUse() //&& g_TextureBrowser_currentDirectory != ""
+               && shader_equal_prefix( shader_get_textureName( shader->getName() ), TextureBrowser_getCommonShadersDir() ) ){
+               return false;
+       }
+
        if ( GlobalTextureBrowser().m_searchedTags ) {
                if ( !TextureSearch_IsShown( shader->getName() ) ) {
                        return false;
@@ -626,7 +633,7 @@ void TextureBrowser_evaluateHeight( TextureBrowser& textureBrowser ){
                {
                        IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-                       if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+                       if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
                                continue;
                        }
 
@@ -1020,13 +1027,7 @@ void TextureBrowser_enableAlpha( const Callback<void(bool)> & importer ){
 typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
 
 void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
-       if ( hideUnused ) {
-               textureBrowser.m_hideUnused = true;
-       }
-       else
-       {
-               textureBrowser.m_hideUnused = false;
-       }
+       textureBrowser.m_hideUnused = hideUnused;
 
        textureBrowser.m_hideunused_item.update();
 
@@ -1054,7 +1055,7 @@ void TextureBrowser_Focus( TextureBrowser& textureBrowser, const char* name ){
        {
                IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
                        continue;
                }
 
@@ -1098,7 +1099,7 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){
        {
                IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
                        continue;
                }
 
@@ -1248,7 +1249,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
        {
                IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
 
-               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused ) ) {
+               if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) {
                        continue;
                }
 
@@ -3008,6 +3009,14 @@ void TextureBrowser_constructPreferences( PreferencesPage& page ){
                const char* startup_shaders[] = { "None", TextureBrowser_getCommonShadersName() };
                page.appendCombo( "Load Shaders at Startup", reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ), STRING_ARRAY_RANGE( startup_shaders ) );
        }
+       {
+               StringOutputStream sstream( 256 );
+               sstream << "Hide nonShaders in " << TextureBrowser_getCommonShadersDir() << " folder";
+               page.appendCheckBox(
+                       "", sstream.c_str(),
+                       GlobalTextureBrowser().m_hideNonShadersInCommon
+                       );
+       }
 }
 
 void TextureBrowser_constructPage( PreferenceGroup& group ){
@@ -3062,6 +3071,7 @@ void TextureBrowser_Construct(){
        GlobalPreferenceSystem().registerPreference( "LoadShaders", make_property_string( reinterpret_cast<int&>( textureBrowser.m_startupShaders ) ) );
        GlobalPreferenceSystem().registerPreference( "WheelMouseInc", make_property_string( textureBrowser.m_mouseWheelScrollIncrement ) );
        GlobalPreferenceSystem().registerPreference( "SI_Colors0", make_property_string( textureBrowser.color_textureback ) );
+       GlobalPreferenceSystem().registerPreference( "HideNonShadersInCommon", make_property_string( GlobalTextureBrowser().m_hideNonShadersInCommon ) );
 
        textureBrowser.shader = texdef_name_default();
 
index 5024d68f69246e5652d6ee7272db05eef3166cee..a238d056745bb6280480fe62943adcfc406f392c 100644 (file)
@@ -2179,6 +2179,7 @@ void XYWnd::UpdateCameraIcon( void ){
                                XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
 
                                glDisable( GL_BLEND );
+                               glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
                        }
 
                        glDrawBuffer( GL_BACK );
@@ -2629,6 +2630,7 @@ void XYWnd::XY_Draw(){
        glEnable( GL_BLEND );
        glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
        DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
+       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glDisable( GL_BLEND );
 
        Feedback_draw2D( m_viewType );