mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-20 00:51:20 -08:00
Spotless
This commit is contained in:
1 parent
4ff461b49f
commit
a9cdcbcfdf
4 files changed
+30
-30
No files matched your search
@@ -54,8 +54,10 @@ private fun isUserSitting(fk: ComputedSkeleton): Boolean {
|
||||
private fun isFootOnGround(fk: ComputedSkeleton): Boolean {
|
||||
val leftFoot = fk[BodyPart.LEFT_FOOT] ?: return false
|
||||
val rightFoot = fk[BodyPart.RIGHT_FOOT] ?: return false
|
||||
return leftFoot.headPosition.y <= 0f || rightFoot.headPosition.y <= 0f ||
|
||||
leftFoot.tailPosition.y <= 0f || rightFoot.tailPosition.y <= 0f
|
||||
return leftFoot.headPosition.y <= 0f ||
|
||||
rightFoot.headPosition.y <= 0f ||
|
||||
leftFoot.tailPosition.y <= 0f ||
|
||||
rightFoot.tailPosition.y <= 0f
|
||||
}
|
||||
|
||||
private fun getSourceToFollow(fk: ComputedSkeleton): FollowSource = if (isUserSitting(fk)) {
|
||||
@@ -91,12 +93,12 @@ object FootLocalizer {
|
||||
}
|
||||
|
||||
private fun isFootLocked(bone: BoneState, lastPlantedFoot: PlantedFoot): Boolean = shouldLock(
|
||||
bone.tailPosition,
|
||||
bone.tailPosition,
|
||||
bone.acceleration,
|
||||
bone.velocity,
|
||||
lastPlantedFoot == whichPlantedFoot(bone.bodyPart),
|
||||
)
|
||||
bone.tailPosition,
|
||||
bone.tailPosition,
|
||||
bone.acceleration,
|
||||
bone.velocity,
|
||||
lastPlantedFoot == whichPlantedFoot(bone.bodyPart),
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns the average percentage the real velocity and acceleration are of
|
||||
@@ -194,21 +196,19 @@ object COMLocalizer {
|
||||
|
||||
fun getTargetCOM(targetCOM: Vector3, comVelocity: Vector3, deltaTime: Duration) = targetCOM + (comVelocity * deltaTime.inFloatingSeconds)
|
||||
|
||||
fun floorAdjustTargetCOM(targetCOM: Vector3, lowestBone: BoneState?) =
|
||||
lowestBone?.let {
|
||||
if (it.tailPosition.y < FLOOR_CALIBRATION_OFFSET) {
|
||||
Vector3(targetCOM.x, targetCOM.y + (FLOOR_CALIBRATION_OFFSET - it.tailPosition.y), targetCOM.z)
|
||||
}
|
||||
targetCOM
|
||||
} ?: targetCOM
|
||||
fun floorAdjustTargetCOM(targetCOM: Vector3, lowestBone: BoneState?) = lowestBone?.let {
|
||||
if (it.tailPosition.y < FLOOR_CALIBRATION_OFFSET) {
|
||||
Vector3(targetCOM.x, targetCOM.y + (FLOOR_CALIBRATION_OFFSET - it.tailPosition.y), targetCOM.z)
|
||||
}
|
||||
targetCOM
|
||||
} ?: targetCOM
|
||||
|
||||
fun floorAdjustCOMVelocity(comVelocity: Vector3, lowestBone: BoneState?) =
|
||||
lowestBone?.let {
|
||||
if (it.tailPosition.y < FLOOR_CALIBRATION_OFFSET) {
|
||||
Vector3(comVelocity.x, 0f, comVelocity.z)
|
||||
}
|
||||
comVelocity
|
||||
} ?: comVelocity
|
||||
fun floorAdjustCOMVelocity(comVelocity: Vector3, lowestBone: BoneState?) = lowestBone?.let {
|
||||
if (it.tailPosition.y < FLOOR_CALIBRATION_OFFSET) {
|
||||
Vector3(comVelocity.x, 0f, comVelocity.z)
|
||||
}
|
||||
comVelocity
|
||||
} ?: comVelocity
|
||||
|
||||
fun computeCOMTravel(currentCOM: Vector3, targetCOM: Vector3) = targetCOM - currentCOM
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class LocalizerFkProcessor(val settings: Settings) :
|
||||
} ?: Vector3.ZERO
|
||||
|
||||
// Get COM travel
|
||||
val comTravel= COMLocalizer.computeCOMTravel(currentCom, targetCOM)
|
||||
val comTravel = COMLocalizer.computeCOMTravel(currentCom, targetCOM)
|
||||
|
||||
// Return horizontal foot travel and vertical COM travel
|
||||
Vector3(footTravel.x, comTravel.y, footTravel.z)
|
||||
@@ -308,7 +308,7 @@ class LocalizerFkProcessor(val settings: Settings) :
|
||||
// Return the sitting travel
|
||||
HipLocalizer.computeSittingTravel(currentHip, targetHip)
|
||||
|
||||
Vector3.ZERO // TODO
|
||||
Vector3.ZERO // TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,5 +65,6 @@ fun reduce(state: SkeletonState, action: SkeletonActions): SkeletonState = when
|
||||
}
|
||||
|
||||
is SkeletonActions.RequestProcessorReset -> state.copy(processorResets = state.processorResets + action.resetType)
|
||||
|
||||
is SkeletonActions.ProcessorResetsApplied -> state.copy(processorResets = state.processorResets.drop(action.count))
|
||||
}
|
||||
+4
-4
@@ -52,10 +52,10 @@ fun shouldLock(
|
||||
val thresholdMultiplier = (if (wasLocked) 1f else SKATING_LOCK_ENGAGE_PERCENT) * (correctionStrength * 0.5f + 0.5f)
|
||||
val floorLevel = floorLevel + FLOOR_CALIBRATION_OFFSET
|
||||
return ((position - lastPosition).let { Vector3(it.x, 0f, it.z) }.lenSq() <= SKATING_DISTANCE_THRESHOLD_SQ) &&
|
||||
(velocity.linear.lenSq() <= SKATING_LINEAR_VELOCITY_THRESHOLD_SQ * thresholdMultiplier) &&
|
||||
(velocity.angular.lenSq() <= SKATING_ANGULAR_VELOCITY_THRESHOLD_SQ * thresholdMultiplier) &&
|
||||
(position.y - floorLevel <= FLOOR_DISTANCE_THRESHOLD * thresholdMultiplier) &&
|
||||
(acceleration.lenSq() <= SKATING_ACCELERATION_THRESHOLD_SQ * thresholdMultiplier * correctionStrength)
|
||||
(velocity.linear.lenSq() <= SKATING_LINEAR_VELOCITY_THRESHOLD_SQ * thresholdMultiplier) &&
|
||||
(velocity.angular.lenSq() <= SKATING_ANGULAR_VELOCITY_THRESHOLD_SQ * thresholdMultiplier) &&
|
||||
(position.y - floorLevel <= FLOOR_DISTANCE_THRESHOLD * thresholdMultiplier) &&
|
||||
(acceleration.lenSq() <= SKATING_ACCELERATION_THRESHOLD_SQ * thresholdMultiplier * correctionStrength)
|
||||
}
|
||||
|
||||
fun computeLockState(
|
||||
|
||||
@@ -64,8 +64,7 @@ internal fun buildOutgoingBundle(
|
||||
|
||||
internal fun buildInitRequestMessage(): OscMessage = OscMessage("/VMC/Ext/Req", emptyList())
|
||||
|
||||
private fun trackingBodyPart(targetBodyPart: BodyPart, mirror: Boolean): BodyPart =
|
||||
if (mirror) vmcMirrorSource(targetBodyPart) else targetBodyPart
|
||||
private fun trackingBodyPart(targetBodyPart: BodyPart, mirror: Boolean): BodyPart = if (mirror) vmcMirrorSource(targetBodyPart) else targetBodyPart
|
||||
|
||||
private fun restAdjustedWorld(
|
||||
bone: BoneState,
|
||||
|
||||
Reference in new issue
Block a user