Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,33 @@ public bool IsFingerTrackingPinching()

return false;
}

private float GetSteamVRWorldScale()
{
try
{
var chaperone = OpenVR.Chaperone;
if (chaperone != null)
{
float x = 0f, z = 0f;
chaperone.GetPlayAreaSize(ref x, ref z);

// Baseline play area is 2x2 meters at 100% scale
// World scale is inversely proportional to play area size
const float baseline = 2.0f;
float worldScale = baseline / x;

return worldScale;
}
}
catch (System.Exception e)
{
Utils.LogError($"[WorldScale] Error: {e.Message}");
}

// Utils.LogWarning("[WorldScale] Could not get play area, using 1.0");
return 1.0f;
}

protected void Update()
{
Expand Down Expand Up @@ -525,6 +552,14 @@ protected void Update()
handObject.SetActive(isRendering);

}

// Compensate for world scale
if (isRendering && isRenderingHands.IsChanged())
{
float worldScale = GetSteamVRWorldScale();
transform.localScale = Vector3.one / worldScale;
}

}

private void UpdateCollider()
Expand Down