Option to gently fade chaperone to disabled below a certain height (#622)

* Option to fade out chaperone when HMD goes below a configured height

Useful for setups in which you have a seat just outside your VR space,
or like to sit in the middle of your space for any amount of time. Will
fade out the boundaries to 0% opacity over 5 seconds, 5 seconds after
you sit down. Standing back up to the configured height will make them
pop back in immediately.

Can be found under Chaperone -> Additional Settings.

* Update format.sh to require clang-format v10

* Use fade distance instead of opacity, opacity inconsistently applied

* Bugfixes (#624)

* stop crashing on HMD Init Errors, as well as bypass force quit on all steamvr Init Errors

* add qtc clang to gitignore

* add app volume adjustment

* adjust app volume placement in menu

* fix type error

* increment version

* fix version number

---------

Co-authored-by: ykeara <ykeara1@gmail.com>
This commit is contained in:
Chelsea Jaggi
2023-05-17 14:21:59 -05:00
committed by GitHub
co-authored by ykeara
parent 65b5aace06
commit 1cfd9ff104
14 changed files with 340 additions and 14 deletions
@@ -248,6 +248,27 @@ void ChaperoneTabController::eventLoopTick(
checkCenterMarkerOverlayRotationCount();
}
if ( m_dimmingActive && m_dimNotificationTimestamp )
{
auto count = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now()
- *m_dimNotificationTimestamp )
.count();
if ( count > 10000 )
{
m_dimNotificationTimestamp.reset();
setFadeDistance( 0.0f, true );
}
else
{
float pct = std::min(
1.0f, 2.0f - static_cast<float>( count ) / 5000.0f );
// Originally this used opacity, but steam will override that it
// seems
setFadeDistance( pct * 0.4f, true );
}
}
if ( devicePoses )
{
m_isHMDActive = false;
@@ -277,6 +298,26 @@ void ChaperoneTabController::eventLoopTick(
{
minDistance = distanceHmd.distance;
}
if ( chaperoneDimHeight() > 0.0f )
{
// Both of these only activate on state changes (e.g. when first
// going above/below chaperoneDimHeight())
if ( !m_dimmingActive
&& poseHmd.mDeviceToAbsoluteTracking.m[1][3]
< chaperoneDimHeight() )
{
m_dimmingActive = true;
m_dimNotificationTimestamp.emplace(
std::chrono::steady_clock::now() );
}
else if ( m_dimmingActive
&& poseHmd.mDeviceToAbsoluteTracking.m[1][3]
>= chaperoneDimHeight() )
{
m_dimmingActive = false;
setFadeDistance( 0.4f, true );
}
}
}
auto leftIndex = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(
vr::TrackedControllerRole_LeftHand );
@@ -556,6 +597,12 @@ bool ChaperoneTabController::disableChaperone() const
settings::BoolSetting::CHAPERONE_disableChaperone );
}
float ChaperoneTabController::chaperoneDimHeight() const
{
return static_cast<float>(
settings::getSetting( settings::DoubleSetting::CHAPERONE_dimHeight ) );
}
float ChaperoneTabController::chaperoneAlarmSoundDistance() const
{
return static_cast<float>( settings::getSetting(
@@ -1061,6 +1108,17 @@ void ChaperoneTabController::setChaperoneAlarmSoundAdjustVolume( bool value,
}
}
void ChaperoneTabController::setChaperoneDimHeight( float value, bool notify )
{
settings::setSetting( settings::DoubleSetting::CHAPERONE_dimHeight,
static_cast<double>( value ) );
if ( notify )
{
emit chaperoneDimHeightChanged( value );
}
}
void ChaperoneTabController::setChaperoneAlarmSoundDistance( float value,
bool notify )
{
@@ -1221,6 +1279,7 @@ void ChaperoneTabController::addChaperoneProfile(
if ( includeFadeDistance )
{
profile->fadeDistance = m_fadeDistance;
profile->chaperoneDimHeight = chaperoneDimHeight();
}
profile->includesCenterMarker = includeCenterMarker;
if ( includeCenterMarker )
@@ -1312,6 +1371,7 @@ void ChaperoneTabController::applyChaperoneProfile( unsigned index )
if ( profile.includesFadeDistance )
{
setFadeDistance( profile.fadeDistance );
setChaperoneDimHeight( profile.chaperoneDimHeight );
}
if ( profile.includesCenterMarker )
{
@@ -69,6 +69,7 @@ struct ChaperoneProfile : settings::ISettingsObject
bool enableChaperoneShowDashboard = false;
float chaperoneShowDashboardDistance = 0.0f;
bool centerMarkerNew = false;
float chaperoneDimHeight = 0.0f;
virtual settings::SettingsObjectData saveSettings() const override
{
@@ -147,6 +148,7 @@ struct ChaperoneProfile : settings::ISettingsObject
o.addValue( enableChaperoneShowDashboard );
o.addValue( static_cast<double>( chaperoneShowDashboardDistance ) );
o.addValue( centerMarkerNew );
o.addValue( static_cast<double>( chaperoneDimHeight ) );
return o;
}
@@ -238,6 +240,8 @@ struct ChaperoneProfile : settings::ISettingsObject
chaperoneShowDashboardDistance
= static_cast<float>( obj.getNextValueOrDefault( 0.0 ) );
centerMarkerNew = obj.getNextValueOrDefault( false );
chaperoneDimHeight
= static_cast<float>( obj.getNextValueOrDefault( 0.0 ) );
}
virtual std::string settingsName() const override
@@ -298,6 +302,9 @@ class ChaperoneTabController : public QObject
setChaperoneAlarmSoundDistance NOTIFY
chaperoneAlarmSoundDistanceChanged )
Q_PROPERTY( float chaperoneDimHeight READ chaperoneDimHeight WRITE
setChaperoneDimHeight NOTIFY chaperoneDimHeightChanged )
Q_PROPERTY(
bool chaperoneShowDashboardEnabled READ isChaperoneShowDashboardEnabled
WRITE setChaperoneShowDashboardEnabled NOTIFY
@@ -380,6 +387,10 @@ private:
int m_rotationCurrent = 0;
bool m_centerMarkerOverlayIsInit = false;
bool m_dimmingActive = false;
std::optional<std::chrono::steady_clock::time_point>
m_dimNotificationTimestamp;
vr::ETrackingUniverseOrigin m_trackingUniverse
= vr::TrackingUniverseRawAndUncalibrated;
@@ -417,6 +428,8 @@ public:
int collisionBoundStyle();
float chaperoneDimHeight() const;
void setRightHapticActionHandle( vr::VRActionHandle_t handle );
void setLeftHapticActionHandle( vr::VRActionHandle_t handle );
void setRightInputHandle( vr::VRInputValueHandle_t handle );
@@ -477,6 +490,8 @@ public slots:
void setChaperoneShowDashboardEnabled( bool value, bool notify = true );
void setChaperoneShowDashboardDistance( float value, bool notify = true );
void setChaperoneDimHeight( float value, bool notify = true );
void setChaperoneColorR( int value, bool notify = true );
void setChaperoneColorG( int value, bool notify = true );
void setChaperoneColorB( int value, bool notify = true );
@@ -515,6 +530,7 @@ signals:
void boundsVisibilityChanged( float value );
void fadeDistanceChanged( float value );
void heightChanged( float value );
void chaperoneDimHeightChanged( float value );
void centerMarkerChanged( bool value );
void playSpaceMarkerChanged( bool value );
void forceBoundsChanged( bool value );