From f01886433e096ba3048dae1052739770c73417ee Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Tue, 15 Aug 2023 22:57:49 -0700 Subject: [PATCH] Camera: trivial refactoring --- .../com/github/stephengold/vsport/Camera.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/src/main/java/com/github/stephengold/vsport/Camera.java b/lib/src/main/java/com/github/stephengold/vsport/Camera.java index e72ed04c..89cc0e25 100644 --- a/lib/src/main/java/com/github/stephengold/vsport/Camera.java +++ b/lib/src/main/java/com/github/stephengold/vsport/Camera.java @@ -277,9 +277,11 @@ public Camera setLocation(Vector3fc location) { * @return the (modified) current instance (for chaining) */ public Camera setLookDirection(Vector3fc direction) { - this.azimuthRadians = FastMath.atan2(direction.z, direction.x); - float nxz = MyMath.hypotenuse(direction.x, direction.z); - this.upAngleRadians = FastMath.atan2(direction.y, nxz); + float y = direction.y(); + float z = direction.z(); + this.azimuthRadians = FastMath.atan2(z, direction.x()); + float nxz = MyMath.hypotenuse(direction.x(), z); + this.upAngleRadians = FastMath.atan2(y, nxz); updateDirectionVectors(); return this; @@ -327,8 +329,11 @@ public float upAngle() { * @param storeMatrix the matrix to update (not null, modified) */ void updateViewMatrix(Matrix4f storeMatrix) { - Vector3f tmpTarget = new Vector3f(eyeLocation).add(lookDirection); - storeMatrix.setLookAt(eyeLocation, tmpTarget, upDirection); + storeMatrix.setLookAt(eyeLocation.x, eyeLocation.y, eyeLocation.z, + eyeLocation.x + lookDirection.x, + eyeLocation.y + lookDirection.y, + eyeLocation.z + lookDirection.z, + upDirection.x, upDirection.y, upDirection.z); } /**