Add smooth turn and universe centered rotation
This commit is contained in:
@@ -83,6 +83,11 @@ void MoveCenterTabController::initStage1()
|
||||
{
|
||||
m_snapTurnAngle = value.toInt();
|
||||
}
|
||||
value = settings->value( "smoothTurnRate", m_smoothTurnRate );
|
||||
if ( value.isValid() && !value.isNull() )
|
||||
{
|
||||
m_smoothTurnRate = value.toInt();
|
||||
}
|
||||
value = settings->value( "heightToggleOffset", m_heightToggleOffset );
|
||||
if ( value.isValid() && !value.isNull() )
|
||||
{
|
||||
@@ -133,6 +138,12 @@ void MoveCenterTabController::initStage1()
|
||||
{
|
||||
m_oldStyleMotion = value.toBool();
|
||||
}
|
||||
value = settings->value( "universeCenteredRotation",
|
||||
m_universeCenteredRotation );
|
||||
if ( value.isValid() && !value.isNull() )
|
||||
{
|
||||
m_universeCenteredRotation = value.toBool();
|
||||
}
|
||||
settings->endGroup();
|
||||
m_lastDragUpdateTimePoint = std::chrono::steady_clock::now();
|
||||
m_lastGravityUpdateTimePoint = std::chrono::steady_clock::now();
|
||||
@@ -199,6 +210,10 @@ void MoveCenterTabController::outputLogSettings()
|
||||
{
|
||||
LOG( INFO ) << "LOADED SETTINGS: Old-Style Motion Enabled";
|
||||
}
|
||||
if ( m_universeCenteredRotation )
|
||||
{
|
||||
LOG( INFO ) << "LOADED SETTINGS: Universe-Centered Rotation Enabled";
|
||||
}
|
||||
}
|
||||
|
||||
void MoveCenterTabController::outputLogPoses()
|
||||
@@ -381,6 +396,16 @@ void MoveCenterTabController::setRotation( int value, bool notify )
|
||||
{
|
||||
if ( m_rotation != value )
|
||||
{
|
||||
if ( m_universeCenteredRotation )
|
||||
{
|
||||
m_rotation = value;
|
||||
if ( notify )
|
||||
{
|
||||
emit rotationChanged( m_rotation );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
double angle = ( value - m_rotation ) * k_centidegreesToRadians;
|
||||
|
||||
// Get hmd pose matrix.
|
||||
@@ -476,6 +501,28 @@ void MoveCenterTabController::setSnapTurnAngle( int value, bool notify )
|
||||
}
|
||||
}
|
||||
|
||||
int MoveCenterTabController::smoothTurnRate() const
|
||||
{
|
||||
return m_smoothTurnRate;
|
||||
}
|
||||
|
||||
void MoveCenterTabController::setSmoothTurnRate( int value, bool notify )
|
||||
{
|
||||
if ( m_smoothTurnRate != value )
|
||||
{
|
||||
m_smoothTurnRate = value;
|
||||
auto settings = OverlayController::appSettings();
|
||||
settings->beginGroup( "playspaceSettings" );
|
||||
settings->setValue( "smoothTurnRate", m_smoothTurnRate );
|
||||
settings->endGroup();
|
||||
settings->sync();
|
||||
if ( notify )
|
||||
{
|
||||
emit smoothTurnRateChanged( m_smoothTurnRate );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MoveCenterTabController::adjustChaperone() const
|
||||
{
|
||||
return m_adjustChaperone;
|
||||
@@ -904,6 +951,29 @@ void MoveCenterTabController::setOldStyleMotion( bool value, bool notify )
|
||||
<< m_oldStyleMotion;
|
||||
}
|
||||
|
||||
bool MoveCenterTabController::universeCenteredRotation() const
|
||||
{
|
||||
return m_universeCenteredRotation;
|
||||
}
|
||||
|
||||
void MoveCenterTabController::setUniverseCenteredRotation( bool value,
|
||||
bool notify )
|
||||
{
|
||||
m_universeCenteredRotation = value;
|
||||
auto settings = OverlayController::appSettings();
|
||||
settings->beginGroup( "playspaceSettings" );
|
||||
settings->setValue( "universeCenteredRotation",
|
||||
m_universeCenteredRotation );
|
||||
settings->endGroup();
|
||||
settings->sync();
|
||||
if ( notify )
|
||||
{
|
||||
emit universeCenteredRotationChanged( m_universeCenteredRotation );
|
||||
}
|
||||
LOG( INFO ) << "CHANGED SETTINGS: Universe-Centered Rotation Set: "
|
||||
<< m_universeCenteredRotation;
|
||||
}
|
||||
|
||||
void MoveCenterTabController::modOffsetX( float value, bool notify )
|
||||
{
|
||||
if ( !m_lockXToggle )
|
||||
@@ -1780,8 +1850,6 @@ void MoveCenterTabController::snapTurnLeft( bool snapTurnLeftJustPressed )
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO add interface to configure snap angle.
|
||||
// temporarily hard coded to 45 degrees
|
||||
int newRotationAngleDeg = m_rotation - m_snapTurnAngle;
|
||||
// Keep angle within -18000 ~ 18000 centidegrees
|
||||
if ( newRotationAngleDeg > 18000 )
|
||||
@@ -1803,8 +1871,6 @@ void MoveCenterTabController::snapTurnRight( bool snapTurnRightJustPressed )
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO add interface to configure snap angle.
|
||||
// temporarily hard coded to 45 degrees
|
||||
int newRotationAngleDeg = m_rotation + m_snapTurnAngle;
|
||||
// Keep angle within -18000 ~ 18000 centidegrees
|
||||
if ( newRotationAngleDeg > 18000 )
|
||||
@@ -1819,6 +1885,54 @@ void MoveCenterTabController::snapTurnRight( bool snapTurnRightJustPressed )
|
||||
setRotation( newRotationAngleDeg );
|
||||
}
|
||||
|
||||
void MoveCenterTabController::smoothTurnLeft( bool smoothTurnLeftActive )
|
||||
{
|
||||
if ( !smoothTurnLeftActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Activates every tick. m_smoothTurnRate effectively becomes a percentage
|
||||
// of a degree per tick. A setting of 100 would equal 90 degrees/sec or 15
|
||||
// RPM with a framerate of 90fps
|
||||
int newRotationAngleDeg = m_rotation - m_smoothTurnRate;
|
||||
// Keep angle within -18000 ~ 18000 centidegrees
|
||||
if ( newRotationAngleDeg > 18000 )
|
||||
{
|
||||
newRotationAngleDeg -= 36000;
|
||||
}
|
||||
else if ( newRotationAngleDeg < -18000 )
|
||||
{
|
||||
newRotationAngleDeg += 36000;
|
||||
}
|
||||
|
||||
setRotation( newRotationAngleDeg );
|
||||
}
|
||||
|
||||
void MoveCenterTabController::smoothTurnRight( bool smoothTurnRightActive )
|
||||
{
|
||||
if ( !smoothTurnRightActive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Activates every tick. m_smoothTurnRate effectively becomes a percentage
|
||||
// of a degree per tick. A setting of 100 would equal 90 degrees/sec or 15
|
||||
// RPM with a framerate of 90fps
|
||||
int newRotationAngleDeg = m_rotation + m_smoothTurnRate;
|
||||
// Keep angle within -18000 ~ 18000 centidegrees
|
||||
if ( newRotationAngleDeg > 18000 )
|
||||
{
|
||||
newRotationAngleDeg -= 36000;
|
||||
}
|
||||
else if ( newRotationAngleDeg < -18000 )
|
||||
{
|
||||
newRotationAngleDeg += 36000;
|
||||
}
|
||||
|
||||
setRotation( newRotationAngleDeg );
|
||||
}
|
||||
|
||||
void MoveCenterTabController::xAxisLockToggle( bool xAxisLockToggleJustPressed )
|
||||
{
|
||||
if ( !xAxisLockToggleJustPressed )
|
||||
|
||||
@@ -36,6 +36,8 @@ class MoveCenterTabController : public QObject
|
||||
tempRotationChanged )
|
||||
Q_PROPERTY( int snapTurnAngle READ snapTurnAngle WRITE setSnapTurnAngle
|
||||
NOTIFY snapTurnAngleChanged )
|
||||
Q_PROPERTY( int smoothTurnRate READ smoothTurnRate WRITE setSmoothTurnRate
|
||||
NOTIFY smoothTurnRateChanged )
|
||||
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
|
||||
setAdjustChaperone NOTIFY adjustChaperoneChanged )
|
||||
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
|
||||
@@ -75,6 +77,9 @@ class MoveCenterTabController : public QObject
|
||||
setAllowExternalEdits NOTIFY allowExternalEditsChanged )
|
||||
Q_PROPERTY( bool oldStyleMotion READ oldStyleMotion WRITE setOldStyleMotion
|
||||
NOTIFY oldStyleMotionChanged )
|
||||
Q_PROPERTY(
|
||||
bool universeCenteredRotation READ universeCenteredRotation WRITE
|
||||
setUniverseCenteredRotation NOTIFY universeCenteredRotationChanged )
|
||||
|
||||
private:
|
||||
OverlayController* parent;
|
||||
@@ -91,6 +96,7 @@ private:
|
||||
int m_oldRotation = 0;
|
||||
int m_tempRotation = 0;
|
||||
int m_snapTurnAngle = 4500;
|
||||
int m_smoothTurnRate = 100;
|
||||
bool m_adjustChaperone = true;
|
||||
bool m_moveShortcutRightPressed = false;
|
||||
bool m_moveShortcutLeftPressed = false;
|
||||
@@ -151,6 +157,7 @@ private:
|
||||
bool m_showLogMatricesButton = false;
|
||||
bool m_allowExternalEdits = false;
|
||||
bool m_oldStyleMotion = false;
|
||||
bool m_universeCenteredRotation = false;
|
||||
unsigned settingsUpdateCounter = 0;
|
||||
int m_hmdRotationStatsUpdateCounter = 0;
|
||||
unsigned m_dragComfortFrameSkipCounter = 0;
|
||||
@@ -190,6 +197,7 @@ public:
|
||||
int rotation() const;
|
||||
int tempRotation() const;
|
||||
int snapTurnAngle() const;
|
||||
int smoothTurnRate() const;
|
||||
bool adjustChaperone() const;
|
||||
bool moveShortcutRight() const;
|
||||
bool moveShortcutLeft() const;
|
||||
@@ -209,6 +217,7 @@ public:
|
||||
bool showLogMatricesButton() const;
|
||||
bool allowExternalEdits() const;
|
||||
bool oldStyleMotion() const;
|
||||
bool universeCenteredRotation() const;
|
||||
double getHmdYawTotal();
|
||||
void resetHmdYawTotal();
|
||||
void incomingSeatedReset();
|
||||
@@ -230,6 +239,8 @@ public:
|
||||
void resetOffsets( bool resetOffsetsJustPressed );
|
||||
void snapTurnLeft( bool snapTurnLeftJustPressed );
|
||||
void snapTurnRight( bool snapTurnRightJustPressed );
|
||||
void smoothTurnLeft( bool smoothTurnLeftActive );
|
||||
void smoothTurnRight( bool smoothTurnRightActive );
|
||||
void xAxisLockToggle( bool xAxisLockToggleJustPressed );
|
||||
void yAxisLockToggle( bool yAxisLockToggleJustPressed );
|
||||
void zAxisLockToggle( bool zAxisLockToggleJustPressed );
|
||||
@@ -245,6 +256,7 @@ public slots:
|
||||
void setRotation( int value, bool notify = true );
|
||||
void setTempRotation( int value, bool notify = true );
|
||||
void setSnapTurnAngle( int value, bool notify = true );
|
||||
void setSmoothTurnRate( int value, bool notify = true );
|
||||
|
||||
void setAdjustChaperone( bool value, bool notify = true );
|
||||
void setMoveShortcutRight( bool value, bool notify = true );
|
||||
@@ -270,6 +282,7 @@ public slots:
|
||||
void setShowLogMatricesButton( bool value, bool notify = true );
|
||||
void setAllowExternalEdits( bool value, bool notify = true );
|
||||
void setOldStyleMotion( bool value, bool notify = true );
|
||||
void setUniverseCenteredRotation( bool value, bool notify = true );
|
||||
|
||||
void shutdown();
|
||||
void reset();
|
||||
@@ -285,6 +298,7 @@ signals:
|
||||
void rotationChanged( int value );
|
||||
void tempRotationChanged( int value );
|
||||
void snapTurnAngleChanged( int value );
|
||||
void smoothTurnRateChanged( int value );
|
||||
void adjustChaperoneChanged( bool value );
|
||||
void moveShortcutRightChanged( bool value );
|
||||
void moveShortcutLeftChanged( bool value );
|
||||
@@ -304,6 +318,7 @@ signals:
|
||||
void showLogMatricesButtonChanged( bool value );
|
||||
void allowExternalEditsChanged( bool value );
|
||||
void oldStyleMotionChanged( bool value );
|
||||
void universeCenteredRotationChanged( bool value );
|
||||
};
|
||||
|
||||
} // namespace advsettings
|
||||
|
||||
Reference in New Issue
Block a user