Skip to content

Commit 50c0a39

Browse files
committed
private
1 parent 139c02c commit 50c0a39

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/progressed/graphics/draw3d/Perspective.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class Perspective{
2828
if(!headless){
2929
Events.run(Trigger.preDraw, () -> {
3030
int newFov = settings.getInt("pm-fov", 60);
31+
32+
//Recalculate viewport size on scale or fov change
3133
if(renderer.getDisplayScale() != lastScale || newFov != fov){
3234
lastScale = renderer.getDisplayScale();
3335
fov = newFov;
@@ -111,18 +113,6 @@ public static float viewportZ(){
111113
return cameraZ - viewportOffset;
112114
}
113115

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-
126116
public static Vec3 scaleToViewport(float x, float y, float z){
127117
if(z <= groundTolerance) return scalingPos.set(x, y, 0);
128118

@@ -142,6 +132,18 @@ public static float dstToViewport(float x, float y, float z){
142132
return scaled.dst(x - camera.position.x, y - camera.position.y, z);
143133
}
144134

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+
145147
/**
146148
* Calculates the camera z coordinate based on FOV and the size of the vanilla camera.
147149
* @return camera z coordinate

0 commit comments

Comments
 (0)