Skip to content

Commit 1666034

Browse files
committed
Cache previousFieldOfView to use in case video capture starts
During video capture, the camera fov may change to not match what's actually being rendered.
1 parent 38e0556 commit 1666034

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Assets/MRTK/Services/DiagnosticsSystem/MixedRealityToolkitVisualProfiler.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ private void LateUpdate()
462462

463463
#if WINDOWS_UWP
464464
private void AppCapture_CapturingChanged(AppCapture sender, object args) => appCaptureIsCapturingVideo = sender.IsCapturingVideo;
465+
private float previousFieldOfView = -1.0f;
465466
#endif // WINDOWS_UWP
466467

467468
private static readonly ProfilerMarker CalculateWindowPositionPerfMarker = new ProfilerMarker("[MRTK] MixedRealityToolkitVisualProfiler.CalculateWindowPosition");
@@ -470,7 +471,13 @@ private Vector3 CalculateWindowPosition(Transform cameraTransform)
470471
{
471472
using (CalculateWindowPositionPerfMarker.Auto())
472473
{
473-
float windowDistance = Mathf.Max(16.0f / CameraCache.Main.fieldOfView, CameraCache.Main.nearClipPlane + 0.25f);
474+
float windowDistance =
475+
#if WINDOWS_UWP
476+
Mathf.Max(16.0f / (appCaptureIsCapturingVideo ? previousFieldOfView : previousFieldOfView = CameraCache.Main.fieldOfView), CameraCache.Main.nearClipPlane + 0.25f);
477+
#else
478+
Mathf.Max(16.0f / CameraCache.Main.fieldOfView, CameraCache.Main.nearClipPlane + 0.25f);
479+
#endif // WINDOWS_UWP
480+
474481
Vector3 position = cameraTransform.position + (cameraTransform.forward * windowDistance);
475482
Vector3 horizontalOffset = cameraTransform.right * windowOffset.x;
476483
Vector3 verticalOffset = cameraTransform.up * windowOffset.y;

0 commit comments

Comments
 (0)