Skip to content

Commit 25a1bd4

Browse files
committed
Do not scale if no need to scale
1 parent 67746bb commit 25a1bd4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/progressed/graphics/draw3d/Perspective.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ public static void viewportSize(){
118118

119119
public static Vec3 scaleToViewport(float x, float y, float z){
120120
float cx = camera.position.x, cy = camera.position.y;
121-
float cz = cameraZ;
121+
122+
if(z < viewportZ()) return scalingPos.set(x - cx, y - cy, z);
122123

123124
x -= cx;
124125
y -= cy;
125-
float zz = cz - z;
126+
float zz = cameraZ - z;
126127

127128
float vx = x / zz * viewportOffset, //Position scaled to near plane.
128129
vy = y / zz * viewportOffset;
@@ -133,8 +134,7 @@ public static Vec3 scaleToViewport(float x, float y, float z){
133134

134135
public static float dstToViewport(float x, float y, float z){
135136
Vec3 scaled = scaleToViewport(x, y, z);
136-
float cx = camera.position.x, cy = camera.position.y;
137-
return scaled.dst(x - cx, y - cy, z);
137+
return scaled.dst(x - camera.position.x, y - camera.position.y, z);
138138
}
139139

140140
/**

0 commit comments

Comments
 (0)