8 Commits

3 changed files with 35 additions and 8 deletions

View File

@@ -17,12 +17,22 @@ public class FpsCameraController {
private float yaw = 0f; private float yaw = 0f;
private float pitch = 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 velocityY = 0f;
private float gravity = -50f;
private float jumpSpeed = 12f;
private boolean grounded = false; 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 tmpForward = new Vector3();
private final Vector3 tmpRight = new Vector3(); private final Vector3 tmpRight = new Vector3();
@@ -205,12 +215,29 @@ public class FpsCameraController {
velocityY = jumpSpeed; velocityY = jumpSpeed;
grounded = false; 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() { private void updateCameraDirection() {
// build direction vector from yaw/pitch // build direction vector from yaw/pitch
float yawRad = (float) Math.toRadians(yaw); float useYaw = yaw;
float pitchRad = (float) Math.toRadians(pitch); 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 x = (float) (Math.cos(pitchRad) * Math.sin(yawRad));
float y = (float) Math.sin(pitchRad); float y = (float) Math.sin(pitchRad);

View File

@@ -4,9 +4,9 @@ buildscript {
gradlePluginPortal() gradlePluginPortal()
} }
dependencies { dependencies {
classpath "io.github.fourlastor:construo:2.0.2" classpath "io.github.fourlastor:construo:2.1.0"
if(enableGraalNative == 'true') { if(enableGraalNative == 'true') {
classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.9.28" classpath "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.11.3"
} }
} }
} }

View File

@@ -1,6 +1,6 @@
plugins { plugins {
// Applies the foojay-resolver plugin to allow automatic download of JDKs. // Applies the foojay-resolver plugin to allow automatic download of JDKs.
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0" id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
} }
// A list of which subprojects to load as part of the same larger project. // A list of which subprojects to load as part of the same larger project.
// You can remove Strings from the list and reload the Gradle project // You can remove Strings from the list and reload the Gradle project