From 60ffaea19517eed266fb21b0cbeed40497ea795b Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Thu, 25 Jun 2020 23:20:38 +0200 Subject: [PATCH] Pointer mode verbiage. protected member variables for vranimation --- apps/openmw/mwvr/vranimation.cpp | 9 ++++++--- apps/openmw/mwvr/vranimation.hpp | 8 ++++---- apps/openmw/mwvr/vrgui.cpp | 6 +++--- apps/openmw/mwvr/vrinputmanager.cpp | 9 ++++----- apps/openmw/mwworld/worldimp.cpp | 4 ++-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwvr/vranimation.cpp b/apps/openmw/mwvr/vranimation.cpp index 04648114e..2891aa4e1 100644 --- a/apps/openmw/mwvr/vranimation.cpp +++ b/apps/openmw/mwvr/vranimation.cpp @@ -247,7 +247,7 @@ void HandController::operator()(osg::Node* node, osg::NodeVisitor* nv) auto weaponType = world->getActiveWeaponType(); // Morrowind models do not hold most weapons at a natural angle, so i rotate the hand // to more natural angles on weapons to allow more comfortable combat. - if (!windowManager->isGuiMode() && !animation->isPointingForward()) + if (!windowManager->isGuiMode() && !animation->fingerPointingMode()) { switch (weaponType) @@ -495,8 +495,11 @@ void VRAnimation::updateParts() Environment::get().getSession()->setPlayerScale(sizeFactor); } -void VRAnimation::setPointForward(bool enabled) +void VRAnimation::setFingerPointingMode(bool enabled) { + if (enabled == mFingerPointingMode) + return; + auto finger = mNodeMap.find("bip01 r finger1"); if (finger != mNodeMap.end()) { @@ -524,7 +527,7 @@ void VRAnimation::setPointForward(bool enabled) mPointerTarget = MWRender::RayResult{}; } - mIsPointingForward = enabled; + mFingerPointingMode = enabled; } osg::ref_ptr VRAnimation::createPointerGeometry(void) diff --git a/apps/openmw/mwvr/vranimation.hpp b/apps/openmw/mwvr/vranimation.hpp index 204e46dfe..a0cde5666 100644 --- a/apps/openmw/mwvr/vranimation.hpp +++ b/apps/openmw/mwvr/vranimation.hpp @@ -53,8 +53,8 @@ public: virtual void updateParts(); /// Overrides finger animations to point forward - void setPointForward(bool enabled); - bool isPointingForward(void) const { return mIsPointingForward; } + void setFingerPointingMode(bool enabled); + bool fingerPointingMode() const { return mFingerPointingMode; } bool canPlaceObject(); ///< @return true if it is possible to place on object where the player is currently pointing @@ -73,14 +73,14 @@ protected: float getVelocity(const std::string& groupname) const override; -public: +protected: std::shared_ptr mSession; osg::ref_ptr mForearmControllers[2]; osg::ref_ptr mHandControllers[2]; osg::ref_ptr mIndexFingerControllers[2]; osg::ref_ptr mModelOffset; - bool mIsPointingForward{ false }; + bool mFingerPointingMode{ false }; osg::ref_ptr mPointerGeometry{ nullptr }; osg::ref_ptr mPointerRescale{ nullptr }; osg::ref_ptr mPointerTransform{ nullptr }; diff --git a/apps/openmw/mwvr/vrgui.cpp b/apps/openmw/mwvr/vrgui.cpp index 7a12bc557..8b73255e8 100644 --- a/apps/openmw/mwvr/vrgui.cpp +++ b/apps/openmw/mwvr/vrgui.cpp @@ -714,10 +714,10 @@ void VRGUIManager::updateTracking(osg::Camera* camera) bool VRGUIManager::updateFocus() { auto* anim = MWVR::Environment::get().getPlayerAnimation(); - if (anim && anim->mPointerTarget.mHit) + if (anim && anim->getPointerTarget().mHit) { std::shared_ptr newFocusLayer = nullptr; - auto* node = anim->mPointerTarget.mHitNode; + auto* node = anim->getPointerTarget().mHitNode; if (node->getName() == "VRGUILayer") { VRGUILayerUserData* userData = static_cast(node->getUserData()); @@ -727,7 +727,7 @@ bool VRGUIManager::updateFocus() if (newFocusLayer && newFocusLayer->mLayerName != "Notification") { setFocusLayer(newFocusLayer.get()); - computeGuiCursor(anim->mPointerTarget.mHitPointLocal); + computeGuiCursor(anim->getPointerTarget().mHitPointLocal); return true; } } diff --git a/apps/openmw/mwvr/vrinputmanager.cpp b/apps/openmw/mwvr/vrinputmanager.cpp index 7968d8965..6110ed425 100644 --- a/apps/openmw/mwvr/vrinputmanager.cpp +++ b/apps/openmw/mwvr/vrinputmanager.cpp @@ -48,8 +48,7 @@ void OpenXRInputManager::updateActivationIndication(void) bool show = guiMode | mActivationIndication; auto* playerAnimation = Environment::get().getPlayerAnimation(); if (playerAnimation) - if (show != playerAnimation->isPointingForward()) - playerAnimation->setPointForward(show); + playerAnimation->setFingerPointingMode(show); } @@ -91,10 +90,10 @@ void OpenXRInputManager::pointActivation(bool onPress) { auto* world = MWBase::Environment::get().getWorld(); auto* anim = MWVR::Environment::get().getPlayerAnimation(); - if (world && anim && anim->mPointerTarget.mHit) + if (world && anim && anim->getPointerTarget().mHit) { - auto* node = anim->mPointerTarget.mHitNode; - MWWorld::Ptr ptr = anim->mPointerTarget.mHitObject; + auto* node = anim->getPointerTarget().mHitNode; + MWWorld::Ptr ptr = anim->getPointerTarget().mHitObject; auto& dnd = MWBase::Environment::get().getWindowManager()->getDragAndDrop(); if (node && node->getName() == "VRGUILayer") diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4d5a150c7..84cdd03fa 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1127,8 +1127,8 @@ namespace MWWorld // TODO: Rename this method to getTargetObject? // "getFacedObject" doesn't make sense with finger pointing. auto* anim = MWVR::Environment::get().getPlayerAnimation(); - if (anim && anim->mPointerTarget.mHit) - return anim->mPointerTarget.mHitObject; + if (anim && anim->getPointerTarget().mHit) + return anim->getPointerTarget().mHitObject; else return MWWorld::Ptr(); #endif