mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 01:21:25 -08:00
spotless
This commit is contained in:
1 parent
8d42f98e57
commit
6d8366d41f
5 files changed
+41
-49
No files matched your search
@@ -122,22 +122,22 @@ class ComputedSkeletonBehaviour(
|
||||
val fk = buildBones(processedInputs, rootHead)
|
||||
|
||||
// Run IK processors
|
||||
val ikTargets = targetProcessors.fold(bodyPartMap<Vector3>()) { targets, processor -> processor.process(fk, targets) }
|
||||
val ikTargets = targetProcessors.fold(bodyPartMap<Vector3>()) { targets, processor -> processor.process(fk, targets) }
|
||||
|
||||
// Run IK
|
||||
val ikOutput = ccdIk(
|
||||
processedInputs,
|
||||
fk,
|
||||
ikTargets.map { (bodyPart, target) ->
|
||||
IKChainGoal(
|
||||
listOf(bodyPart),
|
||||
target,
|
||||
)
|
||||
},
|
||||
null,
|
||||
0.01f,
|
||||
100,
|
||||
)
|
||||
val ikOutput = ccdIk(
|
||||
processedInputs,
|
||||
fk,
|
||||
ikTargets.map { (bodyPart, target) ->
|
||||
IKChainGoal(
|
||||
listOf(bodyPart),
|
||||
target,
|
||||
)
|
||||
},
|
||||
null,
|
||||
0.01f,
|
||||
100,
|
||||
)
|
||||
|
||||
// Updated the computed skeleton with the result
|
||||
receiver.computed.tryEmit(ikOutput.bones)
|
||||
|
||||
@@ -23,17 +23,15 @@ class BoneActiveLinkProcessor : SkeletonProcessor {
|
||||
BodyPart.HIP to arrayOf(BodyPart.WAIST, BodyPart.CHEST, BodyPart.UPPER_CHEST),
|
||||
)
|
||||
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton {
|
||||
return inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, sources) in linkedToSources) {
|
||||
val bone = inputSkeleton.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton = inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, sources) in linkedToSources) {
|
||||
val bone = inputSkeleton.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
|
||||
val closestActiveBone = sources.firstNotNullOfOrNull { part ->
|
||||
inputSkeleton[part]?.takeIf { it.isActive }
|
||||
} ?: continue
|
||||
updated[bodyPart] = bone.copy(rawRotation = closestActiveBone.rawRotation)
|
||||
}
|
||||
val closestActiveBone = sources.firstNotNullOfOrNull { part ->
|
||||
inputSkeleton[part]?.takeIf { it.isActive }
|
||||
} ?: continue
|
||||
updated[bodyPart] = bone.copy(rawRotation = closestActiveBone.rawRotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,15 +37,13 @@ class BoneDirectLinkProcessor : SkeletonProcessor {
|
||||
BodyPart.RIGHT_HAND to BodyPart.RIGHT_LOWER_ARM,
|
||||
)
|
||||
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton {
|
||||
return inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, source) in linkedToSource) {
|
||||
val bone = updated.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton = inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, source) in linkedToSource) {
|
||||
val bone = updated.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
|
||||
val sourceBone = updated[source]
|
||||
updated[bodyPart] = bone.copy(rawRotation = sourceBone?.rawRotation ?: bone.rawRotation)
|
||||
}
|
||||
val sourceBone = updated[source]
|
||||
updated[bodyPart] = bone.copy(rawRotation = sourceBone?.rawRotation ?: bone.rawRotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,15 +48,13 @@ class FingerImputeProcessor : SkeletonProcessor {
|
||||
)
|
||||
|
||||
// TODO : There's more math to do here. Reference the original code.
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton {
|
||||
return inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, source) in fingerToSource) {
|
||||
val bone = updated.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton = inputSkeleton.mutate { updated ->
|
||||
for ((bodyPart, source) in fingerToSource) {
|
||||
val bone = updated.getValue(bodyPart)
|
||||
if (bone.isActive) continue
|
||||
|
||||
val sourceBone = updated[source]
|
||||
updated[bodyPart] = bone.copy(rawRotation = sourceBone?.rawRotation ?: bone.rawRotation)
|
||||
}
|
||||
val sourceBone = updated[source]
|
||||
updated[bodyPart] = bone.copy(rawRotation = sourceBone?.rawRotation ?: bone.rawRotation)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,13 @@ class HipYawRollAlignProcessor(val settings: Settings) : SkeletonProcessor {
|
||||
|
||||
val source = arrayOf(BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG)
|
||||
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton {
|
||||
return inputSkeleton.mutate { updated ->
|
||||
val hipBone = updated.getValue(BodyPart.HIP)
|
||||
if (!hipBone.isActive) {
|
||||
val ratio = settings.context.state.value.data.skeletonConfig.ratios.interpolateHipWithUpperLegs
|
||||
val sourceRotation = updated.resolveAverageRotationFor(source)
|
||||
val alignedRotation = alignYawRoll(hipBone.rawRotation, sourceRotation)
|
||||
updated[BodyPart.HIP] = hipBone.copy(rawRotation = hipBone.rawRotation.interpQ(alignedRotation, ratio))
|
||||
}
|
||||
override fun process(inputSkeleton: InputSkeleton): InputSkeleton = inputSkeleton.mutate { updated ->
|
||||
val hipBone = updated.getValue(BodyPart.HIP)
|
||||
if (!hipBone.isActive) {
|
||||
val ratio = settings.context.state.value.data.skeletonConfig.ratios.interpolateHipWithUpperLegs
|
||||
val sourceRotation = updated.resolveAverageRotationFor(source)
|
||||
val alignedRotation = alignYawRoll(hipBone.rawRotation, sourceRotation)
|
||||
updated[BodyPart.HIP] = hipBone.copy(rawRotation = hipBone.rawRotation.interpQ(alignedRotation, ratio))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user