Skip to content

Commit

Permalink
Do not scale if no need to scale
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Nov 21, 2024
1 parent 67746bb commit 25a1bd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/progressed/graphics/draw3d/Perspective.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ public static void viewportSize(){

public static Vec3 scaleToViewport(float x, float y, float z){
float cx = camera.position.x, cy = camera.position.y;
float cz = cameraZ;

if(z < viewportZ()) return scalingPos.set(x - cx, y - cy, z);

x -= cx;
y -= cy;
float zz = cz - z;
float zz = cameraZ - z;

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

public static float dstToViewport(float x, float y, float z){
Vec3 scaled = scaleToViewport(x, y, z);
float cx = camera.position.x, cy = camera.position.y;
return scaled.dst(x - cx, y - cy, z);
return scaled.dst(x - camera.position.x, y - camera.position.y, z);
}

/**
Expand Down

0 comments on commit 25a1bd4

Please sign in to comment.