Add x and z offset to recenter playspace during floor fix.

This commit is contained in:
Moritz Ls
2018-04-02 12:42:20 +02:00
committed by Robin Appelman
parent 4e2a4bd570
commit 04687352df
2 changed files with 16 additions and 8 deletions
+11 -7
View File
@@ -62,7 +62,9 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
}
auto& m = devicePoses[referenceController].mDeviceToAbsoluteTracking.m;
tempOffsetX = (double)m[0][3];
tempOffsetY = (double)m[1][3];
tempOffsetZ = (double)m[2][3];
/*
| Intrinsic y-x'-z" rotation matrix:
| cr*cy+sp*sr*sy | cr*sp*sy-cy*sr | cp*sy |
@@ -96,12 +98,14 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses)
if (measurementCount >= 25) {
if (std::abs(tempRoll) <= M_PI_2) {
floorOffset = tempOffsetY - controllerUpOffsetCorrection;
floorOffsetY = tempOffsetY - controllerUpOffsetCorrection;
} else {
floorOffset = tempOffsetY - controllerDownOffsetCorrection;
floorOffsetY = tempOffsetY - controllerDownOffsetCorrection;
}
LOG(INFO) << "Fix Floor: Floor Offset = " << floorOffset;
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, floorOffset, false);
LOG(INFO) << "Fix Floor: Floor Offset = [" << floorOffsetX << ", " << floorOffsetY << ", " << floorOffsetZ << "]";
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 0, floorOffsetX, false);
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, floorOffsetY, false);
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 2, floorOffsetZ, false);
statusMessage = "Fixing ... OK";
statusMessageTimeout = 1.0;
emit statusMessageSignal();
@@ -144,9 +148,9 @@ void FixFloorTabController::fixFloorClicked() {
}
void FixFloorTabController::undoFixFloorClicked() {
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, -floorOffset, false);
LOG(INFO) << "Fix Floor: Undo Floor Offset = " << -floorOffset;
floorOffset = 0.0f;
parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, -floorOffsetY, false);
LOG(INFO) << "Fix Floor: Undo Floor Offset = " << -floorOffsetY;
floorOffsetY = 0.0f;
statusMessage = "Undo ... OK";
statusMessageTimeout = 1.0;
emit statusMessageSignal();
+5 -1
View File
@@ -25,9 +25,13 @@ private:
int state = 0; // 0 .. idle, 1 .. measurement in progress
vr::TrackedDeviceIndex_t referenceController = vr::k_unTrackedDeviceIndexInvalid;
unsigned measurementCount = 0;
double tempOffsetX = 0.0;
double tempOffsetY = 0.0;
double tempOffsetZ = 0.0;
double tempRoll = 0.0;
float floorOffset = 0.0f;
float floorOffsetX = 0.0f;
float floorOffsetY = 0.0f;
float floorOffsetZ = 0.0f;
QString statusMessage = "";
float statusMessageTimeout = 0.0f;
bool m_canUndo = false;