Commit a293d8d4 authored by jherico's avatar jherico
Browse files

wip

parent b2bcfa2a
Pipeline #1414 failed with stage
in 11 minutes and 48 seconds
#
# Created by Bradley Austin Davis on 2015/11/18
# Copyright 2015 High Fidelity, Inc.
# Created by Bradley Austin Davis on 2021/08/14
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
......
//
// Created by Bradley Austin Davis on 2015/05/12
// Copyright 2015 High Fidelity, Inc.
// Created by Bradley Austin Davis on 2021/08/14
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
......@@ -108,13 +107,18 @@ bool OpenXrDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
withNonPresentThreadLock([&] {
xrs::FrameData frameData = _nextFrame;
if (frameData.viewState.viewStateFlags & requiredFlags) {
_currentRenderFrameInfo.renderPose = xrs::toGlm(frameData.views[0].pose);
const auto leftPose = xrs::toGlmPose(frameData.views[0].pose);
const auto rightPose = xrs::toGlmPose(frameData.views[1].pose);
const auto center = (leftPose.position + rightPose.position) / 2.0f;
const auto centerPose = GlmPose{ leftPose.orientation, center };
_ipd = glm::length(leftPose.position - rightPose.position);
_currentRenderFrameInfo.renderPose = centerPose.getMatrix();
_currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose;
_currentRenderFrameInfo.sensorSampleTime = xrs::FrameData::toSeconds(frameData.frameState.predictedDisplayTime);
_currentRenderFrameInfo.predictedDisplayTime = xrs::FrameData::toSeconds(frameData.frameState.predictedDisplayTime);
xrs::for_each_side_index([&](size_t eye) {
_eyeProjections[eye] = xrs::toGlm(frameData.views[eye].fov);
//_eyeOffsets[eye] = glm::translate(mat4(), vec3{ _ipd * (eye == VRAPI_EYE_LEFT ? -0.5f : 0.5f), 0.0f, 0.0f });
_eyeOffsets[eye] = glm::translate(mat4(), vec3{ _ipd * (eye == 0 ? -0.5f : 0.5f), 0.0f, 0.0f });
});
}
_frameInfos[frameIndex] = _currentRenderFrameInfo;
......
//
// Created by Bradley Austin Davis on 2015/06/12
// Copyright 2015 High Fidelity, Inc.
// Created by Bradley Austin Davis on 2021/08/14
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
......
//
// Created by Bradley Austin Davis on 2015/11/01
// Copyright 2015 High Fidelity, Inc.
// Created by Bradley Austin Davis on 2021/08/14
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
......@@ -17,6 +16,7 @@
#include <QtCore/QProcessEnvironment>
#include <QtGui/QInputMethodEvent>
#include <QtQuick/QQuickWindow>
#include <AvatarConstants.h>
#include <unordered_map>
......@@ -197,12 +197,12 @@ void Manager::pollEvents() {
SessionManager::SessionManager(const GraphicsBinding& graphicsBinding) {
//graphicsBinding = ;
_session = _instance.instance.createSession({ {}, _instance.systemId, &graphicsBinding });
// FIXME which reference space is best for Hifi? Does it depend on state?
// auto referenceSpaces = _session.enumerateReferenceSpacesToVector();
_space = _session.createReferenceSpace(xr::ReferenceSpaceCreateInfo{ xr::ReferenceSpaceType::Local, {} });
//glCreateFramebuffers(1, &_copyFbo);
// Use local reference space with the avatar height (or avatar center eye position) as the reference pose so that incoming poses
// come out with a reasonable height. Do not use an identity pose of the camera will be stuck in the user's feet and do not use
// the current OpenXR head because if the user is sitting that will be too low for a standing avatar.
const auto pose = xr::Posef{ xr::Quaternionf{}, xr::Vector3f{ 0, 0.0f - DEFAULT_AVATAR_EYE_HEIGHT, 0 } };
_space = _session.createReferenceSpace(xr::ReferenceSpaceCreateInfo{ xr::ReferenceSpaceType::Local, pose });
buildSwapchain();
FrameData::SESSION = _session;
FrameData::SPACE = _space;
......
//
// Created by Bradley Austin Davis on 2015/06/12
// Copyright 2015 High Fidelity, Inc.
// Created by Bradley Austin Davis on 2021/08/14
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
......@@ -22,6 +21,18 @@
Q_DECLARE_LOGGING_CATEGORY(xr_logging)
class GlmPose {
public:
GlmPose() = default;
GlmPose(GlmPose&& o) = default;
GlmPose(const GlmPose& o) = default;
GlmPose(const glm::quat orientation_, const glm::vec3& position_) : orientation(orientation_), position(position_) {}
glm::quat orientation;
glm::vec3 position;
glm::mat4 getMatrix() const { return glm::translate(glm::mat4{ 1 }, position) * glm::mat4_cast(orientation); }
};
namespace xrs {
......@@ -91,6 +102,11 @@ inline glm::mat4 toGlm(const XrPosef& p) {
return translation * orientation;
}
inline GlmPose toGlmPose(const XrPosef& p) {
return GlmPose{ toGlm(p.orientation), toGlm(p.position) };
}
inline void for_each_side_index(const std::function < void(size_t)>& f) {
f(0);
f(1);
......
//
// Created by Bradley Austin Davis on 2021/09/26.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "OpenXrInputPlugin.h"
#include <QtCore/QLoggingCategory>
#include <ui-plugins/PluginContainer.h>
#include <controllers/UserInputMapper.h>
#include <controllers/StandardControls.h>
#include <AvatarConstants.h>
#include <PerfStat.h>
#include <PathUtils.h>
#include <NumericalConstants.h>
#include <StreamUtils.h>
#include "OpenXrHelpers.h"
const char* OpenXrInputPlugin::NAME = "OpenXrInput";
bool OpenXrInputPlugin::isSupported() const {
return true;
}
bool OpenXrInputPlugin::activate() {
InputPlugin::activate();
return true;
}
void OpenXrInputPlugin::deactivate() {
InputPlugin::deactivate();
//// unregister with UserInputMapper
//auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
//if (_touch) {
// userInputMapper->removeDevice(_touch->getDeviceID());
//}
//if (_remote) {
// userInputMapper->removeDevice(_remote->getDeviceID());
//}
}
void OpenXrInputPlugin::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
//PerformanceTimer perfTimer("OpenXrInputPlugin::TouchDevice::update");
//checkForConnectedDevices();
//bool updateRemote = false, updateTouch = false;
//ovr::withSession([&](ovrSession session) {
// if (_remote) {
// updateRemote = OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Remote, &_remoteInputState));
// if (!updateRemote) {
// qCWarning(oculusLog) << "Unable to read Oculus remote input state" << ovr::getError();
// }
// }
//});
//if (_remote && updateRemote) {
// _remote->update(deltaTime, inputCalibrationData);
//}
}
void OpenXrInputPlugin::pluginFocusOutEvent() {
//if (_remote) {
// _remote->focusOutEvent();
//}
}
//
// Created by Bradley Austin Davis on 2021/09/26.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#include <QObject>
#include <unordered_set>
#include <vector>
#include <map>
#include <utility>
#include <GLMHelpers.h>
#include <controllers/InputDevice.h>
#include <plugins/InputPlugin.h>
#include "OpenXrHelpers.h"
class OpenXrInputPlugin : public InputPlugin {
using Parent = InputPlugin ;
Q_OBJECT
public:
bool isSupported() const override;
const QString getName() const override { return NAME; }
bool isHandController() const override { return true; }
bool configurable() override { return true; }
bool isHeadController() const override { return true; }
bool activate() override;
void deactivate() override;
void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
private:
static const char* NAME;
};
//
// Created by Bradley Austin Davis on 2015/10/25
// Copyright 2015 High Fidelity, Inc.
// Created by Bradley Austin Davis on 2021/08/14
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment