mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Merge pull request #15333 from highfidelity/revert-15266-stencil
Case 22070: Revert "Case 20060: Grab correct stencil masks from display plugins"
This commit is contained in:
commit
19b109c1f7
16 changed files with 27 additions and 208 deletions
4
cmake/externals/LibOVR/CMakeLists.txt
vendored
4
cmake/externals/LibOVR/CMakeLists.txt
vendored
|
@ -17,8 +17,8 @@ if (WIN32)
|
||||||
|
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
URL https://hifi-public.s3.amazonaws.com/dependencies/ovr_sdk_win_1.35.0.zip
|
URL https://public.highfidelity.com/dependencies/ovr_sdk_win_1.26.0_public.zip
|
||||||
URL_MD5 1e3e8b2101387af07ff9c841d0ea285e
|
URL_MD5 06804ff9727b910dcd04a37c800053b5
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
PATCH_COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/LibOVRCMakeLists.txt" <SOURCE_DIR>/CMakeLists.txt
|
PATCH_COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/LibOVRCMakeLists.txt" <SOURCE_DIR>/CMakeLists.txt
|
||||||
LOG_DOWNLOAD 1
|
LOG_DOWNLOAD 1
|
||||||
|
|
|
@ -6723,11 +6723,6 @@ void Application::updateRenderArgs(float deltaTime) {
|
||||||
// Configure the type of display / stereo
|
// Configure the type of display / stereo
|
||||||
appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR);
|
appRenderArgs._renderArgs._displayMode = (isHMDMode() ? RenderArgs::STEREO_HMD : RenderArgs::STEREO_MONITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
appRenderArgs._renderArgs._stencilMode = getActiveDisplayPlugin()->getStencilMaskMode();
|
|
||||||
if (appRenderArgs._renderArgs._stencilMode == StencilMode::MESH) {
|
|
||||||
appRenderArgs._renderArgs._stencilMaskOperator = getActiveDisplayPlugin()->getStencilMaskMeshOperator();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,8 +48,6 @@ public:
|
||||||
|
|
||||||
void pluginUpdate() override {};
|
void pluginUpdate() override {};
|
||||||
|
|
||||||
virtual StencilMode getStencilMaskMode() const override { return StencilMode::PAINT; }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hmdMountedChanged();
|
void hmdMountedChanged();
|
||||||
void hmdVisibleChanged(bool visible);
|
void hmdVisibleChanged(bool visible);
|
||||||
|
|
|
@ -362,6 +362,7 @@ MeshPointer Mesh::createIndexedTriangles_P3F(uint32_t numVertices, uint32_t numI
|
||||||
mesh->setIndexBuffer(gpu::BufferView(new gpu::Buffer(numIndices * sizeof(uint32_t), (gpu::Byte*) indices), gpu::Element::INDEX_INT32));
|
mesh->setIndexBuffer(gpu::BufferView(new gpu::Buffer(numIndices * sizeof(uint32_t), (gpu::Byte*) indices), gpu::Element::INDEX_INT32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<graphics::Mesh::Part> parts;
|
std::vector<graphics::Mesh::Part> parts;
|
||||||
parts.push_back(graphics::Mesh::Part(0, numIndices, 0, graphics::Mesh::TRIANGLES));
|
parts.push_back(graphics::Mesh::Part(0, numIndices, 0, graphics::Mesh::TRIANGLES));
|
||||||
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL));
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <SimpleMovingAverage.h>
|
#include <SimpleMovingAverage.h>
|
||||||
#include <gpu/Forward.h>
|
#include <gpu/Forward.h>
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
#include "StencilMode.h"
|
|
||||||
|
|
||||||
class QOpenGLFramebufferObject;
|
class QOpenGLFramebufferObject;
|
||||||
|
|
||||||
|
@ -222,10 +221,6 @@ public:
|
||||||
// for updating plugin-related commands. Mimics the input plugin.
|
// for updating plugin-related commands. Mimics the input plugin.
|
||||||
virtual void pluginUpdate() = 0;
|
virtual void pluginUpdate() = 0;
|
||||||
|
|
||||||
virtual StencilMode getStencilMaskMode() const { return StencilMode::NONE; }
|
|
||||||
using StencilMaskMeshOperator = std::function<void(gpu::Batch&)>;
|
|
||||||
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void recommendedFramebufferSizeChanged(const QSize& size);
|
void recommendedFramebufferSizeChanged(const QSize& size);
|
||||||
void resetSensorsRequested();
|
void resetSensorsRequested();
|
||||||
|
|
|
@ -19,6 +19,7 @@ using namespace render;
|
||||||
|
|
||||||
void PrepareStencil::configure(const Config& config) {
|
void PrepareStencil::configure(const Config& config) {
|
||||||
_maskMode = config.maskMode;
|
_maskMode = config.maskMode;
|
||||||
|
_forceDraw = config.forceDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics::MeshPointer PrepareStencil::getMesh() {
|
graphics::MeshPointer PrepareStencil::getMesh() {
|
||||||
|
@ -42,7 +43,6 @@ gpu::PipelinePointer PrepareStencil::getMeshStencilPipeline() {
|
||||||
auto state = std::make_shared<gpu::State>();
|
auto state = std::make_shared<gpu::State>();
|
||||||
drawMask(*state);
|
drawMask(*state);
|
||||||
state->setColorWriteMask(gpu::State::WRITE_NONE);
|
state->setColorWriteMask(gpu::State::WRITE_NONE);
|
||||||
state->setCullMode(gpu::State::CullMode::CULL_NONE);
|
|
||||||
|
|
||||||
_meshStencilPipeline = gpu::Pipeline::create(program, state);
|
_meshStencilPipeline = gpu::Pipeline::create(program, state);
|
||||||
}
|
}
|
||||||
|
@ -64,37 +64,30 @@ gpu::PipelinePointer PrepareStencil::getPaintStencilPipeline() {
|
||||||
void PrepareStencil::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer) {
|
void PrepareStencil::run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer) {
|
||||||
RenderArgs* args = renderContext->args;
|
RenderArgs* args = renderContext->args;
|
||||||
|
|
||||||
StencilMode maskMode = _maskMode;
|
// Only draw the stencil mask if in HMD mode or not forced.
|
||||||
std::function<void(gpu::Batch&)> maskOperator = [this](gpu::Batch& batch) {
|
if (!_forceDraw && (args->_displayMode != RenderArgs::STEREO_HMD)) {
|
||||||
auto mesh = getMesh();
|
|
||||||
batch.setIndexBuffer(mesh->getIndexBuffer());
|
|
||||||
batch.setInputFormat((mesh->getVertexFormat()));
|
|
||||||
batch.setInputStream(0, mesh->getVertexStream());
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
auto part = mesh->getPartBuffer().get<graphics::Mesh::Part>(0);
|
|
||||||
batch.drawIndexed(gpu::TRIANGLES, part._numIndices, part._startIndex);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (maskMode == StencilMode::NONE) {
|
|
||||||
maskMode = args->_stencilMode;
|
|
||||||
maskOperator = args->_stencilMaskOperator;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maskMode == StencilMode::NONE || (maskMode == StencilMode::MESH && !maskOperator)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doInBatch("PrepareStencil::run", args->_context, [&](gpu::Batch& batch) {
|
doInBatch("PrepareStencil::run", args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
|
||||||
if (maskMode == StencilMode::PAINT) {
|
if (_maskMode < 0) {
|
||||||
|
batch.setPipeline(getMeshStencilPipeline());
|
||||||
|
|
||||||
|
auto mesh = getMesh();
|
||||||
|
batch.setIndexBuffer(mesh->getIndexBuffer());
|
||||||
|
batch.setInputFormat((mesh->getVertexFormat()));
|
||||||
|
batch.setInputStream(0, mesh->getVertexStream());
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
auto part = mesh->getPartBuffer().get<graphics::Mesh::Part>(0);
|
||||||
|
batch.drawIndexed(gpu::TRIANGLES, part._numIndices, part._startIndex);
|
||||||
|
} else {
|
||||||
batch.setPipeline(getPaintStencilPipeline());
|
batch.setPipeline(getPaintStencilPipeline());
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
} else if (maskMode == StencilMode::MESH) {
|
|
||||||
batch.setPipeline(getMeshStencilPipeline());
|
|
||||||
maskOperator(batch);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,19 +15,17 @@
|
||||||
#include <render/Engine.h>
|
#include <render/Engine.h>
|
||||||
#include <gpu/Pipeline.h>
|
#include <gpu/Pipeline.h>
|
||||||
#include <graphics/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
#include <StencilMode.h>
|
|
||||||
|
|
||||||
class PrepareStencilConfig : public render::Job::Config {
|
class PrepareStencilConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(StencilMode maskMode MEMBER maskMode NOTIFY dirty)
|
Q_PROPERTY(int maskMode MEMBER maskMode NOTIFY dirty)
|
||||||
|
Q_PROPERTY(bool forceDraw MEMBER forceDraw NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrepareStencilConfig(bool enabled = true) : JobConfig(enabled) {}
|
PrepareStencilConfig(bool enabled = true) : JobConfig(enabled) {}
|
||||||
|
|
||||||
// -1 -> don't force drawing (fallback to render args mode)
|
int maskMode { 0 };
|
||||||
// 0 -> force draw without mesh
|
bool forceDraw { false };
|
||||||
// 1 -> force draw with mesh
|
|
||||||
StencilMode maskMode { StencilMode::NONE };
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
@ -68,7 +66,8 @@ private:
|
||||||
graphics::MeshPointer _mesh;
|
graphics::MeshPointer _mesh;
|
||||||
graphics::MeshPointer getMesh();
|
graphics::MeshPointer getMesh();
|
||||||
|
|
||||||
StencilMode _maskMode { StencilMode::NONE };
|
int _maskMode { 0 };
|
||||||
|
bool _forceDraw { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
|
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
#include <StencilMode.h>
|
|
||||||
|
|
||||||
#include <gpu/Forward.h>
|
#include <gpu/Forward.h>
|
||||||
#include "Forward.h"
|
#include "Forward.h"
|
||||||
|
|
||||||
|
|
||||||
class AABox;
|
class AABox;
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
@ -133,9 +133,6 @@ namespace render {
|
||||||
|
|
||||||
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator;
|
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator;
|
||||||
gpu::TexturePointer _hudTexture;
|
gpu::TexturePointer _hudTexture;
|
||||||
|
|
||||||
StencilMode _stencilMode { StencilMode::NONE };
|
|
||||||
std::function<void(gpu::Batch&)> _stencilMaskOperator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ int qMapURLStringMetaTypeId = qRegisterMetaType<QMap<QUrl,QString>>();
|
||||||
int socketErrorMetaTypeId = qRegisterMetaType<QAbstractSocket::SocketError>();
|
int socketErrorMetaTypeId = qRegisterMetaType<QAbstractSocket::SocketError>();
|
||||||
int voidLambdaType = qRegisterMetaType<std::function<void()>>();
|
int voidLambdaType = qRegisterMetaType<std::function<void()>>();
|
||||||
int variantLambdaType = qRegisterMetaType<std::function<QVariant()>>();
|
int variantLambdaType = qRegisterMetaType<std::function<QVariant()>>();
|
||||||
int stencilModeMetaTypeId = qRegisterMetaType<StencilMode>();
|
|
||||||
|
|
||||||
void registerMetaTypes(QScriptEngine* engine) {
|
void registerMetaTypes(QScriptEngine* engine) {
|
||||||
qScriptRegisterMetaType(engine, vec2ToScriptValue, vec2FromScriptValue);
|
qScriptRegisterMetaType(engine, vec2ToScriptValue, vec2FromScriptValue);
|
||||||
|
@ -65,8 +64,6 @@ void registerMetaTypes(QScriptEngine* engine) {
|
||||||
qScriptRegisterMetaType(engine, collisionToScriptValue, collisionFromScriptValue);
|
qScriptRegisterMetaType(engine, collisionToScriptValue, collisionFromScriptValue);
|
||||||
qScriptRegisterMetaType(engine, quuidToScriptValue, quuidFromScriptValue);
|
qScriptRegisterMetaType(engine, quuidToScriptValue, quuidFromScriptValue);
|
||||||
qScriptRegisterMetaType(engine, aaCubeToScriptValue, aaCubeFromScriptValue);
|
qScriptRegisterMetaType(engine, aaCubeToScriptValue, aaCubeFromScriptValue);
|
||||||
|
|
||||||
qScriptRegisterMetaType(engine, stencilModeToScriptValue, stencilModeFromScriptValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue vec2ToScriptValue(QScriptEngine* engine, const glm::vec2& vec2) {
|
QScriptValue vec2ToScriptValue(QScriptEngine* engine, const glm::vec2& vec2) {
|
||||||
|
@ -1286,12 +1283,4 @@ QVariantMap parseTexturesToMap(QString newTextures, const QVariantMap& defaultTe
|
||||||
}
|
}
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
|
||||||
|
|
||||||
QScriptValue stencilModeToScriptValue(QScriptEngine* engine, const StencilMode& stencilMode) {
|
|
||||||
return engine->newVariant((int)stencilMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void stencilModeFromScriptValue(const QScriptValue& object, StencilMode& stencilMode) {
|
|
||||||
stencilMode = StencilMode(object.toVariant().toInt());
|
|
||||||
}
|
}
|
|
@ -25,7 +25,6 @@
|
||||||
#include "shared/Bilateral.h"
|
#include "shared/Bilateral.h"
|
||||||
#include "Transform.h"
|
#include "Transform.h"
|
||||||
#include "PhysicsCollisionGroups.h"
|
#include "PhysicsCollisionGroups.h"
|
||||||
#include "StencilMode.h"
|
|
||||||
|
|
||||||
class QColor;
|
class QColor;
|
||||||
class QUrl;
|
class QUrl;
|
||||||
|
@ -730,8 +729,5 @@ void qVectorMeshFaceFromScriptValue(const QScriptValue& array, QVector<MeshFace>
|
||||||
|
|
||||||
QVariantMap parseTexturesToMap(QString textures, const QVariantMap& defaultTextures);
|
QVariantMap parseTexturesToMap(QString textures, const QVariantMap& defaultTextures);
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(StencilMode)
|
|
||||||
QScriptValue stencilModeToScriptValue(QScriptEngine* engine, const StencilMode& stencilMode);
|
|
||||||
void stencilModeFromScriptValue(const QScriptValue &object, StencilMode& stencilMode);
|
|
||||||
|
|
||||||
#endif // hifi_RegisteredMetaTypes_h
|
#endif // hifi_RegisteredMetaTypes_h
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
//
|
|
||||||
// Created by Sam Gondelman on 3/26/19.
|
|
||||||
// Copyright 2019 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_StencilMode_h
|
|
||||||
#define hifi_StencilMode_h
|
|
||||||
|
|
||||||
enum class StencilMode {
|
|
||||||
NONE = -1, // for legacy reasons, this is -1
|
|
||||||
PAINT = 0,
|
|
||||||
MESH = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // hifi_StencilMode_h
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ if (WIN32 AND (NOT USE_GLES))
|
||||||
link_hifi_libraries(
|
link_hifi_libraries(
|
||||||
shared task gl shaders gpu ${PLATFORM_GL_BACKEND} controllers ui qml
|
shared task gl shaders gpu ${PLATFORM_GL_BACKEND} controllers ui qml
|
||||||
plugins ui-plugins display-plugins input-plugins
|
plugins ui-plugins display-plugins input-plugins
|
||||||
audio-client networking render-utils graphics
|
audio-client networking render-utils
|
||||||
${PLATFORM_GL_BACKEND}
|
${PLATFORM_GL_BACKEND}
|
||||||
)
|
)
|
||||||
include_hifi_library_headers(octree)
|
include_hifi_library_headers(octree)
|
||||||
|
|
|
@ -227,66 +227,3 @@ QVector<glm::vec3> OculusBaseDisplayPlugin::getSensorPositions() {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayPlugin::StencilMaskMeshOperator OculusBaseDisplayPlugin::getStencilMaskMeshOperator() {
|
|
||||||
if (_session) {
|
|
||||||
if (!_stencilMeshesInitialized) {
|
|
||||||
_stencilMeshesInitialized = true;
|
|
||||||
ovr::for_each_eye([&](ovrEyeType eye) {
|
|
||||||
ovrFovStencilDesc stencilDesc = {
|
|
||||||
ovrFovStencil_HiddenArea, 0, eye,
|
|
||||||
_eyeRenderDescs[eye].Fov, _eyeRenderDescs[eye].HmdToEyePose.Orientation
|
|
||||||
};
|
|
||||||
// First we get the size of the buffer we need
|
|
||||||
ovrFovStencilMeshBuffer buffer = { 0, 0, nullptr, 0, 0, nullptr };
|
|
||||||
ovrResult result = ovr_GetFovStencil(_session, &stencilDesc, &buffer);
|
|
||||||
if (!OVR_SUCCESS(result)) {
|
|
||||||
_stencilMeshesInitialized = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<ovrVector2f> ovrVertices(buffer.UsedVertexCount);
|
|
||||||
std::vector<uint16_t> ovrIndices(buffer.UsedIndexCount);
|
|
||||||
|
|
||||||
// Now we populate the actual buffer
|
|
||||||
buffer = { (int)ovrVertices.size(), 0, ovrVertices.data(), (int)ovrIndices.size(), 0, ovrIndices.data() };
|
|
||||||
result = ovr_GetFovStencil(_session, &stencilDesc, &buffer);
|
|
||||||
|
|
||||||
if (!OVR_SUCCESS(result)) {
|
|
||||||
_stencilMeshesInitialized = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<glm::vec3> vertices;
|
|
||||||
vertices.reserve(ovrVertices.size());
|
|
||||||
for (auto& ovrVertex : ovrVertices) {
|
|
||||||
// We need the vertices in clip space
|
|
||||||
vertices.emplace_back(ovrVertex.x - (1.0f - (float)eye), 2.0f * ovrVertex.y - 1.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint32_t> indices;
|
|
||||||
indices.reserve(ovrIndices.size());
|
|
||||||
for (auto& ovrIndex : ovrIndices) {
|
|
||||||
indices.push_back(ovrIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
_stencilMeshes[eye] = graphics::Mesh::createIndexedTriangles_P3F((uint32_t)vertices.size(), (uint32_t)indices.size(), vertices.data(), indices.data());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_stencilMeshesInitialized) {
|
|
||||||
return [&](gpu::Batch& batch) {
|
|
||||||
for (auto& mesh : _stencilMeshes) {
|
|
||||||
batch.setIndexBuffer(mesh->getIndexBuffer());
|
|
||||||
batch.setInputFormat((mesh->getVertexFormat()));
|
|
||||||
batch.setInputStream(0, mesh->getVertexStream());
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
auto part = mesh->getPartBuffer().get<graphics::Mesh::Part>(0);
|
|
||||||
batch.drawIndexed(gpu::TRIANGLES, part._numIndices, part._startIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
|
@ -16,8 +16,6 @@
|
||||||
#define OVRPL_DISABLED
|
#define OVRPL_DISABLED
|
||||||
#include <OVR_Platform.h>
|
#include <OVR_Platform.h>
|
||||||
|
|
||||||
#include <graphics/Geometry.h>
|
|
||||||
|
|
||||||
class OculusBaseDisplayPlugin : public HmdDisplayPlugin {
|
class OculusBaseDisplayPlugin : public HmdDisplayPlugin {
|
||||||
using Parent = HmdDisplayPlugin;
|
using Parent = HmdDisplayPlugin;
|
||||||
public:
|
public:
|
||||||
|
@ -36,9 +34,6 @@ public:
|
||||||
QRectF getPlayAreaRect() override;
|
QRectF getPlayAreaRect() override;
|
||||||
QVector<glm::vec3> getSensorPositions() override;
|
QVector<glm::vec3> getSensorPositions() override;
|
||||||
|
|
||||||
virtual StencilMode getStencilMaskMode() const override { return StencilMode::MESH; }
|
|
||||||
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void customizeContext() override;
|
void customizeContext() override;
|
||||||
void uncustomizeContext() override;
|
void uncustomizeContext() override;
|
||||||
|
@ -57,7 +52,4 @@ protected:
|
||||||
// ovrLayerEyeFovDepth _depthLayer;
|
// ovrLayerEyeFovDepth _depthLayer;
|
||||||
bool _hmdMounted { false };
|
bool _hmdMounted { false };
|
||||||
bool _visible { true };
|
bool _visible { true };
|
||||||
|
|
||||||
std::array<graphics::MeshPointer, 2> _stencilMeshes;
|
|
||||||
bool _stencilMeshesInitialized { false };
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -784,49 +784,3 @@ QRectF OpenVrDisplayPlugin::getPlayAreaRect() {
|
||||||
|
|
||||||
return QRectF(center.x, center.y, dimensions.x, dimensions.y);
|
return QRectF(center.x, center.y, dimensions.x, dimensions.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DisplayPlugin::StencilMaskMeshOperator OpenVrDisplayPlugin::getStencilMaskMeshOperator() {
|
|
||||||
if (_system) {
|
|
||||||
if (!_stencilMeshesInitialized) {
|
|
||||||
_stencilMeshesInitialized = true;
|
|
||||||
for (auto eye : VR_EYES) {
|
|
||||||
vr::HiddenAreaMesh_t stencilMesh = _system->GetHiddenAreaMesh(eye);
|
|
||||||
if (stencilMesh.pVertexData && stencilMesh.unTriangleCount > 0) {
|
|
||||||
std::vector<glm::vec3> vertices;
|
|
||||||
std::vector<uint32_t> indices;
|
|
||||||
|
|
||||||
const int NUM_INDICES_PER_TRIANGLE = 3;
|
|
||||||
int numIndices = stencilMesh.unTriangleCount * NUM_INDICES_PER_TRIANGLE;
|
|
||||||
vertices.reserve(numIndices);
|
|
||||||
indices.reserve(numIndices);
|
|
||||||
for (int i = 0; i < numIndices; i++) {
|
|
||||||
vr::HmdVector2_t vertex2D = stencilMesh.pVertexData[i];
|
|
||||||
// We need the vertices in clip space
|
|
||||||
vertices.emplace_back(vertex2D.v[0] - (1.0f - (float)eye), 2.0f * vertex2D.v[1] - 1.0f, 0.0f);
|
|
||||||
indices.push_back(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
_stencilMeshes[eye] = graphics::Mesh::createIndexedTriangles_P3F((uint32_t)vertices.size(), (uint32_t)indices.size(), vertices.data(), indices.data());
|
|
||||||
} else {
|
|
||||||
_stencilMeshesInitialized = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_stencilMeshesInitialized) {
|
|
||||||
return [&](gpu::Batch& batch) {
|
|
||||||
for (auto& mesh : _stencilMeshes) {
|
|
||||||
batch.setIndexBuffer(mesh->getIndexBuffer());
|
|
||||||
batch.setInputFormat((mesh->getVertexFormat()));
|
|
||||||
batch.setInputStream(0, mesh->getVertexStream());
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
auto part = mesh->getPartBuffer().get<graphics::Mesh::Part>(0);
|
|
||||||
batch.drawIndexed(gpu::TRIANGLES, part._numIndices, part._startIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
|
@ -13,8 +13,6 @@
|
||||||
|
|
||||||
#include <display-plugins/hmd/HmdDisplayPlugin.h>
|
#include <display-plugins/hmd/HmdDisplayPlugin.h>
|
||||||
|
|
||||||
#include <graphics/Geometry.h>
|
|
||||||
|
|
||||||
const float TARGET_RATE_OpenVr = 90.0f; // FIXME: get from sdk tracked device property? This number is vive-only.
|
const float TARGET_RATE_OpenVr = 90.0f; // FIXME: get from sdk tracked device property? This number is vive-only.
|
||||||
|
|
||||||
namespace gl {
|
namespace gl {
|
||||||
|
@ -69,9 +67,6 @@ public:
|
||||||
|
|
||||||
QRectF getPlayAreaRect() override;
|
QRectF getPlayAreaRect() override;
|
||||||
|
|
||||||
virtual StencilMode getStencilMaskMode() const override{ return StencilMode::MESH; }
|
|
||||||
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool internalActivate() override;
|
bool internalActivate() override;
|
||||||
void internalDeactivate() override;
|
void internalDeactivate() override;
|
||||||
|
@ -99,7 +94,4 @@ private:
|
||||||
bool _asyncReprojectionActive { false };
|
bool _asyncReprojectionActive { false };
|
||||||
|
|
||||||
bool _hmdMounted { false };
|
bool _hmdMounted { false };
|
||||||
|
|
||||||
std::array<graphics::MeshPointer, 2> _stencilMeshes;
|
|
||||||
bool _stencilMeshesInitialized { false };
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue