@@ -123,6 +123,27 @@ void MoveCenterTabController::applyOffsetProfile( unsigned index )
123123 }
124124}
125125
126+ void MoveCenterTabController::addOffset ( float offset[] )
127+ {
128+ m_universeCenterForReset.m [0 ][3 ] += offset[0 ];
129+ m_universeCenterForReset.m [1 ][3 ] += offset[1 ];
130+ m_universeCenterForReset.m [2 ][3 ] += offset[2 ];
131+
132+ m_seatedCenterForReset.m [0 ][3 ] += offset[0 ];
133+ m_seatedCenterForReset.m [1 ][3 ] += offset[1 ];
134+ m_seatedCenterForReset.m [2 ][3 ] += offset[2 ];
135+
136+ updateSpace ( true );
137+ }
138+
139+ void MoveCenterTabController::addCurOffsetAsCenter ()
140+ {
141+ float off[3 ] = { -m_offsetX, m_offsetY, -m_offsetZ };
142+ // zeroOffsets();
143+ resetOffsets ( true );
144+ addOffset ( off );
145+ }
146+
126147void MoveCenterTabController::deleteOffsetProfile ( unsigned index )
127148{
128149 if ( index < m_offsetProfiles.size () )
@@ -1097,18 +1118,25 @@ void MoveCenterTabController::zeroOffsets()
10971118 setTrackingUniverse ( vr::VRCompositor ()->GetTrackingSpace () );
10981119 if ( parent->isPreviousShutdownSafe () )
10991120 {
1100- // all init complete, safe to autosave chaperone profile
1101- parent->m_chaperoneTabController .createNewAutosaveProfile ();
1102- m_initComplete = true ;
11031121 auto calState = vr::VRChaperone ()->GetCalibrationState ();
1104- LOG ( INFO ) << " Calibration State after autosave profile is: "
1105- << calState;
1122+ if ( calState == 200 )
1123+ {
1124+ LOG ( WARNING )
1125+ << " Chaperone State Does Not Exist Yet, will wait for "
1126+ " universe change to finish initialization" ;
1127+ }
1128+ else
1129+ {
1130+ // all init complete, safe to autosave chaperone profile
1131+ parent->m_chaperoneTabController .createNewAutosaveProfile ();
1132+ m_initComplete = true ;
1133+ }
11061134 }
11071135 else
11081136 {
11091137 // shutdown was unsafe last session!
11101138 LOG ( WARNING ) << " DETECTED UNSAFE SHUTDOWN FROM LAST SESSION" ;
1111- m_initComplete = true ;
1139+ m_initComplete = false ;
11121140 if ( !parent->crashRecoveryDisabled () )
11131141 {
11141142 parent->m_chaperoneTabController .applyAutosavedProfile ();
@@ -1165,8 +1193,18 @@ void MoveCenterTabController::clampVelocity( double* velocity )
11651193
11661194void MoveCenterTabController::updateChaperoneResetData ()
11671195{
1168- // TODO
1169- // vr::VRChaperoneSetup()->RevertWorkingCopy();
1196+ auto cstate = vr::VRChaperone ()->GetCalibrationState ();
1197+ if ( cstate > 199 )
1198+ {
1199+ LOG ( WARNING ) << " Chaperone Calibration State is error: " << cstate
1200+ << " While Trying to Update Reset Data" ;
1201+ }
1202+ else
1203+ {
1204+ vr::VRChaperoneSetup ()->CommitWorkingCopy (
1205+ vr::EChaperoneConfigFile_Live );
1206+ vr::VRChaperoneSetup ()->RevertWorkingCopy ();
1207+ }
11701208 unsigned currentQuadCount = 0 ;
11711209 vr::VRChaperoneSetup ()->GetWorkingCollisionBoundsInfo ( nullptr ,
11721210 ¤tQuadCount );
@@ -1857,16 +1895,6 @@ void MoveCenterTabController::resetOffsets( bool resetOffsetsJustPressed )
18571895 // of keyboard input.
18581896 if ( resetOffsetsJustPressed )
18591897 {
1860- auto calState = vr::VRChaperone ()->GetCalibrationState ();
1861- LOG ( INFO ) << " Calibration State on Reset Offsets is: " << calState;
1862-
1863- if ( calState > 199 && m_initComplete )
1864- {
1865- LOG ( INFO ) << " Chaperone calibration state is error, attempting "
1866- " to apply autosaved profile to fix issue" ;
1867- parent->m_chaperoneTabController .applyAutosavedProfile ();
1868- }
1869-
18701898 m_offsetX = 0 .0f ;
18711899 m_offsetY = 0 .0f ;
18721900 m_offsetZ = 0 .0f ;
@@ -1876,6 +1904,16 @@ void MoveCenterTabController::resetOffsets( bool resetOffsetsJustPressed )
18761904 emit offsetZChanged ( m_offsetZ );
18771905 emit rotationChanged ( m_rotation );
18781906 updateSpace ( true );
1907+ auto calState = vr::VRChaperone ()->GetCalibrationState ();
1908+ LOG ( INFO ) << " Calibration State on Reset Offsets is: " << calState;
1909+
1910+ // if ( calState > 199 && m_initComplete )
1911+ // {
1912+ // LOG( INFO ) << "Chaperone calibration state is error,
1913+ // attempting "
1914+ // "to apply autosaved profile to fix issue";
1915+ // parent->m_chaperoneTabController.applyAutosavedProfile();
1916+ // }
18791917 // reset();
18801918 }
18811919}
@@ -2478,6 +2516,18 @@ void MoveCenterTabController::updateSpace( bool forceUpdate )
24782516 {
24792517 return ;
24802518 }
2519+ if ( ( abs ( m_offsetX ) + abs ( m_offsetY ) + abs ( m_offsetZ )
2520+ + abs ( static_cast <float >( m_rotation ) ) )
2521+ == 0
2522+ && !forceUpdate )
2523+ {
2524+ if ( m_chaperoneHasCommit )
2525+ {
2526+ m_chaperoneHasCommit = true ;
2527+ updateChaperoneResetData ();
2528+ }
2529+ }
2530+ m_chaperoneHasCommit = false ;
24812531
24822532 vr::HmdMatrix34_t offsetUniverseCenter;
24832533
0 commit comments