Reimplement chaperone height slider for OVRAS 3.0 motion
Addresses #264
This commit is contained in:
@@ -385,7 +385,7 @@ MyStackViewPage {
|
|||||||
MySlider {
|
MySlider {
|
||||||
id: chaperoneHeightSlider
|
id: chaperoneHeightSlider
|
||||||
from: 0.01
|
from: 0.01
|
||||||
to: 15.0
|
to: 5.0
|
||||||
stepSize: 0.01
|
stepSize: 0.01
|
||||||
value: 2.0
|
value: 2.0
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ namespace advsettings
|
|||||||
{
|
{
|
||||||
void ChaperoneTabController::initStage1()
|
void ChaperoneTabController::initStage1()
|
||||||
{
|
{
|
||||||
m_height = getBoundsMaxY();
|
|
||||||
|
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( "chaperoneSettings" );
|
settings->beginGroup( "chaperoneSettings" );
|
||||||
m_enableChaperoneSwitchToBeginner
|
m_enableChaperoneSwitchToBeginner
|
||||||
@@ -705,7 +703,6 @@ void ChaperoneTabController::updateChaperoneSettings()
|
|||||||
vrSettingsError );
|
vrSettingsError );
|
||||||
}
|
}
|
||||||
setPlaySpaceMarker( ps );
|
setPlaySpaceMarker( ps );
|
||||||
updateHeight( getBoundsMaxY() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float ChaperoneTabController::boundsVisibility() const
|
float ChaperoneTabController::boundsVisibility() const
|
||||||
@@ -770,31 +767,7 @@ void ChaperoneTabController::setHeight( float value, bool notify )
|
|||||||
if ( fabs( static_cast<double>( m_height - value ) ) > 0.005 )
|
if ( fabs( static_cast<double>( m_height - value ) ) > 0.005 )
|
||||||
{
|
{
|
||||||
m_height = value;
|
m_height = value;
|
||||||
// TODO revert?
|
parent->m_moveCenterTabController.setBoundsBasisHeight( m_height );
|
||||||
// vr::VRChaperoneSetup()->RevertWorkingCopy();
|
|
||||||
unsigned collisionBoundsCount = 0;
|
|
||||||
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo(
|
|
||||||
nullptr, &collisionBoundsCount );
|
|
||||||
if ( collisionBoundsCount > 0 )
|
|
||||||
{
|
|
||||||
vr::HmdQuad_t* collisionBounds
|
|
||||||
= new vr::HmdQuad_t[collisionBoundsCount];
|
|
||||||
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo(
|
|
||||||
collisionBounds, &collisionBoundsCount );
|
|
||||||
for ( unsigned b = 0; b < collisionBoundsCount; b++ )
|
|
||||||
{
|
|
||||||
collisionBounds[b].vCorners[0].v[1] = 0.0;
|
|
||||||
collisionBounds[b].vCorners[1].v[1] = value;
|
|
||||||
collisionBounds[b].vCorners[2].v[1] = value;
|
|
||||||
collisionBounds[b].vCorners[3].v[1] = 0.0;
|
|
||||||
}
|
|
||||||
vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(
|
|
||||||
collisionBounds, collisionBoundsCount );
|
|
||||||
// TODO revert?
|
|
||||||
// vr::VRChaperoneSetup()->CommitWorkingCopy(
|
|
||||||
// vr::EChaperoneConfigFile_Live );
|
|
||||||
delete[] collisionBounds;
|
|
||||||
}
|
|
||||||
if ( notify )
|
if ( notify )
|
||||||
{
|
{
|
||||||
emit heightChanged( m_height );
|
emit heightChanged( m_height );
|
||||||
@@ -1505,7 +1478,6 @@ void ChaperoneTabController::applyChaperoneProfile( unsigned index )
|
|||||||
profile.enableChaperoneShowDashboard );
|
profile.enableChaperoneShowDashboard );
|
||||||
}
|
}
|
||||||
vr::VRSettings()->Sync( true );
|
vr::VRSettings()->Sync( true );
|
||||||
updateHeight( getBoundsMaxY() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1606,41 +1578,6 @@ void ChaperoneTabController::applyAutosavedProfile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float ChaperoneTabController::getBoundsMaxY()
|
|
||||||
{
|
|
||||||
unsigned collisionBoundsCount = 0;
|
|
||||||
float result = FP_NAN;
|
|
||||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo( nullptr,
|
|
||||||
&collisionBoundsCount );
|
|
||||||
if ( collisionBoundsCount > 0 )
|
|
||||||
{
|
|
||||||
vr::HmdQuad_t* collisionBounds
|
|
||||||
= new vr::HmdQuad_t[collisionBoundsCount];
|
|
||||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo(
|
|
||||||
collisionBounds, &collisionBoundsCount );
|
|
||||||
for ( unsigned b = 0; b < collisionBoundsCount; b++ )
|
|
||||||
{
|
|
||||||
int ci;
|
|
||||||
if ( collisionBounds[b].vCorners[1].v[1]
|
|
||||||
>= collisionBounds[b].vCorners[2].v[1] )
|
|
||||||
{
|
|
||||||
ci = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ci = 2;
|
|
||||||
}
|
|
||||||
if ( std::isnan( result )
|
|
||||||
|| result < collisionBounds[b].vCorners[ci].v[1] )
|
|
||||||
{
|
|
||||||
result = collisionBounds[b].vCorners[ci].v[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete[] collisionBounds;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChaperoneTabController::reset()
|
void ChaperoneTabController::reset()
|
||||||
{
|
{
|
||||||
vr::EVRSettingsError vrSettingsError;
|
vr::EVRSettingsError vrSettingsError;
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ public:
|
|||||||
Q_INVOKABLE unsigned getChaperoneProfileCount();
|
Q_INVOKABLE unsigned getChaperoneProfileCount();
|
||||||
Q_INVOKABLE QString getChaperoneProfileName( unsigned index );
|
Q_INVOKABLE QString getChaperoneProfileName( unsigned index );
|
||||||
|
|
||||||
float getBoundsMaxY();
|
|
||||||
std::pair<bool, unsigned>
|
std::pair<bool, unsigned>
|
||||||
getChaperoneProfileIndexFromName( std::string name );
|
getChaperoneProfileIndexFromName( std::string name );
|
||||||
void createNewAutosaveProfile();
|
void createNewAutosaveProfile();
|
||||||
|
|||||||
@@ -1501,6 +1501,20 @@ void MoveCenterTabController::updateChaperoneResetData()
|
|||||||
vr::VRChaperoneSetup()->GetWorkingSeatedZeroPoseToRawTrackingPose(
|
vr::VRChaperoneSetup()->GetWorkingSeatedZeroPoseToRawTrackingPose(
|
||||||
&m_seatedCenterForReset );
|
&m_seatedCenterForReset );
|
||||||
|
|
||||||
|
updateCollisionBoundsForOffset();
|
||||||
|
parent->m_chaperoneTabController.updateHeight( getBoundsBasisMaxY() );
|
||||||
|
|
||||||
|
unsigned checkQuadCount = 0;
|
||||||
|
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo( nullptr,
|
||||||
|
&checkQuadCount );
|
||||||
|
if ( checkQuadCount > 0 )
|
||||||
|
{
|
||||||
|
parent->chaperoneUtils().loadChaperoneData( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveCenterTabController::updateCollisionBoundsForOffset()
|
||||||
|
{
|
||||||
if ( m_collisionBoundsCountForReset > 0 )
|
if ( m_collisionBoundsCountForReset > 0 )
|
||||||
{
|
{
|
||||||
float universeCenterForResetYaw
|
float universeCenterForResetYaw
|
||||||
@@ -1531,14 +1545,6 @@ void MoveCenterTabController::updateChaperoneResetData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned checkQuadCount = 0;
|
|
||||||
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo( nullptr,
|
|
||||||
&checkQuadCount );
|
|
||||||
if ( checkQuadCount > 0 )
|
|
||||||
{
|
|
||||||
parent->chaperoneUtils().loadChaperoneData( false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::applyChaperoneResetData()
|
void MoveCenterTabController::applyChaperoneResetData()
|
||||||
@@ -1566,6 +1572,50 @@ void MoveCenterTabController::applyChaperoneResetData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveCenterTabController::setBoundsBasisHeight( float newHeight )
|
||||||
|
{
|
||||||
|
if ( m_collisionBoundsCountForReset > 0 )
|
||||||
|
{
|
||||||
|
for ( unsigned b = 0; b < m_collisionBoundsCountForReset; b++ )
|
||||||
|
{
|
||||||
|
m_collisionBoundsForReset[b].vCorners[0].v[1] = 0.0;
|
||||||
|
m_collisionBoundsForReset[b].vCorners[1].v[1] = newHeight;
|
||||||
|
m_collisionBoundsForReset[b].vCorners[2].v[1] = newHeight;
|
||||||
|
m_collisionBoundsForReset[b].vCorners[3].v[1] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCollisionBoundsForOffset();
|
||||||
|
updateSpace( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float MoveCenterTabController::getBoundsBasisMaxY()
|
||||||
|
{
|
||||||
|
float result = FP_NAN;
|
||||||
|
if ( m_collisionBoundsCountForReset > 0 )
|
||||||
|
{
|
||||||
|
for ( unsigned b = 0; b < m_collisionBoundsCountForReset; b++ )
|
||||||
|
{
|
||||||
|
int ci;
|
||||||
|
if ( m_collisionBoundsForReset[b].vCorners[1].v[1]
|
||||||
|
>= m_collisionBoundsForReset[b].vCorners[2].v[1] )
|
||||||
|
{
|
||||||
|
ci = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ci = 2;
|
||||||
|
}
|
||||||
|
if ( std::isnan( result )
|
||||||
|
|| result < m_collisionBoundsForReset[b].vCorners[ci].v[1] )
|
||||||
|
{
|
||||||
|
result = m_collisionBoundsForReset[b].vCorners[ci].v[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// START of drag bindings:
|
// START of drag bindings:
|
||||||
|
|
||||||
void MoveCenterTabController::leftHandSpaceDrag( bool leftHandDragActive )
|
void MoveCenterTabController::leftHandSpaceDrag( bool leftHandDragActive )
|
||||||
@@ -2677,11 +2727,12 @@ void MoveCenterTabController::updateGravity()
|
|||||||
m_velocity[2] = 0.0;
|
m_velocity[2] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveCenterTabController::updateSpace()
|
void MoveCenterTabController::updateSpace( bool forceUpdate )
|
||||||
{
|
{
|
||||||
// Do nothing if all offsets and rotation are still the same...
|
// Do nothing if all offsets and rotation are still the same...
|
||||||
if ( m_offsetX == m_oldOffsetX && m_offsetY == m_oldOffsetY
|
if ( m_offsetX == m_oldOffsetX && m_offsetY == m_oldOffsetY
|
||||||
&& m_offsetZ == m_oldOffsetZ && m_rotation == m_oldRotation )
|
&& m_offsetZ == m_oldOffsetZ && m_rotation == m_oldRotation
|
||||||
|
&& !forceUpdate )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,13 +201,14 @@ private:
|
|||||||
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||||
{ 0.0f, 0.0f, 1.0f, 0.0f } } };
|
{ 0.0f, 0.0f, 1.0f, 0.0f } } };
|
||||||
vr::HmdQuad_t* m_collisionBoundsForOffset;
|
vr::HmdQuad_t* m_collisionBoundsForOffset;
|
||||||
|
void updateCollisionBoundsForOffset();
|
||||||
|
|
||||||
void updateHmdRotationCounter( vr::TrackedDevicePose_t hmdPose,
|
void updateHmdRotationCounter( vr::TrackedDevicePose_t hmdPose,
|
||||||
double angle );
|
double angle );
|
||||||
void updateHandDrag( vr::TrackedDevicePose_t* devicePoses, double angle );
|
void updateHandDrag( vr::TrackedDevicePose_t* devicePoses, double angle );
|
||||||
void updateHandTurn( vr::TrackedDevicePose_t* devicePoses, double angle );
|
void updateHandTurn( vr::TrackedDevicePose_t* devicePoses, double angle );
|
||||||
void updateGravity();
|
void updateGravity();
|
||||||
void updateSpace();
|
void updateSpace( bool forceUpdate = false );
|
||||||
void clampVelocity( double* velocity );
|
void clampVelocity( double* velocity );
|
||||||
void updateChaperoneResetData();
|
void updateChaperoneResetData();
|
||||||
void applyChaperoneResetData();
|
void applyChaperoneResetData();
|
||||||
@@ -258,6 +259,8 @@ public:
|
|||||||
double getHmdYawTotal();
|
double getHmdYawTotal();
|
||||||
void resetHmdYawTotal();
|
void resetHmdYawTotal();
|
||||||
void incomingSeatedReset();
|
void incomingSeatedReset();
|
||||||
|
void setBoundsBasisHeight( float newHeight );
|
||||||
|
float getBoundsBasisMaxY();
|
||||||
|
|
||||||
void reloadOffsetProfiles();
|
void reloadOffsetProfiles();
|
||||||
void saveOffsetProfiles();
|
void saveOffsetProfiles();
|
||||||
|
|||||||
Reference in New Issue
Block a user