mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Fix VMC tests
This commit is contained in:
1 parent
a0abe1e33b
commit
99a4f5420e
3 files changed
+10
-7
No files matched your search
@@ -7,6 +7,7 @@ import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
// Neck bends less when looking up
|
||||
private const val UP_RATIO = 0.75f
|
||||
|
||||
// Neck bends slightly more when looking down.
|
||||
private const val DOWN_RATIO = 1.1f
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ private fun emittedLocalPosition(
|
||||
vmcLocalPosition(bonePosition, parentRotation, parentPosition, parentUnityBone, mirror)
|
||||
}
|
||||
|
||||
private fun hipToNeckOffset(
|
||||
private fun hipToHeadOffset(
|
||||
unityBoneGlobalRotations: MutableMap<UnityBone, Quaternion>,
|
||||
unityBoneGlobalPositions: MutableMap<UnityBone, Vector3>,
|
||||
vrm: VrmGeometry?,
|
||||
@@ -188,15 +188,15 @@ private fun vmcHipPosition(
|
||||
val anchoredHipPosition = vrm?.hipPosition ?: Vector3(0f, restHipHeight(bones, skeletonHeight), 0f)
|
||||
if (config.anchorAtHips) return anchoredHipPosition
|
||||
|
||||
val neckPosition = unityBoneGlobalPositions[UnityBone.NECK] ?: return anchoredHipPosition
|
||||
val adjustedNeckPosition = if (config.mirrorTracking) vmcMirrorPosition(neckPosition) else neckPosition
|
||||
val headPosition = unityBoneGlobalPositions[UnityBone.HEAD] ?: return anchoredHipPosition
|
||||
val adjustedHeadPosition = if (config.mirrorTracking) vmcMirrorPosition(headPosition) else headPosition
|
||||
val restHeight = vrm?.outputRestHeight ?: skeletonHeight
|
||||
val scale = if (skeletonHeight != 0f) restHeight / skeletonHeight else 1f
|
||||
val floorRelativeNeck = (adjustedNeckPosition - Vector3(0f, floorLevel, 0f)) * scale
|
||||
val floorRelativeHead = (adjustedHeadPosition - Vector3(0f, floorLevel, 0f)) * scale
|
||||
|
||||
val neckOffset = hipToNeckOffset(unityBoneGlobalRotations, unityBoneGlobalPositions, vrm, config.mirrorTracking)
|
||||
val headOffset = hipToHeadOffset(unityBoneGlobalRotations, unityBoneGlobalPositions, vrm, config.mirrorTracking)
|
||||
|
||||
return floorRelativeNeck - neckOffset
|
||||
return floorRelativeHead - headOffset
|
||||
}
|
||||
|
||||
private fun transformMessage(address: String, name: String, pos: Vector3, rot: Quaternion): OscMessage = OscMessage(
|
||||
|
||||
Reference in new issue
Block a user