1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-06 04:45:32 +00:00

Some cleanup. Fixed problems arising from latest merge (refactoring).

This commit is contained in:
Mads Buvik Sandvei 2020-05-21 01:01:15 +02:00
parent cbbc82f053
commit 288530510d
24 changed files with 346 additions and 213 deletions

View file

@ -655,8 +655,6 @@ namespace MWBase
virtual int getActiveWeaponType(void) = 0; virtual int getActiveWeaponType(void) = 0;
virtual MWPhysics::PhysicsSystem* getPhysicsSystem(void) = 0; virtual MWPhysics::PhysicsSystem* getPhysicsSystem(void) = 0;
virtual void toggleWaterRTT(bool enable) = 0;
virtual bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const = 0; virtual bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const = 0;
}; };

View file

@ -5,6 +5,8 @@
#include <extern/oics/ICSChannelListener.h> #include <extern/oics/ICSChannelListener.h>
#include <extern/oics/ICSInputControlSystem.h> #include <extern/oics/ICSInputControlSystem.h>
#include <components/debug/debuglog.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -48,6 +50,12 @@ namespace MWInput
} }
}; };
ICS::InputControlSystem&
BindingsManager::ics()
{
return *mInputBinder;
}
class BindingsListener : class BindingsListener :
public ICS::ChannelListener, public ICS::ChannelListener,
public ICS::DetectingBindingListener public ICS::DetectingBindingListener

View file

@ -6,6 +6,11 @@
#include <components/sdlutil/events.hpp> #include <components/sdlutil/events.hpp>
namespace ICS
{
class InputControlSystem;
}
namespace MWInput namespace MWInput
{ {
class BindingsListener; class BindingsListener;
@ -59,6 +64,8 @@ namespace MWInput
void actionValueChanged(int action, float currentValue, float previousValue); void actionValueChanged(int action, float currentValue, float previousValue);
ICS::InputControlSystem& ics();
private: private:
void setupSDLKeyMappings(); void setupSDLKeyMappings();

View file

@ -94,15 +94,18 @@ namespace MWInput
virtual void executeAction(int action); virtual void executeAction(int action);
private: void applyHapticsLeftHand(float intensity) override {};
void applyHapticsRightHand(float intensity) override {};
protected:
void convertMousePosForMyGUI(int& x, int& y); void convertMousePosForMyGUI(int& x, int& y);
void handleGuiArrowKey(int action); void handleGuiArrowKey(int action);
void updateCursorMode(); void updateCursorMode();
void quickKey(int index); //void quickKey(int index);
void showQuickKeysMenu(); //void showQuickKeysMenu();
void loadKeyDefaults(bool force = false); void loadKeyDefaults(bool force = false);
void loadControllerDefaults(bool force = false); void loadControllerDefaults(bool force = false);

View file

@ -224,4 +224,14 @@ namespace MWInput
{ {
mInputWrapper->warpMouse(static_cast<int>(mGuiCursorX / mInvUiScalingFactor), static_cast<int>(mGuiCursorY / mInvUiScalingFactor)); mInputWrapper->warpMouse(static_cast<int>(mGuiCursorX / mInvUiScalingFactor), static_cast<int>(mGuiCursorY / mInvUiScalingFactor));
} }
void MouseManager::setMousePosition(int x, int y)
{
mGuiCursorX = x * mInvUiScalingFactor;
mGuiCursorY = y * mInvUiScalingFactor;
}
void MouseManager::setGUIScale(float scale)
{
mInvUiScalingFactor = 1.f / scale;
}
} }

View file

@ -37,6 +37,10 @@ namespace MWInput
void setMouseLookEnabled(bool enabled) { mMouseLookEnabled = enabled; } void setMouseLookEnabled(bool enabled) { mMouseLookEnabled = enabled; }
void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; } void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; }
// Used to override mouse position when using controllers not through SDL, such as OpenXR.
void setMousePosition(int x, int y);
void setGUIScale(float scale);
private: private:
bool mInvertX; bool mInvertX;
bool mInvertY; bool mInvertY;

View file

@ -19,6 +19,12 @@
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#ifdef USE_OPENXR
#include "../mwvr/openxrsession.hpp"
#include "../mwvr/openxrinputmanager.hpp"
#include "../mwvr/vrenvironment.hpp"
#endif
#include "actor.hpp" #include "actor.hpp"
#include "collisiontype.hpp" #include "collisiontype.hpp"
#include "constants.hpp" #include "constants.hpp"
@ -82,12 +88,32 @@ namespace MWPhysics
bool isFlying, float waterlevel, float slowFall, const btCollisionWorld* collisionWorld, bool isFlying, float waterlevel, float slowFall, const btCollisionWorld* collisionWorld,
std::map<MWWorld::Ptr, MWWorld::Ptr>& standingCollisionTracker) std::map<MWWorld::Ptr, MWWorld::Ptr>& standingCollisionTracker)
{ {
const ESM::Position& refpos = ptr.getRefData().getPosition(); ESM::Position refpos = ptr.getRefData().getPosition();
// Early-out for totally static creatures // Early-out for totally static creatures
// (Not sure if gravity should still apply?) // (Not sure if gravity should still apply?)
if (!ptr.getClass().isMobile(ptr)) if (!ptr.getClass().isMobile(ptr))
return position; return position;
const bool isPlayer = (ptr == MWMechanics::getPlayer());
auto* world = MWBase::Environment::get().getWorld();
// In VR, player should move according to current direction of
// a selected limb, rather than current orientation of camera.
#ifdef USE_OPENXR
if (isPlayer)
{
auto* session = MWVR::Environment::get().getSession();
if (session)
{
float pitch = 0.f;
float yaw = 0.f;
session->movementAngles(yaw, pitch);
refpos.rot[0] += pitch;
refpos.rot[2] += yaw;
}
}
#endif
// Reset per-frame data // Reset per-frame data
physicActor->setWalkingOnWater(false); physicActor->setWalkingOnWater(false);
// Anything to collide with? // Anything to collide with?
@ -107,7 +133,7 @@ namespace MWPhysics
// While this is strictly speaking wrong, it's needed for MW compatibility. // While this is strictly speaking wrong, it's needed for MW compatibility.
position.z() += halfExtents.z(); position.z() += halfExtents.z();
static const float fSwimHeightScale = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat(); static const float fSwimHeightScale = world->getStore().get<ESM::GameSetting>().find("fSwimHeightScale")->mValue.getFloat();
float swimlevel = waterlevel + halfExtents.z() - (physicActor->getRenderingHalfExtents().z() * 2 * fSwimHeightScale); float swimlevel = waterlevel + halfExtents.z() - (physicActor->getRenderingHalfExtents().z() * 2 * fSwimHeightScale);
ActorTracer tracer; ActorTracer tracer;
@ -136,18 +162,17 @@ namespace MWPhysics
if (ptr.getClass().getMovementSettings(ptr).mPosition[2]) if (ptr.getClass().getMovementSettings(ptr).mPosition[2])
{ {
const bool isPlayer = (ptr == MWMechanics::getPlayer());
// Advance acrobatics and set flag for GetPCJumping // Advance acrobatics and set flag for GetPCJumping
if (isPlayer) if (isPlayer)
{ {
ptr.getClass().skillUsageSucceeded(ptr, ESM::Skill::Acrobatics, 0); ptr.getClass().skillUsageSucceeded(ptr, ESM::Skill::Acrobatics, 0);
MWBase::Environment::get().getWorld()->getPlayer().setJumping(true); world->getPlayer().setJumping(true);
} }
// Decrease fatigue // Decrease fatigue
if (!isPlayer || !MWBase::Environment::get().getWorld()->getGodModeState()) if (!isPlayer || !world->getGodModeState())
{ {
const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); const MWWorld::Store<ESM::GameSetting> &gmst = world->getStore().get<ESM::GameSetting>();
const float fFatigueJumpBase = gmst.find("fFatigueJumpBase")->mValue.getFloat(); const float fFatigueJumpBase = gmst.find("fFatigueJumpBase")->mValue.getFloat();
const float fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat(); const float fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat();
const float normalizedEncumbrance = std::min(1.f, ptr.getClass().getNormalizedEncumbrance(ptr)); const float normalizedEncumbrance = std::min(1.f, ptr.getClass().getNormalizedEncumbrance(ptr));
@ -160,17 +185,91 @@ namespace MWPhysics
} }
// Now that we have the effective movement vector, apply wind forces to it // Now that we have the effective movement vector, apply wind forces to it
if (MWBase::Environment::get().getWorld()->isInStorm()) if (world->isInStorm())
{ {
osg::Vec3f stormDirection = MWBase::Environment::get().getWorld()->getStormDirection(); osg::Vec3f stormDirection = world->getStormDirection();
float angleDegrees = osg::RadiansToDegrees(std::acos(stormDirection * velocity / (stormDirection.length() * velocity.length()))); float angleDegrees = osg::RadiansToDegrees(std::acos(stormDirection * velocity / (stormDirection.length() * velocity.length())));
static const float fStromWalkMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fStromWalkMult")->mValue.getFloat(); static const float fStromWalkMult = world->getStore().get<ESM::GameSetting>().find("fStromWalkMult")->mValue.getFloat();
velocity *= 1.f-(fStromWalkMult * (angleDegrees/180.f)); velocity *= 1.f-(fStromWalkMult * (angleDegrees/180.f));
} }
Stepper stepper(collisionWorld, colobj); Stepper stepper(collisionWorld, colobj);
osg::Vec3f origVelocity = velocity; osg::Vec3f origVelocity = velocity;
osg::Vec3f newPosition = position; osg::Vec3f newPosition = position;
#ifdef USE_OPENXR
// TODO: For now this is just a (partial) duplication of the loop below
// Could/should probably be refactored into its own function.
if (isPlayer && !world->getPlayer().isDisabled())
{
auto* inputManager = MWVR::Environment::get().getInputManager();
osg::Vec3 trackingOffset = inputManager->mHeadOffset;
// Player's tracking height should not affect character position
trackingOffset.z() = 0;
float remainingTime = time;
float remainder = 1.f;
for (int iterations = 0; iterations < sMaxIterations && remainingTime > 0.01f && remainder > 0.01; ++iterations)
{
osg::Vec3 toMove = trackingOffset * remainder;
osg::Vec3 nextpos = newPosition + toMove;
if ((newPosition - nextpos).length2() > 0.0001)
{
// trace to where character would go if there were no obstructions
tracer.doTrace(colobj, newPosition, nextpos, collisionWorld);
// check for obstructions
if (tracer.mFraction >= 1.0f)
{
newPosition = tracer.mEndPos; // ok to move, so set newPosition
remainder = 0.f;
break;
}
}
else
{
// The current position and next position are nearly the same, so just exit.
// Note: Bullet can trigger an assert in debug modes if the positions
// are the same, since that causes it to attempt to normalize a zero
// length vector (which can also happen with nearly identical vectors, since
// precision can be lost due to any math Bullet does internally). Since we
// aren't performing any collision detection, we want to reject the next
// position, so that we don't slowly move inside another object.
remainder = 0.f;
break;
}
// We are touching something.
if (tracer.mFraction < 1E-9f)
{
// Try to separate by backing off slighly to unstuck the solver
osg::Vec3f backOff = (newPosition - tracer.mHitPoint) * 1E-2f;
newPosition += backOff;
}
// We hit something. Check if we can step up.
float hitHeight = tracer.mHitPoint.z() - tracer.mEndPos.z() + halfExtents.z();
osg::Vec3f oldPosition = newPosition;
bool result = false;
if (hitHeight < sStepSizeUp && !isActor(tracer.mHitObject))
{
// Try to step up onto it.
// NOTE: stepMove does not allow stepping over, modifies newPosition if successful
result = stepper.step(newPosition, toMove, remainingTime);
remainder = remainingTime / time;
}
}
// Try not to lose any tracking
osg::Vec3 moved = newPosition - position;
inputManager->mHeadOffset.x() -= moved.x();
inputManager->mHeadOffset.y() -= moved.y();
}
#endif
/* /*
* A loop to find newPosition using tracer, if successful different from the starting position. * A loop to find newPosition using tracer, if successful different from the starting position.
* nextpos is the local variable used to find potential newPosition, using velocity and remainingTime * nextpos is the local variable used to find potential newPosition, using velocity and remainingTime

View file

@ -907,10 +907,10 @@ namespace MWRender
const bool isPlayer = (mPtr == MWMechanics::getPlayer()); const bool isPlayer = (mPtr == MWMechanics::getPlayer());
if (isPlayer) //if (isPlayer)
{ //{
Log(Debug::Verbose) << "groupname=" << groupname << ", start=" << start << ", stop=" << stop << ", accumRoot=" << mAccumRoot->getName(); // Log(Debug::Verbose) << "groupname=" << groupname << ", start=" << start << ", stop=" << stop << ", accumRoot=" << mAccumRoot->getName();
} //}
AnimStateMap::iterator stateiter = mStates.begin(); AnimStateMap::iterator stateiter = mStates.begin();
while(stateiter != mStates.end()) while(stateiter != mStates.end())

View file

@ -73,6 +73,7 @@
#ifdef USE_OPENXR #ifdef USE_OPENXR
#include "../mwvr/vranimation.hpp" #include "../mwvr/vranimation.hpp"
#include "../mwvr/openxrviewer.hpp"
#include "../mwvr/vrenvironment.hpp" #include "../mwvr/vrenvironment.hpp"
#endif #endif
@ -760,10 +761,12 @@ namespace MWRender
NotifyDrawCompletedCallback(unsigned int frame) NotifyDrawCompletedCallback(unsigned int frame)
: mDone(false), mFrame(frame) : mDone(false), mFrame(frame)
{ {
Log(Debug::Verbose) << "NotifyDrawCompletedCallback: " << mFrame;
} }
virtual void operator () (osg::RenderInfo& renderInfo) const virtual void operator () (osg::RenderInfo& renderInfo) const
{ {
Log(Debug::Verbose) << "NotifyDrawCompletedCallback: " << renderInfo.getState()->getFrameStamp()->getFrameNumber() << " >= " << mFrame;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
if (renderInfo.getState()->getFrameStamp()->getFrameNumber() >= mFrame) if (renderInfo.getState()->getFrameStamp()->getFrameNumber() >= mFrame)
{ {
@ -1010,12 +1013,18 @@ namespace MWRender
void RenderingManager::screenshotFramebuffer(osg::Image* image, int w, int h) void RenderingManager::screenshotFramebuffer(osg::Image* image, int w, int h)
{ {
osg::Camera* camera = mViewer->getCamera(); osg::Camera* camera = mViewer->getCamera();
#ifdef USE_OPENXR
// In VR mode, the main camera is disabled.
auto& slave = mViewer->getSlave(1);
camera = slave._camera;
#endif
osg::ref_ptr<osg::Drawable> tempDrw = new osg::Drawable; osg::ref_ptr<osg::Drawable> tempDrw = new osg::Drawable;
tempDrw->setDrawCallback(new ReadImageFromFramebufferCallback(image, w, h)); tempDrw->setDrawCallback(new ReadImageFromFramebufferCallback(image, w, h));
tempDrw->setCullingActive(false); tempDrw->setCullingActive(false);
tempDrw->getOrCreateStateSet()->setRenderBinDetails(100, "RenderBin", osg::StateSet::USE_RENDERBIN_DETAILS); // so its after all scene bins but before POST_RENDER gui camera tempDrw->getOrCreateStateSet()->setRenderBinDetails(100, "RenderBin", osg::StateSet::USE_RENDERBIN_DETAILS); // so its after all scene bins but before POST_RENDER gui camera
camera->addChild(tempDrw); camera->addChild(tempDrw);
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback(mViewer->getFrameStamp()->getFrameNumber())); osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback(mViewer->getFrameStamp()->getFrameNumber()));
auto* oldCb = camera->getFinalDrawCallback();
camera->setFinalDrawCallback(callback); camera->setFinalDrawCallback(callback);
mViewer->eventTraversal(); mViewer->eventTraversal();
mViewer->updateTraversal(); mViewer->updateTraversal();
@ -1024,7 +1033,7 @@ namespace MWRender
// now that we've "used up" the current frame, get a fresh frame number for the next frame() following after the screenshot is completed // now that we've "used up" the current frame, get a fresh frame number for the next frame() following after the screenshot is completed
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime()); mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
camera->removeChild(tempDrw); camera->removeChild(tempDrw);
camera->setFinalDrawCallback(nullptr); camera->setFinalDrawCallback(oldCb);
} }
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform) void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
@ -1535,11 +1544,6 @@ namespace MWRender
mNavMeshNumber = value; mNavMeshNumber = value;
} }
void RenderingManager::toggleWaterRTT(bool enable)
{
mWater->toggleRTT(enable);
}
void RenderingManager::updateNavMesh() void RenderingManager::updateNavMesh()
{ {
if (!mNavMesh->isEnabled()) if (!mNavMesh->isEnabled())

View file

@ -244,8 +244,6 @@ namespace MWRender
void setNavMeshNumber(const std::size_t value); void setNavMeshNumber(const std::size_t value);
void toggleWaterRTT(bool enable);
private: private:
void updateProjectionMatrix(); void updateProjectionMatrix();
void updateTextureFiltering(); void updateTextureFiltering();

View file

@ -29,6 +29,11 @@
#include "../mwgui/itemmodel.hpp" #include "../mwgui/itemmodel.hpp"
#include "../mwgui/draganddrop.hpp" #include "../mwgui/draganddrop.hpp"
#include "../mwinput/actionmanager.hpp"
#include "../mwinput/bindingsmanager.hpp"
#include "../mwinput/controlswitch.hpp"
#include "../mwinput/mousemanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
@ -40,6 +45,8 @@
#include <openxr/openxr.h> #include <openxr/openxr.h>
#include <extern/oics/ICSInputControlSystem.h>
#include <osg/Camera> #include <osg/Camera>
#include <vector> #include <vector>
@ -275,7 +282,7 @@ public:
struct OpenXRInput struct OpenXRInput
{ {
using Actions = MWInput::InputManager::Actions; using Actions = MWInput::Actions;
// The OpenMW input manager iterates from 0 to A_Last in its actions enum. // The OpenMW input manager iterates from 0 to A_Last in its actions enum.
// I don't know that it would cause any ill effects, but i nonetheless do not // I don't know that it would cause any ill effects, but i nonetheless do not
@ -283,7 +290,7 @@ struct OpenXRInput
// Therefore i add them here to a separate enum whose values start past A_Last. // Therefore i add them here to a separate enum whose values start past A_Last.
enum XrActions enum XrActions
{ {
A_XrFirst = MWInput::InputManager::A_Last, A_XrFirst = MWInput::A_Last,
A_ActivateTouch, A_ActivateTouch,
A_RepositionMenu, A_RepositionMenu,
A_XrLast A_XrLast
@ -542,31 +549,31 @@ OpenXRInput::OpenXRInput()
, mAPath(generateControllerActionPaths("/input/a/click")) , mAPath(generateControllerActionPaths("/input/a/click"))
, 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::InputManager::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_RepositionMenu, "reposition_menu", "Reposition Menu", { })))
, mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Inventory, "inventory", "Inventory", { }))) , mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::A_Inventory, "inventory", "Inventory", { })))
, mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Activate, "activate", "Activate", { }))) , mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::A_Activate, "activate", "Activate", { })))
, mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::InputManager::A_Use, "use", "Use", { }))) , mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Use, "use", "Use", { })))
, mJump(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Jump, "jump", "Jump", { }))) , mJump(std::move(createMWAction<ButtonPressAction>(MWInput::A_Jump, "jump", "Jump", { })))
, mToggleWeapon(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_ToggleWeapon, "weapon", "Weapon", { }))) , mToggleWeapon(std::move(createMWAction<ButtonPressAction>(MWInput::A_ToggleWeapon, "weapon", "Weapon", { })))
, mToggleSpell(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_ToggleSpell, "spell", "Spell", { }))) , mToggleSpell(std::move(createMWAction<ButtonPressAction>(MWInput::A_ToggleSpell, "spell", "Spell", { })))
, mCycleSpellLeft(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleSpellLeft, "cycle_spell_left", "Cycle Spell Left", { }))) , mCycleSpellLeft(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleSpellLeft, "cycle_spell_left", "Cycle Spell Left", { })))
, mCycleSpellRight(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleSpellRight, "cycle_spell_right", "Cycle Spell Right", { }))) , mCycleSpellRight(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleSpellRight, "cycle_spell_right", "Cycle Spell Right", { })))
, mCycleWeaponLeft(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleWeaponLeft, "cycle_weapon_left", "Cycle Weapon Left", { }))) , mCycleWeaponLeft(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleWeaponLeft, "cycle_weapon_left", "Cycle Weapon Left", { })))
, mCycleWeaponRight(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleWeaponRight, "cycle_weapon_right", "Cycle Weapon Right", { }))) , mCycleWeaponRight(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleWeaponRight, "cycle_weapon_right", "Cycle Weapon Right", { })))
, mSneak(std::move(createMWAction<ButtonHoldAction>(MWInput::InputManager::A_Sneak, "sneak", "Sneak", { }))) , mSneak(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Sneak, "sneak", "Sneak", { })))
, mQuickMenu(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_QuickMenu, "quick_menu", "Quick Menu", { }))) , mQuickMenu(std::move(createMWAction<ButtonPressAction>(MWInput::A_QuickMenu, "quick_menu", "Quick Menu", { })))
, mLookLeftRight(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_LookLeftRight, "look_left_right", "Look Left Right", { }))) , mLookLeftRight(std::move(createMWAction<AxisAction>(MWInput::A_LookLeftRight, "look_left_right", "Look Left Right", { })))
, mMoveForwardBackward(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_MoveForwardBackward, "move_forward_backward", "Move Forward Backward", { }))) , mMoveForwardBackward(std::move(createMWAction<AxisAction>(MWInput::A_MoveForwardBackward, "move_forward_backward", "Move Forward Backward", { })))
, mMoveLeftRight(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_MoveLeftRight, "move_left_right", "Move Left Right", { }))) , mMoveLeftRight(std::move(createMWAction<AxisAction>(MWInput::A_MoveLeftRight, "move_left_right", "Move Left Right", { })))
, mJournal(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_Journal, "journal_book", "Journal Book", { }))) , mJournal(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_Journal, "journal_book", "Journal Book", { })))
, mQuickSave(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_QuickSave, "quick_save", "Quick Save", { }))) , mQuickSave(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_QuickSave, "quick_save", "Quick Save", { })))
, mRest(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_Rest, "rest", "Rest", { }))) , mRest(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_Rest, "rest", "Rest", { })))
, mActivateTouch(std::move(createMWAction<AxisAction>(A_ActivateTouch, "activate_touched", "Activate Touch", { RIGHT_HAND }))) , mActivateTouch(std::move(createMWAction<AxisAction>(A_ActivateTouch, "activate_touched", "Activate Touch", { RIGHT_HAND })))
, mAlwaysRun(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_AlwaysRun, "always_run", "Always Run", { }))) , mAlwaysRun(std::move(createMWAction<ButtonPressAction>(MWInput::A_AlwaysRun, "always_run", "Always Run", { })))
, mAutoMove(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_AutoMove, "auto_move", "Auto Move", { }))) , mAutoMove(std::move(createMWAction<ButtonPressAction>(MWInput::A_AutoMove, "auto_move", "Auto Move", { })))
, mToggleHUD(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_ToggleHUD, "toggle_hud", "Toggle HUD", { }))) , mToggleHUD(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_ToggleHUD, "toggle_hud", "Toggle HUD", { })))
, mToggleDebug(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_ToggleDebug, "toggle_debug", "Toggle DEBUG", { }))) , mToggleDebug(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_ToggleDebug, "toggle_debug", "Toggle DEBUG", { })))
, mHandPoseAction(std::move(createXRAction(XR_ACTION_TYPE_POSE_INPUT, "hand_pose", "Hand Pose", { LEFT_HAND, RIGHT_HAND }))) , mHandPoseAction(std::move(createXRAction(XR_ACTION_TYPE_POSE_INPUT, "hand_pose", "Hand Pose", { LEFT_HAND, RIGHT_HAND })))
, mHapticsAction(std::move(createXRAction(XR_ACTION_TYPE_VIBRATION_OUTPUT, "vibrate_hand", "Vibrate Hand", { LEFT_HAND, RIGHT_HAND }))) , mHapticsAction(std::move(createXRAction(XR_ACTION_TYPE_VIBRATION_OUTPUT, "vibrate_hand", "Vibrate Hand", { LEFT_HAND, RIGHT_HAND })))
{ {
@ -874,17 +881,10 @@ void OpenXRInputManager::updateActivationIndication(void)
{ {
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
bool show = guiMode | mActivationIndication; bool show = guiMode | mActivationIndication;
if (mPlayer) auto* playerAnimation = Environment::get().getPlayerAnimation();
{ if (playerAnimation)
if (show != mPlayer->getPointing()) if (show != playerAnimation->isPointingForward())
{ playerAnimation->setPointForward(show);
mPlayer->setPointing(show);
auto* playerAnimation = Environment::get().getPlayerAnimation();
if (playerAnimation)
playerAnimation->setPointForward(show);
}
}
} }
@ -952,10 +952,8 @@ private:
} }
else if (!ptr.isEmpty()) else if (!ptr.isEmpty())
{ {
if (mPlayer) MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
{ player.activate(ptr);
mPlayer->activate(ptr);
}
} }
} }
} }
@ -964,9 +962,17 @@ private:
{ {
SDL_MouseButtonEvent arg; SDL_MouseButtonEvent arg;
if (onPress) if (onPress)
mousePressed(arg, sdlButton); mMouseManager->mousePressed(arg, sdlButton);
else else
mouseReleased(arg, sdlButton); mMouseManager->mouseReleased(arg, sdlButton);
}
void OpenXRInputManager::injectChannelValue(
MWInput::Actions action,
float value)
{
auto channel = mBindingsManager->ics().getChannel(MWInput::A_MoveLeftRight);// ->setValue(value);
channel->setEnabled(true);
} }
// TODO: Configurable haptics: on/off + max intensity // TODO: Configurable haptics: on/off + max intensity
@ -1002,9 +1008,8 @@ private:
grab) grab)
, mXRInput(new OpenXRInput()) , mXRInput(new OpenXRInput())
{ {
// VR mode has no concept of these // VR mode should never go vanity mode.
mControlSwitch["vanitymode"] = false; //mControlSwitch->set("vanitymode", false);
//mGuiCursorEnabled = false;
} }
OpenXRInputManager::~OpenXRInputManager() OpenXRInputManager::~OpenXRInputManager()
@ -1027,13 +1032,17 @@ private:
{ {
mXRInput->updateControls(); mXRInput->updateControls();
// Annoyingly, this is called at least once before the World object has been instantiated.
auto* world = MWBase::Environment::get().getWorld();
if (!world)
return;
auto* vrGuiManager = Environment::get().getGUIManager(); auto* vrGuiManager = Environment::get().getGUIManager();
bool vrHasFocus = vrGuiManager->updateFocus(); bool vrHasFocus = vrGuiManager->updateFocus();
auto guiCursor = vrGuiManager->guiCursor(); auto guiCursor = vrGuiManager->guiCursor();
if (vrHasFocus) if (vrHasFocus)
{ {
mGuiCursorX = guiCursor.x(); mMouseManager->setMousePosition(guiCursor.x(), guiCursor.y());
mGuiCursorY = guiCursor.y();
} }
while (auto* action = mXRInput->nextAction()) while (auto* action = mXRInput->nextAction())
@ -1047,16 +1056,16 @@ private:
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode(); bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
setPlayerControlsEnabled(!guiMode); // OpenMW assumes all input will come via SDL which i often violate.
// This keeps player controls correctly enabled for my purposes.
mBindingsManager->setPlayerControlsEnabled(!guiMode);
if (mPlayer) auto& player = world->getPlayer();
{ auto playerPtr = player.getPlayer();
auto player = mPlayer->getPlayer(); if (!mRealisticCombat || mRealisticCombat->ptr != playerPtr)
if (!mRealisticCombat || mRealisticCombat->ptr != player) mRealisticCombat.reset(new RealisticCombat::StateMachine(playerPtr));
mRealisticCombat.reset(new RealisticCombat::StateMachine(player)); bool enabled = !guiMode && player.getDrawState() == MWMechanics::DrawState_Weapon && !player.isDisabled();
bool enabled = !guiMode && mPlayer->getDrawState() == MWMechanics::DrawState_Weapon && !mPlayer->isDisabled(); mRealisticCombat->update(dt, enabled);
mRealisticCombat->update(dt, enabled);
};
updateHead(); updateHead();
@ -1070,7 +1079,7 @@ private:
void OpenXRInputManager::processAction(const Action* action) void OpenXRInputManager::processAction(const Action* action)
{ {
//auto* session = Environment::get().getSession(); static const bool isToggleSneak = Settings::Manager::getBool("toggle sneak", "Input");
auto* xrGUIManager = Environment::get().getGUIManager(); auto* xrGUIManager = Environment::get().getGUIManager();
// Hold actions // Hold actions
@ -1080,22 +1089,24 @@ private:
resetIdleTime(); resetIdleTime();
mActivationIndication = action->isActive(); mActivationIndication = action->isActive();
break; break;
case A_LookLeftRight: case MWInput::A_LookLeftRight:
mYaw += osg::DegreesToRadians(action->value()) * 2.f; mYaw += osg::DegreesToRadians(action->value()) * 2.f;
break; break;
case A_MoveLeftRight: case MWInput::A_MoveLeftRight:
mInputBinder->getChannel(A_MoveLeftRight)->setValue(action->value() / 2.f + 0.5f); mBindingsManager->ics().getChannel(MWInput::A_MoveLeftRight)->setValue(action->value() / 2.f + 0.5f);
break; break;
case A_MoveForwardBackward: case MWInput::A_MoveForwardBackward:
mInputBinder->getChannel(A_MoveForwardBackward)->setValue(-action->value() / 2.f + 0.5f); mBindingsManager->ics().getChannel(MWInput::A_MoveForwardBackward)->setValue(-action->value() / 2.f + 0.5f);
break; break;
case A_Sneak: case MWInput::A_Sneak:
if(!mSneakToggles) {
mInputBinder->getChannel(A_Sneak)->setValue(action->isActive() ? 1.f : 0.f); if (!isToggleSneak)
mBindingsManager->ics().getChannel(MWInput::A_Sneak)->setValue(action->isActive() ? 1.f : 0.f);
break; break;
case A_Use: }
case MWInput::A_Use:
if (!(mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())) if (!(mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode()))
mInputBinder->getChannel(A_Use)->setValue(action->value()); mBindingsManager->ics().getChannel(MWInput::A_Use)->setValue(action->value());
break; break;
default: default:
break; break;
@ -1106,106 +1117,107 @@ private:
{ {
switch (action->openMWActionCode()) switch (action->openMWActionCode())
{ {
case A_GameMenu: case MWInput::A_GameMenu:
toggleMainMenu(); mActionManager->toggleMainMenu();
break; break;
case A_Screenshot: case MWInput::A_Screenshot:
screenshot(); mActionManager->screenshot();
break; break;
case A_Inventory: case MWInput::A_Inventory:
toggleInventory(); //mActionManager->toggleInventory();
injectMousePress(SDL_BUTTON_RIGHT, true);
break; break;
case A_Console: case MWInput::A_Console:
toggleConsole(); mActionManager->toggleConsole();
break; break;
case A_Journal: case MWInput::A_Journal:
toggleJournal(); mActionManager->toggleJournal();
break; break;
case A_AutoMove: case MWInput::A_AutoMove:
toggleAutoMove(); mActionManager->toggleAutoMove();
break; break;
case A_AlwaysRun: case MWInput::A_AlwaysRun:
toggleWalking(); mActionManager->toggleWalking();
break; break;
case A_ToggleWeapon: case MWInput::A_ToggleWeapon:
toggleWeapon(); mActionManager->toggleWeapon();
break; break;
case A_Rest: case MWInput::A_Rest:
rest(); mActionManager->rest();
break; break;
case A_ToggleSpell: case MWInput::A_ToggleSpell:
toggleSpell(); mActionManager->toggleSpell();
break; break;
case A_QuickKey1: case MWInput::A_QuickKey1:
quickKey(1); mActionManager->quickKey(1);
break; break;
case A_QuickKey2: case MWInput::A_QuickKey2:
quickKey(2); mActionManager->quickKey(2);
break; break;
case A_QuickKey3: case MWInput::A_QuickKey3:
quickKey(3); mActionManager->quickKey(3);
break; break;
case A_QuickKey4: case MWInput::A_QuickKey4:
quickKey(4); mActionManager->quickKey(4);
break; break;
case A_QuickKey5: case MWInput::A_QuickKey5:
quickKey(5); mActionManager->quickKey(5);
break; break;
case A_QuickKey6: case MWInput::A_QuickKey6:
quickKey(6); mActionManager->quickKey(6);
break; break;
case A_QuickKey7: case MWInput::A_QuickKey7:
quickKey(7); mActionManager->quickKey(7);
break; break;
case A_QuickKey8: case MWInput::A_QuickKey8:
quickKey(8); mActionManager->quickKey(8);
break; break;
case A_QuickKey9: case MWInput::A_QuickKey9:
quickKey(9); mActionManager->quickKey(9);
break; break;
case A_QuickKey10: case MWInput::A_QuickKey10:
quickKey(10); mActionManager->quickKey(10);
break; break;
case A_QuickKeysMenu: case MWInput::A_QuickKeysMenu:
showQuickKeysMenu(); mActionManager->showQuickKeysMenu();
break; break;
case A_ToggleHUD: case MWInput::A_ToggleHUD:
Log(Debug::Verbose) << "Toggle HUD"; Log(Debug::Verbose) << "Toggle HUD";
MWBase::Environment::get().getWindowManager()->toggleHud(); MWBase::Environment::get().getWindowManager()->toggleHud();
break; break;
case A_ToggleDebug: case MWInput::A_ToggleDebug:
Log(Debug::Verbose) << "Toggle Debug"; Log(Debug::Verbose) << "Toggle Debug";
MWBase::Environment::get().getWindowManager()->toggleDebugWindow(); MWBase::Environment::get().getWindowManager()->toggleDebugWindow();
break; break;
case A_QuickSave: case MWInput::A_QuickSave:
quickSave(); mActionManager->quickSave();
break; break;
case A_QuickLoad: case MWInput::A_QuickLoad:
quickLoad(); mActionManager->quickLoad();
break; break;
case A_CycleSpellLeft: case MWInput::A_CycleSpellLeft:
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic)) if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
MWBase::Environment::get().getWindowManager()->cycleSpell(false); MWBase::Environment::get().getWindowManager()->cycleSpell(false);
break; break;
case A_CycleSpellRight: case MWInput::A_CycleSpellRight:
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic)) if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
MWBase::Environment::get().getWindowManager()->cycleSpell(true); MWBase::Environment::get().getWindowManager()->cycleSpell(true);
break; break;
case A_CycleWeaponLeft: case MWInput::A_CycleWeaponLeft:
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
MWBase::Environment::get().getWindowManager()->cycleWeapon(false); MWBase::Environment::get().getWindowManager()->cycleWeapon(false);
break; break;
case A_CycleWeaponRight: case MWInput::A_CycleWeaponRight:
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
MWBase::Environment::get().getWindowManager()->cycleWeapon(true); MWBase::Environment::get().getWindowManager()->cycleWeapon(true);
break; break;
case A_Jump: case MWInput::A_Jump:
mAttemptJump = true; mActionManager->setAttemptJump(true);
break; break;
case OpenXRInput::A_RepositionMenu: case OpenXRInput::A_RepositionMenu:
xrGUIManager->updateTracking(); xrGUIManager->updateTracking();
break; break;
case A_Use: case MWInput::A_Use:
if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode()) if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())
pointActivation(true); pointActivation(true);
default: default:
@ -1218,15 +1230,17 @@ private:
{ {
switch (action->openMWActionCode()) switch (action->openMWActionCode())
{ {
case A_Use: case MWInput::A_Use:
mInputBinder->getChannel(A_Use)->setValue(0.f); mBindingsManager->ics().getChannel(MWInput::A_Use)->setValue(0.f);
if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode()) if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())
pointActivation(false); pointActivation(false);
break; break;
case A_Sneak: case MWInput::A_Sneak:
if (mSneakToggles) if (isToggleSneak)
toggleSneaking(); mActionManager->toggleSneaking();
break; break;
case MWInput::A_Inventory:
injectMousePress(SDL_BUTTON_RIGHT, false);
default: default:
break; break;
} }
@ -1235,11 +1249,9 @@ private:
void OpenXRInputManager::updateHead() void OpenXRInputManager::updateHead()
{ {
if (!mPlayer)
return;
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
auto player = mPlayer->getPlayer(); auto& player = world->getPlayer();
auto playerPtr = player.getPlayer();
auto* xr = Environment::get().getManager(); auto* xr = Environment::get().getManager();
auto* session = Environment::get().getSession(); auto* session = Environment::get().getSession();
@ -1272,9 +1284,9 @@ private:
mVrAngles[1] = roll; mVrAngles[1] = roll;
mVrAngles[2] = yaw; mVrAngles[2] = yaw;
if (!mPlayer->isDisabled()) if (!player.isDisabled())
{ {
world->rotateObject(player, mVrAngles[0], mVrAngles[1], mVrAngles[2], MWBase::RotationFlag_none); world->rotateObject(playerPtr, mVrAngles[0], mVrAngles[1], mVrAngles[2], MWBase::RotationFlag_none);
} }
else { else {
// Update the camera directly to avoid rotating the disabled player // Update the camera directly to avoid rotating the disabled player

View file

@ -48,6 +48,7 @@ namespace MWVR
void pointActivation(bool onPress); void pointActivation(bool onPress);
void injectMousePress(int sdlButton, bool onPress); void injectMousePress(int sdlButton, bool onPress);
void injectChannelValue(MWInput::Actions action, float value);
void applyHapticsLeftHand(float intensity) override; void applyHapticsLeftHand(float intensity) override;
void applyHapticsRightHand(float intensity) override; void applyHapticsRightHand(float intensity) override;

View file

@ -7,7 +7,6 @@
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/sdlutil/sdlgraphicswindow.hpp> #include <components/sdlutil/sdlgraphicswindow.hpp>
#include <components/sceneutil/vismask.hpp>
// The OpenXR SDK assumes we've included Windows.h // The OpenXR SDK assumes we've included Windows.h
#include <Windows.h> #include <Windows.h>

View file

@ -70,11 +70,6 @@ namespace MWVR {
{ {
auto name = renderInfo.getCurrentCamera()->getName(); auto name = renderInfo.getCurrentCamera()->getName();
mTimer.checkpoint("Postrender"); mTimer.checkpoint("Postrender");
// Water RTT happens before the initial draw callback,
// so i have to disable it in postrender of the first eye, and then re-enable it
auto world = MWBase::Environment::get().getWorld();
if (world)
world->toggleWaterRTT(name == "RightEye");
} }
void OpenXRView::swapBuffers(osg::GraphicsContext* gc) void OpenXRView::swapBuffers(osg::GraphicsContext* gc)

View file

@ -10,8 +10,8 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwrender/vismask.hpp"
#include <components/esm/loadrace.hpp> #include <components/esm/loadrace.hpp>
#include <components/sceneutil/vismask.hpp>
#include <osg/MatrixTransform> #include <osg/MatrixTransform>
namespace MWVR namespace MWVR
@ -80,7 +80,7 @@ namespace MWVR
// Use the main camera to render any GUI to the OpenXR GUI quad's swapchain. // Use the main camera to render any GUI to the OpenXR GUI quad's swapchain.
// (When swapping the window buffer we'll blit the mirror texture to it instead.) // (When swapping the window buffer we'll blit the mirror texture to it instead.)
mainCamera->setCullMask(SceneUtil::Mask_GUI); mainCamera->setCullMask(MWRender::Mask_GUI);
osg::Vec4 clearColor = mainCamera->getClearColor(); osg::Vec4 clearColor = mainCamera->getClearColor();
@ -117,8 +117,8 @@ namespace MWVR
rightCamera->setFinalDrawCallback(mPostDraw); rightCamera->setFinalDrawCallback(mPostDraw);
// Stereo cameras should only draw the scene (AR layers should later add minimap, health, etc.) // Stereo cameras should only draw the scene (AR layers should later add minimap, health, etc.)
leftCamera->setCullMask(~SceneUtil::Mask_GUI); leftCamera->setCullMask(~MWRender::Mask_GUI);
rightCamera->setCullMask(~SceneUtil::Mask_GUI); rightCamera->setCullMask(~MWRender::Mask_GUI);
leftCamera->setName("LeftEye"); leftCamera->setName("LeftEye");
rightCamera->setName("RightEye"); rightCamera->setName("RightEye");
@ -147,13 +147,24 @@ namespace MWVR
mViewer->getSlave(0)._updateSlaveCallback = new OpenXRWorldView::UpdateSlaveCallback(xr, session, leftView, context); mViewer->getSlave(0)._updateSlaveCallback = new OpenXRWorldView::UpdateSlaveCallback(xr, session, leftView, context);
mViewer->getSlave(1)._updateSlaveCallback = new OpenXRWorldView::UpdateSlaveCallback(xr, session, rightView, context); mViewer->getSlave(1)._updateSlaveCallback = new OpenXRWorldView::UpdateSlaveCallback(xr, session, rightView, context);
mainCamera->getGraphicsContext()->setSwapCallback(new OpenXRViewer::SwapBuffersCallback(this)); mMainCameraGC = mainCamera->getGraphicsContext();
mMainCameraGC->setSwapCallback(new OpenXRViewer::SwapBuffersCallback(this));
mainCamera->setGraphicsContext(nullptr); mainCamera->setGraphicsContext(nullptr);
session->setLayer(OpenXRLayerStack::WORLD_VIEW_LAYER, this); session->setLayer(OpenXRLayerStack::WORLD_VIEW_LAYER, this);
mConfigured = true; mConfigured = true;
} }
void OpenXRViewer::enableMainCamera(void)
{
mCameras["MainCamera"]->setGraphicsContext(mMainCameraGC);
}
void OpenXRViewer::disableMainCamera(void)
{
mCameras["MainCamera"]->setGraphicsContext(nullptr);
}
void OpenXRViewer::blitEyesToMirrorTexture(osg::GraphicsContext* gc) void OpenXRViewer::blitEyesToMirrorTexture(osg::GraphicsContext* gc)
{ {
//includeMenu = false; //includeMenu = false;
@ -174,6 +185,7 @@ namespace MWVR
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
mMirrorTextureSwapchain->renderBuffer()->blit(gc, 0, 0, mMirrorTextureSwapchain->width(), mMirrorTextureSwapchain->height()); mMirrorTextureSwapchain->renderBuffer()->blit(gc, 0, 0, mMirrorTextureSwapchain->width(), mMirrorTextureSwapchain->height());
} }
void void
@ -186,7 +198,6 @@ namespace MWVR
void OpenXRViewer::swapBuffers(osg::GraphicsContext* gc) void OpenXRViewer::swapBuffers(osg::GraphicsContext* gc)
{ {
if (!mConfigured) if (!mConfigured)
return; return;

View file

@ -86,12 +86,12 @@ namespace MWVR
void blitEyesToMirrorTexture(osg::GraphicsContext* gc); void blitEyesToMirrorTexture(osg::GraphicsContext* gc);
void swapBuffers(osg::GraphicsContext* gc) override; void swapBuffers(osg::GraphicsContext* gc) override;
void realize(osg::GraphicsContext* gc); void realize(osg::GraphicsContext* gc);
bool realized() { return mConfigured; } bool realized() { return mConfigured; }
void updateTransformNode(osg::Object* object, osg::Object* data); void updateTransformNode(osg::Object* object, osg::Object* data);
void enableMainCamera(void);
void disableMainCamera(void);
public: public:
std::unique_ptr<XrCompositionLayerProjection> mLayer = nullptr; std::unique_ptr<XrCompositionLayerProjection> mLayer = nullptr;
@ -100,8 +100,9 @@ namespace MWVR
osg::ref_ptr<osgViewer::Viewer> mViewer = nullptr; osg::ref_ptr<osgViewer::Viewer> mViewer = nullptr;
std::map<std::string, osg::ref_ptr<OpenXRView> > mViews{}; std::map<std::string, osg::ref_ptr<OpenXRView> > mViews{};
std::map<std::string, osg::ref_ptr<osg::Camera> > mCameras{}; std::map<std::string, osg::ref_ptr<osg::Camera> > mCameras{};
PredrawCallback* mPreDraw{ nullptr }; osg::ref_ptr<PredrawCallback> mPreDraw{ nullptr };
PostdrawCallback* mPostDraw{ nullptr }; osg::ref_ptr<PostdrawCallback> mPostDraw{ nullptr };
osg::GraphicsContext* mMainCameraGC{ nullptr };
std::unique_ptr<OpenXRSwapchain> mMirrorTextureSwapchain{ nullptr }; std::unique_ptr<OpenXRSwapchain> mMirrorTextureSwapchain{ nullptr };

View file

@ -6,8 +6,6 @@
#include "openxrinputmanager.hpp" #include "openxrinputmanager.hpp"
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/sdlutil/sdlgraphicswindow.hpp>
#include <components/sceneutil/vismask.hpp>
#include <Windows.h> #include <Windows.h>

View file

@ -24,7 +24,6 @@
#include <components/sceneutil/attach.hpp> #include <components/sceneutil/attach.hpp>
#include <components/sceneutil/clone.hpp> #include <components/sceneutil/clone.hpp>
#include <components/sceneutil/visitor.hpp> #include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/vismask.hpp>
#include <components/sceneutil/skeleton.hpp> #include <components/sceneutil/skeleton.hpp>
#include <components/sceneutil/riggeometry.hpp> #include <components/sceneutil/riggeometry.hpp>
#include <components/sceneutil/positionattitudetransform.hpp> #include <components/sceneutil/positionattitudetransform.hpp>
@ -547,6 +546,8 @@ void VRAnimation::setPointForward(bool enabled)
{ {
mPointerTarget = MWRender::RayResult{}; mPointerTarget = MWRender::RayResult{};
} }
mIsPointingForward = enabled;
} }
osg::ref_ptr<osg::Geometry> VRAnimation::createPointerGeometry(void) osg::ref_ptr<osg::Geometry> VRAnimation::createPointerGeometry(void)
@ -670,12 +671,12 @@ void VRAnimation::addControllers()
mModelOffset->addChild(mObjectRoot); mModelOffset->addChild(mObjectRoot);
} }
auto wb = mNodeMap.find("weapon bone"); //auto wb = mNodeMap.find("weapon bone");
if (wb != mNodeMap.end()) //if (wb != mNodeMap.end())
{ //{
wb->second->removeChild(mWeaponPointerTransform); // wb->second->removeChild(mWeaponPointerTransform);
wb->second->addChild(mWeaponPointerTransform); // wb->second->addChild(mWeaponPointerTransform);
} //}
} }
void VRAnimation::enableHeadAnimation(bool) void VRAnimation::enableHeadAnimation(bool)
{ {

View file

@ -54,6 +54,7 @@ public:
/// Overrides finger animations to point forward /// Overrides finger animations to point forward
void setPointForward(bool enabled); void setPointForward(bool enabled);
bool isPointingForward(void) const { return mIsPointingForward; }
bool canPlaceObject(); bool canPlaceObject();
///< @return true if it is possible to place on object where the player is currently pointing ///< @return true if it is possible to place on object where the player is currently pointing
@ -78,6 +79,8 @@ public:
osg::ref_ptr<HandController> mHandControllers[2]; osg::ref_ptr<HandController> mHandControllers[2];
osg::ref_ptr<FingerController> mIndexFingerControllers[2]; osg::ref_ptr<FingerController> mIndexFingerControllers[2];
osg::ref_ptr<osg::MatrixTransform> mModelOffset; osg::ref_ptr<osg::MatrixTransform> mModelOffset;
bool mIsPointingForward{ false };
osg::ref_ptr<osg::Geometry> mPointerGeometry{ nullptr }; osg::ref_ptr<osg::Geometry> mPointerGeometry{ nullptr };
osg::ref_ptr<osg::MatrixTransform> mPointerRescale{ nullptr }; osg::ref_ptr<osg::MatrixTransform> mPointerRescale{ nullptr };
osg::ref_ptr<osg::MatrixTransform> mPointerTransform{ nullptr }; osg::ref_ptr<osg::MatrixTransform> mPointerTransform{ nullptr };

View file

@ -18,6 +18,7 @@
#include "../mwrender/renderbin.hpp" #include "../mwrender/renderbin.hpp"
#include "../mwrender/renderingmanager.hpp" #include "../mwrender/renderingmanager.hpp"
#include "../mwrender/camera.hpp" #include "../mwrender/camera.hpp"
#include "../mwrender/vismask.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -63,8 +64,8 @@ public:
setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
setName("GUICamera"); setName("GUICamera");
setCullMask(SceneUtil::Mask_GUI); setCullMask(MWRender::Mask_GUI);
setNodeMask(SceneUtil::Mask_RenderToTexture); setNodeMask(MWRender::Mask_RenderToTexture);
setViewport(0, 0, width, height); setViewport(0, 0, width, height);
@ -637,7 +638,7 @@ void VRGUIManager::removeWidget(MWGui::Layout* widget)
auto it = mLayers.find(name); auto it = mLayers.find(name);
if (it == mLayers.end()) if (it == mLayers.end())
{ {
Log(Debug::Warning) << "Tried to remove widget from nonexistent layer " << name; //Log(Debug::Warning) << "Tried to remove widget from nonexistent layer " << name;
return; return;
} }
@ -653,7 +654,7 @@ void VRGUIManager::setVisible(MWGui::Layout* widget, bool visible)
auto* layer = widget->mMainWidget->getLayer(); auto* layer = widget->mMainWidget->getLayer();
auto name = layer->getName(); auto name = layer->getName();
Log(Debug::Verbose) << "setVisible (" << name << "): " << visible; //Log(Debug::Verbose) << "setVisible (" << name << "): " << visible;
if (layerBlacklist.find(name) != layerBlacklist.end()) if (layerBlacklist.find(name) != layerBlacklist.end())
{ {
Log(Debug::Verbose) << "Blacklisted"; Log(Debug::Verbose) << "Blacklisted";

View file

@ -279,16 +279,6 @@ namespace MWWorld
return mJumping; return mJumping;
} }
void Player::setPointing(bool pointing)
{
mPointing = pointing;
}
bool Player::getPointing() const
{
return mPointing;
}
bool Player::isInCombat() { bool Player::isInCombat() {
return MWBase::Environment::get().getMechanicsManager()->getActorsFighting(getPlayer()).size() != 0; return MWBase::Environment::get().getMechanicsManager()->getActorsFighting(getPlayer()).size() != 0;
} }

View file

@ -121,9 +121,6 @@ namespace MWWorld
void setJumping(bool jumping); void setJumping(bool jumping);
bool getJumping() const; bool getJumping() const;
void setPointing(bool pointing);
bool getPointing(void) const;
///Checks all nearby actors to see if anyone has an aipackage against you ///Checks all nearby actors to see if anyone has an aipackage against you
bool isInCombat(); bool isInCombat();

View file

@ -4080,11 +4080,6 @@ namespace MWWorld
} }
return ESM::Weapon::Type::None; return ESM::Weapon::Type::None;
} }
void World::toggleWaterRTT(bool enable)
{
mRendering->toggleWaterRTT(enable);
}
bool World::isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const bool World::isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const
{ {

View file

@ -752,8 +752,6 @@ namespace MWWorld
/// @Return ESM::Weapon::Type enum describing the type of weapon currently drawn by the player. /// @Return ESM::Weapon::Type enum describing the type of weapon currently drawn by the player.
int getActiveWeaponType(void) override; int getActiveWeaponType(void) override;
void toggleWaterRTT(bool enable) override;
bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const override; bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const override;
}; };