Add -Wdouble-promotion switch to clang/gcc compilers

It introduces a lot of ugly casts. Long term the floats should probably
be changed to doubles everywhere since we're only compiling for 64 bit
x86.
This commit is contained in:
Vasily
2019-02-21 18:48:53 +01:00
committed by username223
parent fe3bbc2959
commit ec014a1e74
10 changed files with 40 additions and 29 deletions
@@ -7,3 +7,5 @@ QMAKE_CXXFLAGS += -Wold-style-cast
QMAKE_CXXFLAGS += -Wnon-virtual-dtor QMAKE_CXXFLAGS += -Wnon-virtual-dtor
QMAKE_CXXFLAGS += -Wcast-align -Wunused -Woverloaded-virtual -Wformat=2 QMAKE_CXXFLAGS += -Wcast-align -Wunused -Woverloaded-virtual -Wformat=2
QMAKE_CXXFLAGS += -Wdouble-promotion
@@ -15,5 +15,4 @@ QMAKE_CXXFLAGS += -Wmost
QMAKE_CXXFLAGS += -Weffc++ QMAKE_CXXFLAGS += -Weffc++
#QMAKE_CXXFLAGS += -Wconversion #QMAKE_CXXFLAGS += -Wconversion
#QMAKE_CXXFLAGS += -Wdouble-promotion
#QMAKE_CXXFLAGS += -Wsign-conversion #QMAKE_CXXFLAGS += -Wsign-conversion
+1 -1
View File
@@ -1076,7 +1076,7 @@ void OverlayController::playAlarm01Sound( bool loop )
void OverlayController::setAlarm01SoundVolume( float vol ) void OverlayController::setAlarm01SoundVolume( float vol )
{ {
m_alarm01SoundEffect.setVolume( vol ); m_alarm01SoundEffect.setVolume( static_cast<double>( vol ) );
} }
void OverlayController::cancelAlarm01Sound() void OverlayController::cancelAlarm01Sound()
@@ -564,7 +564,7 @@ void ChaperoneTabController::eventLoopTick(
{ {
float mod = m_chaperoneVelocityModifier float mod = m_chaperoneVelocityModifier
* std::max( { leftSpeed, rightSpeed, hmdSpeed } ); * std::max( { leftSpeed, rightSpeed, hmdSpeed } );
if ( mod > 0.02 ) if ( mod > 0.02f )
{ {
m_chaperoneVelocityModifierCurrent += mod; m_chaperoneVelocityModifierCurrent += mod;
} }
+6 -4
View File
@@ -135,15 +135,17 @@ void FixFloorTabController::eventLoopTick(
{ {
if ( std::abs( tempRoll ) <= M_PI_2 ) if ( std::abs( tempRoll ) <= M_PI_2 )
{ {
floorOffsetY = tempOffsetY - controllerUpOffsetCorrection; floorOffsetY = static_cast<float>( tempOffsetY )
- controllerUpOffsetCorrection;
} }
else else
{ {
floorOffsetY = tempOffsetY - controllerDownOffsetCorrection; floorOffsetY = static_cast<float>( tempOffsetY )
- controllerDownOffsetCorrection;
} }
floorOffsetX = tempOffsetX; floorOffsetX = static_cast<float>( tempOffsetX );
floorOffsetZ = tempOffsetZ; floorOffsetZ = static_cast<float>( tempOffsetZ );
LOG( INFO ) LOG( INFO )
<< "Fix Floor and adjust room center: Floor Offset = [" << "Fix Floor and adjust room center: Floor Offset = ["
+23 -15
View File
@@ -167,10 +167,12 @@ void MoveCenterTabController::setRotation( int value, bool notify )
= devicePosesForRot[0].mDeviceToAbsoluteTracking; = devicePosesForRot[0].mDeviceToAbsoluteTracking;
// Set up xyz coordinate values from pose matrix. // Set up xyz coordinate values from pose matrix.
double oldHmdXyz[3] double oldHmdXyz[3] = { static_cast<double>( oldHmdPos.m[0][3] ),
= { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] }; static_cast<double>( oldHmdPos.m[1][3] ),
double newHmdXyz[3] static_cast<double>( oldHmdPos.m[2][3] ) };
= { oldHmdPos.m[0][3], oldHmdPos.m[1][3], oldHmdPos.m[2][3] }; double newHmdXyz[3] = { static_cast<double>( oldHmdPos.m[0][3] ),
static_cast<double>( oldHmdPos.m[1][3] ),
static_cast<double>( oldHmdPos.m[2][3] ) };
// Convert oldHmdXyz into un-rotated coordinates. // Convert oldHmdXyz into un-rotated coordinates.
double oldAngle = -m_rotation * k_centidegreesToRadians; double oldAngle = -m_rotation * k_centidegreesToRadians;
@@ -261,9 +263,9 @@ void MoveCenterTabController::setAdjustChaperone( bool value, bool notify )
{ {
double angle = m_rotation * k_centidegreesToRadians; double angle = m_rotation * k_centidegreesToRadians;
double offsetdir = m_adjustChaperone ? -1.0 : 1.0; double offsetdir = m_adjustChaperone ? -1.0 : 1.0;
double offset[3] = { offsetdir * m_offsetX, double offset[3] = { offsetdir * static_cast<double>( m_offsetX ),
offsetdir * m_offsetY, offsetdir * static_cast<double>( m_offsetY ),
offsetdir * m_offsetZ }; offsetdir * static_cast<double>( m_offsetZ ) };
rotateCoordinates( offset, angle ); rotateCoordinates( offset, angle );
// We're done with calculations so down-cast to float for // We're done with calculations so down-cast to float for
@@ -407,7 +409,7 @@ void MoveCenterTabController::modOffsetX( float value, bool notify )
if ( !m_lockXToggle ) if ( !m_lockXToggle )
{ {
double angle = m_rotation * k_centidegreesToRadians; double angle = m_rotation * k_centidegreesToRadians;
double offset[3] = { value, 0, 0 }; double offset[3] = { static_cast<double>( value ), 0, 0 };
rotateCoordinates( offset, angle ); rotateCoordinates( offset, angle );
float offsetFloat[3] = { static_cast<float>( offset[0] ), float offsetFloat[3] = { static_cast<float>( offset[0] ),
static_cast<float>( offset[1] ), static_cast<float>( offset[1] ),
@@ -446,7 +448,7 @@ void MoveCenterTabController::modOffsetZ( float value, bool notify )
if ( !m_lockZToggle ) if ( !m_lockZToggle )
{ {
double angle = m_rotation * k_centidegreesToRadians; double angle = m_rotation * k_centidegreesToRadians;
double offset[3] = { 0, 0, value }; double offset[3] = { 0, 0, static_cast<double>( value ) };
rotateCoordinates( offset, angle ); rotateCoordinates( offset, angle );
float offsetFloat[3] = { static_cast<float>( offset[0] ), float offsetFloat[3] = { static_cast<float>( offset[0] ),
static_cast<float>( offset[1] ), static_cast<float>( offset[1] ),
@@ -964,9 +966,12 @@ void MoveCenterTabController::eventLoopTick(
else else
{ {
double relativeControllerPosition[] double relativeControllerPosition[]
= { movePose->mDeviceToAbsoluteTracking.m[0][3], = { static_cast<double>(
movePose->mDeviceToAbsoluteTracking.m[1][3], movePose->mDeviceToAbsoluteTracking.m[0][3] ),
movePose->mDeviceToAbsoluteTracking.m[2][3] }; static_cast<double>(
movePose->mDeviceToAbsoluteTracking.m[1][3] ),
static_cast<double>(
movePose->mDeviceToAbsoluteTracking.m[2][3] ) };
rotateCoordinates( relativeControllerPosition, -angle ); rotateCoordinates( relativeControllerPosition, -angle );
float absoluteControllerPosition[] = { float absoluteControllerPosition[] = {
@@ -978,9 +983,12 @@ void MoveCenterTabController::eventLoopTick(
if ( m_lastMoveHand == m_activeDragHand ) if ( m_lastMoveHand == m_activeDragHand )
{ {
double diff[3] = { double diff[3] = {
absoluteControllerPosition[0] - m_lastControllerPosition[0], static_cast<double>( absoluteControllerPosition[0]
absoluteControllerPosition[1] - m_lastControllerPosition[1], - m_lastControllerPosition[0] ),
absoluteControllerPosition[2] - m_lastControllerPosition[2], static_cast<double>( absoluteControllerPosition[1]
- m_lastControllerPosition[1] ),
static_cast<double>( absoluteControllerPosition[2]
- m_lastControllerPosition[2] ),
}; };
// offset is un-rotated coordinates // offset is un-rotated coordinates
+2 -2
View File
@@ -44,7 +44,7 @@ void ReviveTabController::initStage1( bool forceRevivePage )
} }
else else
{ {
if ( valuef == 0.0 ) if ( valuef == 0.0f )
{ {
m_pixelsPerDisplayPixelOverrideEnabled = false; m_pixelsPerDisplayPixelOverrideEnabled = false;
m_pixelsPerDisplayPixelOverride = 1.0; m_pixelsPerDisplayPixelOverride = 1.0;
@@ -321,7 +321,7 @@ void ReviveTabController::eventLoopTick()
&vrSettingsError ); &vrSettingsError );
if ( vrSettingsError == vr::VRSettingsError_None ) if ( vrSettingsError == vr::VRSettingsError_None )
{ {
if ( valuef == 0.0 ) if ( valuef == 0.0f )
{ {
setPixelsPerDisplayPixelOverrideEnabled( false ); setPixelsPerDisplayPixelOverrideEnabled( false );
} }
@@ -54,7 +54,7 @@ void StatisticsTabController::eventLoopTick(
+ std::pow( m[2][3] - lastHmdPos[2], 2 ) ); + std::pow( m[2][3] - lastHmdPos[2], 2 ) );
if ( delta >= 0.01f ) if ( delta >= 0.01f )
{ {
m_hmdDistanceMoved += delta; m_hmdDistanceMoved += static_cast<double>( delta );
} }
} }
lastHmdPos[0] = m[0][3]; lastHmdPos[0] = m[0][3];
@@ -164,7 +164,7 @@ void StatisticsTabController::statsRotationResetClicked()
void StatisticsTabController::statsLeftControllerSpeedResetClicked() void StatisticsTabController::statsLeftControllerSpeedResetClicked()
{ {
if ( m_leftControllerMaxSpeed != 0.0 ) if ( m_leftControllerMaxSpeed != 0.0f )
{ {
m_leftControllerMaxSpeed = 0.0; m_leftControllerMaxSpeed = 0.0;
} }
@@ -172,7 +172,7 @@ void StatisticsTabController::statsLeftControllerSpeedResetClicked()
void StatisticsTabController::statsRightControllerSpeedResetClicked() void StatisticsTabController::statsRightControllerSpeedResetClicked()
{ {
if ( m_rightControllerMaxSpeed != 0.0 ) if ( m_rightControllerMaxSpeed != 0.0f )
{ {
m_rightControllerMaxSpeed = 0.0; m_rightControllerMaxSpeed = 0.0;
} }
+1 -1
View File
@@ -56,7 +56,7 @@ void SteamVRTabController::eventLoopTick()
<< "\" setting: " << "\" setting: "
<< vr::VRSettings()->GetSettingsErrorNameFromEnum( << vr::VRSettings()->GetSettingsErrorNameFromEnum(
vrSettingsError ); vrSettingsError );
if ( m_superSampling != 1.0 ) if ( m_superSampling != 1.0f )
{ {
LOG( DEBUG ) LOG( DEBUG )
<< "OpenVR returns an error and we have a custom " << "OpenVR returns an error and we have a custom "
@@ -583,7 +583,7 @@ void UtilitiesTabController::setSteamDesktopOverlayWidth( float width,
bool notify, bool notify,
bool notifyOpenVr ) bool notifyOpenVr )
{ {
if ( std::abs( m_steamDesktopOverlayWidth - width ) > 0.01 ) if ( std::abs( m_steamDesktopOverlayWidth - width ) > 0.01f )
{ {
m_steamDesktopOverlayWidth = width; m_steamDesktopOverlayWidth = width;
if ( notifyOpenVr ) if ( notifyOpenVr )