mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 00:45:31 +00:00
Some cleanup. Fixed problems arising from latest merge (refactoring).
This commit is contained in:
parent
cbbc82f053
commit
288530510d
24 changed files with 346 additions and 213 deletions
|
@ -655,8 +655,6 @@ namespace MWBase
|
|||
virtual int getActiveWeaponType(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;
|
||||
};
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <extern/oics/ICSChannelListener.h>
|
||||
#include <extern/oics/ICSInputControlSystem.h>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -48,6 +50,12 @@ namespace MWInput
|
|||
}
|
||||
};
|
||||
|
||||
ICS::InputControlSystem&
|
||||
BindingsManager::ics()
|
||||
{
|
||||
return *mInputBinder;
|
||||
}
|
||||
|
||||
class BindingsListener :
|
||||
public ICS::ChannelListener,
|
||||
public ICS::DetectingBindingListener
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
#include <components/sdlutil/events.hpp>
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
class InputControlSystem;
|
||||
}
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
class BindingsListener;
|
||||
|
@ -59,6 +64,8 @@ namespace MWInput
|
|||
|
||||
void actionValueChanged(int action, float currentValue, float previousValue);
|
||||
|
||||
ICS::InputControlSystem& ics();
|
||||
|
||||
private:
|
||||
void setupSDLKeyMappings();
|
||||
|
||||
|
|
|
@ -94,15 +94,18 @@ namespace MWInput
|
|||
|
||||
virtual void executeAction(int action);
|
||||
|
||||
private:
|
||||
void applyHapticsLeftHand(float intensity) override {};
|
||||
void applyHapticsRightHand(float intensity) override {};
|
||||
|
||||
protected:
|
||||
void convertMousePosForMyGUI(int& x, int& y);
|
||||
|
||||
void handleGuiArrowKey(int action);
|
||||
|
||||
void updateCursorMode();
|
||||
|
||||
void quickKey(int index);
|
||||
void showQuickKeysMenu();
|
||||
//void quickKey(int index);
|
||||
//void showQuickKeysMenu();
|
||||
|
||||
void loadKeyDefaults(bool force = false);
|
||||
void loadControllerDefaults(bool force = false);
|
||||
|
|
|
@ -224,4 +224,14 @@ namespace MWInput
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,10 @@ namespace MWInput
|
|||
void setMouseLookEnabled(bool enabled) { mMouseLookEnabled = 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:
|
||||
bool mInvertX;
|
||||
bool mInvertY;
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#include "../mwworld/player.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 "collisiontype.hpp"
|
||||
#include "constants.hpp"
|
||||
|
@ -82,12 +88,32 @@ namespace MWPhysics
|
|||
bool isFlying, float waterlevel, float slowFall, const btCollisionWorld* collisionWorld,
|
||||
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
|
||||
// (Not sure if gravity should still apply?)
|
||||
if (!ptr.getClass().isMobile(ptr))
|
||||
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
|
||||
physicActor->setWalkingOnWater(false);
|
||||
// Anything to collide with?
|
||||
|
@ -107,7 +133,7 @@ namespace MWPhysics
|
|||
// While this is strictly speaking wrong, it's needed for MW compatibility.
|
||||
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);
|
||||
|
||||
ActorTracer tracer;
|
||||
|
@ -136,18 +162,17 @@ namespace MWPhysics
|
|||
|
||||
if (ptr.getClass().getMovementSettings(ptr).mPosition[2])
|
||||
{
|
||||
const bool isPlayer = (ptr == MWMechanics::getPlayer());
|
||||
// Advance acrobatics and set flag for GetPCJumping
|
||||
if (isPlayer)
|
||||
{
|
||||
ptr.getClass().skillUsageSucceeded(ptr, ESM::Skill::Acrobatics, 0);
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setJumping(true);
|
||||
world->getPlayer().setJumping(true);
|
||||
}
|
||||
|
||||
// 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 fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat();
|
||||
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
|
||||
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())));
|
||||
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));
|
||||
}
|
||||
|
||||
Stepper stepper(collisionWorld, colobj);
|
||||
osg::Vec3f origVelocity = velocity;
|
||||
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.
|
||||
* nextpos is the local variable used to find potential newPosition, using velocity and remainingTime
|
||||
|
|
|
@ -907,10 +907,10 @@ namespace MWRender
|
|||
|
||||
const bool isPlayer = (mPtr == MWMechanics::getPlayer());
|
||||
|
||||
if (isPlayer)
|
||||
{
|
||||
Log(Debug::Verbose) << "groupname=" << groupname << ", start=" << start << ", stop=" << stop << ", accumRoot=" << mAccumRoot->getName();
|
||||
}
|
||||
//if (isPlayer)
|
||||
//{
|
||||
// Log(Debug::Verbose) << "groupname=" << groupname << ", start=" << start << ", stop=" << stop << ", accumRoot=" << mAccumRoot->getName();
|
||||
//}
|
||||
|
||||
AnimStateMap::iterator stateiter = mStates.begin();
|
||||
while(stateiter != mStates.end())
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
|
||||
#ifdef USE_OPENXR
|
||||
#include "../mwvr/vranimation.hpp"
|
||||
#include "../mwvr/openxrviewer.hpp"
|
||||
#include "../mwvr/vrenvironment.hpp"
|
||||
#endif
|
||||
|
||||
|
@ -760,10 +761,12 @@ namespace MWRender
|
|||
NotifyDrawCompletedCallback(unsigned int frame)
|
||||
: mDone(false), mFrame(frame)
|
||||
{
|
||||
Log(Debug::Verbose) << "NotifyDrawCompletedCallback: " << mFrame;
|
||||
}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
Log(Debug::Verbose) << "NotifyDrawCompletedCallback: " << renderInfo.getState()->getFrameStamp()->getFrameNumber() << " >= " << mFrame;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
|
||||
if (renderInfo.getState()->getFrameStamp()->getFrameNumber() >= mFrame)
|
||||
{
|
||||
|
@ -1010,12 +1013,18 @@ namespace MWRender
|
|||
void RenderingManager::screenshotFramebuffer(osg::Image* image, int w, int h)
|
||||
{
|
||||
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;
|
||||
tempDrw->setDrawCallback(new ReadImageFromFramebufferCallback(image, w, h));
|
||||
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
|
||||
camera->addChild(tempDrw);
|
||||
osg::ref_ptr<NotifyDrawCompletedCallback> callback (new NotifyDrawCompletedCallback(mViewer->getFrameStamp()->getFrameNumber()));
|
||||
auto* oldCb = camera->getFinalDrawCallback();
|
||||
camera->setFinalDrawCallback(callback);
|
||||
mViewer->eventTraversal();
|
||||
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
|
||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||
camera->removeChild(tempDrw);
|
||||
camera->setFinalDrawCallback(nullptr);
|
||||
camera->setFinalDrawCallback(oldCb);
|
||||
}
|
||||
|
||||
void RenderingManager::screenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
|
||||
|
@ -1535,11 +1544,6 @@ namespace MWRender
|
|||
mNavMeshNumber = value;
|
||||
}
|
||||
|
||||
void RenderingManager::toggleWaterRTT(bool enable)
|
||||
{
|
||||
mWater->toggleRTT(enable);
|
||||
}
|
||||
|
||||
void RenderingManager::updateNavMesh()
|
||||
{
|
||||
if (!mNavMesh->isEnabled())
|
||||
|
|
|
@ -244,8 +244,6 @@ namespace MWRender
|
|||
|
||||
void setNavMeshNumber(const std::size_t value);
|
||||
|
||||
void toggleWaterRTT(bool enable);
|
||||
|
||||
private:
|
||||
void updateProjectionMatrix();
|
||||
void updateTextureFiltering();
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
#include "../mwgui/itemmodel.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/class.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
@ -40,6 +45,8 @@
|
|||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include <extern/oics/ICSInputControlSystem.h>
|
||||
|
||||
#include <osg/Camera>
|
||||
|
||||
#include <vector>
|
||||
|
@ -275,7 +282,7 @@ public:
|
|||
|
||||
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.
|
||||
// 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.
|
||||
enum XrActions
|
||||
{
|
||||
A_XrFirst = MWInput::InputManager::A_Last,
|
||||
A_XrFirst = MWInput::A_Last,
|
||||
A_ActivateTouch,
|
||||
A_RepositionMenu,
|
||||
A_XrLast
|
||||
|
@ -542,31 +549,31 @@ OpenXRInput::OpenXRInput()
|
|||
, mAPath(generateControllerActionPaths("/input/a/click"))
|
||||
, mBPath(generateControllerActionPaths("/input/b/click"))
|
||||
, 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", { })))
|
||||
, mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Inventory, "inventory", "Inventory", { })))
|
||||
, mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Activate, "activate", "Activate", { })))
|
||||
, mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::InputManager::A_Use, "use", "Use", { })))
|
||||
, mJump(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_Jump, "jump", "Jump", { })))
|
||||
, mToggleWeapon(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_ToggleWeapon, "weapon", "Weapon", { })))
|
||||
, mToggleSpell(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_ToggleSpell, "spell", "Spell", { })))
|
||||
, mCycleSpellLeft(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleSpellLeft, "cycle_spell_left", "Cycle Spell Left", { })))
|
||||
, mCycleSpellRight(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleSpellRight, "cycle_spell_right", "Cycle Spell Right", { })))
|
||||
, mCycleWeaponLeft(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleWeaponLeft, "cycle_weapon_left", "Cycle Weapon Left", { })))
|
||||
, mCycleWeaponRight(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_CycleWeaponRight, "cycle_weapon_right", "Cycle Weapon Right", { })))
|
||||
, mSneak(std::move(createMWAction<ButtonHoldAction>(MWInput::InputManager::A_Sneak, "sneak", "Sneak", { })))
|
||||
, mQuickMenu(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_QuickMenu, "quick_menu", "Quick Menu", { })))
|
||||
, mLookLeftRight(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_LookLeftRight, "look_left_right", "Look Left Right", { })))
|
||||
, mMoveForwardBackward(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_MoveForwardBackward, "move_forward_backward", "Move Forward Backward", { })))
|
||||
, mMoveLeftRight(std::move(createMWAction<AxisAction>(MWInput::InputManager::A_MoveLeftRight, "move_left_right", "Move Left Right", { })))
|
||||
, mJournal(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_Journal, "journal_book", "Journal Book", { })))
|
||||
, mQuickSave(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_QuickSave, "quick_save", "Quick Save", { })))
|
||||
, mRest(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_Rest, "rest", "Rest", { })))
|
||||
, mInventory(std::move(createMWAction<ButtonPressAction>(MWInput::A_Inventory, "inventory", "Inventory", { })))
|
||||
, mActivate(std::move(createMWAction<ButtonPressAction>(MWInput::A_Activate, "activate", "Activate", { })))
|
||||
, mUse(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Use, "use", "Use", { })))
|
||||
, mJump(std::move(createMWAction<ButtonPressAction>(MWInput::A_Jump, "jump", "Jump", { })))
|
||||
, mToggleWeapon(std::move(createMWAction<ButtonPressAction>(MWInput::A_ToggleWeapon, "weapon", "Weapon", { })))
|
||||
, mToggleSpell(std::move(createMWAction<ButtonPressAction>(MWInput::A_ToggleSpell, "spell", "Spell", { })))
|
||||
, mCycleSpellLeft(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleSpellLeft, "cycle_spell_left", "Cycle Spell Left", { })))
|
||||
, mCycleSpellRight(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleSpellRight, "cycle_spell_right", "Cycle Spell Right", { })))
|
||||
, mCycleWeaponLeft(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleWeaponLeft, "cycle_weapon_left", "Cycle Weapon Left", { })))
|
||||
, mCycleWeaponRight(std::move(createMWAction<ButtonPressAction>(MWInput::A_CycleWeaponRight, "cycle_weapon_right", "Cycle Weapon Right", { })))
|
||||
, mSneak(std::move(createMWAction<ButtonHoldAction>(MWInput::A_Sneak, "sneak", "Sneak", { })))
|
||||
, mQuickMenu(std::move(createMWAction<ButtonPressAction>(MWInput::A_QuickMenu, "quick_menu", "Quick Menu", { })))
|
||||
, mLookLeftRight(std::move(createMWAction<AxisAction>(MWInput::A_LookLeftRight, "look_left_right", "Look Left Right", { })))
|
||||
, mMoveForwardBackward(std::move(createMWAction<AxisAction>(MWInput::A_MoveForwardBackward, "move_forward_backward", "Move Forward Backward", { })))
|
||||
, mMoveLeftRight(std::move(createMWAction<AxisAction>(MWInput::A_MoveLeftRight, "move_left_right", "Move Left Right", { })))
|
||||
, mJournal(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_Journal, "journal_book", "Journal Book", { })))
|
||||
, mQuickSave(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_QuickSave, "quick_save", "Quick Save", { })))
|
||||
, mRest(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_Rest, "rest", "Rest", { })))
|
||||
, 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", { })))
|
||||
, mAutoMove(std::move(createMWAction<ButtonPressAction>(MWInput::InputManager::A_AutoMove, "auto_move", "Auto Move", { })))
|
||||
, mToggleHUD(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_ToggleHUD, "toggle_hud", "Toggle HUD", { })))
|
||||
, mToggleDebug(std::move(createMWAction<ButtonLongPressAction>(MWInput::InputManager::A_ToggleDebug, "toggle_debug", "Toggle DEBUG", { })))
|
||||
, mAlwaysRun(std::move(createMWAction<ButtonPressAction>(MWInput::A_AlwaysRun, "always_run", "Always Run", { })))
|
||||
, mAutoMove(std::move(createMWAction<ButtonPressAction>(MWInput::A_AutoMove, "auto_move", "Auto Move", { })))
|
||||
, mToggleHUD(std::move(createMWAction<ButtonLongPressAction>(MWInput::A_ToggleHUD, "toggle_hud", "Toggle HUD", { })))
|
||||
, 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 })))
|
||||
, 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 show = guiMode | mActivationIndication;
|
||||
if (mPlayer)
|
||||
{
|
||||
if (show != mPlayer->getPointing())
|
||||
{
|
||||
mPlayer->setPointing(show);
|
||||
|
||||
auto* playerAnimation = Environment::get().getPlayerAnimation();
|
||||
if (playerAnimation)
|
||||
playerAnimation->setPointForward(show);
|
||||
}
|
||||
}
|
||||
auto* playerAnimation = Environment::get().getPlayerAnimation();
|
||||
if (playerAnimation)
|
||||
if (show != playerAnimation->isPointingForward())
|
||||
playerAnimation->setPointForward(show);
|
||||
}
|
||||
|
||||
|
||||
|
@ -952,10 +952,8 @@ private:
|
|||
}
|
||||
else if (!ptr.isEmpty())
|
||||
{
|
||||
if (mPlayer)
|
||||
{
|
||||
mPlayer->activate(ptr);
|
||||
}
|
||||
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
|
||||
player.activate(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -964,9 +962,17 @@ private:
|
|||
{
|
||||
SDL_MouseButtonEvent arg;
|
||||
if (onPress)
|
||||
mousePressed(arg, sdlButton);
|
||||
mMouseManager->mousePressed(arg, sdlButton);
|
||||
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
|
||||
|
@ -1002,9 +1008,8 @@ private:
|
|||
grab)
|
||||
, mXRInput(new OpenXRInput())
|
||||
{
|
||||
// VR mode has no concept of these
|
||||
mControlSwitch["vanitymode"] = false;
|
||||
//mGuiCursorEnabled = false;
|
||||
// VR mode should never go vanity mode.
|
||||
//mControlSwitch->set("vanitymode", false);
|
||||
}
|
||||
|
||||
OpenXRInputManager::~OpenXRInputManager()
|
||||
|
@ -1027,13 +1032,17 @@ private:
|
|||
{
|
||||
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();
|
||||
bool vrHasFocus = vrGuiManager->updateFocus();
|
||||
auto guiCursor = vrGuiManager->guiCursor();
|
||||
if (vrHasFocus)
|
||||
{
|
||||
mGuiCursorX = guiCursor.x();
|
||||
mGuiCursorY = guiCursor.y();
|
||||
mMouseManager->setMousePosition(guiCursor.x(), guiCursor.y());
|
||||
}
|
||||
|
||||
while (auto* action = mXRInput->nextAction())
|
||||
|
@ -1047,16 +1056,16 @@ private:
|
|||
|
||||
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 = mPlayer->getPlayer();
|
||||
if (!mRealisticCombat || mRealisticCombat->ptr != player)
|
||||
mRealisticCombat.reset(new RealisticCombat::StateMachine(player));
|
||||
bool enabled = !guiMode && mPlayer->getDrawState() == MWMechanics::DrawState_Weapon && !mPlayer->isDisabled();
|
||||
mRealisticCombat->update(dt, enabled);
|
||||
};
|
||||
auto& player = world->getPlayer();
|
||||
auto playerPtr = player.getPlayer();
|
||||
if (!mRealisticCombat || mRealisticCombat->ptr != playerPtr)
|
||||
mRealisticCombat.reset(new RealisticCombat::StateMachine(playerPtr));
|
||||
bool enabled = !guiMode && player.getDrawState() == MWMechanics::DrawState_Weapon && !player.isDisabled();
|
||||
mRealisticCombat->update(dt, enabled);
|
||||
|
||||
updateHead();
|
||||
|
||||
|
@ -1070,7 +1079,7 @@ private:
|
|||
|
||||
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();
|
||||
|
||||
// Hold actions
|
||||
|
@ -1080,22 +1089,24 @@ private:
|
|||
resetIdleTime();
|
||||
mActivationIndication = action->isActive();
|
||||
break;
|
||||
case A_LookLeftRight:
|
||||
case MWInput::A_LookLeftRight:
|
||||
mYaw += osg::DegreesToRadians(action->value()) * 2.f;
|
||||
break;
|
||||
case A_MoveLeftRight:
|
||||
mInputBinder->getChannel(A_MoveLeftRight)->setValue(action->value() / 2.f + 0.5f);
|
||||
case MWInput::A_MoveLeftRight:
|
||||
mBindingsManager->ics().getChannel(MWInput::A_MoveLeftRight)->setValue(action->value() / 2.f + 0.5f);
|
||||
break;
|
||||
case A_MoveForwardBackward:
|
||||
mInputBinder->getChannel(A_MoveForwardBackward)->setValue(-action->value() / 2.f + 0.5f);
|
||||
case MWInput::A_MoveForwardBackward:
|
||||
mBindingsManager->ics().getChannel(MWInput::A_MoveForwardBackward)->setValue(-action->value() / 2.f + 0.5f);
|
||||
break;
|
||||
case A_Sneak:
|
||||
if(!mSneakToggles)
|
||||
mInputBinder->getChannel(A_Sneak)->setValue(action->isActive() ? 1.f : 0.f);
|
||||
case MWInput::A_Sneak:
|
||||
{
|
||||
if (!isToggleSneak)
|
||||
mBindingsManager->ics().getChannel(MWInput::A_Sneak)->setValue(action->isActive() ? 1.f : 0.f);
|
||||
break;
|
||||
case A_Use:
|
||||
}
|
||||
case MWInput::A_Use:
|
||||
if (!(mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode()))
|
||||
mInputBinder->getChannel(A_Use)->setValue(action->value());
|
||||
mBindingsManager->ics().getChannel(MWInput::A_Use)->setValue(action->value());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1106,106 +1117,107 @@ private:
|
|||
{
|
||||
switch (action->openMWActionCode())
|
||||
{
|
||||
case A_GameMenu:
|
||||
toggleMainMenu();
|
||||
case MWInput::A_GameMenu:
|
||||
mActionManager->toggleMainMenu();
|
||||
break;
|
||||
case A_Screenshot:
|
||||
screenshot();
|
||||
case MWInput::A_Screenshot:
|
||||
mActionManager->screenshot();
|
||||
break;
|
||||
case A_Inventory:
|
||||
toggleInventory();
|
||||
case MWInput::A_Inventory:
|
||||
//mActionManager->toggleInventory();
|
||||
injectMousePress(SDL_BUTTON_RIGHT, true);
|
||||
break;
|
||||
case A_Console:
|
||||
toggleConsole();
|
||||
case MWInput::A_Console:
|
||||
mActionManager->toggleConsole();
|
||||
break;
|
||||
case A_Journal:
|
||||
toggleJournal();
|
||||
case MWInput::A_Journal:
|
||||
mActionManager->toggleJournal();
|
||||
break;
|
||||
case A_AutoMove:
|
||||
toggleAutoMove();
|
||||
case MWInput::A_AutoMove:
|
||||
mActionManager->toggleAutoMove();
|
||||
break;
|
||||
case A_AlwaysRun:
|
||||
toggleWalking();
|
||||
case MWInput::A_AlwaysRun:
|
||||
mActionManager->toggleWalking();
|
||||
break;
|
||||
case A_ToggleWeapon:
|
||||
toggleWeapon();
|
||||
case MWInput::A_ToggleWeapon:
|
||||
mActionManager->toggleWeapon();
|
||||
break;
|
||||
case A_Rest:
|
||||
rest();
|
||||
case MWInput::A_Rest:
|
||||
mActionManager->rest();
|
||||
break;
|
||||
case A_ToggleSpell:
|
||||
toggleSpell();
|
||||
case MWInput::A_ToggleSpell:
|
||||
mActionManager->toggleSpell();
|
||||
break;
|
||||
case A_QuickKey1:
|
||||
quickKey(1);
|
||||
case MWInput::A_QuickKey1:
|
||||
mActionManager->quickKey(1);
|
||||
break;
|
||||
case A_QuickKey2:
|
||||
quickKey(2);
|
||||
case MWInput::A_QuickKey2:
|
||||
mActionManager->quickKey(2);
|
||||
break;
|
||||
case A_QuickKey3:
|
||||
quickKey(3);
|
||||
case MWInput::A_QuickKey3:
|
||||
mActionManager->quickKey(3);
|
||||
break;
|
||||
case A_QuickKey4:
|
||||
quickKey(4);
|
||||
case MWInput::A_QuickKey4:
|
||||
mActionManager->quickKey(4);
|
||||
break;
|
||||
case A_QuickKey5:
|
||||
quickKey(5);
|
||||
case MWInput::A_QuickKey5:
|
||||
mActionManager->quickKey(5);
|
||||
break;
|
||||
case A_QuickKey6:
|
||||
quickKey(6);
|
||||
case MWInput::A_QuickKey6:
|
||||
mActionManager->quickKey(6);
|
||||
break;
|
||||
case A_QuickKey7:
|
||||
quickKey(7);
|
||||
case MWInput::A_QuickKey7:
|
||||
mActionManager->quickKey(7);
|
||||
break;
|
||||
case A_QuickKey8:
|
||||
quickKey(8);
|
||||
case MWInput::A_QuickKey8:
|
||||
mActionManager->quickKey(8);
|
||||
break;
|
||||
case A_QuickKey9:
|
||||
quickKey(9);
|
||||
case MWInput::A_QuickKey9:
|
||||
mActionManager->quickKey(9);
|
||||
break;
|
||||
case A_QuickKey10:
|
||||
quickKey(10);
|
||||
case MWInput::A_QuickKey10:
|
||||
mActionManager->quickKey(10);
|
||||
break;
|
||||
case A_QuickKeysMenu:
|
||||
showQuickKeysMenu();
|
||||
case MWInput::A_QuickKeysMenu:
|
||||
mActionManager->showQuickKeysMenu();
|
||||
break;
|
||||
case A_ToggleHUD:
|
||||
case MWInput::A_ToggleHUD:
|
||||
Log(Debug::Verbose) << "Toggle HUD";
|
||||
MWBase::Environment::get().getWindowManager()->toggleHud();
|
||||
break;
|
||||
case A_ToggleDebug:
|
||||
case MWInput::A_ToggleDebug:
|
||||
Log(Debug::Verbose) << "Toggle Debug";
|
||||
MWBase::Environment::get().getWindowManager()->toggleDebugWindow();
|
||||
break;
|
||||
case A_QuickSave:
|
||||
quickSave();
|
||||
case MWInput::A_QuickSave:
|
||||
mActionManager->quickSave();
|
||||
break;
|
||||
case A_QuickLoad:
|
||||
quickLoad();
|
||||
case MWInput::A_QuickLoad:
|
||||
mActionManager->quickLoad();
|
||||
break;
|
||||
case A_CycleSpellLeft:
|
||||
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
|
||||
case MWInput::A_CycleSpellLeft:
|
||||
if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
|
||||
MWBase::Environment::get().getWindowManager()->cycleSpell(false);
|
||||
break;
|
||||
case A_CycleSpellRight:
|
||||
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
|
||||
case MWInput::A_CycleSpellRight:
|
||||
if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Magic))
|
||||
MWBase::Environment::get().getWindowManager()->cycleSpell(true);
|
||||
break;
|
||||
case A_CycleWeaponLeft:
|
||||
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||
case MWInput::A_CycleWeaponLeft:
|
||||
if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||
MWBase::Environment::get().getWindowManager()->cycleWeapon(false);
|
||||
break;
|
||||
case A_CycleWeaponRight:
|
||||
if (checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||
case MWInput::A_CycleWeaponRight:
|
||||
if (mActionManager->checkAllowedToUseItems() && MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||
MWBase::Environment::get().getWindowManager()->cycleWeapon(true);
|
||||
break;
|
||||
case A_Jump:
|
||||
mAttemptJump = true;
|
||||
case MWInput::A_Jump:
|
||||
mActionManager->setAttemptJump(true);
|
||||
break;
|
||||
case OpenXRInput::A_RepositionMenu:
|
||||
xrGUIManager->updateTracking();
|
||||
break;
|
||||
case A_Use:
|
||||
case MWInput::A_Use:
|
||||
if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
pointActivation(true);
|
||||
default:
|
||||
|
@ -1218,15 +1230,17 @@ private:
|
|||
{
|
||||
switch (action->openMWActionCode())
|
||||
{
|
||||
case A_Use:
|
||||
mInputBinder->getChannel(A_Use)->setValue(0.f);
|
||||
case MWInput::A_Use:
|
||||
mBindingsManager->ics().getChannel(MWInput::A_Use)->setValue(0.f);
|
||||
if (mActivationIndication || MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
pointActivation(false);
|
||||
break;
|
||||
case A_Sneak:
|
||||
if (mSneakToggles)
|
||||
toggleSneaking();
|
||||
case MWInput::A_Sneak:
|
||||
if (isToggleSneak)
|
||||
mActionManager->toggleSneaking();
|
||||
break;
|
||||
case MWInput::A_Inventory:
|
||||
injectMousePress(SDL_BUTTON_RIGHT, false);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1235,11 +1249,9 @@ private:
|
|||
|
||||
void OpenXRInputManager::updateHead()
|
||||
{
|
||||
if (!mPlayer)
|
||||
return;
|
||||
|
||||
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* session = Environment::get().getSession();
|
||||
|
@ -1272,9 +1284,9 @@ private:
|
|||
mVrAngles[1] = roll;
|
||||
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 {
|
||||
// Update the camera directly to avoid rotating the disabled player
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace MWVR
|
|||
void pointActivation(bool onPress);
|
||||
|
||||
void injectMousePress(int sdlButton, bool onPress);
|
||||
void injectChannelValue(MWInput::Actions action, float value);
|
||||
|
||||
void applyHapticsLeftHand(float intensity) override;
|
||||
void applyHapticsRightHand(float intensity) override;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/sdlutil/sdlgraphicswindow.hpp>
|
||||
#include <components/sceneutil/vismask.hpp>
|
||||
|
||||
// The OpenXR SDK assumes we've included Windows.h
|
||||
#include <Windows.h>
|
||||
|
|
|
@ -70,11 +70,6 @@ namespace MWVR {
|
|||
{
|
||||
auto name = renderInfo.getCurrentCamera()->getName();
|
||||
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)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwrender/vismask.hpp"
|
||||
#include <components/esm/loadrace.hpp>
|
||||
#include <components/sceneutil/vismask.hpp>
|
||||
#include <osg/MatrixTransform>
|
||||
|
||||
namespace MWVR
|
||||
|
@ -80,7 +80,7 @@ namespace MWVR
|
|||
|
||||
// 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.)
|
||||
mainCamera->setCullMask(SceneUtil::Mask_GUI);
|
||||
mainCamera->setCullMask(MWRender::Mask_GUI);
|
||||
|
||||
osg::Vec4 clearColor = mainCamera->getClearColor();
|
||||
|
||||
|
@ -117,8 +117,8 @@ namespace MWVR
|
|||
rightCamera->setFinalDrawCallback(mPostDraw);
|
||||
|
||||
// Stereo cameras should only draw the scene (AR layers should later add minimap, health, etc.)
|
||||
leftCamera->setCullMask(~SceneUtil::Mask_GUI);
|
||||
rightCamera->setCullMask(~SceneUtil::Mask_GUI);
|
||||
leftCamera->setCullMask(~MWRender::Mask_GUI);
|
||||
rightCamera->setCullMask(~MWRender::Mask_GUI);
|
||||
|
||||
leftCamera->setName("LeftEye");
|
||||
rightCamera->setName("RightEye");
|
||||
|
@ -147,13 +147,24 @@ namespace MWVR
|
|||
mViewer->getSlave(0)._updateSlaveCallback = new OpenXRWorldView::UpdateSlaveCallback(xr, session, leftView, 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);
|
||||
session->setLayer(OpenXRLayerStack::WORLD_VIEW_LAYER, this);
|
||||
mConfigured = true;
|
||||
|
||||
}
|
||||
|
||||
void OpenXRViewer::enableMainCamera(void)
|
||||
{
|
||||
mCameras["MainCamera"]->setGraphicsContext(mMainCameraGC);
|
||||
}
|
||||
|
||||
void OpenXRViewer::disableMainCamera(void)
|
||||
{
|
||||
mCameras["MainCamera"]->setGraphicsContext(nullptr);
|
||||
}
|
||||
|
||||
void OpenXRViewer::blitEyesToMirrorTexture(osg::GraphicsContext* gc)
|
||||
{
|
||||
//includeMenu = false;
|
||||
|
@ -174,6 +185,7 @@ namespace MWVR
|
|||
|
||||
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
mMirrorTextureSwapchain->renderBuffer()->blit(gc, 0, 0, mMirrorTextureSwapchain->width(), mMirrorTextureSwapchain->height());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -186,7 +198,6 @@ namespace MWVR
|
|||
|
||||
void OpenXRViewer::swapBuffers(osg::GraphicsContext* gc)
|
||||
{
|
||||
|
||||
if (!mConfigured)
|
||||
return;
|
||||
|
||||
|
|
|
@ -86,12 +86,12 @@ namespace MWVR
|
|||
void blitEyesToMirrorTexture(osg::GraphicsContext* gc);
|
||||
void swapBuffers(osg::GraphicsContext* gc) override;
|
||||
void realize(osg::GraphicsContext* gc);
|
||||
|
||||
bool realized() { return mConfigured; }
|
||||
|
||||
|
||||
void updateTransformNode(osg::Object* object, osg::Object* data);
|
||||
|
||||
void enableMainCamera(void);
|
||||
void disableMainCamera(void);
|
||||
|
||||
public:
|
||||
|
||||
std::unique_ptr<XrCompositionLayerProjection> mLayer = nullptr;
|
||||
|
@ -100,8 +100,9 @@ namespace MWVR
|
|||
osg::ref_ptr<osgViewer::Viewer> mViewer = nullptr;
|
||||
std::map<std::string, osg::ref_ptr<OpenXRView> > mViews{};
|
||||
std::map<std::string, osg::ref_ptr<osg::Camera> > mCameras{};
|
||||
PredrawCallback* mPreDraw{ nullptr };
|
||||
PostdrawCallback* mPostDraw{ nullptr };
|
||||
osg::ref_ptr<PredrawCallback> mPreDraw{ nullptr };
|
||||
osg::ref_ptr<PostdrawCallback> mPostDraw{ nullptr };
|
||||
osg::GraphicsContext* mMainCameraGC{ nullptr };
|
||||
|
||||
std::unique_ptr<OpenXRSwapchain> mMirrorTextureSwapchain{ nullptr };
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "openxrinputmanager.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/sdlutil/sdlgraphicswindow.hpp>
|
||||
#include <components/sceneutil/vismask.hpp>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <components/sceneutil/attach.hpp>
|
||||
#include <components/sceneutil/clone.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
#include <components/sceneutil/vismask.hpp>
|
||||
#include <components/sceneutil/skeleton.hpp>
|
||||
#include <components/sceneutil/riggeometry.hpp>
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
|
@ -547,6 +546,8 @@ void VRAnimation::setPointForward(bool enabled)
|
|||
{
|
||||
mPointerTarget = MWRender::RayResult{};
|
||||
}
|
||||
|
||||
mIsPointingForward = enabled;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Geometry> VRAnimation::createPointerGeometry(void)
|
||||
|
@ -670,12 +671,12 @@ void VRAnimation::addControllers()
|
|||
mModelOffset->addChild(mObjectRoot);
|
||||
}
|
||||
|
||||
auto wb = mNodeMap.find("weapon bone");
|
||||
if (wb != mNodeMap.end())
|
||||
{
|
||||
wb->second->removeChild(mWeaponPointerTransform);
|
||||
wb->second->addChild(mWeaponPointerTransform);
|
||||
}
|
||||
//auto wb = mNodeMap.find("weapon bone");
|
||||
//if (wb != mNodeMap.end())
|
||||
//{
|
||||
// wb->second->removeChild(mWeaponPointerTransform);
|
||||
// wb->second->addChild(mWeaponPointerTransform);
|
||||
//}
|
||||
}
|
||||
void VRAnimation::enableHeadAnimation(bool)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
|
||||
/// Overrides finger animations to point forward
|
||||
void setPointForward(bool enabled);
|
||||
bool isPointingForward(void) const { return mIsPointingForward; }
|
||||
|
||||
bool canPlaceObject();
|
||||
///< @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<FingerController> mIndexFingerControllers[2];
|
||||
osg::ref_ptr<osg::MatrixTransform> mModelOffset;
|
||||
|
||||
bool mIsPointingForward{ false };
|
||||
osg::ref_ptr<osg::Geometry> mPointerGeometry{ nullptr };
|
||||
osg::ref_ptr<osg::MatrixTransform> mPointerRescale{ nullptr };
|
||||
osg::ref_ptr<osg::MatrixTransform> mPointerTransform{ nullptr };
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "../mwrender/renderbin.hpp"
|
||||
#include "../mwrender/renderingmanager.hpp"
|
||||
#include "../mwrender/camera.hpp"
|
||||
#include "../mwrender/vismask.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -63,8 +64,8 @@ public:
|
|||
setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
setName("GUICamera");
|
||||
|
||||
setCullMask(SceneUtil::Mask_GUI);
|
||||
setNodeMask(SceneUtil::Mask_RenderToTexture);
|
||||
setCullMask(MWRender::Mask_GUI);
|
||||
setNodeMask(MWRender::Mask_RenderToTexture);
|
||||
|
||||
setViewport(0, 0, width, height);
|
||||
|
||||
|
@ -637,7 +638,7 @@ void VRGUIManager::removeWidget(MWGui::Layout* widget)
|
|||
auto it = mLayers.find(name);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -653,7 +654,7 @@ void VRGUIManager::setVisible(MWGui::Layout* widget, bool visible)
|
|||
auto* layer = widget->mMainWidget->getLayer();
|
||||
auto name = layer->getName();
|
||||
|
||||
Log(Debug::Verbose) << "setVisible (" << name << "): " << visible;
|
||||
//Log(Debug::Verbose) << "setVisible (" << name << "): " << visible;
|
||||
if (layerBlacklist.find(name) != layerBlacklist.end())
|
||||
{
|
||||
Log(Debug::Verbose) << "Blacklisted";
|
||||
|
|
|
@ -279,16 +279,6 @@ namespace MWWorld
|
|||
return mJumping;
|
||||
}
|
||||
|
||||
void Player::setPointing(bool pointing)
|
||||
{
|
||||
mPointing = pointing;
|
||||
}
|
||||
|
||||
bool Player::getPointing() const
|
||||
{
|
||||
return mPointing;
|
||||
}
|
||||
|
||||
bool Player::isInCombat() {
|
||||
return MWBase::Environment::get().getMechanicsManager()->getActorsFighting(getPlayer()).size() != 0;
|
||||
}
|
||||
|
|
|
@ -121,9 +121,6 @@ namespace MWWorld
|
|||
void setJumping(bool jumping);
|
||||
bool getJumping() const;
|
||||
|
||||
void setPointing(bool pointing);
|
||||
bool getPointing(void) const;
|
||||
|
||||
///Checks all nearby actors to see if anyone has an aipackage against you
|
||||
bool isInCombat();
|
||||
|
||||
|
|
|
@ -4080,11 +4080,6 @@ namespace MWWorld
|
|||
}
|
||||
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
|
||||
{
|
||||
|
|
|
@ -752,8 +752,6 @@ namespace MWWorld
|
|||
|
||||
/// @Return ESM::Weapon::Type enum describing the type of weapon currently drawn by the player.
|
||||
int getActiveWeaponType(void) override;
|
||||
|
||||
void toggleWaterRTT(bool enable) override;
|
||||
|
||||
bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const override;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue