From 7d72dc2c8a6ad5ba6c87651458b50acc5d9d4668 Mon Sep 17 00:00:00 2001 From: Erimel Date: Tue, 13 Oct 2026 18:28:34 -0400 Subject: [PATCH] No more hip-upperlegs interpolation; improve chest-only tracking --- gui/app/public/i18n/en/translation.ftl | 8 ++-- .../components/settings/SettingsSidebar.tsx | 2 +- .../settings/pages/TrackingSettings.tsx | 24 +++--------- gui/app/src/hooks/tracker-assignment.ts | 15 ++----- .../main/java/dev/slimevr/config/module.kt | 6 +-- .../main/java/dev/slimevr/config/settings.kt | 3 +- .../java/dev/slimevr/config/user-reducer.kt | 1 - .../java/dev/slimevr/hid/behaviours/config.kt | 2 +- .../inputprocessors/hip-yaw-roll-align.kt | 39 ------------------- .../slimevr/skeleton/inputprocessors/spine.kt | 15 ++++--- .../main/java/dev/slimevr/skeleton/module.kt | 2 - .../slimevr/solarxr/rpc/skeleton-settings.kt | 6 +-- .../dev/slimevr/tapdetection/behaviours.kt | 6 +-- solarxr-protocol | 2 +- 14 files changed, 29 insertions(+), 102 deletions(-) delete mode 100644 server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/hip-yaw-roll-align.kt diff --git a/gui/app/public/i18n/en/translation.ftl b/gui/app/public/i18n/en/translation.ftl index 7e757c0ce..448b3a408 100644 --- a/gui/app/public/i18n/en/translation.ftl +++ b/gui/app/public/i18n/en/translation.ftl @@ -706,14 +706,12 @@ settings-general-fk_settings-arms_mounting_reset_mode-forward = Forward settings-general-fk_settings-arms_mounting_reset_mode-forward-description = Expects your arms to be raised forward. Recommended for VTubing. settings-general-fk_settings-skeleton_settings-ratios = Skeleton ratios settings-general-fk_settings-skeleton_settings-ratios-description = Tweak the behaviour of the skeleton. You may need to adjust your proportions after changing these. +settings-general-fk_settings-skeleton_settings-spine_curvature = Spine curvature +settings-general-fk_settings-skeleton_settings-spine_curvature-description = How much the spine curves when bending instead of remaining straight. Use a lower value for stiffer movements or a higher one for more flexible movements. settings-general-fk_settings-skeleton_settings-impute_spine_from_upper_to_lower = Estimate missing spine trackers from upper to lower settings-general-fk_settings-skeleton_settings-impute_spine_from_upper_to_lower-description = For missing spine trackers, how much to rely on the lower trackers instead of the upper trackers. Use a lower value for more hip isolation or a higher one to increase stability lying down. -settings-general-fk_settings-skeleton_settings-spine_curvature = Spine curvature -settings-general-fk_settings-skeleton_settings-spine_curvature-description = How much the spine curves when bending instead of remaining straight. Use a lower value for stiffer movements or a higher value for more flexible movements. -settings-general-fk_settings-skeleton_settings-interpolate_hip_with_upper_legs = Estimate missing hip tracker from the upper legs -settings-general-fk_settings-skeleton_settings-interpolate_hip_with_upper_legs-description = For a missing hip tracker, how much to make it follow your upper legs' twist and tilt. settings-general-fk_settings-skeleton_settings-interpolate_upper_legs_twist_with_lower_legs = Interpolate the upper legs' twists with the lower legs' -settings-general-fk_settings-skeleton_settings-interpolate_upper_legs_twist_with_lower_legs-description = How much the twist of your upper legs follows your lower legs. Use a lower value for motion capture or a higher value for VR. +settings-general-fk_settings-skeleton_settings-interpolate_upper_legs_twist_with_lower_legs-description = How much the twist of your upper legs follows your lower legs. Use a lower value for motion capture or a higher one for VR. settings-general-fk_settings-self_localization-title = Mocap mode settings-general-fk_settings-self_localization-description = Mocap Mode allows the skeleton to roughly track its position in space without any positional tracker. diff --git a/gui/app/src/components/settings/SettingsSidebar.tsx b/gui/app/src/components/settings/SettingsSidebar.tsx index 4dfdfb67d..a5664caca 100644 --- a/gui/app/src/components/settings/SettingsSidebar.tsx +++ b/gui/app/src/components/settings/SettingsSidebar.tsx @@ -84,12 +84,12 @@ export function SettingsSidebar() {
+ - {vrcConfigState?.isSupported && ( - td.tracker.trackerId === trackerId); - sendAssign(trackerId, bodyPart, moved?.tracker.info?.mountingOrientation ?? null); + sendAssign(trackerId, bodyPart); }; const { tryOpenChokerWarning, closeChokerWarning, shouldShowChokerWarn } = @@ -123,11 +118,7 @@ export function useTrackerAssignment(mode: AssignmentMode) { const unassignPart = (part: BodyPart) => { const td = trackerByPart[part]; if (td) { - sendAssign( - td.tracker.trackerId, - BodyPart.NONE, - td.tracker.info?.mountingOrientation ?? null - ); + sendAssign(td.tracker.trackerId, BodyPart.NONE); } if (armedPart === part) clearPending(); }; diff --git a/server/core/src/main/java/dev/slimevr/config/module.kt b/server/core/src/main/java/dev/slimevr/config/module.kt index 6f8631695..b5373610d 100644 --- a/server/core/src/main/java/dev/slimevr/config/module.kt +++ b/server/core/src/main/java/dev/slimevr/config/module.kt @@ -157,8 +157,7 @@ class AppConfig( ProfileKind.UNKNOWN -> error("No active profile for $kind") } - private suspend fun listProfiles(kind: ProfileKind): List = - (profileNamesIn(storage.list(dirOf(kind))) + activeProfile(kind)).distinct().sortedBy { it.lowercase() } + private suspend fun listProfiles(kind: ProfileKind): List = (profileNamesIn(storage.list(dirOf(kind))) + activeProfile(kind)).distinct().sortedBy { it.lowercase() } private suspend fun profileOperation(kind: ProfileKind, block: suspend () -> ProfileOperationStatus): ProfileOperationStatus = profilesLock.withLock { if (kind == ProfileKind.UNKNOWN) return@withLock ProfileOperationStatus.INVALID_KIND @@ -275,8 +274,7 @@ class AppConfig( } // A profile named like the default in another case is the same file on case-insensitive filesystems - private suspend fun defaultProfileName(kind: ProfileKind, name: String): String = - listProfiles(kind).firstOrNull { it.equals(name, ignoreCase = true) } ?: name + private suspend fun defaultProfileName(kind: ProfileKind, name: String): String = listProfiles(kind).firstOrNull { it.equals(name, ignoreCase = true) } ?: name companion object { suspend fun create(scope: CoroutineScope, storage: ConfigStorage): AppConfig { diff --git a/server/core/src/main/java/dev/slimevr/config/settings.kt b/server/core/src/main/java/dev/slimevr/config/settings.kt index 497d687a3..8a6a6c071 100644 --- a/server/core/src/main/java/dev/slimevr/config/settings.kt +++ b/server/core/src/main/java/dev/slimevr/config/settings.kt @@ -137,9 +137,8 @@ data class SkeletonTogglesConfig( // Used in SkeletonConfig @Serializable data class SkeletonRatiosConfig( - val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER, val spineCurvature: Float = 0.75f, - val interpolateHipWithUpperLegs: Float = 0.25f, + val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER, val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f, val skatingCorrectionStrength: Float = 0.5f, ) diff --git a/server/core/src/main/java/dev/slimevr/config/user-reducer.kt b/server/core/src/main/java/dev/slimevr/config/user-reducer.kt index 99084604e..433a7f627 100644 --- a/server/core/src/main/java/dev/slimevr/config/user-reducer.kt +++ b/server/core/src/main/java/dev/slimevr/config/user-reducer.kt @@ -3,6 +3,5 @@ package dev.slimevr.config fun reduce(state: UserConfigState, action: UserConfigActions): UserConfigState = when (action) { is UserConfigActions.Update -> state.copy(data = action.transform(state.data)) is UserConfigActions.LoadProfile -> action.newState - is UserConfigActions.Rename -> state.copy(name = action.name) } diff --git a/server/core/src/main/java/dev/slimevr/hid/behaviours/config.kt b/server/core/src/main/java/dev/slimevr/hid/behaviours/config.kt index 5922e0d8f..ed3518e08 100644 --- a/server/core/src/main/java/dev/slimevr/hid/behaviours/config.kt +++ b/server/core/src/main/java/dev/slimevr/hid/behaviours/config.kt @@ -5,9 +5,9 @@ import dev.slimevr.config.SettingsActions import dev.slimevr.hid.HIDReceiver import dev.slimevr.hid.HIDReceiverActions import dev.slimevr.hid.HIDReceiverBehaviour +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChangedBy import kotlinx.coroutines.flow.drop -import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/hip-yaw-roll-align.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/hip-yaw-roll-align.kt deleted file mode 100644 index 64f07317b..000000000 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/hip-yaw-roll-align.kt +++ /dev/null @@ -1,39 +0,0 @@ -package dev.slimevr.skeleton.inputprocessors - -import dev.slimevr.config.Settings -import dev.slimevr.skeleton.InputSkeleton -import dev.slimevr.skeleton.SkeletonInputProcessor -import io.github.axisangles.ktmath.Quaternion -import solarxr_protocol.datatypes.BodyPart - -/** - * Rotates the first Quaternion to match its yaw and roll to the rotation of - * the second Quaternion - * - * @param from the first Quaternion - * @param to the second Quaternion - * @return the rotated Quaternion - */ -private fun alignYawRoll(from: Quaternion, to: Quaternion): Quaternion { - val r = from.inv() * to - val c = Quaternion(r.w, -r.x, 0f, 0f) - return (from * r * c).unit() -} - -/** - * Handles rotating the hip' yaw and roll to match the upper legs' yaw and roll. - */ -class HipYawRollAlignInputProcessor(val settings: Settings) : SkeletonInputProcessor { - override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { - val hipBone = mutableInputSkeleton[BodyPart.HIP] ?: return - if (hipBone.isRotationActive) return - val leftUpperLegBone = mutableInputSkeleton[BodyPart.LEFT_UPPER_LEG] ?: return - val rightUpperLegBone = mutableInputSkeleton[BodyPart.RIGHT_UPPER_LEG] ?: return - if (!leftUpperLegBone.isRotationActive || !rightUpperLegBone.isRotationActive) return - - val ratio = settings.context.state.value.data.skeletonConfig.ratios.interpolateHipWithUpperLegs - val sourceRotation = leftUpperLegBone.rotation.lerpQ(rightUpperLegBone.rotation, 0.5f) - val alignedRotation = alignYawRoll(hipBone.rotation, sourceRotation) - mutableInputSkeleton[BodyPart.HIP] = hipBone.copy(rotation = hipBone.rotation.interpQ(alignedRotation, ratio)) - } -} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt index 36aff627a..bcd73fb50 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt @@ -34,7 +34,6 @@ private val SPINE_SOURCES = enumEntries().toTypedArray() // If a "To" is the same as "From", it'll do 50-50. // 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 = arrayOf( SpineSource.UPPER_CHEST to mapOf( SpineSource.UPPER_CHEST to Reliability(-6.5f, -24f), // Itself @@ -43,7 +42,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf( SpineSource.UPPER_WAIST to Reliability(1.5f), SpineSource.LOWER_WAIST to Reliability(2f), SpineSource.HIP to Reliability(4f), - SpineSource.UPPER_LEGS to Reliability(2.5f), + SpineSource.UPPER_LEGS to Reliability(1.5f, 1.75f), ), SpineSource.LOWER_CHEST to mapOf( // From @@ -53,7 +52,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf( SpineSource.UPPER_WAIST to Reliability(1.5f, 10f), SpineSource.LOWER_WAIST to Reliability(2f, 7f), SpineSource.HIP to Reliability(4f), - SpineSource.UPPER_LEGS to Reliability(2.5f), + SpineSource.UPPER_LEGS to Reliability(3.25f, 3.75f), ), SpineSource.UPPER_WAIST to mapOf( // From @@ -63,7 +62,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf( // To SpineSource.LOWER_WAIST to Reliability(17f, 20f), SpineSource.HIP to Reliability(5.5f, 5.5f), - SpineSource.UPPER_LEGS to Reliability(3f, 2.5f), + SpineSource.UPPER_LEGS to Reliability(0.25f, 2.5f), ), SpineSource.LOWER_WAIST to mapOf( // From @@ -72,8 +71,8 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf( SpineSource.UPPER_WAIST to Reliability(9f), SpineSource.LOWER_WAIST to Reliability(44f), // Itself // To - SpineSource.HIP to Reliability(10f, 6.5f), - SpineSource.UPPER_LEGS to Reliability(3.5f, 2.75f), + SpineSource.HIP to Reliability(10f, 9f), + SpineSource.UPPER_LEGS to Reliability(1.75f, 6f), ), SpineSource.HIP to mapOf( // From @@ -81,9 +80,9 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf( SpineSource.LOWER_CHEST to Reliability(9.5f), SpineSource.UPPER_WAIST to Reliability(13f, 14f), SpineSource.LOWER_WAIST to Reliability(14f, 15f), - SpineSource.HIP to Reliability(35f), // Itself + SpineSource.HIP to Reliability(32f, 48f), // Itself // To - SpineSource.UPPER_LEGS to Reliability(12f, 10f), + SpineSource.UPPER_LEGS to Reliability(7f, 18f), ), ) 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 54374a1c7..e061e3f4f 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/module.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/module.kt @@ -13,7 +13,6 @@ import dev.slimevr.skeleton.inputprocessors.DirectLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.FallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.FingersInputProcessor import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackProcessor -import dev.slimevr.skeleton.inputprocessors.HipYawRollAlignInputProcessor import dev.slimevr.skeleton.inputprocessors.RotationPredictionInputProcessor import dev.slimevr.skeleton.inputprocessors.RotationSmoothingInputProcessor import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor @@ -276,7 +275,6 @@ class Skeleton( HeadPositionFallbackProcessor(settings), FallbackInputProcessor(), SpineInputProcessor(settings), - HipYawRollAlignInputProcessor(settings), UpperLegsRollAlignInputProcessor(settings), DirectLinkInputProcessor(), FingersInputProcessor(), diff --git a/server/core/src/main/java/dev/slimevr/solarxr/rpc/skeleton-settings.kt b/server/core/src/main/java/dev/slimevr/solarxr/rpc/skeleton-settings.kt index 2efe60ded..0bb5ff894 100644 --- a/server/core/src/main/java/dev/slimevr/solarxr/rpc/skeleton-settings.kt +++ b/server/core/src/main/java/dev/slimevr/solarxr/rpc/skeleton-settings.kt @@ -37,9 +37,8 @@ internal fun buildSkeletonSettingsResponse(config: SkeletonConfig) = SkeletonSet enforceConstraints = config.toggles.enforceConstraints, ), ratios = SkeletonRatios( - imputeSpineFromUpperToLower = config.ratios.imputeSpineFromUpperToLower, spineCurvature = config.ratios.spineCurvature, - interpolateHipWithUpperLegs = config.ratios.interpolateHipWithUpperLegs, + imputeSpineFromUpperToLower = config.ratios.imputeSpineFromUpperToLower, interpolateUpperLegsTwistWithLowerLegs = config.ratios.interpolateUpperLegsTwistWithLowerLegs, skatingCorrectionStrength = config.ratios.skatingCorrectionStrength, ), @@ -85,9 +84,8 @@ class SkeletonSettingsBehaviour( } ?: skeletonConfig.toggles, ratios = req.ratios?.let { SkeletonRatiosConfig( - imputeSpineFromUpperToLower = it.imputeSpineFromUpperToLower ?: 0f, spineCurvature = it.spineCurvature ?: 0f, - interpolateHipWithUpperLegs = it.interpolateHipWithUpperLegs ?: 0f, + imputeSpineFromUpperToLower = it.imputeSpineFromUpperToLower ?: 0f, interpolateUpperLegsTwistWithLowerLegs = it.interpolateUpperLegsTwistWithLowerLegs ?: 0f, skatingCorrectionStrength = it.skatingCorrectionStrength ?: 0f, ) diff --git a/server/core/src/main/java/dev/slimevr/tapdetection/behaviours.kt b/server/core/src/main/java/dev/slimevr/tapdetection/behaviours.kt index 2f1709149..a89f567cb 100644 --- a/server/core/src/main/java/dev/slimevr/tapdetection/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/tapdetection/behaviours.kt @@ -44,6 +44,8 @@ class TapDetectionBasicBehaviour : TapDetectionBehaviour { BodyPart.RIGHT_UPPER_LEG, BodyPart.LEFT_LOWER_LEG, BodyPart.RIGHT_LOWER_LEG, + BodyPart.LEFT_FOOT, + BodyPart.RIGHT_FOOT, ) @OptIn(ExperimentalCoroutinesApi::class) @@ -208,8 +210,6 @@ class TapDetectionBasicBehaviour : TapDetectionBehaviour { trackerAcceleration: Vector3, thresholdMultiplier: Float, ): Boolean { - // TODO check logic against main since taps seem harder to trigger - // Remove old stored accelerations (if they are too old) while (trackerTapDetectionState.accelList.isNotEmpty() && (trackerTapDetectionState.accelList.first().second + ACCEL_WINDOW).hasPassedNow()) { trackerTapDetectionState.accelList.removeFirst() @@ -254,7 +254,7 @@ class TapDetectionBasicBehaviour : TapDetectionBehaviour { const val NEEDED_ACCEL_DELTA = 6.0f const val ALLOWED_BODY_ACCEL = 2.5f const val ALLOWED_BODY_ACCEL_SQUARED = ALLOWED_BODY_ACCEL * ALLOWED_BODY_ACCEL - const val HID_MULTIPLIER = 1.2f + const val HID_MULTIPLIER = 1.25f val ACCEL_WINDOW = 0.06.seconds val TAP_WINDOW_PER_TAP = 0.3.seconds } diff --git a/solarxr-protocol b/solarxr-protocol index 37999b5c1..d60782f08 160000 --- a/solarxr-protocol +++ b/solarxr-protocol @@ -1 +1 @@ -Subproject commit 37999b5c1285dd14b55da8cc4f6989cda71feb9a +Subproject commit d60782f0838ee7e071e7ce7be93373d738da75a2