Skip to content

Commit

Permalink
OpenXR: Fix cylinder layer not correcting the distance
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 3, 2023
1 parent 8ab7fa0 commit 363fe91
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mods/vr/OverlayComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,12 @@ std::optional<std::reference_wrapper<XrCompositionLayerCylinderKHR>> OverlayComp
// radius is the non-negative radius of the cylinder. Values of zero or floating point positive infinity are treated as an infinite cylinder.
// centralAngle is the angle of the visible section of the cylinder, based at 0 radians, in the range of [0, 2π). It grows symmetrically around the 0 radian angle.
// aspectRatio is the ratio of the visible cylinder section width / height. The height of the cylinder is given by: (cylinder radius × cylinder angle) / aspectRatio.
layer.radius = meters_w / 2.0f;
layer.centralAngle = glm::radians(m_parent->m_slate_cylinder_angle->value());
layer.aspectRatio = meters_w / meters_h;
layer.centralAngle = glm::max<float>(1.0f, glm::radians(m_parent->m_slate_cylinder_angle->value()));
layer.aspectRatio = (meters_w / meters_h);
layer.radius = (meters_h / layer.centralAngle) * layer.aspectRatio;

glm_matrix[3] -= glm_matrix[2] * m_parent->m_slate_distance->value();
glm_matrix[3] += glm_matrix[2] * layer.radius;
glm_matrix[3] += m_parent->m_slate_x_offset->value() * glm_matrix[0];
glm_matrix[3] += m_parent->m_slate_y_offset->value() * glm_matrix[1];
glm_matrix[3].w = 1.0f;
Expand Down

0 comments on commit 363fe91

Please sign in to comment.