From 131be48e98c557e597f4bf915ea26d0f98863d53 Mon Sep 17 00:00:00 2001 From: Erimel Date: Wed, 7 Oct 2026 13:55:30 -0400 Subject: [PATCH] Simplify floorclip and fix it again lol --- .../slimevr/skeleton/fkprocessors/localizer.kt | 11 +++++------ .../skeleton/targetprocessors/floor-clip.kt | 15 +++++++-------- .../src/main/java/dev/slimevr/vrcosc/oscquery.kt | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/localizer.kt b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/localizer.kt index a3dbf000d..7d0a1686b 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/localizer.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/localizer.kt @@ -28,9 +28,8 @@ const val MAX_TORSO_VERTICAL_ACCEL = 8f const val FLOOR_TOUCH_DISTANCE = 0.03f // 1 = up, -1 = down -const val SITTING_KNEE_MIN = -0.4f - -const val SITTING_THRESHOLD_SECONDS = 0.8f +const val SITTING_KNEE_THRESHOLD = -0.4f +const val SITTING_SECONDS_THRESHOLD = 0.8f // Legs, spine and head are always used even if inactive val alwaysActiveBodyParts = arrayOf( @@ -88,8 +87,8 @@ object SittingLocalizer { // if the y component of the vectors is small then the user is probably sitting val leftKneeVertical = leftKnee.localTailPosition.unit().y val rightKneeVertical = rightKnee.localTailPosition.unit().y - val sittingLeft = leftKneeVertical > SITTING_KNEE_MIN - val sittingRight = rightKneeVertical > SITTING_KNEE_MIN + val sittingLeft = leftKneeVertical > SITTING_KNEE_THRESHOLD + val sittingRight = rightKneeVertical > SITTING_KNEE_THRESHOLD return sittingLeft && sittingRight } @@ -227,7 +226,7 @@ class LocalizerFkProcessor(val settings: Settings) : val followSource = getSourceToFollow(fk, lowestBone, bodyAcceleration).let { if (it == FollowSource.SITTING) { sittingTime += deltaTime - if (sittingTime < SITTING_THRESHOLD_SECONDS) { + if (sittingTime < SITTING_SECONDS_THRESHOLD) { FollowSource.FLOOR } else { FollowSource.SITTING diff --git a/server/core/src/main/java/dev/slimevr/skeleton/targetprocessors/floor-clip.kt b/server/core/src/main/java/dev/slimevr/skeleton/targetprocessors/floor-clip.kt index 1cdbe5896..ee661e533 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/targetprocessors/floor-clip.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/targetprocessors/floor-clip.kt @@ -22,20 +22,19 @@ class FloorClipTargetProcessor( for (parentPart in targetParts) { // Get existing target or make a new one at the current bone position. - val parentTargetY = mutableIkTargets[parentPart] ?: fk[parentPart]?.tailPosition ?: continue + val parentTarget = mutableIkTargets[parentPart] ?: fk[parentPart]?.tailPosition ?: continue - // Offset the parent target by the lowest child as well so that none of its active children are under the floor either. - var lowestChildTargetY = 0f + // Find the lowest y position, either the parent's or its children's. + var lowestTargetY = parentTarget.y for ((_, childPart) in iterateBodyPartHierarchy(parentPart, true)) { if (inputSkeleton[childPart]?.isRotationActive == false) continue val target = mutableIkTargets[childPart] ?: fk[childPart]?.tailPosition ?: continue - if (target.y < lowestChildTargetY) lowestChildTargetY = target.y + if (target.y < lowestTargetY) lowestTargetY = target.y } - val childOffset = if (lowestChildTargetY < 0f) (parentTargetY.y - lowestChildTargetY).coerceAtLeast(0f) else 0f - // Snap the parent up. - val targetY = parentTargetY.y.coerceAtLeast(floorLevel) + childOffset - mutableIkTargets[parentPart] = Vector3(parentTargetY.x, targetY, parentTargetY.z) + // Snap the parent up + val offsetY = (floorLevel - lowestTargetY).coerceAtLeast(0f) + mutableIkTargets[parentPart] = Vector3(parentTarget.x, parentTarget.y + offsetY, parentTarget.z) } } } diff --git a/server/core/src/main/java/dev/slimevr/vrcosc/oscquery.kt b/server/core/src/main/java/dev/slimevr/vrcosc/oscquery.kt index 2cbf4b194..f9d238dad 100644 --- a/server/core/src/main/java/dev/slimevr/vrcosc/oscquery.kt +++ b/server/core/src/main/java/dev/slimevr/vrcosc/oscquery.kt @@ -49,7 +49,7 @@ class VRCOSCOscQueryBehaviour( combine( settingsFlow, portInFlow, - ::Pair + ::Pair, ) .onEach { (settings, portIn) -> if (!settings.first || settings.second || portIn == null) {