diff --git a/server/core/src/main/java/dev/slimevr/skeleton/ik.kt b/server/core/src/main/java/dev/slimevr/skeleton/ik.kt index dfa9a5b86..868b98f5d 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/ik.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/ik.kt @@ -115,7 +115,7 @@ fun ccdIk( threshold: Float, maxIterations: Int, ): IKOutput { - // No goals leaves every bone as the FK pass built it, so nothing below needs to run + // No goal leaves every bone as the FK pass built it, so nothing below needs to run if (goals.isEmpty()) return IKOutput(bones, emptyMap()) val workingBoneInputs = EnumMap(boneInputs) diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/neck.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/neck.kt index 5d17fb212..c7b26edb0 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/neck.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/neck.kt @@ -14,17 +14,17 @@ private const val DOWN_RATIO = 1.1f * Guesses where the neck is supposed to be when the user has a head tracker but no neck tracker. * * Tries to mitigate the problem where looking down make your whole tracking go down (or - * knees bend if floorclip is enabled). + * knees bend if floor-clip is enabled). */ class NeckInputProcessor : SkeletonInputProcessor { override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { - val headBone = mutableInputSkeleton[BodyPart.HEAD] ?: return val neckBone = mutableInputSkeleton[BodyPart.NECK] ?: return - val upperChestBone = mutableInputSkeleton[BodyPart.UPPER_CHEST] ?: return - if (!headBone.isRotationActive || neckBone.isRotationActive) return + if (neckBone.isRotationActive) return + val upperChestRotation = mutableInputSkeleton[BodyPart.UPPER_CHEST]?.rotation ?: return + val headRotation = mutableInputSkeleton[BodyPart.HEAD]?.rotation ?: return // Work with the rotation delta to avoid axes being ambiguous - val delta = upperChestBone.rotation.inv() * headBone.rotation + val delta = upperChestRotation.inv() * headRotation // Decompose the delta into its twist (forward) and swing (remaining/sides) along the x-axis val forward = delta.project(Vector3.POS_X).unit() @@ -34,7 +34,7 @@ class NeckInputProcessor : SkeletonInputProcessor { val ratio = if (forward.x < 0f) DOWN_RATIO else UP_RATIO val scaledDelta = side * forward.pow(ratio) - val newRotation = upperChestBone.rotation * scaledDelta + val newRotation = upperChestRotation * scaledDelta mutableInputSkeleton[BodyPart.NECK] = neckBone.copy(rotation = newRotation) } }