mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Fix VMC head using neck
This commit is contained in:
1 parent
06bd37a854
commit
8e8d4e433b
3 files changed
+4
-4
No files matched your search
@@ -97,8 +97,8 @@ private val VMC_TREE = VmcBoneTree(VMC_HIERARCHY)
|
||||
val VMC_BONE_ORDER: List<UnityBone> = VMC_TREE.order
|
||||
val VMC_BONE_PARENTS: EnumMap<UnityBone, UnityBone?> = VMC_TREE.parents
|
||||
|
||||
// Bones between the hips and the neck, hips first, as VMC's hierarchy links them.
|
||||
val VMC_HIP_TO_NECK_CHAIN: List<UnityBone> = generateSequence(UnityBone.NECK) { VMC_BONE_PARENTS[it] }
|
||||
// Bones between the hips and the head, hips first, as VMC's hierarchy links them.
|
||||
val VMC_HIP_TO_HEAD_CHAIN: List<UnityBone> = generateSequence(UnityBone.HEAD) { VMC_BONE_PARENTS[it] }
|
||||
.takeWhile { it != UnityBone.HIPS }
|
||||
.toList()
|
||||
.asReversed()
|
||||
|
||||
@@ -158,7 +158,7 @@ private fun hipToNeckOffset(
|
||||
): Vector3 {
|
||||
var parentUnityBone = UnityBone.HIPS
|
||||
var offset = Vector3.ZERO
|
||||
for (childUnityBone in VMC_HIP_TO_NECK_CHAIN) {
|
||||
for (childUnityBone in VMC_HIP_TO_HEAD_CHAIN) {
|
||||
val parentRotation = unityBoneGlobalRotations[parentUnityBone] ?: Quaternion.IDENTITY
|
||||
val bonePosition = unityBoneGlobalPositions[childUnityBone] ?: Vector3.ZERO
|
||||
val parentPosition = unityBoneGlobalPositions[parentUnityBone] ?: Vector3.ZERO
|
||||
|
||||
@@ -111,7 +111,7 @@ fun buildVrmGeometry(reader: VrmReader): VrmGeometry {
|
||||
acc + offset(unityBone)
|
||||
}.y
|
||||
|
||||
val outputRestHeight = hipPosition.y + VMC_HIP_TO_NECK_CHAIN.sumOf { offset(it).y.toDouble() }.toFloat()
|
||||
val outputRestHeight = hipPosition.y + VMC_HIP_TO_HEAD_CHAIN.sumOf { offset(it).y.toDouble() }.toFloat()
|
||||
|
||||
return VrmGeometry(
|
||||
bindOffsets = bindOffsets,
|
||||
|
||||
Reference in new issue
Block a user