1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-10-10 16:56:32 +00:00

Recenter action

This commit is contained in:
Mads Buvik Sandvei 2020-05-31 12:15:31 +02:00
parent 930ee48da6
commit b65c1f582a
2 changed files with 10 additions and 8 deletions

View file

@ -292,7 +292,7 @@ struct OpenXRInput
{ {
A_XrFirst = MWInput::A_Last, A_XrFirst = MWInput::A_Last,
A_ActivateTouch, A_ActivateTouch,
A_RepositionMenu, A_Recenter,
A_XrLast A_XrLast
}; };
@ -550,7 +550,7 @@ OpenXRInput::OpenXRInput()
, mBPath(generateControllerActionPaths("/input/b/click")) , mBPath(generateControllerActionPaths("/input/b/click"))
, mTriggerValuePath(generateControllerActionPaths("/input/trigger/value")) , mTriggerValuePath(generateControllerActionPaths("/input/trigger/value"))
, mGameMenu(std::move(createMWAction<ButtonPressAction>(MWInput::A_GameMenu, "game_menu", "Game Menu", { }))) , mGameMenu(std::move(createMWAction<ButtonPressAction>(MWInput::A_GameMenu, "game_menu", "Game Menu", { })))
, mRepositionMenu(std::move(createMWAction<ButtonLongPressAction>(A_RepositionMenu, "reposition_menu", "Reposition Menu", { }))) , mRepositionMenu(std::move(createMWAction<ButtonLongPressAction>(A_Recenter, "reposition_menu", "Reposition Menu", { })))
, mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::A_Inventory, "inventory", "Inventory", { }))) , mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::A_Inventory, "inventory", "Inventory", { })))
, mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::A_Activate, "activate", "Activate", { }))) , mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::A_Activate, "activate", "Activate", { })))
, mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Use, "use", "Use", { }))) , mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Use, "use", "Use", { })))
@ -652,8 +652,8 @@ OpenXRInput::OpenXRInput()
Long: Journal Long: Journal
Menu: Menu:
Press: GameMenun Press: GameMenu
Long: Reposition GUI Long: Recenter on player and reset GUI
*/ */
@ -1199,8 +1199,10 @@ private:
case MWInput::A_Jump: case MWInput::A_Jump:
mActionManager->setAttemptJump(true); mActionManager->setAttemptJump(true);
break; break;
case OpenXRInput::A_RepositionMenu: case OpenXRInput::A_Recenter:
xrGUIManager->updateTracking(); xrGUIManager->updateTracking();
if(!MWBase::Environment::get().getWindowManager()->isGuiMode())
mShouldRecenter = true;
break; break;
case MWInput::A_Use: case MWInput::A_Use:
if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode()) if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())
@ -1242,12 +1244,12 @@ private:
osg::Quat gameworldYaw = osg::Quat(mYaw, osg::Vec3(0, 0, -1)); osg::Quat gameworldYaw = osg::Quat(mYaw, osg::Vec3(0, 0, -1));
mHeadOffset += gameworldYaw * vrMovement; mHeadOffset += gameworldYaw * vrMovement;
if (mRecenter) if (mShouldRecenter)
{ {
mHeadOffset = osg::Vec3(0, 0, 0); mHeadOffset = osg::Vec3(0, 0, 0);
// Z should not be affected // Z should not be affected
mHeadOffset.z() = mHeadPose.position.z(); mHeadOffset.z() = mHeadPose.position.z();
mRecenter = false; mShouldRecenter = false;
} }
else else
{ {

View file

@ -57,7 +57,7 @@ namespace MWVR
std::unique_ptr<RealisticCombat::StateMachine> mRealisticCombat; std::unique_ptr<RealisticCombat::StateMachine> mRealisticCombat;
Pose mHeadPose{}; Pose mHeadPose{};
osg::Vec3 mHeadOffset{ 0,0,0 }; osg::Vec3 mHeadOffset{ 0,0,0 };
bool mRecenter{ true }; bool mShouldRecenter{ true };
bool mActivationIndication{ false }; bool mActivationIndication{ false };
float mYaw{ 0.f }; float mYaw{ 0.f };