MCPcopy Create free account
hub / github.com/LibreVR/Revive / ovr_TestBoundaryPoint

Function ovr_TestBoundaryPoint

ReviveXR/REV_CAPI.cpp:634–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634OVR_PUBLIC_FUNCTION(ovrResult) ovr_TestBoundaryPoint(ovrSession session, const ovrVector3f* point,
635 ovrBoundaryType singleBoundaryType, ovrBoundaryTestResult* outTestResult)
636{
637 REV_TRACE(ovr_TestBoundaryPoint);
638
639 ovrBoundaryTestResult result = { 0 };
640
641 result.IsTriggering = ovrFalse;
642
643 ovrVector3f bounds;
644 CHK_OVR(ovr_GetBoundaryDimensions(session, singleBoundaryType, &bounds));
645
646 // Clamp the point to the AABB
647 OVR::Vector2f p(point->x, point->z);
648 OVR::Vector2f halfExtents(bounds.x / 2.0f, bounds.z / 2.0f);
649 OVR::Vector2f clamped = OVR::Vector2f::Min(OVR::Vector2f::Max(p, -halfExtents), halfExtents);
650
651 // If the point is inside the AABB, we need to do some extra work
652 if (clamped.Compare(p))
653 {
654 if (std::abs(p.x) > std::abs(p.y))
655 clamped.x = halfExtents.x * (p.x / std::abs(p.x));
656 else
657 clamped.y = halfExtents.y * (p.y / std::abs(p.y));
658 }
659
660 // We don't have a ceiling, use the height from the original point
661 result.ClosestPoint.x = clamped.x;
662 result.ClosestPoint.y = point->y;
663 result.ClosestPoint.z = clamped.y;
664
665 // Get the normal, closest distance is the length of this normal
666 OVR::Vector2f normal = p - clamped;
667 result.ClosestDistance = normal.Length();
668
669 // Normalize the normal
670 normal.Normalize();
671 result.ClosestPointNormal.x = normal.x;
672 result.ClosestPointNormal.y = 0.0f;
673 result.ClosestPointNormal.z = normal.y;
674
675 *outTestResult = result;
676 return ovrSuccess;
677}
678
679OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetBoundaryLookAndFeel(ovrSession session, const ovrBoundaryLookAndFeel* lookAndFeel)
680{

Callers 1

ovr_TestBoundaryFunction · 0.70

Calls 1

Tested by

no test coverage detected