binds...
	* m1 + shift drag: snapped modes of manipulators:
		freedrag: constrain to axis with biggest move amount
		rotate axis: snap to angles, multiple of 15'
		scale axis: scale all axes synchronously
		scale free: scale axes with non zero drag synchronously (i.e. two visible ones in projection views)
misc...
	* fix: CameraFreeMoveUp, CameraFreeMoveDown shortcuts are editable
	* prism, cone prefabs: increased precision
	* fix: out of pivot rotating is active from start, no additional magic is needed for that
	* fix: could lock (but not set) transform origin in non-pivoted mode
	* arbitrary rotation dialog allows decimals
	* fix: grid rendering with ToggleGridSnap off
	* fix of: scale tool scale, locked to 1 for things w/o bbox with bigger grid (e.g. single misc_model)
		(snapped drag start was = 0, scale func depends on initial click point: closer to center = more extreme scaling)
	* fix: make detail / structural are undoable
	* default autosave period: 5 -> 15 minutes
	* texBro option: hide nonShaders in common folder; def = yes; are shown, if are in use
This commit is contained in:
Garux 2017-08-02 09:10:43 +03:00
parent c845c5cd8f
commit 3a78d90201
9 changed files with 214 additions and 112 deletions

View File

@ -122,6 +122,7 @@ void set( rectangle_t rectangle ){
glVertex2f( rectangle.x, rectangle.y ); glVertex2f( rectangle.x, rectangle.y );
glEnd(); glEnd();
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDrawBuffer( GL_BACK ); glDrawBuffer( GL_BACK );
GlobalOpenGL_debugAssertNoErrors(); GlobalOpenGL_debugAssertNoErrors();
//glwidget_swap_buffers( m_widget ); //glwidget_swap_buffers( m_widget );

View File

@ -104,7 +104,7 @@ void Map_Snapshot(){
*/ */
bool g_AutoSave_Enabled = true; bool g_AutoSave_Enabled = true;
int m_AutoSave_Frequency = 5; int m_AutoSave_Frequency = 15;
bool g_SnapShots_Enabled = false; bool g_SnapShots_Enabled = false;
namespace namespace

View File

@ -376,7 +376,8 @@ SavedState( const FaceShader& faceShader ){
void exportState( FaceShader& faceShader ) const { void exportState( FaceShader& faceShader ) const {
faceShader.setShader( m_shader.c_str() ); faceShader.setShader( m_shader.c_str() );
faceShader.setFlags( m_flags ); //faceShader.setFlags( m_flags );
faceShader.m_flags = m_flags;
} }
}; };

View File

@ -138,17 +138,22 @@ void Brush_ConstructPrism( Brush& brush, const AABB& bounds, std::size_t sides,
double sv = sin( i * 3.14159265 * 2 / sides ); double sv = sin( i * 3.14159265 * 2 / sides );
double cv = cos( 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 + 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 + 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[0][axis] = mins[axis];
planepts[1][( axis + 1 ) % 3] = planepts[0][( axis + 1 ) % 3]; planepts[1][( axis + 1 ) % 3] = planepts[0][( axis + 1 ) % 3];
planepts[1][( axis + 2 ) % 3] = planepts[0][( axis + 2 ) % 3]; planepts[1][( axis + 2 ) % 3] = planepts[0][( axis + 2 ) % 3];
planepts[1][axis] = maxs[axis]; 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 + 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 + 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]; 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 ); brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
} }
@ -189,16 +194,20 @@ void Brush_ConstructCone( Brush& brush, const AABB& bounds, std::size_t sides, c
double sv = sin( i * 3.14159265 * 2 / sides ); double sv = sin( i * 3.14159265 * 2 / sides );
double cv = cos( 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][0] = static_cast<float>( mid[0] + radius * cv );
planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) ); 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[0][2] = mins[2];
planepts[1][0] = mid[0]; planepts[1][0] = mid[0];
planepts[1][1] = mid[1]; planepts[1][1] = mid[1];
planepts[1][2] = maxs[2]; planepts[1][2] = maxs[2];
planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) ); planepts[2][0] = static_cast<float>( planepts[0][0] - radius * sv );
planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) ); 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]; planepts[2][2] = maxs[2];
brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection ); brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
@ -428,12 +437,12 @@ void Scene_BrushSetTexdef_Component_Selected( scene::Graph& graph, const Texture
class FaceSetFlags class FaceSetFlags
{ {
const ContentsFlagsValue& m_projection; const ContentsFlagsValue& m_flags;
public: public:
FaceSetFlags( const ContentsFlagsValue& flags ) : m_projection( flags ){ FaceSetFlags( const ContentsFlagsValue& flags ) : m_flags( flags ){
} }
void operator()( Face& face ) const { void operator()( Face& face ) const {
face.SetFlags( m_projection ); face.SetFlags( m_flags );
} }
}; };

View File

@ -319,17 +319,17 @@ void Camera_FreeMove( camera_t& camera, int dx, int dy ){
} }
void Cam_MouseControl( camera_t& camera, int x, int y ){ void Cam_MouseControl( camera_t& camera, int x, int y ){
int xl, xh; // int xl, xh;
int yl, yh; // int yl, yh;
float xf, yf; float xf, yf;
xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 ); xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 ); yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
xl = camera.width / 3; // xl = camera.width / 3;
xh = xl * 2; // xh = xl * 2;
yl = camera.height / 3; // yl = camera.height / 3;
yh = yl * 2; // yh = yl * 2;
xf *= 1.0f - fabsf( yf ); xf *= 1.0f - fabsf( yf );
if ( xf < 0 ) { if ( xf < 0 ) {
@ -913,101 +913,101 @@ void KeyEvent_disconnect( const char* name ){
} }
void CamWnd_registerCommands( CamWnd& camwnd ){ void CamWnd_registerCommands( CamWnd& camwnd ){
GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ), GlobalKeyEvents_insert( "CameraForward", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ), GlobalKeyEvents_insert( "CameraBack", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ), GlobalKeyEvents_insert( "CameraLeft", accelerator_null(),
ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ), GlobalKeyEvents_insert( "CameraRight", accelerator_null(),
ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ), GlobalKeyEvents_insert( "CameraStrafeRight", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ), GlobalKeyEvents_insert( "CameraStrafeLeft", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraUp", Accelerator( 'D' ), GlobalKeyEvents_insert( "CameraUp", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveUp_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveUp_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveUp_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraDown", Accelerator( 'C' ), GlobalKeyEvents_insert( "CameraDown", accelerator_null(),
ReferenceCaller<camera_t, Camera_MoveDown_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_MoveDown_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_MoveDown_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraAngleDown", Accelerator( 'A' ), GlobalKeyEvents_insert( "CameraAngleUp", accelerator_null(),
ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraAngleUp", Accelerator( 'Z' ),
ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( camwnd.getCamera() ), ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_PitchUp_KeyUp>( camwnd.getCamera() ) ReferenceCaller<camera_t, Camera_PitchUp_KeyUp>( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraAngleDown", accelerator_null(),
ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( 'W' ), GlobalKeyEvents_insert( "CameraFreeMoveForward", accelerator_null(),
FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( 'S' ), GlobalKeyEvents_insert( "CameraFreeMoveBack", accelerator_null(),
FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( 'A' ), GlobalKeyEvents_insert( "CameraFreeMoveLeft", accelerator_null(),
FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( 'D' ), GlobalKeyEvents_insert( "CameraFreeMoveRight", accelerator_null(),
FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveForward2", Accelerator( GDK_Up ), GlobalKeyEvents_insert( "CameraFreeMoveForward2", accelerator_null(),
FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveBack2", Accelerator( GDK_Down ), GlobalKeyEvents_insert( "CameraFreeMoveBack2", accelerator_null(),
FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ), GlobalKeyEvents_insert( "CameraFreeMoveLeft2", accelerator_null(),
FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ), GlobalKeyEvents_insert( "CameraFreeMoveRight2", accelerator_null(),
FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveUp", Accelerator( GDK_period ), GlobalKeyEvents_insert( "CameraFreeMoveUp", accelerator_null(),
FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() )
); );
GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( GDK_comma ), GlobalKeyEvents_insert( "CameraFreeMoveDown", accelerator_null(),
FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ), FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() ) FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
); );
GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Up ) ); GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Down ) ); GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Left ) ); GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Right ) ); GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_period ) ); GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_comma ) ); GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ), Accelerator( 'D' ) ); GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) ); GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) ); GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) ); GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
} }
void CamWnd_Move_Enable( CamWnd& camwnd ){ void CamWnd_Move_Enable( CamWnd& camwnd ){
@ -1997,6 +1997,9 @@ void CamWnd_Construct(){
GlobalShortcuts_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ) ); GlobalShortcuts_insert( "CameraFreeMoveLeft2", Accelerator( GDK_Left ) );
GlobalShortcuts_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ) ); GlobalShortcuts_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ) );
GlobalShortcuts_insert( "CameraFreeMoveUp", accelerator_null() );
GlobalShortcuts_insert( "CameraFreeMoveDown", accelerator_null() );
GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) ); GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) ); GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );

View File

@ -1169,7 +1169,7 @@ void DoRotateDlg(){
} }
{ {
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
gtk_widget_show( GTK_WIDGET( spin ) ); gtk_widget_show( GTK_WIDGET( spin ) );
gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1, gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
@ -1183,7 +1183,7 @@ void DoRotateDlg(){
} }
{ {
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
gtk_widget_show( GTK_WIDGET( spin ) ); gtk_widget_show( GTK_WIDGET( spin ) );
gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2, gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
@ -1195,7 +1195,7 @@ void DoRotateDlg(){
} }
{ {
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) ); GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) ); GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
gtk_widget_show( GTK_WIDGET( spin ) ); gtk_widget_show( GTK_WIDGET( spin ) );
gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3, gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),

View File

@ -193,7 +193,7 @@ class Manipulatable
{ {
public: public:
virtual void Construct( const Matrix4& device2manip, const float x, const float y ) = 0; 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 ){ void transform_local2object( Matrix4& object, const Matrix4& local, const Matrix4& local2object ){
@ -221,12 +221,26 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
point_on_sphere( m_start, device2manip, x, y ); point_on_sphere( m_start, device2manip, x, y );
vector3_normalise( m_start ); 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; Vector3 current;
point_on_sphere( current, device2manip, x, y ); 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 ) ); m_rotatable.rotate( quaternion_for_unit_vectors( m_start, current ) );
} }
}; };
@ -245,12 +259,17 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
constrain_to_axis( m_start, m_axis ); constrain_to_axis( m_start, m_axis );
} }
/// \brief Converts current position to a normalised vector orthogonal to 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; Vector3 current;
point_on_sphere( current, device2manip, x, y ); point_on_sphere( current, device2manip, x, y );
constrain_to_axis( current, m_axis ); constrain_to_axis( 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 ) ) ); m_rotatable.rotate( quaternion_for_axisangle( m_axis, angle_for_axis( m_start, current, m_axis ) ) );
}
} }
void SetAxis( const Vector3& axis ){ void SetAxis( const Vector3& axis ){
@ -285,7 +304,7 @@ TranslateAxis( Translatable& translatable )
void Construct( const Matrix4& device2manip, const float x, const float y ){ void Construct( const Matrix4& device2manip, const float x, const float y ){
point_on_axis( m_start, m_axis, device2manip, x, 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; Vector3 current;
point_on_axis( current, m_axis, device2manip, x, y ); point_on_axis( current, m_axis, device2manip, x, y );
current = vector3_scaled( m_axis, distance_for_axis( m_start, current, m_axis ) ); current = vector3_scaled( m_axis, distance_for_axis( m_start, current, m_axis ) );
@ -313,11 +332,22 @@ TranslateFree( Translatable& translatable )
void Construct( const Matrix4& device2manip, const float x, const float y ){ void Construct( const Matrix4& device2manip, const float x, const float y ){
point_on_plane( m_start, device2manip, x, 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; Vector3 current;
point_on_plane( current, device2manip, x, y ); point_on_plane( current, device2manip, x, y );
current = vector3_subtracted( current, m_start ); 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 ); translation_local2object( current, current, manip2object );
vector3_snap( current, GetSnapGridSize() ); vector3_snap( current, GetSnapGridSize() );
@ -326,7 +356,7 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
}; };
void GetSelectionAABB( AABB& bounds ); void GetSelectionAABB( AABB& bounds );
const Matrix4& ssGetPivot2World(); const Matrix4& SelectionSystem_GetPivot2World();
class Scalable class Scalable
{ {
@ -353,14 +383,15 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
AABB aabb; AABB aabb;
GetSelectionAABB( aabb ); GetSelectionAABB( aabb );
Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() ); 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] ), 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[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] ) 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"; //globalOutputStream() << "manip2object: " << manip2object << " device2manip: " << device2manip << " x: " << x << " y:" << y <<"\n";
Vector3 current; Vector3 current;
point_on_axis( current, m_axis, device2manip, x, y ); point_on_axis( current, m_axis, device2manip, x, y );
@ -369,8 +400,13 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
translation_local2object( delta, delta, manip2object ); translation_local2object( delta, delta, manip2object );
vector3_snap( delta, GetSnapGridSize() ); vector3_snap( delta, GetSnapGridSize() );
Vector3 start( vector3_snapped( m_start, GetSnapGridSize() ) ); Vector3 start( vector3_snapped( m_start, GetSnapGridSize() != 0.0f ? GetSnapGridSize() : 0.001f ) );
//globalOutputStream() << "start: " << start << " delta: " << delta <<"\n"; 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( Vector3 scale(
start[0] == 0 ? 1 : 1 + delta[0] / start[0], start[0] == 0 ? 1 : 1 + delta[0] / start[0],
start[1] == 0 ? 1 : 1 + delta[1] / start[1], start[1] == 0 ? 1 : 1 + delta[1] / start[1],
@ -378,11 +414,18 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
); );
for( std::size_t i = 0; i < 3; i++ ){ 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]; 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 ); m_scalable.scale( scale );
} }
@ -408,13 +451,14 @@ void Construct( const Matrix4& device2manip, const float x, const float y ){
AABB aabb; AABB aabb;
GetSelectionAABB( aabb ); GetSelectionAABB( aabb );
Vector3 transform_origin = vector4_to_vector3( ssGetPivot2World().t() ); 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] ), 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[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] ) 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; Vector3 current;
point_on_plane( current, device2manip, x, y ); point_on_plane( current, device2manip, x, y );
Vector3 delta = vector3_subtracted( current, m_start ); Vector3 delta = vector3_subtracted( current, m_start );
@ -422,19 +466,41 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
translation_local2object( delta, delta, manip2object ); translation_local2object( delta, delta, manip2object );
vector3_snap( delta, GetSnapGridSize() ); 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( Vector3 scale(
start[0] == 0 ? 1 : 1 + delta[0] / start[0], start[0] == 0 ? 1 : 1 + delta[0] / start[0],
start[1] == 0 ? 1 : 1 + delta[1] / start[1], start[1] == 0 ? 1 : 1 + delta[1] / start[1],
start[2] == 0 ? 1 : 1 + delta[2] / start[2] 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++ ){ 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]; 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 ); m_scalable.scale( scale );
} }
}; };
@ -940,6 +1006,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 * 1.15f, m_circle_screen.m_vertices.data(), RemapXYZ() );
draw_circle( segments, radius, m_circle_sphere.m_vertices.data(), RemapXYZ() ); draw_circle( segments, radius, m_circle_sphere.m_vertices.data(), RemapXYZ() );
m_selectable_sphere.setSelected( true );
} }
@ -3216,7 +3284,7 @@ void scaleSelected( const Vector3& scaling ){
freezeTransforms(); 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_manipulator->isSelected() ) {
if ( !m_undo_begun ) { if ( !m_undo_begun ) {
m_undo_begun = true; m_undo_begun = true;
@ -3225,7 +3293,7 @@ void MoveSelected( const View& view, const float device_point[2] ){
Matrix4 device2manip; Matrix4 device2manip;
ConstructDevice2Manip( device2manip, m_pivot2world_start, view.GetModelview(), view.GetProjection(), view.GetViewport() ); 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 );
} }
} }
@ -3617,11 +3685,6 @@ void RadiantSelectionSystem::ConstructPivot() const {
} }
void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) 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 ) ) { if ( !nothingSelected() && ( m_manipulator_mode == eTranslate || m_manipulator_mode == eRotate || m_manipulator_mode == eScale ) ) {
AABB bounds; AABB bounds;
if ( Mode() == eComponent ) { if ( Mode() == eComponent ) {
@ -3632,11 +3695,8 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
Scene_BoundsSelected( GlobalSceneGraph(), bounds ); Scene_BoundsSelected( GlobalSceneGraph(), bounds );
} }
//globalOutputStream() << point << "\n"; //globalOutputStream() << point << "\n";
const float gridsize = GetSnapGridSize();
//const float bbox_epsilon = gridsize / 4.0;
for( std::size_t i = 0; i < 3; i++ ){ 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 bestsnapDist = fabs( bounds.origin[i] - point[i] );
float bestsnapTo = bounds.origin[i]; float bestsnapTo = bounds.origin[i];
float othersnapDist = fabs( bounds.origin[i] + bounds.extents[i] - point[i] ); float othersnapDist = fabs( bounds.origin[i] + bounds.extents[i] - point[i] );
@ -3649,20 +3709,13 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
bestsnapDist = othersnapDist; bestsnapDist = othersnapDist;
bestsnapTo = bounds.origin[i] - bounds.extents[i]; 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 ){ if( othersnapDist < bestsnapDist ){
bestsnapDist = othersnapDist; bestsnapDist = othersnapDist;
bestsnapTo = float_snapped( point[i], gridsize ); bestsnapTo = float_snapped( point[i], GetSnapGridSize() );
} }
point[i] = bestsnapTo; 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() m_pivot2world[i + 12] = point[i]; //m_pivot2world.tx() .ty() .tz()
} }
} }
@ -3692,8 +3745,9 @@ void RadiantSelectionSystem::setCustomPivotOrigin( Vector3& point ) const {
default: default:
break; break;
} }
}
m_pivotIsCustom = true; m_pivotIsCustom = true;
}
} }
void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const { void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const {
@ -3712,7 +3766,7 @@ void GetSelectionAABB( AABB& bounds ){
getSelectionSystem().getSelectionAABB( bounds ); getSelectionSystem().getSelectionAABB( bounds );
} }
const Matrix4& ssGetPivot2World(){ const Matrix4& SelectionSystem_GetPivot2World(){
return getSelectionSystem().GetPivot2World(); return getSelectionSystem().GetPivot2World();
} }
@ -3979,13 +4033,17 @@ class Manipulator_
public: public:
DeviceVector m_epsilon; DeviceVector m_epsilon;
const View* m_view; const View* m_view;
ModifierFlags m_state;
Manipulator_() : m_state( c_modifierNone ){
}
bool mouseDown( DeviceVector position ){ bool mouseDown( DeviceVector position ){
return getSelectionSystem().SelectManipulator( *m_view, &position[0], &m_epsilon[0] ); return getSelectionSystem().SelectManipulator( *m_view, &position[0], &m_epsilon[0] );
} }
void mouseMoved( DeviceVector position ){ void mouseMoved( DeviceVector position ){
getSelectionSystem().MoveSelected( *m_view, &position[0] ); getSelectionSystem().MoveSelected( *m_view, &position[0], ( m_state & c_modifierShift ) == c_modifierShift );
} }
typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseMoved> MouseMovedCaller; typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseMoved> MouseMovedCaller;
@ -3995,6 +4053,21 @@ void mouseUp( DeviceVector position ){
g_mouseUpCallback.clear(); g_mouseUpCallback.clear();
} }
typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseUp> MouseUpCaller; typedef MemberCaller1<Manipulator_, 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 ); void Scene_copyClosestTexture( SelectionTest& test );
@ -4099,9 +4172,11 @@ void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierF
} }
void onModifierDown( ModifierFlags type ){ void onModifierDown( ModifierFlags type ){
m_selector.modifierEnable( type ); m_selector.modifierEnable( type );
m_manipulator.modifierEnable( type );
} }
void onModifierUp( ModifierFlags type ){ void onModifierUp( ModifierFlags type ){
m_selector.modifierDisable( type ); m_selector.modifierDisable( type );
m_manipulator.modifierDisable( type );
} }
}; };

View File

@ -276,6 +276,8 @@ bool m_move_started;
// The uniform size (in pixels) that textures are resized to when m_resizeTextures is true. // The uniform size (in pixels) that textures are resized to when m_resizeTextures is true.
int m_uniformTextureSize; int m_uniformTextureSize;
int m_uniformTextureMinSize; int m_uniformTextureMinSize;
bool m_hideNonShadersInCommon;
// Return the display width of a texture in the texture browser // Return the display width of a texture in the texture browser
void getTextureWH( qtexture_t* tex, int &W, int &H ){ void getTextureWH( qtexture_t* tex, int &W, int &H ){
// Don't use uniform size // Don't use uniform size
@ -335,6 +337,7 @@ TextureBrowser() :
m_tags( false ), m_tags( false ),
m_uniformTextureSize( 160 ), m_uniformTextureSize( 160 ),
m_uniformTextureMinSize( 48 ), m_uniformTextureMinSize( 48 ),
m_hideNonShadersInCommon( true ),
m_move_started( false ){ m_move_started( false ){
} }
}; };
@ -476,7 +479,7 @@ CopiedString g_notex;
CopiedString g_shadernotex; CopiedString g_shadernotex;
// if texture_showinuse jump over non in-use textures // 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 notex / shadernotex images // filter notex / shadernotex images
if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) { if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) {
return false; return false;
@ -511,6 +514,11 @@ bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bo
return false; return false;
} }
if( hideNonShadersInCommon && shader->IsDefault() && !shader->IsInUse() //&& g_TextureBrowser_currentDirectory != ""
&& shader_equal_prefix( shader_get_textureName( shader->getName() ), TextureBrowser_getComonShadersDir() ) ){
return false;
}
if ( GlobalTextureBrowser().m_searchedTags ) { if ( GlobalTextureBrowser().m_searchedTags ) {
if ( !TextureSearch_IsShown( shader->getName() ) ) { if ( !TextureSearch_IsShown( shader->getName() ) ) {
return false; return false;
@ -547,7 +555,7 @@ void TextureBrowser_evaluateHeight( TextureBrowser& textureBrowser ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); 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; continue;
} }
@ -864,13 +872,7 @@ void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport; typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){ void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
if ( hideUnused ) { textureBrowser.m_hideUnused = hideUnused;
textureBrowser.m_hideUnused = true;
}
else
{
textureBrowser.m_hideUnused = false;
}
textureBrowser.m_hideunused_item.update(); textureBrowser.m_hideunused_item.update();
@ -898,7 +900,7 @@ void TextureBrowser_Focus( TextureBrowser& textureBrowser, const char* name ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); 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; continue;
} }
@ -942,7 +944,7 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); 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; continue;
} }
@ -1086,7 +1088,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); 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; continue;
} }
@ -2717,6 +2719,14 @@ void TextureBrowser_constructPreferences( PreferencesPage& page ){
const char* startup_shaders[] = { "None", TextureBrowser_getComonShadersName() }; const char* startup_shaders[] = { "None", TextureBrowser_getComonShadersName() };
page.appendCombo( "Load Shaders at Startup", reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ), STRING_ARRAY_RANGE( startup_shaders ) ); 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_getComonShadersDir() << " folder";
page.appendCheckBox(
"", sstream.c_str(),
GlobalTextureBrowser().m_hideNonShadersInCommon
);
}
} }
void TextureBrowser_constructPage( PreferenceGroup& group ){ void TextureBrowser_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Texture Browser", "Texture Browser Preferences" ) ); PreferencesPage page( group.createPage( "Texture Browser", "Texture Browser Preferences" ) );
@ -2778,6 +2788,7 @@ void TextureBrowser_Construct(){
GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) ); GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) ); GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) ); GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) );
GlobalPreferenceSystem().registerPreference( "HideNonShadersInCommon", BoolImportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ), BoolExportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ) );
g_TextureBrowser.shader = texdef_name_default(); g_TextureBrowser.shader = texdef_name_default();

View File

@ -2155,6 +2155,7 @@ void XYWnd::UpdateCameraIcon( void ){
XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) ); XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
glDisable( GL_BLEND ); glDisable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
} }
glDrawBuffer( GL_BACK ); glDrawBuffer( GL_BACK );
@ -2601,6 +2602,7 @@ void XYWnd::XY_Draw(){
glEnable( GL_BLEND ); glEnable( GL_BLEND );
glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) ); DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDisable( GL_BLEND ); glDisable( GL_BLEND );
Feedback_draw2D( m_viewType ); Feedback_draw2D( m_viewType );