Skip to content

Commit

Permalink
Make lock to horizon amount adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
Detegr committed Jan 18, 2024
1 parent 23c4eae commit b3d1ab8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.5.1

- SteamVR: Improve concurrent Vulkan queue usage
- Make the amount of correction that lock to horizon applies adjustable

## 0.5.0

Expand Down
6 changes: 6 additions & 0 deletions Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct Config {
glm::vec3 overlayTranslation;
float superSampling;
HorizonLock lockToHorizon;
float horizonLockMultiplier;
bool drawCompanionWindow;
bool drawLoadingScreen;
bool debug;
Expand All @@ -73,6 +74,7 @@ struct Config {
"overlayTranslateY = {:.2f}\n"
"overlayTranslateZ = {:.2f}\n"
"lockToHorizon = {}\n"
"horizonLockMultiplier = {}\n"
"drawDesktopWindow = {}\n"
"drawLoadingScreen = {}\n"
"debug = {}\n"
Expand All @@ -88,6 +90,7 @@ struct Config {
overlayTranslation.y,
overlayTranslation.z,
static_cast<int>(lockToHorizon),
horizonLockMultiplier,
drawCompanionWindow,
drawLoadingScreen,
debug,
Expand Down Expand Up @@ -117,6 +120,7 @@ struct Config {
.overlayTranslation = glm::vec3 { 0.0f, 0.0f, 0.0f },
.superSampling = 1.0,
.lockToHorizon = LOCK_NONE,
.horizonLockMultiplier = 1.0,
.drawCompanionWindow = true,
.drawLoadingScreen = true,
.debug = false,
Expand Down Expand Up @@ -173,6 +177,8 @@ struct Config {
cfg.superSampling = floatOrDefault(value, 1.0);
} else if (key == "lockToHorizon") {
cfg.lockToHorizon = static_cast<HorizonLock>(intOrDefault(value, 0));
} else if (key == "horizonLockMultiplier") {
cfg.horizonLockMultiplier = static_cast<HorizonLock>(floatOrDefault(value, 1.0));
} else if (key == "drawDesktopWindow") {
cfg.drawCompanionWindow = (value == "true");
} else if (key == "drawLoadingScreen") {
Expand Down
38 changes: 27 additions & 11 deletions Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,7 @@ void Toggle(bool& value) { value = !value; }
// clang-format off
static class Menu mainMenu = { "openRBRVR", {
{ .text = id("Recenter VR view"), .longText = {"Recenters VR view"}, .menuColor = IRBRGame::EMenuColors::MENU_TEXT, .position = Menu::menuItemsStartPos, .selectAction = RecenterVR },
{ .text = [] { return std::format("Lock horizon: {}", GetHorizonLockStr()); },
.longText = {
"Enable to rotate the car around the headset instead of rotating the headset with the car.",
"For some people, enabling this option gives a more comfortable VR experience.",
"Roll means locking the left-right axis.",
"Pitch means locking the front-back axis."
},
.leftAction = [] { ChangeHorizonLock(false); },
.rightAction = [] { ChangeHorizonLock(true); },
.selectAction = [] { ChangeHorizonLock(true); },
},
{ .text = id("Horizon lock settings") , .longText = {"Horizon lock settings"}, .selectAction = [] { SelectMenu(4); } },
{ .text = id("Graphics settings") , .longText = {"Graphics settings"}, .selectAction = [] { SelectMenu(1); } },
{ .text = id("Debug settings"), .longText = {"Not intended to be changed unless there is a problem that needs more information."}, .selectAction = [] { SelectMenu(2); } },
{ .text = [] { return std::format("VR runtime: {}", gCfg.runtime == OPENVR ? "OpenVR (SteamVR)" : (gCfg.wmrWorkaround ? "OpenXR (Reverb compatibility mode)" : "OpenXR")); },
Expand Down Expand Up @@ -201,13 +191,39 @@ static Menu debugMenu = { "openRBRVR debug settings", {
},
}};
static LicenseMenu licenseMenu;
static Menu horizonLockMenu = { "openRBRVR horizon lock settings", {
{ .text = [] { return std::format("Lock horizon: {}", GetHorizonLockStr()); },
.longText = {
"Enable to rotate the car around the headset instead of rotating the headset with the car.",
"For some people, enabling this option gives a more comfortable VR experience.",
"Roll means locking the left-right axis.",
"Pitch means locking the front-back axis."
},
.menuColor = IRBRGame::EMenuColors::MENU_TEXT,
.position = Menu::menuItemsStartPos,
.leftAction = [] { ChangeHorizonLock(false); },
.rightAction = [] { ChangeHorizonLock(true); },
.selectAction = [] { ChangeHorizonLock(true); },
},
{ .text = [] { return std::format("Percentage: {}%", static_cast<int>(gCfg.horizonLockMultiplier * 100.0f)); },
.longText = {
"Amount of locking that's happening. 100 means the horizon is always level.",
},
.leftAction = [] { gCfg.horizonLockMultiplier = std::max<float>(0.05f, gCfg.horizonLockMultiplier - 0.05f); },
.rightAction = [] { gCfg.horizonLockMultiplier = std::min<float>(1.0f, gCfg.horizonLockMultiplier + 0.05f); },
},
{ .text = id("Back to previous menu"),
.selectAction = [] { SelectMenu(0); }
},
}};
// clang-format on

static auto menus = std::to_array<Menu*>({
&mainMenu,
&graphicsMenu,
&debugMenu,
&licenseMenu,
&horizonLockMenu,
});

Menu* gMenu = menus[0];
Expand Down
2 changes: 1 addition & 1 deletion VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ M4 GetHorizonLockMatrix(Quaternion* carQuat, Config::HorizonLock lockSetting)
glm::vec3 ang = glm::eulerAngles(q);
auto pitch = (lockSetting & Config::HorizonLock::LOCK_PITCH) ? glm::pitch(q) : 0.0f;
auto roll = (lockSetting & Config::HorizonLock::LOCK_ROLL) ? glm::yaw(q) : 0.0f; // somehow in glm the axis is yaw
glm::quat cancelCarRotation = glm::quat(glm::vec3(pitch, 0.0f, roll));
glm::quat cancelCarRotation = glm::normalize(glm::quat(glm::vec3(pitch, 0.0f, roll))) * gCfg.horizonLockMultiplier;
return glm::mat4_cast(cancelCarRotation);
} else {
return glm::identity<M4>();
Expand Down

0 comments on commit b3d1ab8

Please sign in to comment.