From 7aacbd27b9fd5124de2e8aaf81d197ce962aed9b Mon Sep 17 00:00:00 2001 From: Russ Taylor Date: Sat, 10 Jun 2017 21:19:00 -0400 Subject: [PATCH] Enable specification of the number of desired triangles in the generated distortion mesh in the configuration file. --- osvr/RenderKit/DistortionParameters.cpp | 1 + osvr/RenderKit/RenderManagerBase.cpp | 1 - osvr/RenderKit/osvr_display_configuration.cpp | 10 ++++++++++ osvr/RenderKit/osvr_display_configuration.h | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/osvr/RenderKit/DistortionParameters.cpp b/osvr/RenderKit/DistortionParameters.cpp index e03e3af..6b44c43 100644 --- a/osvr/RenderKit/DistortionParameters.cpp +++ b/osvr/RenderKit/DistortionParameters.cpp @@ -35,6 +35,7 @@ namespace osvr { OSVR_RENDERMANAGER_EXPORT DistortionParameters::DistortionParameters( OSVRDisplayConfiguration& osvrParams, size_t eye) : DistortionParameters() { + m_desiredTriangles = osvrParams.getDesiredDistortionTriangleCount(); if (osvrParams.getDistortionType() == OSVRDisplayConfiguration::RGB_SYMMETRIC_POLYNOMIALS) { m_type = rgb_symmetric_polynomials; diff --git a/osvr/RenderKit/RenderManagerBase.cpp b/osvr/RenderKit/RenderManagerBase.cpp index 22ab333..62aa13f 100644 --- a/osvr/RenderKit/RenderManagerBase.cpp +++ b/osvr/RenderKit/RenderManagerBase.cpp @@ -2160,7 +2160,6 @@ namespace renderkit { // @todo Remove once we get a general polynomial from Core. for (size_t i = 0; i < p.m_displayConfiguration->getEyes().size(); i++) { DistortionParameters distortion(*p.m_displayConfiguration, i); - distortion.m_desiredTriangles = 200 * 64; p.m_distortionParameters.push_back(distortion); } diff --git a/osvr/RenderKit/osvr_display_configuration.cpp b/osvr/RenderKit/osvr_display_configuration.cpp index 0e07272..cd2f36d 100644 --- a/osvr/RenderKit/osvr_display_configuration.cpp +++ b/osvr/RenderKit/osvr_display_configuration.cpp @@ -530,6 +530,11 @@ void OSVRDisplayConfiguration::parse(const std::string& display_description) { { auto const& distortion = hmd["distortion"]; + /// Find out how many desired triangles, if this is specified. + /// If not specified, set to a default. + m_distortionDesiredTriangleCount = + distortion.get("desired_triangle_count", 200 * 64).asInt(); + /// We will detect distortion type based on either the explicitly /// specified string or the presence of essential object members. m_distortionTypeString = distortion["type"].asString(); @@ -783,6 +788,11 @@ OSVRDisplayConfiguration::getDistortionPolynomalBlue() const { return m_distortionPolynomialBlue; } +int OSVR_RENDERMANAGER_EXPORT +OSVRDisplayConfiguration::getDesiredDistortionTriangleCount() const { + return m_distortionDesiredTriangleCount; +} + std::vector const& OSVRDisplayConfiguration::getEyes() const { return m_eyes; diff --git a/osvr/RenderKit/osvr_display_configuration.h b/osvr/RenderKit/osvr_display_configuration.h index b4b7fc3..39f3700 100644 --- a/osvr/RenderKit/osvr_display_configuration.h +++ b/osvr/RenderKit/osvr_display_configuration.h @@ -132,6 +132,9 @@ class OSVRDisplayConfiguration { std::vector const& getDistortionPolynomalBlue() const; ///@} + /// Returns the desired number of triangles in the constructed distortion mesh. + int OSVR_RENDERMANAGER_EXPORT getDesiredDistortionTriangleCount() const; + /// Structure holding the information for one eye. class EyeInfo { public: @@ -186,6 +189,7 @@ class OSVRDisplayConfiguration { std::vector m_distortionPolynomialRed; std::vector m_distortionPolynomialGreen; std::vector m_distortionPolynomialBlue; + int m_distortionDesiredTriangleCount; // Rendering double m_rightRoll = 0.;