From caa59cd72f861fcd04b54cf091814e03840f979e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Fri, 14 Nov 2025 15:18:42 +0100 Subject: [PATCH] implement camera/position quantization --- .../engine/FpsCameraController.java | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java b/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java index 6dede62..6e9c884 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java +++ b/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java @@ -17,12 +17,22 @@ public class FpsCameraController { private float yaw = 0f; private float pitch = 0f; - private float eyeHeight = 1.8f; + private final float eyeHeight = 1.8f; + private final float jumpSpeed = 12f; + private final float gravity = -50f; private float velocityY = 0f; - private float gravity = -50f; - private float jumpSpeed = 12f; private boolean grounded = false; + // --- approximation toggles + private final boolean retroQuantization = true; + + // how coarse the rotation is (0.25f = round to 0.25°) + private final float yawStepDegrees = 0.2f; + private final float pitchStepDegrees = 0.2f; + + // how coarse the position is (16f = steps of 1/16 units) + private final float positionQuantize = 64f; + private final Vector3 tmpForward = new Vector3(); private final Vector3 tmpRight = new Vector3(); @@ -205,12 +215,29 @@ public class FpsCameraController { velocityY = jumpSpeed; grounded = false; } + + // snap position to quantization steps + if (retroQuantization) { + float q = positionQuantize; + camera.position.x = Math.round(camera.position.x * q) / q; + camera.position.y = Math.round(camera.position.y * q) / q; + camera.position.z = Math.round(camera.position.z * q) / q; + } } private void updateCameraDirection() { // build direction vector from yaw/pitch - float yawRad = (float) Math.toRadians(yaw); - float pitchRad = (float) Math.toRadians(pitch); + float useYaw = yaw; + float usePitch = pitch; + + if (retroQuantization) { + // snap yaw/pitch to fixed angular steps + useYaw = Math.round(useYaw / yawStepDegrees) * yawStepDegrees; + usePitch = Math.round(usePitch / pitchStepDegrees) * pitchStepDegrees; + } + + float yawRad = (float) Math.toRadians(useYaw); + float pitchRad = (float) Math.toRadians(usePitch); float x = (float) (Math.cos(pitchRad) * Math.sin(yawRad)); float y = (float) Math.sin(pitchRad);