mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Simplify floorclip and fix it again lol
This commit is contained in:
1 parent
dc6e986650
commit
131be48e98
3 files changed
+13
-15
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class VRCOSCOscQueryBehaviour(
|
||||
combine(
|
||||
settingsFlow,
|
||||
portInFlow,
|
||||
::Pair
|
||||
::Pair,
|
||||
)
|
||||
.onEach { (settings, portIn) ->
|
||||
if (!settings.first || settings.second || portIn == null) {
|
||||
|
||||
Reference in new issue
Block a user