From 4e1aaabe95ecf968467bfd71087bfea9295bc2d7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 2 Apr 2018 13:09:04 +0200 Subject: [PATCH] seperate recentering of playspace into it's own button --- bin/win64/res/qml/FixFloorPage.qml | 10 +++++++++ bin/win64/res/qml/RootPage.qml | 2 +- src/tabcontrollers/FixFloorTabController.cpp | 23 +++++++++++++++----- src/tabcontrollers/FixFloorTabController.h | 3 ++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/bin/win64/res/qml/FixFloorPage.qml b/bin/win64/res/qml/FixFloorPage.qml index da16b1e..9974526 100644 --- a/bin/win64/res/qml/FixFloorPage.qml +++ b/bin/win64/res/qml/FixFloorPage.qml @@ -54,6 +54,16 @@ MyStackViewPage { } } + MyPushButton { + id: recenterButton + Layout.fillWidth: true + text: "Recenter Playspace" + Layout.preferredHeight: 100 + onClicked: { + FixFloorTabController.recenterClicked() + } + } + MyPushButton { id: undoFixButton enabled: false diff --git a/bin/win64/res/qml/RootPage.qml b/bin/win64/res/qml/RootPage.qml index 37d8e77..1580e3f 100644 --- a/bin/win64/res/qml/RootPage.qml +++ b/bin/win64/res/qml/RootPage.qml @@ -58,7 +58,7 @@ MyStackViewPage { MyPushButton { id: fixFloorButton activationSoundEnabled: false - text: "Floor Fix" + text: "Playspace Fix" Layout.fillWidth: true onClicked: { MyResources.playFocusChangedSound() diff --git a/src/tabcontrollers/FixFloorTabController.cpp b/src/tabcontrollers/FixFloorTabController.cpp index e6d5427..1da09b3 100644 --- a/src/tabcontrollers/FixFloorTabController.cpp +++ b/src/tabcontrollers/FixFloorTabController.cpp @@ -15,7 +15,7 @@ void FixFloorTabController::initStage2(OverlayController * parent, QQuickWindow } void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses) { - if (state == 1) { + if (state > 0) { if (measurementCount == 0) { // Get Controller ids for left/right hand auto leftId = vr::VRSystem()->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_LeftHand); @@ -107,10 +107,14 @@ void FixFloorTabController::eventLoopTick(vr::TrackedDevicePose_t* devicePoses) floorOffsetZ = tempOffsetZ; LOG(INFO) << "Fix Floor and adjust playspace center: 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"; + float offset[3]; + offset[1] = floorOffsetY; + if (state == 2) { + offset[0] = floorOffsetX; + offset[2] = floorOffsetZ; + } + parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, offset, true); + statusMessage = (state == 2) ? "Recentering ... Ok" : "Fixing ... OK"; statusMessageTimeout = 1.0; emit statusMessageSignal(); emit measureEndSignal(); @@ -151,6 +155,15 @@ void FixFloorTabController::fixFloorClicked() { state = 1; } +void FixFloorTabController::recenterClicked() { + statusMessage = "Fixing ..."; + statusMessageTimeout = 1.0; + emit statusMessageSignal(); + emit measureStartSignal(); + measurementCount = 0; + state = 2; +} + void FixFloorTabController::undoFixFloorClicked() { parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 0, -floorOffsetX, false); parent->AddOffsetToUniverseCenter(vr::TrackingUniverseStanding, 1, -floorOffsetY, false); diff --git a/src/tabcontrollers/FixFloorTabController.h b/src/tabcontrollers/FixFloorTabController.h index 1f7e358..2dec3bd 100644 --- a/src/tabcontrollers/FixFloorTabController.h +++ b/src/tabcontrollers/FixFloorTabController.h @@ -22,7 +22,7 @@ private: float controllerUpOffsetCorrection = 0.062f; // Controller touchpad facing upwards float controllerDownOffsetCorrection = 0.006f; // Controller touchpad facing downwards - int state = 0; // 0 .. idle, 1 .. measurement in progress + int state = 0; // 0 .. idle, 1 .. floor fix in progress, 2 .. recenter in progress vr::TrackedDeviceIndex_t referenceController = vr::k_unTrackedDeviceIndexInvalid; unsigned measurementCount = 0; double tempOffsetX = 0.0; @@ -50,6 +50,7 @@ public: public slots: void fixFloorClicked(); + void recenterClicked(); void undoFixFloorClicked(); void setCanUndo(bool value, bool notify = true);