Remove old style casts and enable warnings for them
This commit is contained in:
@@ -9,3 +9,5 @@ include(common-msvc.pri)
|
||||
QMAKE_CXXFLAGS += /std:c++17
|
||||
|
||||
QMAKE_CXXFLAGS += -Xclang -Wshadow
|
||||
|
||||
QMAKE_CXXFLAGS += -Wold-style-cast
|
||||
|
||||
@@ -3,3 +3,5 @@ QMAKE_CXXFLAGS += -Werror
|
||||
QMAKE_CXXFLAGS += --system-header-prefix=third-party
|
||||
|
||||
QMAKE_CXXFLAGS += -Wshadow
|
||||
|
||||
QMAKE_CXXFLAGS += -Wold-style-cast
|
||||
|
||||
@@ -4,3 +4,5 @@ QMAKE_CXX = g++-7
|
||||
QMAKE_CXXFLAGS += -Werror
|
||||
|
||||
QMAKE_CXXFLAGS += -Wshadow
|
||||
|
||||
QMAKE_CXXFLAGS += -Wold-style-cast
|
||||
|
||||
@@ -361,7 +361,8 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
|
||||
m_pRenderControl->initialize( m_pOpenGLContext.get() );
|
||||
|
||||
vr::HmdVector2_t vecWindowSize
|
||||
= { ( float ) quickItem->width(), ( float ) quickItem->height() };
|
||||
= { static_cast<float>( quickItem->width() ),
|
||||
static_cast<float>( quickItem->height() ) };
|
||||
vr::VROverlay()->SetOverlayMouseScale( m_ulOverlayHandle,
|
||||
&vecWindowSize );
|
||||
|
||||
@@ -425,11 +426,13 @@ void OverlayController::renderOverlay()
|
||||
#if defined _WIN64 || defined _LP64
|
||||
// To avoid any compiler warning because of cast to a larger pointer
|
||||
// type (warning C4312 on VC)
|
||||
vr::Texture_t texture = { ( void* ) ( ( uint64_t ) unTexture ),
|
||||
vr::TextureType_OpenGL,
|
||||
vr::ColorSpace_Auto };
|
||||
vr::Texture_t texture
|
||||
= { reinterpret_cast<void*>(
|
||||
( static_cast<uint64_t>( unTexture ) ) ),
|
||||
vr::TextureType_OpenGL,
|
||||
vr::ColorSpace_Auto };
|
||||
#else
|
||||
vr::Texture_t texture = { ( void* ) unTexture,
|
||||
vr::Texture_t texture = { reinterpret_cast<void*>( unTexture ),
|
||||
vr::TextureType_OpenGL,
|
||||
vr::ColorSpace_Auto };
|
||||
#endif
|
||||
|
||||
@@ -928,7 +928,7 @@ float ChaperoneTabController::chaperoneVelocityModifier() const
|
||||
|
||||
Q_INVOKABLE unsigned ChaperoneTabController::getChaperoneProfileCount()
|
||||
{
|
||||
return ( unsigned ) chaperoneProfiles.size();
|
||||
return static_cast<unsigned int>( chaperoneProfiles.size() );
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
@@ -1244,7 +1244,7 @@ void ChaperoneTabController::flipOrientation()
|
||||
{
|
||||
parent->m_moveCenterTabController.reset();
|
||||
parent->RotateUniverseCenter( vr::TrackingUniverseStanding,
|
||||
( float ) M_PI );
|
||||
static_cast<float>( M_PI ) );
|
||||
}
|
||||
|
||||
void ChaperoneTabController::reloadFromDisk()
|
||||
|
||||
@@ -86,9 +86,9 @@ void FixFloorTabController::eventLoopTick(
|
||||
|
||||
auto& m = devicePoses[referenceController]
|
||||
.mDeviceToAbsoluteTracking.m;
|
||||
tempOffsetX = ( double ) m[0][3];
|
||||
tempOffsetY = ( double ) m[1][3];
|
||||
tempOffsetZ = ( double ) m[2][3];
|
||||
tempOffsetX = static_cast<double>( m[0][3] );
|
||||
tempOffsetY = static_cast<double>( m[1][3] );
|
||||
tempOffsetZ = static_cast<double>( m[2][3] );
|
||||
/*
|
||||
| Intrinsic y-x'-z" rotation matrix:
|
||||
| cr*cy+sp*sr*sy | cr*sp*sy-cy*sr | cp*sy |
|
||||
@@ -99,7 +99,8 @@ void FixFloorTabController::eventLoopTick(
|
||||
pitch = -asin(-sp) [pi/2, -pi/2]
|
||||
roll = atan2(cp*sr, cp*cr) [pi, -pi], CW
|
||||
*/
|
||||
tempRoll = std::atan2( ( double ) m[1][0], ( double ) m[1][1] );
|
||||
tempRoll = std::atan2( static_cast<double>( m[1][0] ),
|
||||
static_cast<double>( m[1][1] ) );
|
||||
measurementCount = 1;
|
||||
}
|
||||
}
|
||||
@@ -109,9 +110,9 @@ void FixFloorTabController::eventLoopTick(
|
||||
auto& m
|
||||
= devicePoses[referenceController].mDeviceToAbsoluteTracking.m;
|
||||
|
||||
double rollDiff
|
||||
= std::atan2( ( double ) m[1][0], ( double ) m[1][1] )
|
||||
- tempRoll;
|
||||
double rollDiff = std::atan2( static_cast<double>( m[1][0] ),
|
||||
static_cast<double>( m[1][1] ) )
|
||||
- tempRoll;
|
||||
if ( rollDiff > M_PI )
|
||||
{
|
||||
rollDiff -= 2.0 * M_PI;
|
||||
@@ -120,7 +121,7 @@ void FixFloorTabController::eventLoopTick(
|
||||
{
|
||||
rollDiff += 2.0 * M_PI;
|
||||
}
|
||||
tempRoll += rollDiff / ( double ) measurementCount;
|
||||
tempRoll += rollDiff / static_cast<double>( measurementCount );
|
||||
if ( tempRoll > M_PI )
|
||||
{
|
||||
tempRoll -= 2.0 * M_PI;
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
OverlayController* parent;
|
||||
QQuickWindow* widget;
|
||||
|
||||
int m_trackingUniverse = ( int ) vr::TrackingUniverseStanding;
|
||||
int m_trackingUniverse = static_cast<int>( vr::TrackingUniverseStanding );
|
||||
float m_offsetX = 0.0f;
|
||||
float m_offsetY = 0.0f;
|
||||
float m_offsetZ = 0.0f;
|
||||
|
||||
@@ -43,7 +43,8 @@ void PttController::setPttControllerConfig( unsigned controller,
|
||||
uint64_t buttonMask = 0;
|
||||
for ( auto b : buttons )
|
||||
{
|
||||
buttonMask |= vr::ButtonMaskFromId( ( vr::EVRButtonId ) b.toInt() );
|
||||
buttonMask |= vr::ButtonMaskFromId(
|
||||
( static_cast<vr::EVRButtonId>( b.toInt() ) ) );
|
||||
}
|
||||
m_pttControllerConfigs[controller].digitalButtons = buttons;
|
||||
m_pttControllerConfigs[controller].digitalButtonMask = buttonMask;
|
||||
@@ -78,7 +79,8 @@ void PttController::reloadPttProfiles()
|
||||
uint64_t buttonMask = 0;
|
||||
for ( auto b : entry.controllerConfigs[0].digitalButtons )
|
||||
{
|
||||
buttonMask |= vr::ButtonMaskFromId( ( vr::EVRButtonId ) b.toInt() );
|
||||
buttonMask |= vr::ButtonMaskFromId(
|
||||
static_cast<vr::EVRButtonId>( b.toInt() ) );
|
||||
}
|
||||
entry.controllerConfigs[0].digitalButtonMask = buttonMask;
|
||||
entry.controllerConfigs[0].triggerMode
|
||||
@@ -92,7 +94,8 @@ void PttController::reloadPttProfiles()
|
||||
buttonMask = 0;
|
||||
for ( auto b : entry.controllerConfigs[1].digitalButtons )
|
||||
{
|
||||
buttonMask |= vr::ButtonMaskFromId( ( vr::EVRButtonId ) b.toInt() );
|
||||
buttonMask |= vr::ButtonMaskFromId(
|
||||
static_cast<vr::EVRButtonId>( b.toInt() ) );
|
||||
}
|
||||
entry.controllerConfigs[1].digitalButtonMask = buttonMask;
|
||||
entry.controllerConfigs[1].triggerMode
|
||||
@@ -165,7 +168,8 @@ void PttController::reloadPttConfig()
|
||||
uint64_t buttonMask = 0;
|
||||
for ( auto b : m_pttControllerConfigs[0].digitalButtons )
|
||||
{
|
||||
buttonMask |= vr::ButtonMaskFromId( ( vr::EVRButtonId ) b.toInt() );
|
||||
buttonMask |= vr::ButtonMaskFromId(
|
||||
static_cast<vr::EVRButtonId>( b.toInt() ) );
|
||||
}
|
||||
m_pttControllerConfigs[0].digitalButtonMask = buttonMask;
|
||||
m_pttControllerConfigs[0].triggerMode
|
||||
@@ -179,7 +183,8 @@ void PttController::reloadPttConfig()
|
||||
buttonMask = 0;
|
||||
for ( auto b : m_pttControllerConfigs[0].digitalButtons )
|
||||
{
|
||||
buttonMask |= vr::ButtonMaskFromId( ( vr::EVRButtonId ) b.toInt() );
|
||||
buttonMask |= vr::ButtonMaskFromId(
|
||||
static_cast<vr::EVRButtonId>( b.toInt() ) );
|
||||
}
|
||||
m_pttControllerConfigs[1].digitalButtonMask = buttonMask;
|
||||
m_pttControllerConfigs[1].triggerMode
|
||||
@@ -388,7 +393,7 @@ unsigned PttController::pttTouchpadArea( unsigned controller )
|
||||
|
||||
unsigned PttController::getPttProfileCount()
|
||||
{
|
||||
return ( unsigned ) pttProfiles.size();
|
||||
return static_cast<unsigned int>( pttProfiles.size() );
|
||||
}
|
||||
|
||||
QString PttController::getPttProfileName( unsigned index )
|
||||
|
||||
@@ -1015,17 +1015,17 @@ void ReviveTabController::setPiGender( int value, bool notify )
|
||||
{
|
||||
m_piGender = value;
|
||||
vr::EVRSettingsError vrSettingsError;
|
||||
char* txt;
|
||||
const char* txt;
|
||||
switch ( value )
|
||||
{
|
||||
case 1:
|
||||
txt = ( char* ) "Male";
|
||||
txt = static_cast<const char*>( "Male" );
|
||||
break;
|
||||
case 2:
|
||||
txt = ( char* ) "Female";
|
||||
txt = static_cast<const char*>( "Female" );
|
||||
break;
|
||||
default:
|
||||
txt = ( char* ) "Unknown";
|
||||
txt = static_cast<const char*>( "Unknown" );
|
||||
break;
|
||||
}
|
||||
vr::VRSettings()->SetString(
|
||||
@@ -1255,7 +1255,7 @@ void ReviveTabController::saveControllerProfiles()
|
||||
|
||||
Q_INVOKABLE unsigned ReviveTabController::getControllerProfileCount()
|
||||
{
|
||||
return ( unsigned ) controllerProfiles.size();
|
||||
return static_cast<unsigned int>( controllerProfiles.size() );
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
|
||||
@@ -133,10 +133,10 @@ unsigned StatisticsTabController::timedOut() const
|
||||
|
||||
float StatisticsTabController::totalReprojectedRatio() const
|
||||
{
|
||||
float totalFrames = ( float ) ( m_cumStats.m_nNumFramePresents
|
||||
- m_totalRatioPresentedOffset );
|
||||
float reprojectedFrames = ( float ) ( m_cumStats.m_nNumReprojectedFrames
|
||||
- m_totalRatioReprojectedOffset );
|
||||
float totalFrames = static_cast<float>(
|
||||
( m_cumStats.m_nNumFramePresents - m_totalRatioPresentedOffset ) );
|
||||
float reprojectedFrames = static_cast<float>( (
|
||||
m_cumStats.m_nNumReprojectedFrames - m_totalRatioReprojectedOffset ) );
|
||||
if ( totalFrames != 0.0f )
|
||||
{
|
||||
return reprojectedFrames / totalFrames;
|
||||
|
||||
@@ -422,8 +422,9 @@ void UtilitiesTabController::eventLoopTick()
|
||||
vr::VRNotificationId notificationId;
|
||||
vr::EVRInitError eError;
|
||||
vr::IVRNotifications* vrnotification
|
||||
= ( vr::IVRNotifications* ) vr::VR_GetGenericInterface(
|
||||
vr::IVRNotifications_Version, &eError );
|
||||
= static_cast<vr::IVRNotifications*>(
|
||||
vr::VR_GetGenericInterface(
|
||||
vr::IVRNotifications_Version, &eError ) );
|
||||
if ( eError != vr::VRInitError_None )
|
||||
{
|
||||
LOG( ERROR )
|
||||
|
||||
@@ -13,7 +13,7 @@ AudioManagerWindows::~AudioManagerWindows()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock( _mutex );
|
||||
audioDeviceEnumerator->UnregisterEndpointNotificationCallback(
|
||||
( IMMNotificationClient* ) this );
|
||||
static_cast<IMMNotificationClient*>( this ) );
|
||||
if ( mirrorAudioEndpointVolume )
|
||||
{
|
||||
mirrorAudioEndpointVolume->Release();
|
||||
@@ -61,7 +61,7 @@ void AudioManagerWindows::init( AudioTabController* var_controller )
|
||||
}
|
||||
this->controller = var_controller;
|
||||
audioDeviceEnumerator->RegisterEndpointNotificationCallback(
|
||||
( IMMNotificationClient* ) this );
|
||||
static_cast<IMMNotificationClient*>( this ) );
|
||||
policyConfig = getPolicyConfig();
|
||||
if ( !policyConfig )
|
||||
{
|
||||
@@ -373,7 +373,7 @@ IMMDeviceEnumerator* AudioManagerWindows::getAudioDeviceEnumerator()
|
||||
NULL,
|
||||
CLSCTX_ALL,
|
||||
__uuidof( IMMDeviceEnumerator ),
|
||||
( void** ) &pEnumerator )
|
||||
reinterpret_cast<void**>( &pEnumerator ) )
|
||||
< 0 )
|
||||
{
|
||||
return nullptr;
|
||||
@@ -385,18 +385,19 @@ IPolicyConfig* AudioManagerWindows::getPolicyConfig()
|
||||
{
|
||||
IPolicyConfig* var_policyConfig = nullptr;
|
||||
// for Win 10
|
||||
auto hr = CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IPolicyConfig2,
|
||||
( LPVOID* ) &var_policyConfig );
|
||||
auto hr
|
||||
= CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IPolicyConfig2,
|
||||
reinterpret_cast<LPVOID*>( &var_policyConfig ) );
|
||||
if ( hr != S_OK )
|
||||
{
|
||||
hr = CoCreateInstance( __uuidof( CPolicyConfigClient ),
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IPolicyConfig1,
|
||||
( LPVOID* ) &var_policyConfig );
|
||||
reinterpret_cast<LPVOID*>( &var_policyConfig ) );
|
||||
}
|
||||
// for Win Vista, 7, 8, 8.1
|
||||
if ( hr != S_OK )
|
||||
@@ -405,7 +406,7 @@ IPolicyConfig* AudioManagerWindows::getPolicyConfig()
|
||||
NULL,
|
||||
CLSCTX_INPROC,
|
||||
IID_IPolicyConfig0,
|
||||
( LPVOID* ) &var_policyConfig );
|
||||
reinterpret_cast<LPVOID*>( &var_policyConfig ) );
|
||||
}
|
||||
if ( hr != S_OK )
|
||||
{
|
||||
@@ -471,7 +472,7 @@ IAudioEndpointVolume*
|
||||
if ( device->Activate( __uuidof( IAudioEndpointVolume ),
|
||||
CLSCTX_INPROC_SERVER,
|
||||
NULL,
|
||||
( void** ) &pEndpointVolume )
|
||||
reinterpret_cast<void**>( &pEndpointVolume ) )
|
||||
< 0 )
|
||||
{
|
||||
return nullptr;
|
||||
@@ -536,12 +537,12 @@ HRESULT AudioManagerWindows::QueryInterface( REFIID riid, void** ppvObject )
|
||||
if ( IID_IUnknown == riid )
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = ( IUnknown* ) this;
|
||||
*ppvObject = static_cast<IUnknown*>( this );
|
||||
}
|
||||
else if ( __uuidof( IMMNotificationClient ) == riid )
|
||||
{
|
||||
AddRef();
|
||||
*ppvObject = ( IMMNotificationClient* ) this;
|
||||
*ppvObject = static_cast<IMMNotificationClient*>( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -77,7 +77,8 @@ void ChaperoneUtils::loadChaperoneData()
|
||||
std::unique_ptr<vr::HmdQuad_t> quadsBuffer(
|
||||
new vr::HmdQuad_t[_quadsCount] );
|
||||
vr::HmdQuad_t* quadsBufferPtr = quadsBuffer.get();
|
||||
_corners.reset( ( vr::HmdVector3_t* ) new vr::HmdQuad_t[_quadsCount] );
|
||||
_corners.reset( reinterpret_cast<vr::HmdVector3_t*>(
|
||||
new vr::HmdQuad_t[_quadsCount] ) );
|
||||
vr::HmdVector3_t* _cornersPtr = _corners.get();
|
||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo( quadsBufferPtr,
|
||||
&_quadsCount );
|
||||
|
||||
Reference in New Issue
Block a user