1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-22 11:09:40 +00:00
openmw-tes3mp/apps/openmw/mwvr/openxrsession.hpp

74 lines
1.8 KiB
C++
Raw Normal View History

#ifndef MWVR_OPENRXSESSION_H
#define MWVR_OPENRXSESSION_H
#include <memory>
#include <mutex>
#include <array>
#include <chrono>
#include <deque>
#include <components/debug/debuglog.hpp>
#include <components/sdlutil/sdlgraphicswindow.hpp>
#include <components/settings/settings.hpp>
#include "openxrmanager.hpp"
#include "openxrlayer.hpp"
namespace MWVR
{
2020-02-23 10:02:38 +00:00
extern void getEulerAngles(const osg::Quat& quat, float& yaw, float& pitch, float& roll);
2020-02-15 19:01:11 +00:00
class OpenXRSession
{
2020-03-23 22:32:47 +00:00
public:
2020-02-15 19:01:11 +00:00
using seconds = std::chrono::duration<double>;
using nanoseconds = std::chrono::nanoseconds;
using clock = std::chrono::steady_clock;
using time_point = clock::time_point;
2020-03-23 22:32:47 +00:00
enum class PredictionSlice
{
Predraw = 0, //!< Get poses predicted for the next frame to be drawn
Draw = 1, //!< Get poses predicted for the current rendering
NumSlices
};
2020-02-15 19:01:11 +00:00
public:
2020-02-29 22:53:56 +00:00
OpenXRSession();
2020-02-15 19:01:11 +00:00
~OpenXRSession();
void setLayer(OpenXRLayerStack::Layer layerType, OpenXRLayer* layer);
void swapBuffers(osg::GraphicsContext* gc);
2020-03-23 22:32:47 +00:00
const PoseSets& predictedPoses(PredictionSlice slice);
2020-02-15 19:01:11 +00:00
//! Call before updating poses and other inputs
void waitFrame();
2020-02-15 19:01:11 +00:00
//! Update predictions
void predictNext(int extraPeriods);
2020-05-12 20:13:01 +00:00
//! Angles to be used for overriding movement direction
void movementAngles(float& yaw, float& pitch);
2020-03-23 22:32:47 +00:00
void advanceFrame(void);
bool isRunning() { return mIsRunning; }
bool shouldRender() { return mShouldRender; }
2020-02-15 19:01:11 +00:00
OpenXRLayerStack mLayerStack{};
2020-03-23 22:32:47 +00:00
PoseSets mPredictedPoses[(int)PredictionSlice::NumSlices]{};
int mRenderFrame{ 0 };
int mRenderedFrames{ 0 };
int mPredictionFrame{ 1 };
int mPredictedFrames{ 0 };
bool mIsRunning{ false };
bool mShouldRender{ false };
2020-02-15 19:01:11 +00:00
};
}
#endif