1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 12:49:56 +00:00
openmw-tes3mp/apps/openmw/mwvr/vrenvironment.cpp

118 lines
2.2 KiB
C++
Raw Normal View History

2020-03-15 14:31:38 +00:00
#include "vrenvironment.hpp"
2020-02-29 22:53:56 +00:00
#include <cassert>
2020-03-15 14:31:38 +00:00
#include "vranimation.hpp"
#include "vrinputmanager.hpp"
#include "vrsession.hpp"
#include "vrgui.hpp"
2020-02-29 22:53:56 +00:00
#include "../mwbase/environment.hpp"
2020-03-15 14:31:38 +00:00
MWVR::Environment *MWVR::Environment::sThis = 0;
2020-02-29 22:53:56 +00:00
2020-03-15 14:31:38 +00:00
MWVR::Environment::Environment()
2020-02-29 22:53:56 +00:00
: mSession(nullptr)
{
assert (!sThis);
sThis = this;
}
2020-03-15 14:31:38 +00:00
MWVR::Environment::~Environment()
2020-02-29 22:53:56 +00:00
{
cleanup();
sThis = 0;
}
2020-03-15 14:31:38 +00:00
void MWVR::Environment::cleanup()
2020-02-29 22:53:56 +00:00
{
if (mSession)
delete mSession;
mSession = nullptr;
if (mGUIManager)
delete mGUIManager;
mGUIManager = nullptr;
2020-02-29 22:53:56 +00:00
if (mViewer)
delete mViewer;
mViewer = nullptr;
if (mOpenXRManager)
delete mOpenXRManager;
mOpenXRManager = nullptr;
}
2020-03-15 14:31:38 +00:00
MWVR::Environment& MWVR::Environment::get()
2020-02-29 22:53:56 +00:00
{
assert (sThis);
return *sThis;
}
2020-03-15 14:31:38 +00:00
MWVR::OpenXRInputManager* MWVR::Environment::getInputManager() const
2020-02-29 22:53:56 +00:00
{
auto* inputManager = MWBase::Environment::get().getInputManager();
assert(inputManager);
auto xrInputManager = dynamic_cast<MWVR::OpenXRInputManager*>(inputManager);
assert(xrInputManager);
return xrInputManager;
}
MWVR::VRSession* MWVR::Environment::getSession() const
2020-02-29 22:53:56 +00:00
{
return mSession;
}
void MWVR::Environment::setSession(MWVR::VRSession* xrSession)
2020-02-29 22:53:56 +00:00
{
mSession = xrSession;
}
MWVR::VRGUIManager* MWVR::Environment::getGUIManager() const
2020-02-29 22:53:56 +00:00
{
return mGUIManager;
2020-02-29 22:53:56 +00:00
}
void MWVR::Environment::setGUIManager(MWVR::VRGUIManager* GUIManager)
2020-02-29 22:53:56 +00:00
{
mGUIManager = GUIManager;
2020-02-29 22:53:56 +00:00
}
2020-03-15 14:31:38 +00:00
MWVR::VRAnimation* MWVR::Environment::getPlayerAnimation() const
2020-03-08 13:14:24 +00:00
{
return mPlayerAnimation;
}
2020-03-15 14:31:38 +00:00
void MWVR::Environment::setPlayerAnimation(MWVR::VRAnimation* xrAnimation)
2020-03-08 13:14:24 +00:00
{
mPlayerAnimation = xrAnimation;
}
2020-02-29 22:53:56 +00:00
MWVR::VRViewer* MWVR::Environment::getViewer() const
2020-02-29 22:53:56 +00:00
{
return mViewer;
}
void MWVR::Environment::setViewer(MWVR::VRViewer* xrViewer)
2020-02-29 22:53:56 +00:00
{
mViewer = xrViewer;
}
2020-03-15 14:31:38 +00:00
MWVR::OpenXRManager* MWVR::Environment::getManager() const
2020-02-29 22:53:56 +00:00
{
return mOpenXRManager;
}
2020-03-15 14:31:38 +00:00
void MWVR::Environment::setManager(MWVR::OpenXRManager* xrManager)
2020-02-29 22:53:56 +00:00
{
mOpenXRManager = xrManager;
}
2020-03-15 14:31:38 +00:00
float MWVR::Environment::unitsPerMeter() const
2020-02-29 22:53:56 +00:00
{
return mUnitsPerMeter;
}
2020-03-15 14:31:38 +00:00
void MWVR::Environment::setUnitsPerMeter(float unitsPerMeter)
2020-02-29 22:53:56 +00:00
{
mUnitsPerMeter = unitsPerMeter;
}