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
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 );
*/
bool g_AutoSave_Enabled = true;
-int m_AutoSave_Frequency = 5;
+int m_AutoSave_Frequency = 15;
bool g_SnapShots_Enabled = false;
namespace
void exportState( FaceShader& faceShader ) const {
faceShader.setShader( m_shader.c_str() );
- faceShader.setFlags( m_flags );
+ //faceShader.setFlags( m_flags );
+ faceShader.m_flags = m_flags;
}
};
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 );
}
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 );
class FaceSetFlags
{
-const ContentsFlagsValue& m_projection;
+const ContentsFlagsValue& m_flags;
public:
-FaceSetFlags( const ContentsFlagsValue& flags ) : m_projection( flags ){
+FaceSetFlags( const ContentsFlagsValue& flags ) : m_flags( flags ){
}
void operator()( Face& face ) const {
- face.SetFlags( m_projection );
+ face.SetFlags( m_flags );
}
};
}
void Cam_MouseControl( camera_t& camera, int x, int y ){
- int xl, xh;
- int yl, yh;
+// int xl, xh;
+// int yl, yh;
float xf, yf;
xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
- xl = camera.width / 3;
- xh = xl * 2;
- yl = camera.height / 3;
- yh = yl * 2;
+// xl = camera.width / 3;
+// xh = xl * 2;
+// yl = camera.height / 3;
+// yh = yl * 2;
xf *= 1.0f - fabsf( yf );
if ( xf < 0 ) {
}
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_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_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_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_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_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_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_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_KeyUp>( camwnd.getCamera() )
);
- GlobalKeyEvents_insert( "CameraAngleDown", Accelerator( 'A' ),
- ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
- );
- GlobalKeyEvents_insert( "CameraAngleUp", Accelerator( 'Z' ),
+ GlobalKeyEvents_insert( "CameraAngleUp", accelerator_null(),
ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( 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() ),
FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
);
- GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( 'S' ),
+ GlobalKeyEvents_insert( "CameraFreeMoveBack", accelerator_null(),
FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
);
- GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( 'A' ),
+ GlobalKeyEvents_insert( "CameraFreeMoveLeft", accelerator_null(),
FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
);
- GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( 'D' ),
+ 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( GDK_period ),
+ GlobalKeyEvents_insert( "CameraFreeMoveUp", accelerator_null(),
FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() )
);
- GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( GDK_comma ),
+ GlobalKeyEvents_insert( "CameraFreeMoveDown", accelerator_null(),
FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
);
- GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Up ) );
- GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Down ) );
- GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Left ) );
- GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Right ) );
- GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_period ) );
- GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_comma ) );
+ GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
+ 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( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) );
- GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) );
- GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) );
+ GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
}
void CamWnd_Move_Enable( CamWnd& camwnd ){
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", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
}
{
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_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
}
{
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_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
}
{
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_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
{
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 ){
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 ) );
}
};
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 ){
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 ) );
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() );
};
void GetSelectionAABB( AABB& bounds );
-const Matrix4& ssGetPivot2World();
+const Matrix4& SelectionSystem_GetPivot2World();
class Scalable
{
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 );
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],
);
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 );
}
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 );
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 );
}
};
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 );
}
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;
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 );
}
}
}
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 ) {
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] );
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()
}
}
default:
break;
}
+
+ m_pivotIsCustom = true;
}
- m_pivotIsCustom = true;
}
void RadiantSelectionSystem::getSelectionAABB( AABB& bounds ) const {
getSelectionSystem().getSelectionAABB( bounds );
}
-const Matrix4& ssGetPivot2World(){
+const Matrix4& SelectionSystem_GetPivot2World(){
return getSelectionSystem().GetPivot2World();
}
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 MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseMoved> MouseMovedCaller;
g_mouseUpCallback.clear();
}
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 onModifierDown( ModifierFlags type ){
m_selector.modifierEnable( type );
+ m_manipulator.modifierEnable( type );
}
void onModifierUp( ModifierFlags type ){
m_selector.modifierDisable( type );
+ m_manipulator.modifierDisable( type );
}
};
// The uniform size (in pixels) that textures are resized to when m_resizeTextures is true.
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
m_tags( false ),
m_uniformTextureSize( 160 ),
m_uniformTextureMinSize( 48 ),
+ m_hideNonShadersInCommon( true ),
m_move_started( false ){
}
};
CopiedString g_shadernotex;
// 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
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;
}
+ 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 ( !TextureSearch_IsShown( shader->getName() ) ) {
return false;
{
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;
}
typedef FreeCaller1<const BoolImportCallback&, 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();
{
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;
}
{
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;
}
{
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;
}
const char* startup_shaders[] = { "None", TextureBrowser_getComonShadersName() };
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 ){
PreferencesPage page( group.createPage( "Texture Browser", "Texture Browser Preferences" ) );
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( "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();
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 );
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 );