From ebe5c6b0104ebabfd73b317832bac8d89c767eaa Mon Sep 17 00:00:00 2001 From: Erimel Date: Fri, 11 Sep 2026 17:29:01 -0400 Subject: [PATCH] Rewrite relaxed spine processor --- .../skeleton/inputprocessors/relaxed-spine.kt | 304 +++++++----------- ...bone-active-link.kt => toe-active-link.kt} | 46 ++- .../main/java/dev/slimevr/skeleton/module.kt | 4 +- 3 files changed, 143 insertions(+), 211 deletions(-) rename server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/{bone-active-link.kt => toe-active-link.kt} (52%) diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/relaxed-spine.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/relaxed-spine.kt index a76f0ce9d..c6d79a9af 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/relaxed-spine.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/relaxed-spine.kt @@ -7,7 +7,7 @@ import dev.slimevr.skeleton.InputSkeleton import dev.slimevr.skeleton.SkeletonInputProcessor import io.github.axisangles.ktmath.Quaternion import solarxr_protocol.datatypes.BodyPart -import java.util.EnumMap +import kotlin.enums.enumEntries // At this default value, the user's spine should behave as we meant it to. const val DEFAULT_SPINE_UPPER_LOWER = 0.5f @@ -21,99 +21,109 @@ private enum class SpineSource(val parts: Array) { UPPER_LEGS(arrayOf(BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG)), } -private val SPINE_BONES_TO_RELAX = arrayOf( - BodyPart.UPPER_CHEST, - BodyPart.LOWER_CHEST, - BodyPart.UPPER_WAIST, - BodyPart.LOWER_WAIST, - BodyPart.HIP, +private val SPINE_SOURCES = enumEntries().toTypedArray() +private val NB_SPINE_SOURCES = SPINE_SOURCES.count() + +/** Ordered from parent to child */ +private val SPINE_BONES = arrayOf( + SpineSource.UPPER_CHEST, + SpineSource.LOWER_CHEST, + SpineSource.UPPER_WAIST, + SpineSource.LOWER_WAIST, + SpineSource.HIP, ) -// TODO : fine tuning! :3 -// (also, refactoring this whole file as it has become a mess!) -// The higher a value is, the more reliable it is. +// The higher a value is, the more reliable that source is. // If a "To" is 2x the "From", it'll use 100% "To". // If a "To" is the same as "From", it'll do 50-50. -private fun reliabilityOf(bodyPart: BodyPart, source: SpineSource): Float = when (bodyPart) { - BodyPart.UPPER_CHEST -> when (source) { - // From - SpineSource.UPPER_CHEST -> 7f - - // To (negative to relax the spine - SpineSource.LOWER_CHEST -> -1f - - SpineSource.UPPER_WAIST -> -1.5f - - SpineSource.LOWER_WAIST -> -2f - - SpineSource.HIP -> -4f - - SpineSource.UPPER_LEGS -> -3f - } - - BodyPart.LOWER_CHEST -> when (source) { - // From - SpineSource.UPPER_CHEST -> 10f - - SpineSource.LOWER_CHEST -> 20f - - // To (negative to relax the spine - SpineSource.UPPER_WAIST -> -1.5f - - SpineSource.LOWER_WAIST -> -2f - - SpineSource.HIP -> -4f - - SpineSource.UPPER_LEGS -> -3f - } - - BodyPart.UPPER_WAIST -> when (source) { - // From - SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 10f - - SpineSource.UPPER_WAIST -> 68f - +// A negative value will go towards the opposite rotation. +// A From and To may be taken from different roots. +// TODO: Fine tune +private val SPINE_SOURCE_RELIABILITY = mapOf( + SpineSource.UPPER_CHEST to mapOf( + SpineSource.UPPER_CHEST to -6f, // Itself // To - SpineSource.LOWER_WAIST -> 17f - - SpineSource.HIP -> 5.5f - - SpineSource.UPPER_LEGS -> 4.5f - } - - BodyPart.LOWER_WAIST -> when (source) { + SpineSource.LOWER_CHEST to 1f, + SpineSource.UPPER_WAIST to 1.5f, + SpineSource.LOWER_WAIST to 2f, + SpineSource.HIP to 4f, + SpineSource.UPPER_LEGS to 3f, + ), + SpineSource.LOWER_CHEST to mapOf( // From - SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 6f - - SpineSource.UPPER_WAIST -> 6.25f - - SpineSource.LOWER_WAIST -> 44f - + SpineSource.UPPER_CHEST to -10f, + SpineSource.LOWER_CHEST to -11f, // Itself // To - SpineSource.HIP -> 10f - - SpineSource.UPPER_LEGS -> 4.25f - } - - BodyPart.HIP -> when (source) { + SpineSource.UPPER_WAIST to 1.5f, + SpineSource.LOWER_WAIST to 2f, + SpineSource.HIP to 4f, + SpineSource.UPPER_LEGS to 3f, + ), + SpineSource.UPPER_WAIST to mapOf( // From - SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 9.5f - - SpineSource.UPPER_WAIST -> 12.5f - - SpineSource.LOWER_WAIST -> 13f - - SpineSource.HIP -> 48f - + SpineSource.UPPER_CHEST to 10f, + SpineSource.LOWER_CHEST to 10f, + SpineSource.UPPER_WAIST to 68f, // Itself // To - SpineSource.UPPER_LEGS -> 13f - } + SpineSource.LOWER_WAIST to 17f, + SpineSource.HIP to 5.5f, + SpineSource.UPPER_LEGS to 4.5f, + ), + SpineSource.LOWER_WAIST to mapOf( + // From + SpineSource.UPPER_CHEST to 6f, + SpineSource.LOWER_CHEST to 6f, + SpineSource.UPPER_WAIST to 6.25f, + SpineSource.LOWER_WAIST to 44f, // Itself + // To + SpineSource.HIP to 10f, + SpineSource.UPPER_LEGS to 4.25f, + ), + SpineSource.HIP to mapOf( + // From + SpineSource.UPPER_CHEST to 9.5f, + SpineSource.LOWER_CHEST to 9.5f, + SpineSource.UPPER_WAIST to 12.5f, + SpineSource.LOWER_WAIST to 13f, + SpineSource.HIP to 40f, // Itself + // To + SpineSource.UPPER_LEGS to 13f, + ), +) - else -> error("Invalid missing spine body part $bodyPart") +private fun nearestActive(startIndex: Int, step: Int, sourceActive: Map): Int? { + var i = startIndex + while (i in SPINE_SOURCES.indices) { + if (sourceActive[SPINE_SOURCES[i]] == true) return i + i += step + } + return null +} + +private fun getFromTo(selfIndex: Int, sourceActive: Map): Pair { + // Find From, the first active bone in itself + its parents. + val from = nearestActive(selfIndex, -1, sourceActive) + + // Find To, the next active bone in its children, skipping the immediate next if itself is active except if it's the only one (for hip). + // If To is null, we return null for the whole thing + val isActive = sourceActive[SPINE_SOURCES[selfIndex]] == true + val immediateNext = selfIndex + 1 + val takeImmediateNext = (!isActive || selfIndex + 2 == NB_SPINE_SOURCES) && sourceActive[SPINE_SOURCES[immediateNext]] == true + val to = if (takeImmediateNext) immediateNext else nearestActive(selfIndex + 2, 1, sourceActive) + + return from to to +} + +/** + * Remaps the From-To ratio with From-To reliability. + */ +private fun remapRatioWithReliability(fromUpperToLower: Float, reliability: Float): Float = if (fromUpperToLower <= DEFAULT_SPINE_UPPER_LOWER) { + fromUpperToLower * (1f / DEFAULT_SPINE_UPPER_LOWER) * reliability +} else { + reliability + (fromUpperToLower - DEFAULT_SPINE_UPPER_LOWER) * (1f / DEFAULT_SPINE_UPPER_LOWER) * (1f - reliability) } private fun interpolateRatio(fromUpperToLower: Float, curvature: Float, fromReliability: Float, toReliability: Float, isActive: Boolean): Float { - // Compute reliability ratio val reliability = (toReliability / fromReliability) * DEFAULT_SPINE_UPPER_LOWER return if (isActive) { @@ -127,15 +137,6 @@ private fun interpolateRatio(fromUpperToLower: Float, curvature: Float, fromReli } } -/** - * Remaps the From-To ratio with From-To reliability. - */ -private fun remapRatioWithReliability(ratio: Float, reliability: Float): Float = if (ratio <= DEFAULT_SPINE_UPPER_LOWER) { - ratio * (1f / DEFAULT_SPINE_UPPER_LOWER) * reliability -} else { - reliability + (ratio - DEFAULT_SPINE_UPPER_LOWER) * (1f / DEFAULT_SPINE_UPPER_LOWER) * (1f - reliability) -} - private fun averageRotation(inputSkeleton: InputSkeleton, takeBodyParts: Array = arrayOf()): Quaternion { val bonesToAverage = inputSkeleton.values.filter { it.bodyPart in takeBodyParts } return bonesToAverage.map { it.rotation } @@ -152,109 +153,48 @@ private fun averageRotation(inputSkeleton: InputSkeleton, takeBodyParts: Array boneInputs[part]?.isRotationActive == true } } + val fromTo = SPINE_BONES.withIndex().associate { (selfIndex, source) -> + source to getFromTo(selfIndex, sourceActive) + } - val hasUpperChest = fixedInputs[BodyPart.UPPER_CHEST]?.isRotationActive == true - val hasLowerChest = fixedInputs[BodyPart.LOWER_CHEST]?.isRotationActive == true - val hasUpperWaist = fixedInputs[BodyPart.UPPER_WAIST]?.isRotationActive == true - val hasLowerWaist = fixedInputs[BodyPart.LOWER_WAIST]?.isRotationActive == true - val hasHip = fixedInputs[BodyPart.HIP]?.isRotationActive == true - val hasUpperLegs = fixedInputs[BodyPart.LEFT_UPPER_LEG]?.isRotationActive == true && fixedInputs[BodyPart.RIGHT_UPPER_LEG]?.isRotationActive == true + for (spineSource in SPINE_BONES) { + // For optimization's sake, assume only one BodyPart per SpineSource we traverse. + val bodyPart = spineSource.parts.first() + val bone = boneInputs[bodyPart] ?: continue + val isActive = bone.isRotationActive - for (bodyPart in SPINE_BONES_TO_RELAX) { - val bone = fixedInputs[bodyPart] ?: continue + // Get reliabilities mapped to this spine bone + val reliabilities = SPINE_SOURCE_RELIABILITY[spineSource] ?: continue - // Get the first active bones above and below this one in the chain - val (fromSource, toSource) = when (bodyPart) { - BodyPart.UPPER_CHEST -> { - val from = SpineSource.UPPER_CHEST.takeIf { hasUpperChest } ?: continue - val to = when { - hasUpperWaist -> SpineSource.UPPER_WAIST - hasLowerWaist -> SpineSource.LOWER_WAIST - hasHip -> SpineSource.HIP - hasUpperLegs -> SpineSource.UPPER_LEGS - else -> continue - } - from to to - } - - BodyPart.LOWER_CHEST -> { - val from = when { - hasLowerChest -> SpineSource.LOWER_CHEST - hasUpperChest -> SpineSource.UPPER_CHEST - else -> continue - } - val to = when { - hasUpperWaist -> SpineSource.UPPER_WAIST - hasLowerWaist -> SpineSource.LOWER_WAIST - hasHip -> SpineSource.HIP - hasUpperLegs -> SpineSource.UPPER_LEGS - else -> continue - } - from to to - } - - BodyPart.UPPER_WAIST -> { - val from = when { - hasUpperWaist -> SpineSource.UPPER_WAIST - hasLowerChest -> SpineSource.LOWER_CHEST - hasUpperChest -> SpineSource.UPPER_CHEST - else -> continue - } - val to = when { - hasLowerWaist -> SpineSource.LOWER_WAIST - hasHip -> SpineSource.HIP - hasUpperLegs -> SpineSource.UPPER_LEGS - else -> continue - } - from to to - } - - BodyPart.LOWER_WAIST -> { - val from = when { - hasLowerWaist -> SpineSource.LOWER_WAIST - hasUpperWaist -> SpineSource.UPPER_WAIST - hasLowerChest -> SpineSource.LOWER_CHEST - hasUpperChest -> SpineSource.UPPER_CHEST - else -> continue - } - val to = when { - hasHip -> SpineSource.HIP - hasUpperLegs -> SpineSource.UPPER_LEGS - else -> continue - } - from to to - } - - BodyPart.HIP -> { - val from = when { - hasHip -> SpineSource.HIP - hasLowerWaist -> SpineSource.LOWER_WAIST - hasUpperWaist -> SpineSource.UPPER_WAIST - hasLowerChest -> SpineSource.LOWER_CHEST - hasUpperChest -> SpineSource.UPPER_CHEST - else -> continue - } - val to = SpineSource.UPPER_LEGS.takeIf { hasUpperLegs } ?: continue - from to to - } - - else -> error("Invalid missing spine body part $bodyPart") + // Get the spine sources for the current spineSource + val (fromIndex, toIndex) = fromTo[spineSource] ?: error("No fromTo for $spineSource found.") + // toIndex will be null if the bone has no active children. + if (toIndex == null) continue + val (fromSpineSource, toSpineSource) = if (fromIndex != null) { + SPINE_SOURCES[fromIndex] to SPINE_SOURCES[toIndex] + } else { + // Fall back to itself to its to's to + val toTo = fromTo[SPINE_SOURCES[toIndex]] ?: continue + spineSource to SPINE_SOURCES[toTo.second ?: continue] } + // We are interpolating as-if we were the To, but using self instead of to + val sourceActive = isActive || fromIndex == null + // Get the interpolation ratio val interpolateRatio = interpolateRatio( ratios.imputeSpineFromUpperToLower, ratios.imputeSpineCurvature, - reliabilityOf(bodyPart, fromSource), - reliabilityOf(bodyPart, toSource), - bodyPart == fromSource.parts.first(), + reliabilities[fromSpineSource] ?: continue, + reliabilities[toSpineSource] ?: continue, + sourceActive, ) - val fromRotation = averageRotation(fixedInputs, fromSource.parts) - val toRotation = averageRotation(fixedInputs, toSource.parts) - + // Interpolate between from and to using the ratio. + val fromRotation = averageRotation(boneInputs, fromSpineSource.parts) + val toRotation = averageRotation(boneInputs, toSpineSource.parts) mutableInputSkeleton[bodyPart] = bone.copy(rotation = fromRotation.interpQ(toRotation, interpolateRatio)) } } diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-active-link.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt similarity index 52% rename from server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-active-link.kt rename to server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt index a83ab1fc6..610a6f223 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-active-link.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt @@ -5,48 +5,40 @@ import dev.slimevr.skeleton.SkeletonInputProcessor import solarxr_protocol.datatypes.BodyPart /** - * Handles setting the rotation of an inactive bone with the first active bone in its sources, or keeps + * Handles setting the rotation of an inactive toe bone with the first active toe bone in its sources, or keeps * the old rotation if none of them are active. */ -class BoneActiveLinkInputProcessor : SkeletonInputProcessor { +class ToeActiveLinkInputProcessor : SkeletonInputProcessor { /** - * First element is the BodyPart whose rawBone is not actively receiving data. + * First element is the BodyPart whose BoneInput is not actively receiving data. * * Second element contains a set of BodyParts whose rotation should be used as a fallback prioritized from first to last. - * Only active bones will be used. + * First active bone will be prioritized. If none are active, the last bone is used. */ - private val linkedToSources = arrayOf( - BodyPart.UPPER_CHEST to arrayOf(BodyPart.LOWER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST, BodyPart.HIP), - BodyPart.LOWER_CHEST to arrayOf(BodyPart.UPPER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST, BodyPart.HIP), - BodyPart.UPPER_WAIST to arrayOf(BodyPart.LOWER_WAIST, BodyPart.LOWER_CHEST, BodyPart.HIP, BodyPart.UPPER_CHEST), - BodyPart.LOWER_WAIST to arrayOf(BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.HIP, BodyPart.UPPER_CHEST), - BodyPart.HIP to arrayOf(BodyPart.LOWER_WAIST, BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.UPPER_CHEST), + private val toeToSources = arrayOf( + BodyPart.LEFT_BIG_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_FOOT), + BodyPart.LEFT_INDEX_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), + BodyPart.LEFT_MIDDLE_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), + BodyPart.LEFT_RING_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), + BodyPart.LEFT_LITTLE_TOE to arrayOf(BodyPart.LEFT_RING_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), - BodyPart.LEFT_BIG_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG), - BodyPart.LEFT_INDEX_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG), - BodyPart.LEFT_MIDDLE_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG), - BodyPart.LEFT_RING_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG), - BodyPart.LEFT_LITTLE_TOE to arrayOf(BodyPart.LEFT_RING_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG), - - BodyPart.RIGHT_BIG_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG), - BodyPart.RIGHT_INDEX_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG), - BodyPart.RIGHT_MIDDLE_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG), - BodyPart.RIGHT_RING_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG), - BodyPart.RIGHT_LITTLE_TOE to arrayOf(BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG), + BodyPart.RIGHT_BIG_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_FOOT), + BodyPart.RIGHT_INDEX_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), + BodyPart.RIGHT_MIDDLE_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), + BodyPart.RIGHT_RING_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), + BodyPart.RIGHT_LITTLE_TOE to arrayOf(BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), ) override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { - for ((bodyPart, sources) in linkedToSources) { + for ((bodyPart, sources) in toeToSources) { val bone = mutableInputSkeleton[bodyPart] ?: continue if (bone.isRotationActive) continue - // Only inactive bones are written, so one written here can never become a source below - val closestActiveBone = sources.firstNotNullOfOrNull { part -> + val closestActiveBoneOrLast = sources.firstNotNullOfOrNull { part -> mutableInputSkeleton[part]?.takeIf { it.isRotationActive } - } ?: continue - if (closestActiveBone.rotation == bone.rotation) continue + } ?: mutableInputSkeleton[sources.last()] ?: continue - mutableInputSkeleton[bodyPart] = bone.copy(rotation = closestActiveBone.rotation) + mutableInputSkeleton[bodyPart] = bone.copy(rotation = closestActiveBoneOrLast.rotation) } } } diff --git a/server/core/src/main/java/dev/slimevr/skeleton/module.kt b/server/core/src/main/java/dev/slimevr/skeleton/module.kt index 759dc6d53..e90405e86 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/module.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/module.kt @@ -7,7 +7,6 @@ import dev.slimevr.skeleton.computedprocessors.VelocityComputedProcessor import dev.slimevr.skeleton.fkprocessors.FootPlantFkProcessor import dev.slimevr.skeleton.fkprocessors.LocalizerFkProcessor import dev.slimevr.skeleton.fkprocessors.ToeSnapFkProcessor -import dev.slimevr.skeleton.inputprocessors.BoneActiveLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.BoneDirectLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.BoneYawFallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.ConstraintInputProcessor @@ -17,6 +16,7 @@ import dev.slimevr.skeleton.inputprocessors.HipYawRollAlignInputProcessor import dev.slimevr.skeleton.inputprocessors.PredictionInputProcessor import dev.slimevr.skeleton.inputprocessors.RelaxedSpineInputProcessor import dev.slimevr.skeleton.inputprocessors.SmoothingInputProcessor +import dev.slimevr.skeleton.inputprocessors.ToeActiveLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.UpperLegsRollAlignInputProcessor import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor import dev.slimevr.skeleton.targetprocessors.SkatingCorrectionTargetProcessor @@ -223,12 +223,12 @@ class Skeleton( SmoothingInputProcessor(settings).also { resettableSkeletonProcessors.add(it) }, HeadPositionFallbackProcessor(settings), BoneYawFallbackInputProcessor(), - BoneActiveLinkInputProcessor(), RelaxedSpineInputProcessor(settings), HipYawRollAlignInputProcessor(settings), UpperLegsRollAlignInputProcessor(settings), BoneDirectLinkInputProcessor(), FingerImputeInputProcessor(), + ToeActiveLinkInputProcessor(), ConstraintInputProcessor(settings), ), fkComputedProcessors = listOf(