Skip to content

Commit

Permalink
Merge pull request #320 from sensics/distortion-mesh-size-in-config-file
Browse files Browse the repository at this point in the history
Enable specification of the number of desired triangles in the genera…
  • Loading branch information
JeroMiya authored Nov 14, 2017
2 parents 60b6f3e + 7aacbd2 commit 15a4b27
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 @@ -2311,7 +2311,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 @@ -532,6 +532,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 @@ -790,6 +795,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 @@ -133,6 +133,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 @@ -192,6 +195,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 15a4b27

Please sign in to comment.