Skip to content

Commit

Permalink
Enable specification of the number of desired triangles in the genera…
Browse files Browse the repository at this point in the history
…ted distortion mesh in the configuration file.
  • Loading branch information
russell-taylor committed Jun 11, 2017
1 parent 4fb158a commit 7aacbd2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions osvr/RenderKit/DistortionParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion osvr/RenderKit/RenderManagerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions osvr/RenderKit/osvr_display_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -783,6 +788,11 @@ OSVRDisplayConfiguration::getDistortionPolynomalBlue() const {
return m_distortionPolynomialBlue;
}

int OSVR_RENDERMANAGER_EXPORT
OSVRDisplayConfiguration::getDesiredDistortionTriangleCount() const {
return m_distortionDesiredTriangleCount;
}

std::vector<OSVRDisplayConfiguration::EyeInfo> const&
OSVRDisplayConfiguration::getEyes() const {
return m_eyes;
Expand Down
4 changes: 4 additions & 0 deletions osvr/RenderKit/osvr_display_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class OSVRDisplayConfiguration {
std::vector<float> 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:
Expand Down Expand Up @@ -186,6 +189,7 @@ class OSVRDisplayConfiguration {
std::vector<float> m_distortionPolynomialRed;
std::vector<float> m_distortionPolynomialGreen;
std::vector<float> m_distortionPolynomialBlue;
int m_distortionDesiredTriangleCount;

// Rendering
double m_rightRoll = 0.;
Expand Down

0 comments on commit 7aacbd2

Please sign in to comment.