@@ -28,6 +28,8 @@ public class Perspective{
28
28
if (!headless ){
29
29
Events .run (Trigger .preDraw , () -> {
30
30
int newFov = settings .getInt ("pm-fov" , 60 );
31
+
32
+ //Recalculate viewport size on scale or fov change
31
33
if (renderer .getDisplayScale () != lastScale || newFov != fov ){
32
34
lastScale = renderer .getDisplayScale ();
33
35
fov = newFov ;
@@ -111,18 +113,6 @@ public static float viewportZ(){
111
113
return cameraZ - viewportOffset ;
112
114
}
113
115
114
- /** Calculates the size of the viewport. */
115
- public static void viewportSize (){
116
- float v1 = (float )(Math .tan (fov / 2f * Mathf .degRad ) * viewportOffset * 2f );
117
- if (camera .width >= camera .height ){
118
- float v2 = v1 * (camera .height / camera .width );
119
- viewportSize .set (v1 , v2 );
120
- }else {
121
- float v2 = v1 * (camera .width / camera .height );
122
- viewportSize .set (v2 , v1 );
123
- }
124
- }
125
-
126
116
public static Vec3 scaleToViewport (float x , float y , float z ){
127
117
if (z <= groundTolerance ) return scalingPos .set (x , y , 0 );
128
118
@@ -142,6 +132,18 @@ public static float dstToViewport(float x, float y, float z){
142
132
return scaled .dst (x - camera .position .x , y - camera .position .y , z );
143
133
}
144
134
135
+ /** Calculates the size of the viewport. */
136
+ private static void viewportSize (){
137
+ float v1 = (float )(Math .tan (fov / 2f * Mathf .degRad ) * viewportOffset * 2f );
138
+ if (camera .width >= camera .height ){
139
+ float v2 = v1 * (camera .height / camera .width );
140
+ viewportSize .set (v1 , v2 );
141
+ }else {
142
+ float v2 = v1 * (camera .width / camera .height );
143
+ viewportSize .set (v2 , v1 );
144
+ }
145
+ }
146
+
145
147
/**
146
148
* Calculates the camera z coordinate based on FOV and the size of the vanilla camera.
147
149
* @return camera z coordinate
0 commit comments