From 98d7606b66a700aebf1eec555af9b871520810cf Mon Sep 17 00:00:00 2001 From: Erimel Date: Wed, 7 Oct 2026 14:37:32 -0400 Subject: [PATCH] clamp upsampling skeleton processor --- .../main/java/dev/slimevr/heightcalibration/behaviours.kt | 6 +++--- .../java/dev/slimevr/skeleton/inputprocessors/upsampling.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/core/src/main/java/dev/slimevr/heightcalibration/behaviours.kt b/server/core/src/main/java/dev/slimevr/heightcalibration/behaviours.kt index 24eeab7fc..a824089b9 100644 --- a/server/core/src/main/java/dev/slimevr/heightcalibration/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/heightcalibration/behaviours.kt @@ -2,6 +2,7 @@ package dev.slimevr.heightcalibration +import com.jme3.math.FastMath import dev.slimevr.config.UserConfig import dev.slimevr.config.UserConfigActions import dev.slimevr.skeleton.computeDefaultProportionsByBone @@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.withTimeoutOrNull import solarxr_protocol.datatypes.BodyPart import solarxr_protocol.rpc.UserHeightCalibrationStatus -import kotlin.math.PI import kotlin.math.cos import kotlin.math.sqrt @@ -37,8 +37,8 @@ internal const val HEAD_RISE_THRESHOLD = 1.2f internal const val HEIGHT_MIN = 1.4f internal const val HEIGHT_MAX = 1.936f -private val HEAD_ANGLE_THRESHOLD = cos((PI / 180.0) * 15.0) -private val CONTROLLER_ANGLE_THRESHOLD = cos((PI / 180.0) * 45.0) +private val HEAD_ANGLE_THRESHOLD = cos(FastMath.DEG_TO_RAD * 15.0) +private val CONTROLLER_ANGLE_THRESHOLD = cos(FastMath.DEG_TO_RAD * 60.0) internal const val TIMEOUT_MS = 30_000L diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/upsampling.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/upsampling.kt index 76d930d88..547dfc297 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/upsampling.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/upsampling.kt @@ -46,7 +46,7 @@ class UpsamplingInputProcessor : if (bone.expectedTps == null) return@forEachBone // For a 100hz tracker on 500hz skeleton, this will be 0.2f (interpolating 1/5 every frame) - val interpolationRatio = deltaTime * bone.expectedTps.toFloat() + val interpolationRatio = (deltaTime * bone.expectedTps.toFloat()).coerceAtMost(1f) val newBone = interpolationData[bodyPart]?.let { interpolation -> // Interpolate rotation, acceleration and position. val rotation = if (bone.isRotationActive) {