diff --git a/KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs b/KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs index 803e3d89..6770a285 100644 --- a/KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs +++ b/KerbalVR_Mod/KerbalVR/InteractionSystem/KerbalVR_Hand.cs @@ -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() { @@ -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()