mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Split waist, default upper chest, and use lower chest to relax spine
This commit is contained in:
1 parent
59fc10da6e
commit
1b40f12791
36 files changed
+284
-156
No files matched your search
@@ -19,8 +19,9 @@ fun slideContributionWeight(ankleA: Vector3, ankleB: Vector3, localBoneTailA: Ve
|
||||
// TODO This is a placeholder
|
||||
val PLACEHOLDER_BODY_PARTS_TO_ADJUST = arrayOf(
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.CHEST,
|
||||
BodyPart.WAIST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
// etc.
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.context.Behaviour
|
||||
import dev.slimevr.context.Context
|
||||
import dev.slimevr.skeleton.inputprocessors.DEFAULT_SPINE_RATIO
|
||||
import dev.slimevr.skeleton.inputprocessors.DEFAULT_SPINE_UPPER_LOWER
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -77,7 +77,7 @@ data class TapDetectionConfig(
|
||||
var fullResetEnabled: Boolean = true,
|
||||
var mountingResetEnabled: Boolean = true,
|
||||
@Serializable(with = BodyPartSerializer::class)
|
||||
var yawResetBodyPart: BodyPart? = BodyPart.CHEST,
|
||||
var yawResetBodyPart: BodyPart? = BodyPart.UPPER_CHEST,
|
||||
@Serializable(with = BodyPartSerializer::class)
|
||||
var mountingResetBodyPart: BodyPart? = BodyPart.RIGHT_UPPER_LEG,
|
||||
@Serializable(with = BodyPartSerializer::class)
|
||||
@@ -138,8 +138,8 @@ data class SkeletonTogglesConfig(
|
||||
// Used in SkeletonConfig
|
||||
@Serializable
|
||||
data class SkeletonRatiosConfig(
|
||||
val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_RATIO,
|
||||
val imputeSpineCurvature: Float = DEFAULT_SPINE_RATIO,
|
||||
val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER,
|
||||
val imputeSpineCurvature: Float = 0.8f,
|
||||
val interpolateHipWithUpperLegs: Float = 0.25f,
|
||||
val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f,
|
||||
val skatingCorrectionStrength: Float = 0.3f,
|
||||
@@ -148,8 +148,8 @@ data class SkeletonRatiosConfig(
|
||||
// Used in SkeletonConfig
|
||||
@Serializable
|
||||
data class SkeletonFilteringConfig(
|
||||
val type: FilteringType = FilteringType.NONE,
|
||||
val amount: Float = 0.2f,
|
||||
val type: FilteringType = FilteringType.SMOOTHING,
|
||||
val amount: Float = 0.1f,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
import solarxr_protocol.rpc.RoutingOutput
|
||||
import solarxr_protocol.rpc.RoutingOutputState
|
||||
import solarxr_protocol.rpc.VRCOSCOutputState
|
||||
@@ -159,10 +158,10 @@ fun applyRoutingChange(
|
||||
}
|
||||
|
||||
private val candidateToFineBodyParts = mapOf(
|
||||
BodyPart.UPPER_CHEST to setOf(BodyPart.UPPER_CHEST, BodyPart.CHEST),
|
||||
BodyPart.UPPER_CHEST to setOf(BodyPart.UPPER_CHEST, BodyPart.LOWER_CHEST),
|
||||
BodyPart.LEFT_UPPER_ARM to setOf(BodyPart.LEFT_UPPER_ARM, BodyPart.LEFT_LOWER_ARM),
|
||||
BodyPart.RIGHT_UPPER_ARM to setOf(BodyPart.RIGHT_UPPER_ARM, BodyPart.RIGHT_LOWER_ARM),
|
||||
BodyPart.HIP to setOf(BodyPart.HIP, BodyPart.WAIST, BodyPart.CHEST, BodyPart.UPPER_CHEST),
|
||||
BodyPart.HIP to setOf(BodyPart.HIP, BodyPart.LOWER_WAIST, BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.UPPER_CHEST),
|
||||
BodyPart.LEFT_UPPER_LEG to setOf(BodyPart.LEFT_UPPER_LEG),
|
||||
BodyPart.RIGHT_UPPER_LEG to setOf(BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LEFT_FOOT to setOf(BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG, BodyPart.LEFT_UPPER_LEG),
|
||||
|
||||
@@ -78,7 +78,7 @@ class YouSpinMeRightRoundBehaviour(val inputHz: Float = 1f) : SkeletonBehaviour
|
||||
|
||||
receiver.context.dispatch(
|
||||
SkeletonActions.SetBoneRotation(
|
||||
BodyPart.CHEST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
Quaternion.fromRotationVector(Vector3(cos(elapsed), sin(elapsed), 0f)),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -48,11 +48,15 @@ val BODY_PART_CONSTRAINT_MAP: BodyPartMap<Constraint> = BodyPartMap(
|
||||
90f * FastMath.DEG_TO_RAD,
|
||||
120f * FastMath.DEG_TO_RAD,
|
||||
),
|
||||
BodyPart.CHEST to TwistSwingConstraint(
|
||||
BodyPart.LOWER_CHEST to TwistSwingConstraint(
|
||||
60f * FastMath.DEG_TO_RAD,
|
||||
120f * FastMath.DEG_TO_RAD,
|
||||
),
|
||||
BodyPart.WAIST to TwistSwingConstraint(
|
||||
BodyPart.UPPER_WAIST to TwistSwingConstraint(
|
||||
60f * FastMath.DEG_TO_RAD,
|
||||
120f * FastMath.DEG_TO_RAD,
|
||||
),
|
||||
BodyPart.LOWER_WAIST to TwistSwingConstraint(
|
||||
60f * FastMath.DEG_TO_RAD,
|
||||
120f * FastMath.DEG_TO_RAD,
|
||||
),
|
||||
|
||||
@@ -23,8 +23,9 @@ val BODY_PART_IK_CHAIN_MAP: BodyPartMap<IKChain> = BodyPartMap(
|
||||
),
|
||||
BodyPart.HIP to listOf(
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.CHEST,
|
||||
BodyPart.WAIST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
),
|
||||
BodyPart.LEFT_LOWER_LEG to listOf(
|
||||
|
||||
@@ -51,9 +51,10 @@ val BODY_PART_HIERARCHY_MAP: BodyPartMap<Array<BodyPart>> = BodyPartMap(
|
||||
BodyPart.RIGHT_LITTLE_PROXIMAL to arrayOf(BodyPart.RIGHT_LITTLE_INTERMEDIATE),
|
||||
BodyPart.RIGHT_LITTLE_INTERMEDIATE to arrayOf(BodyPart.RIGHT_LITTLE_DISTAL),
|
||||
|
||||
BodyPart.UPPER_CHEST to arrayOf(BodyPart.CHEST),
|
||||
BodyPart.CHEST to arrayOf(BodyPart.WAIST),
|
||||
BodyPart.WAIST to arrayOf(BodyPart.HIP),
|
||||
BodyPart.UPPER_CHEST to arrayOf(BodyPart.LOWER_CHEST),
|
||||
BodyPart.LOWER_CHEST to arrayOf(BodyPart.UPPER_WAIST),
|
||||
BodyPart.UPPER_WAIST to arrayOf(BodyPart.LOWER_WAIST),
|
||||
BodyPart.LOWER_WAIST to arrayOf(BodyPart.HIP),
|
||||
BodyPart.HIP to arrayOf(BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG),
|
||||
|
||||
BodyPart.LEFT_UPPER_LEG to arrayOf(BodyPart.LEFT_LOWER_LEG),
|
||||
|
||||
@@ -12,8 +12,10 @@ val BODY_PART_MASSES = mapOf(
|
||||
BodyPart.RIGHT_UPPER_ARM to 0.0263f,
|
||||
BodyPart.LEFT_LOWER_ARM to 0.0224f,
|
||||
BodyPart.RIGHT_LOWER_ARM to 0.0224f,
|
||||
BodyPart.CHEST to 0.1870f,
|
||||
BodyPart.WAIST to 0.1320f,
|
||||
BodyPart.UPPER_CHEST to 0.0935f,
|
||||
BodyPart.LOWER_CHEST to 0.0935f,
|
||||
BodyPart.UPPER_WAIST to 0.0660f,
|
||||
BodyPart.LOWER_WAIST to 0.0660f,
|
||||
BodyPart.HIP to 0.1530f,
|
||||
BodyPart.LEFT_UPPER_LEG to 0.1122f,
|
||||
BodyPart.RIGHT_UPPER_LEG to 0.1122f,
|
||||
|
||||
@@ -155,7 +155,7 @@ object HipLocalizer {
|
||||
}
|
||||
|
||||
object COMLocalizer {
|
||||
private val TORSO_TRACKERS = setOf(BodyPart.UPPER_CHEST, BodyPart.CHEST, BodyPart.WAIST, BodyPart.HIP)
|
||||
private val TORSO_TRACKERS = setOf(BodyPart.UPPER_CHEST, BodyPart.LOWER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST, BodyPart.HIP)
|
||||
|
||||
/** Get the average accel of the torso bones */
|
||||
fun getTorsoAccel(inputs: InputSkeleton): Vector3 {
|
||||
|
||||
@@ -16,10 +16,11 @@ class BoneActiveLinkInputProcessor : SkeletonInputProcessor {
|
||||
* Only active bones will be used.
|
||||
*/
|
||||
private val linkedToSources = arrayOf(
|
||||
BodyPart.UPPER_CHEST to arrayOf(BodyPart.CHEST, BodyPart.WAIST, BodyPart.HIP),
|
||||
BodyPart.CHEST to arrayOf(BodyPart.UPPER_CHEST, BodyPart.WAIST, BodyPart.HIP),
|
||||
BodyPart.WAIST to arrayOf(BodyPart.CHEST, BodyPart.HIP, BodyPart.UPPER_CHEST),
|
||||
BodyPart.HIP to arrayOf(BodyPart.WAIST, BodyPart.CHEST, BodyPart.UPPER_CHEST),
|
||||
BodyPart.UPPER_CHEST to arrayOf(BodyPart.LOWER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST, BodyPart.HIP),
|
||||
BodyPart.LOWER_CHEST to arrayOf(BodyPart.UPPER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST, BodyPart.HIP),
|
||||
BodyPart.UPPER_WAIST to arrayOf(BodyPart.LOWER_WAIST, BodyPart.LOWER_CHEST, BodyPart.HIP, BodyPart.UPPER_CHEST),
|
||||
BodyPart.LOWER_WAIST to arrayOf(BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.HIP, BodyPart.UPPER_CHEST),
|
||||
BodyPart.HIP to arrayOf(BodyPart.LOWER_WAIST, BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.UPPER_CHEST),
|
||||
|
||||
BodyPart.LEFT_BIG_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_FOOT),
|
||||
BodyPart.LEFT_INDEX_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT),
|
||||
|
||||
@@ -8,46 +8,35 @@ import io.github.axisangles.ktmath.Quaternion
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
// At this default value, the user's spine should behave as we meant it to.
|
||||
const val DEFAULT_SPINE_RATIO = 0.5f
|
||||
const val DEFAULT_SPINE_UPPER_LOWER = 0.5f
|
||||
|
||||
private enum class SpineSource(val parts: Array<BodyPart>) {
|
||||
CHEST(arrayOf(BodyPart.CHEST)),
|
||||
UPPER_CHEST(arrayOf(BodyPart.UPPER_CHEST)),
|
||||
LOWER_CHEST(arrayOf(BodyPart.LOWER_CHEST)),
|
||||
UPPER_WAIST(arrayOf(BodyPart.UPPER_WAIST)),
|
||||
LOWER_WAIST(arrayOf(BodyPart.LOWER_WAIST)),
|
||||
HIP(arrayOf(BodyPart.HIP)),
|
||||
WAIST(arrayOf(BodyPart.WAIST)),
|
||||
UPPER_LEGS(arrayOf(BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG)),
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the interpolation ratio modified with the reliability and curve.
|
||||
* If a single bone is missing, ratio is reliability adjusted.
|
||||
* At 0.0 curve, ratio is raw.
|
||||
* At 0.5 curve, ratio is reliability adjusted.
|
||||
* At 1.0 curve, ratio is 0 for the first in chain and 1 for the last in chain.
|
||||
*/
|
||||
private fun interpolateRatio(chainIndex: Int, chainSize: Int, fromUpperToLower: Float, curvature: Float, fromReliability: Float, toReliability: Float): Float {
|
||||
private fun interpolateRatio(fromUpperToLower: Float, curvature: Float, fromReliability: Float, toReliability: Float): Float {
|
||||
// Remap the upper-lower ratio with reliability
|
||||
val reliabilityAdjusted = remapRatioWithReliability(fromUpperToLower, fromReliability, toReliability)
|
||||
if (chainSize <= 1) return reliabilityAdjusted // Single missing bone; reliability adjusted
|
||||
|
||||
return if (curvature <= DEFAULT_SPINE_RATIO) {
|
||||
// Raw to reliability adjusted
|
||||
FastMath.lerp(fromUpperToLower, reliabilityAdjusted, curvature * 2f)
|
||||
} else {
|
||||
// Reliability adjusted to max curve
|
||||
val maxCurve = chainIndex / (chainSize - 1).toFloat()
|
||||
FastMath.lerp(reliabilityAdjusted, maxCurve, (curvature - DEFAULT_SPINE_RATIO) * 2f)
|
||||
}
|
||||
// Lerp from upper-lower to reliability-adjusted according to curvature
|
||||
return FastMath.lerp(fromUpperToLower, reliabilityAdjusted, curvature)
|
||||
}
|
||||
|
||||
/**
|
||||
* Remaps a ratio This assumes a default ratio of 50%.
|
||||
*/
|
||||
private fun remapRatioWithReliability(ratio: Float, fromReliability: Float, toReliability: Float): Float {
|
||||
val reliability = (fromReliability / toReliability) * DEFAULT_SPINE_RATIO
|
||||
val reliability = (toReliability / fromReliability) * DEFAULT_SPINE_UPPER_LOWER
|
||||
|
||||
return if (ratio <= DEFAULT_SPINE_RATIO) {
|
||||
return if (ratio <= DEFAULT_SPINE_UPPER_LOWER) {
|
||||
ratio * 2f * reliability
|
||||
} else {
|
||||
reliability + (ratio - DEFAULT_SPINE_RATIO) * 2f * (1f - reliability)
|
||||
reliability + (ratio - DEFAULT_SPINE_UPPER_LOWER) * 2f * (1f - reliability)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,16 +48,65 @@ private fun averageRotation(inputSkeleton: InputSkeleton, takeBodyParts: Array<B
|
||||
} ?: Quaternion.IDENTITY
|
||||
}
|
||||
|
||||
// The higher a value is, the more reliable it is.
|
||||
// If a "To" is 2x the "From", it'll use 100% "To".
|
||||
// If a "To" is the same as "From", it'll do 50-50.
|
||||
private fun reliabilityOf(bodyPart: BodyPart, source: SpineSource): Float = when (bodyPart) {
|
||||
BodyPart.WAIST -> when (source) {
|
||||
SpineSource.CHEST -> 0.6f
|
||||
SpineSource.HIP, SpineSource.UPPER_LEGS -> 1.0f
|
||||
BodyPart.LOWER_CHEST -> when (source) {
|
||||
// From
|
||||
SpineSource.UPPER_CHEST -> 10f
|
||||
|
||||
// To
|
||||
SpineSource.UPPER_WAIST -> -1.5f
|
||||
|
||||
SpineSource.LOWER_WAIST -> -2f
|
||||
|
||||
SpineSource.HIP -> -4f
|
||||
|
||||
SpineSource.UPPER_LEGS -> -3f
|
||||
|
||||
else -> error("Invalid spine combination $bodyPart, $source")
|
||||
}
|
||||
|
||||
BodyPart.UPPER_WAIST -> when (source) {
|
||||
// From
|
||||
SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 10f
|
||||
|
||||
// To
|
||||
SpineSource.LOWER_WAIST -> 17f
|
||||
|
||||
SpineSource.HIP -> 5.5f
|
||||
|
||||
SpineSource.UPPER_LEGS -> 4.5f
|
||||
|
||||
else -> error("Invalid spine combination $bodyPart, $source")
|
||||
}
|
||||
|
||||
BodyPart.LOWER_WAIST -> when (source) {
|
||||
// From
|
||||
SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 6f
|
||||
|
||||
SpineSource.UPPER_WAIST -> 6.25f
|
||||
|
||||
// To
|
||||
SpineSource.HIP -> 11f
|
||||
|
||||
SpineSource.UPPER_LEGS -> 4.5f
|
||||
|
||||
else -> error("Invalid spine combination $bodyPart, $source")
|
||||
}
|
||||
|
||||
BodyPart.HIP -> when (source) {
|
||||
SpineSource.CHEST, SpineSource.UPPER_LEGS -> 1.0f
|
||||
SpineSource.WAIST -> 0.8f
|
||||
// From
|
||||
SpineSource.UPPER_CHEST, SpineSource.LOWER_CHEST -> 9.5f
|
||||
|
||||
SpineSource.UPPER_WAIST -> 12.5f
|
||||
|
||||
SpineSource.LOWER_WAIST -> 13f
|
||||
|
||||
// To
|
||||
SpineSource.UPPER_LEGS -> 13f
|
||||
|
||||
else -> error("Invalid spine combination $bodyPart, $source")
|
||||
}
|
||||
|
||||
@@ -85,22 +123,58 @@ class SpineImputeInputProcessor(val settings: Settings) : SkeletonInputProcessor
|
||||
override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) {
|
||||
val ratios = settings.context.state.value.data.skeletonConfig.ratios
|
||||
|
||||
val hasChest = mutableInputSkeleton[BodyPart.UPPER_CHEST]?.isRotationActive == true || mutableInputSkeleton[BodyPart.CHEST]?.isRotationActive == true
|
||||
val hasWaist = mutableInputSkeleton[BodyPart.WAIST]?.isRotationActive == true
|
||||
val hasUpperChest = mutableInputSkeleton[BodyPart.UPPER_CHEST]?.isRotationActive == true
|
||||
val hasLowerChest = mutableInputSkeleton[BodyPart.LOWER_CHEST]?.isRotationActive == true
|
||||
val hasUpperWaist = mutableInputSkeleton[BodyPart.UPPER_WAIST]?.isRotationActive == true
|
||||
val hasLowerWaist = mutableInputSkeleton[BodyPart.LOWER_WAIST]?.isRotationActive == true
|
||||
val hasHip = mutableInputSkeleton[BodyPart.HIP]?.isRotationActive == true
|
||||
val hasUpperLegs = mutableInputSkeleton[BodyPart.LEFT_UPPER_LEG]?.isRotationActive == true && mutableInputSkeleton[BodyPart.RIGHT_UPPER_LEG]?.isRotationActive == true
|
||||
val missingSpineParts = buildList {
|
||||
if (!hasWaist) add(BodyPart.WAIST)
|
||||
if (!hasLowerChest) add(BodyPart.LOWER_CHEST)
|
||||
if (!hasUpperWaist) add(BodyPart.UPPER_WAIST)
|
||||
if (!hasLowerWaist) add(BodyPart.LOWER_WAIST)
|
||||
if (!hasHip) add(BodyPart.HIP)
|
||||
}
|
||||
|
||||
for ((chainIndex, bodyPart) in missingSpineParts.withIndex()) {
|
||||
for (bodyPart in missingSpineParts) {
|
||||
val bone = mutableInputSkeleton[bodyPart] ?: continue
|
||||
|
||||
// Get the first active bones above and below this one in the chain
|
||||
val (fromSource, toSource) = when (bodyPart) {
|
||||
BodyPart.WAIST -> {
|
||||
val from = SpineSource.CHEST.takeIf { hasChest } ?: continue
|
||||
BodyPart.LOWER_CHEST -> {
|
||||
val from = SpineSource.UPPER_CHEST.takeIf { hasUpperChest } ?: continue
|
||||
val to = when {
|
||||
hasUpperWaist -> SpineSource.UPPER_WAIST
|
||||
hasLowerWaist -> SpineSource.LOWER_WAIST
|
||||
hasHip -> SpineSource.HIP
|
||||
hasUpperLegs -> SpineSource.UPPER_LEGS
|
||||
else -> continue
|
||||
}
|
||||
from to to
|
||||
}
|
||||
|
||||
BodyPart.UPPER_WAIST -> {
|
||||
val from = when {
|
||||
hasLowerChest -> SpineSource.LOWER_CHEST
|
||||
hasUpperChest -> SpineSource.UPPER_CHEST
|
||||
else -> continue
|
||||
}
|
||||
val to = when {
|
||||
hasLowerWaist -> SpineSource.LOWER_WAIST
|
||||
hasHip -> SpineSource.HIP
|
||||
hasUpperLegs -> SpineSource.UPPER_LEGS
|
||||
else -> continue
|
||||
}
|
||||
from to to
|
||||
}
|
||||
|
||||
BodyPart.LOWER_WAIST -> {
|
||||
val from = when {
|
||||
hasUpperWaist -> SpineSource.UPPER_WAIST
|
||||
hasLowerChest -> SpineSource.LOWER_CHEST
|
||||
hasUpperChest -> SpineSource.UPPER_CHEST
|
||||
else -> continue
|
||||
}
|
||||
val to = when {
|
||||
hasHip -> SpineSource.HIP
|
||||
hasUpperLegs -> SpineSource.UPPER_LEGS
|
||||
@@ -111,8 +185,10 @@ class SpineImputeInputProcessor(val settings: Settings) : SkeletonInputProcessor
|
||||
|
||||
BodyPart.HIP -> {
|
||||
val from = when {
|
||||
hasWaist -> SpineSource.WAIST
|
||||
hasChest -> SpineSource.CHEST
|
||||
hasLowerWaist -> SpineSource.LOWER_WAIST
|
||||
hasUpperWaist -> SpineSource.UPPER_WAIST
|
||||
hasLowerChest -> SpineSource.LOWER_CHEST
|
||||
hasUpperChest -> SpineSource.UPPER_CHEST
|
||||
else -> continue
|
||||
}
|
||||
val to = SpineSource.UPPER_LEGS.takeIf { hasUpperLegs } ?: continue
|
||||
@@ -123,8 +199,6 @@ class SpineImputeInputProcessor(val settings: Settings) : SkeletonInputProcessor
|
||||
}
|
||||
|
||||
val interpolateRatio = interpolateRatio(
|
||||
chainIndex,
|
||||
missingSpineParts.size,
|
||||
ratios.imputeSpineFromUpperToLower,
|
||||
ratios.imputeSpineCurvature,
|
||||
reliabilityOf(bodyPart, fromSource),
|
||||
|
||||
@@ -12,9 +12,10 @@ val DEFAULT_PROPORTIONS = mapOf(
|
||||
SkeletonBone.HEAD to 0.1f,
|
||||
SkeletonBone.NECK to 0.1f,
|
||||
SkeletonBone.UPPER_CHEST to 0.16f,
|
||||
SkeletonBone.CHEST to 0.16f,
|
||||
SkeletonBone.WAIST to 0.18f,
|
||||
SkeletonBone.HIP to 0.06f,
|
||||
SkeletonBone.LOWER_CHEST to 0.16f,
|
||||
SkeletonBone.UPPER_WAIST to 0.1f,
|
||||
SkeletonBone.LOWER_WAIST to 0.1f,
|
||||
SkeletonBone.HIP to 0.04f,
|
||||
SkeletonBone.HIPS_WIDTH to 0.26f,
|
||||
SkeletonBone.UPPER_LEG to 0.42f,
|
||||
SkeletonBone.LOWER_LEG to 0.5f,
|
||||
@@ -33,8 +34,9 @@ val DEFAULT_PROPORTIONS = mapOf(
|
||||
private val HEIGHT_CONTRIBUTING_BONES: Set<SkeletonBone> = setOf(
|
||||
SkeletonBone.NECK,
|
||||
SkeletonBone.UPPER_CHEST,
|
||||
SkeletonBone.CHEST,
|
||||
SkeletonBone.WAIST,
|
||||
SkeletonBone.LOWER_CHEST,
|
||||
SkeletonBone.UPPER_WAIST,
|
||||
SkeletonBone.LOWER_WAIST,
|
||||
SkeletonBone.HIP,
|
||||
SkeletonBone.UPPER_LEG,
|
||||
SkeletonBone.LOWER_LEG,
|
||||
@@ -45,8 +47,9 @@ private val BONE_VALUE_TO_OFFSETS: Map<SkeletonBone, BodyPartMap<Vector3>> = map
|
||||
SkeletonBone.HEAD to BodyPartMap(mapOf(BodyPart.HEAD to Vector3.POS_Z)),
|
||||
SkeletonBone.NECK to BodyPartMap(mapOf(BodyPart.NECK to Vector3.NEG_Y)),
|
||||
SkeletonBone.UPPER_CHEST to BodyPartMap(mapOf(BodyPart.UPPER_CHEST to Vector3.NEG_Y)),
|
||||
SkeletonBone.CHEST to BodyPartMap(mapOf(BodyPart.CHEST to Vector3.NEG_Y)),
|
||||
SkeletonBone.WAIST to BodyPartMap(mapOf(BodyPart.WAIST to Vector3.NEG_Y)),
|
||||
SkeletonBone.LOWER_CHEST to BodyPartMap(mapOf(BodyPart.LOWER_CHEST to Vector3.NEG_Y)),
|
||||
SkeletonBone.UPPER_WAIST to BodyPartMap(mapOf(BodyPart.UPPER_WAIST to Vector3.NEG_Y)),
|
||||
SkeletonBone.LOWER_WAIST to BodyPartMap(mapOf(BodyPart.LOWER_WAIST to Vector3.NEG_Y)),
|
||||
SkeletonBone.HIP to BodyPartMap(mapOf(BodyPart.HIP to Vector3.NEG_Y)),
|
||||
SkeletonBone.UPPER_LEG to BodyPartMap(mapOf(BodyPart.LEFT_UPPER_LEG to Vector3.NEG_Y, BodyPart.RIGHT_UPPER_LEG to Vector3.NEG_Y)),
|
||||
SkeletonBone.LOWER_LEG to BodyPartMap(mapOf(BodyPart.LEFT_LOWER_LEG to Vector3.NEG_Y, BodyPart.RIGHT_LOWER_LEG to Vector3.NEG_Y)),
|
||||
|
||||
@@ -45,8 +45,8 @@ class DriverOutgoingTrackersBehaviour(
|
||||
// physical tracker. Bones without an entry just report no battery.
|
||||
val bodyPartToNearest: BodyPartMap<Set<BodyPart>> = BodyPartMap(
|
||||
mapOf(
|
||||
BodyPart.UPPER_CHEST to setOf(BodyPart.UPPER_CHEST, BodyPart.CHEST),
|
||||
BodyPart.HIP to setOf(BodyPart.HIP, BodyPart.WAIST, BodyPart.CHEST, BodyPart.UPPER_CHEST),
|
||||
BodyPart.UPPER_CHEST to setOf(BodyPart.UPPER_CHEST, BodyPart.LOWER_CHEST),
|
||||
BodyPart.HIP to setOf(BodyPart.HIP, BodyPart.LOWER_WAIST, BodyPart.UPPER_WAIST, BodyPart.LOWER_CHEST, BodyPart.UPPER_CHEST),
|
||||
BodyPart.LEFT_UPPER_LEG to setOf(BodyPart.LEFT_UPPER_LEG),
|
||||
BodyPart.RIGHT_UPPER_LEG to setOf(BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LEFT_FOOT to setOf(BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG),
|
||||
|
||||
@@ -33,11 +33,12 @@ class TapDetectionBasicBehaviour : TapDetectionBehaviour {
|
||||
var waitForLowAccel: Boolean = false,
|
||||
)
|
||||
|
||||
// This vvv + the assigned tap body parts are used.
|
||||
// This + the assigned tap body parts are used.
|
||||
private val falsePositiveBodyParts = setOf(
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.CHEST,
|
||||
BodyPart.WAIST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
BodyPart.LEFT_UPPER_LEG,
|
||||
BodyPart.RIGHT_UPPER_LEG,
|
||||
@@ -79,11 +80,11 @@ class TapDetectionBasicBehaviour : TapDetectionBehaviour {
|
||||
.flatMapLatest { (tapDetectionConfig, setupMode, trackers) ->
|
||||
// Computed once per outer-flow refresh for all trackers
|
||||
val trackersBodyParts = trackers.map { it.context.state.value.bodyPart }.toSet()
|
||||
val yawResetBodyPart = listOf(tapDetectionConfig.yawResetBodyPart, BodyPart.UPPER_CHEST, BodyPart.CHEST, BodyPart.HIP, BodyPart.WAIST)
|
||||
val yawResetBodyPart = arrayOf(tapDetectionConfig.yawResetBodyPart, BodyPart.UPPER_CHEST, BodyPart.LOWER_CHEST, BodyPart.HIP, BodyPart.LOWER_WAIST, BodyPart.UPPER_WAIST)
|
||||
.firstOrNull { it in trackersBodyParts } ?: BodyPart.UPPER_CHEST
|
||||
val fullResetBodyPart = listOf(tapDetectionConfig.fullResetBodyPart, BodyPart.LEFT_UPPER_LEG, BodyPart.LEFT_LOWER_LEG)
|
||||
val fullResetBodyPart = arrayOf(tapDetectionConfig.fullResetBodyPart, BodyPart.LEFT_UPPER_LEG, BodyPart.LEFT_LOWER_LEG)
|
||||
.firstOrNull { it in trackersBodyParts } ?: BodyPart.LEFT_UPPER_LEG
|
||||
val mountingResetBodyPart = listOf(tapDetectionConfig.mountingResetBodyPart, BodyPart.RIGHT_UPPER_LEG, BodyPart.RIGHT_LOWER_LEG)
|
||||
val mountingResetBodyPart = arrayOf(tapDetectionConfig.mountingResetBodyPart, BodyPart.RIGHT_UPPER_LEG, BodyPart.RIGHT_LOWER_LEG)
|
||||
.firstOrNull { it in trackersBodyParts } ?: BodyPart.RIGHT_UPPER_LEG
|
||||
|
||||
// To keep track of which trackers are moving
|
||||
|
||||
@@ -13,8 +13,9 @@ object StayAlignedBodyParts {
|
||||
val upperBodyGroup = listOf(
|
||||
BodyPart.NECK,
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.CHEST,
|
||||
BodyPart.WAIST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
)
|
||||
val upperBodyOrder = upperBodyGroup.withIndex().associate { it.value to it.index }
|
||||
|
||||
@@ -7,13 +7,14 @@ import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
// TODO how to handle UPPER_WAIST?
|
||||
val BODY_PART_TO_UNITY_BONE: BodyPartMap<Array<String>> = BodyPartMap(
|
||||
mapOf(
|
||||
BodyPart.HEAD to arrayOf("Head"),
|
||||
BodyPart.NECK to arrayOf("Neck"),
|
||||
BodyPart.UPPER_CHEST to arrayOf("UpperChest"),
|
||||
BodyPart.CHEST to arrayOf("Chest"),
|
||||
BodyPart.WAIST to arrayOf("Spine"),
|
||||
BodyPart.LOWER_CHEST to arrayOf("Chest"),
|
||||
BodyPart.LOWER_WAIST to arrayOf("Spine"),
|
||||
BodyPart.HIP to arrayOf("Hips"),
|
||||
BodyPart.LEFT_SHOULDER to arrayOf("LeftShoulder"),
|
||||
BodyPart.RIGHT_SHOULDER to arrayOf("RightShoulder"),
|
||||
@@ -80,9 +81,9 @@ val VMC_SUPPORTED_BONES: Set<BodyPart> = BODY_PART_TO_UNITY_BONE.keys
|
||||
// and figure out how to deal with it (check if present in VRM?)
|
||||
val VMC_HIERARCHY_MAP: BodyPartMap<Array<BodyPart>> = BodyPartMap(
|
||||
mapOf(
|
||||
BodyPart.HIP to arrayOf(BodyPart.WAIST, BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.WAIST to arrayOf(BodyPart.CHEST),
|
||||
BodyPart.CHEST to arrayOf(BodyPart.UPPER_CHEST, BodyPart.NECK, BodyPart.LEFT_SHOULDER, BodyPart.RIGHT_SHOULDER),
|
||||
BodyPart.HIP to arrayOf(BodyPart.LOWER_WAIST, BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LOWER_WAIST to arrayOf(BodyPart.LOWER_CHEST),
|
||||
BodyPart.LOWER_CHEST to arrayOf(BodyPart.UPPER_CHEST, BodyPart.NECK, BodyPart.LEFT_SHOULDER, BodyPart.RIGHT_SHOULDER),
|
||||
BodyPart.NECK to arrayOf(BodyPart.HEAD),
|
||||
BodyPart.LEFT_UPPER_LEG to arrayOf(BodyPart.LEFT_LOWER_LEG),
|
||||
BodyPart.RIGHT_UPPER_LEG to arrayOf(BodyPart.RIGHT_LOWER_LEG),
|
||||
@@ -165,7 +166,7 @@ val VMC_OUTPUT_BONE_PARENTS: BodyPartMap<BodyPart?> = VmcBoneTree(VMC_HIERARCHY_
|
||||
val VMC_INPUT_HIERARCHY_MAP: BodyPartMap<Array<BodyPart>> = BodyPartMap(
|
||||
VMC_HIERARCHY_MAP +
|
||||
mapOf(
|
||||
BodyPart.CHEST to arrayOf(BodyPart.UPPER_CHEST),
|
||||
BodyPart.LOWER_CHEST to arrayOf(BodyPart.UPPER_CHEST),
|
||||
BodyPart.UPPER_CHEST to arrayOf(BodyPart.NECK, BodyPart.LEFT_SHOULDER, BodyPart.RIGHT_SHOULDER),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -109,8 +109,8 @@ fun buildVrmGeometry(reader: VrmReader): VrmGeometry {
|
||||
|
||||
val vrmHeight = (
|
||||
offset(BodyPart.HIP) +
|
||||
offset(BodyPart.WAIST) +
|
||||
offset(BodyPart.CHEST) +
|
||||
offset(BodyPart.LOWER_WAIST) +
|
||||
offset(BodyPart.LOWER_CHEST) +
|
||||
offset(BodyPart.UPPER_CHEST) +
|
||||
offset(BodyPart.NECK)
|
||||
).y
|
||||
|
||||
Reference in new issue
Block a user