float XAxisMultiplier;
4. float YAxisMultiplier;
5. if (CaptureSize.X > CaptureSize.Y) {
6. // if viewport is wider than it is tall
7. XAxisMultiplier = 1.0f;
8. YAxisMultiplier = CaptureSize.X / (float)CaptureSize.Y;
9. } else {
10. // if viewport is taller than it is wide
11. XAxisMultiplier = CaptureSize.Y / (float)CaptureSize.X;
12. YAxisMultiplier = 1.0f;
13. }
14. USceneCaptureComponent2D* SceneCapture2D = Cast(SceneCaptureComponent);
15. if( SceneCapture2D && SceneCapture2D->ProjectionMode == ECameraProjectionMode::Orthographic ) {
16. if (SceneCapture2D->bConstrainAspectRatio)
17. {
18. const float YScale = 1.0f / SceneCapture2D->AspectRatio;
19.
20. const float OrthoWidth = SceneCapture2D->OrthoWidth / 2.0f;
21. const float OrthoHeight = SceneCapture2D->OrthoWidth / 2.0f * YScale;
22.
23. const float NearPlane = SceneCapture2D->OrthoNearClipPlane;
24. const float FarPlane = SceneCapture2D->OrthoFarClipPlane;
25.
26. const float ZScale = 1.0f / (FarPlane - NearPlane);
27. const float ZOffset = -NearPlane;
28.
29. ViewInitOptions.ProjectionMatrix = FReversedZOrthoMatrix(
30. OrthoWidth,
31. OrthoHeight,
32. ZScale,
33. ZOffset
34. );
35. }