From efeada35faf417dac2968fd155eb0894e1fc571e Mon Sep 17 00:00:00 2001 From: loucass003 Date: Mon, 14 Sep 2026 03:19:05 +0200 Subject: [PATCH] Constrains and RotationFallback processors --- .../src/main/java/dev/slimevr/bones/bones.kt | 3 - .../dev/slimevr/bones/compiled-skeleton.kt | 13 +- .../slimevr/{skeleton => bones}/constraint.kt | 2 +- .../slimevr/bones/resource-pack-compiler.kt | 63 +++++++- .../slimevr/resourcepacks/resource-models.kt | 11 +- .../java/dev/slimevr/skeleton/behaviours.kt | 4 +- .../slimevr/skeleton/bodypart-constraints.kt | 151 ------------------ .../skeleton/constraint-application.kt | 56 +++++++ .../src/main/java/dev/slimevr/skeleton/ik.kt | 1 + .../inputprocessors/bone-direct-link.kt | 49 ------ .../skeleton/inputprocessors/constraint.kt | 8 +- .../inputprocessors/copy-rotation-fallback.kt | 23 +++ .../first-active-rotation-fallback.kt | 23 +++ .../inputprocessors/toe-active-link.kt | 48 ------ .../main/java/dev/slimevr/skeleton/module.kt | 11 +- .../resourcepacks/core/data/bones/head.json | 2 +- .../core/schemas/v1/bone.schema.json | 16 -- .../core/schemas/v1/common.schema.json | 6 - .../{skeleton => bones}/ConstraintTest.kt | 2 +- .../slimevr/bones/ResourcePackCompilerTest.kt | 99 ++++++++++++ .../resourcepacks/ResourcePackParserTest.kt | 2 +- .../test/java/dev/slimevr/skeleton/IKTest.kt | 4 +- 22 files changed, 296 insertions(+), 301 deletions(-) rename server/core/src/main/java/dev/slimevr/{skeleton => bones}/constraint.kt (99%) delete mode 100644 server/core/src/main/java/dev/slimevr/skeleton/bodypart-constraints.kt create mode 100644 server/core/src/main/java/dev/slimevr/skeleton/constraint-application.kt delete mode 100644 server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-direct-link.kt create mode 100644 server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/copy-rotation-fallback.kt create mode 100644 server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/first-active-rotation-fallback.kt delete mode 100644 server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt rename server/core/src/test/java/dev/slimevr/{skeleton => bones}/ConstraintTest.kt (98%) diff --git a/server/core/src/main/java/dev/slimevr/bones/bones.kt b/server/core/src/main/java/dev/slimevr/bones/bones.kt index 5991ee327..86d382cc2 100644 --- a/server/core/src/main/java/dev/slimevr/bones/bones.kt +++ b/server/core/src/main/java/dev/slimevr/bones/bones.kt @@ -53,9 +53,6 @@ inline fun BodyPartMap.forEachBone(action: (BodyPart, V) -> Unit) { } } -/** Converts a [BodyPartMap] to a plain [BoneId]-keyed [Map]; no registry needed since every key is standard. */ -fun BodyPartMap.resolveToBoneIds(): Map = mapKeys { it.key.boneId } - /** * Dense array-backed map keyed by [BoneId], scoped to the [registry] it was built for. * IDs run `1..registry.maxId`, slot 0 is unused. diff --git a/server/core/src/main/java/dev/slimevr/bones/compiled-skeleton.kt b/server/core/src/main/java/dev/slimevr/bones/compiled-skeleton.kt index fea34534c..dd3adbf9e 100644 --- a/server/core/src/main/java/dev/slimevr/bones/compiled-skeleton.kt +++ b/server/core/src/main/java/dev/slimevr/bones/compiled-skeleton.kt @@ -49,14 +49,23 @@ data class CompiledOffset(val base: Vector3, val terms: List class BoneOffsets(val tail: BoneMap, val head: BoneMap) /** - * The compiled bone registry, proportion catalog, and per-bone offset produced by - * [compileResourcePacks]. + * The compiled bone registry, proportion catalog, and per-bone offset, constraint, and + * rotation-fallback rule produced by [compileResourcePacks]. [copyRotationFallbacks] (bone to + * source) and [firstActiveRotationFallbacks] (bone to source list) are each in + * ancestor-before-descendant order on their own; every core bone's `copy` source that itself needs + * resolving first is its own parent, and a `firstActive` bone's only source that ever needs + * resolving first is its parent foot, both always a `copy` bone, so running every `copy` fallback + * before any `firstActive` one is enough to keep both schedules correctly ordered relative to + * each other without interleaving them into one. */ class CompiledSkeleton( val registry: BoneRegistry, val proportions: Map, private val tailOffsets: BoneMap, private val headOffsets: BoneMap, + val constraints: BoneMap, + val copyRotationFallbacks: List>, + val firstActiveRotationFallbacks: List>>, ) { /** Every proportion's default value at [height], keyed by proportion key. */ fun defaultProportionValues(height: Float = REFERENCE_HEIGHT): Map { diff --git a/server/core/src/main/java/dev/slimevr/skeleton/constraint.kt b/server/core/src/main/java/dev/slimevr/bones/constraint.kt similarity index 99% rename from server/core/src/main/java/dev/slimevr/skeleton/constraint.kt rename to server/core/src/main/java/dev/slimevr/bones/constraint.kt index 00db554fb..acfcd3bc1 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/constraint.kt +++ b/server/core/src/main/java/dev/slimevr/bones/constraint.kt @@ -1,4 +1,4 @@ -package dev.slimevr.skeleton +package dev.slimevr.bones import io.github.axisangles.ktmath.Quaternion import io.github.axisangles.ktmath.Vector3 diff --git a/server/core/src/main/java/dev/slimevr/bones/resource-pack-compiler.kt b/server/core/src/main/java/dev/slimevr/bones/resource-pack-compiler.kt index d08eed2b7..85511f847 100644 --- a/server/core/src/main/java/dev/slimevr/bones/resource-pack-compiler.kt +++ b/server/core/src/main/java/dev/slimevr/bones/resource-pack-compiler.kt @@ -1,5 +1,8 @@ package dev.slimevr.bones +import dev.slimevr.resourcepacks.CopyRotationFallback +import dev.slimevr.resourcepacks.FirstActiveRotationFallback +import dev.slimevr.resourcepacks.NoRotationFallback import dev.slimevr.resourcepacks.Offset import dev.slimevr.resourcepacks.ParsedResourcePack import dev.slimevr.resourcepacks.ProportionDefinition @@ -7,7 +10,12 @@ import dev.slimevr.resourcepacks.ResourcePackCatalog import dev.slimevr.resourcepacks.SourcedResource import io.github.axisangles.ktmath.Vector3 import solarxr_protocol.connection.BoneDefinition +import com.jme3.math.FastMath.DEG_TO_RAD as degToRad import dev.slimevr.resourcepacks.BoneDefinition as PackBoneDefinition +import dev.slimevr.resourcepacks.Constraint as PackConstraint +import dev.slimevr.resourcepacks.HingeConstraint as PackHingeConstraint +import dev.slimevr.resourcepacks.LooseHingeConstraint as PackLooseHingeConstraint +import dev.slimevr.resourcepacks.TwistSwingConstraint as PackTwistSwingConstraint import solarxr_protocol.connection.BoneRegistry as WireBoneRegistry data class ResourcePackCompilationDiagnostic(val packId: String, val path: String, val message: String) @@ -135,15 +143,68 @@ fun compileResourcePacks(catalog: ResourcePackCatalog): CompiledSkeleton { val tailOffsets = BoneMap.of(registry) val headOffsets = BoneMap.of(registry) + val constraints = BoneMap.of(registry) + val copyFallbacksByBoneId = mutableMapOf>() + val firstActiveFallbacksByBoneId = mutableMapOf>() for (contribution in allContributions) { val definition = contribution.resource.value val boneId = registry[definition.key] ?: continue definition.tailOffset?.let { tailOffsets[boneId] = compileOffset(it, contribution, proportionsByKey, diagnostics) } definition.headOffset?.let { headOffsets[boneId] = compileOffset(it, contribution, proportionsByKey, diagnostics) } + definition.constraint?.let { constraints[boneId] = compileConstraint(it) } + when (val fallback = definition.rotationFallback) { + null, is NoRotationFallback -> {} + is CopyRotationFallback -> copyFallbacksByBoneId[boneId] = contribution to fallback + is FirstActiveRotationFallback -> firstActiveFallbacksByBoneId[boneId] = contribution to fallback + } + } + val hierarchyOrder = registry.hierarchyFrom(registry.root).map { it.second } + val copyRotationFallbacks = hierarchyOrder.mapNotNull { boneId -> + copyFallbacksByBoneId[boneId]?.let { (contribution, fallback) -> boneId to resolveFallbackBone(fallback.source, contribution, registry, diagnostics) } + } + val firstActiveRotationFallbacks = hierarchyOrder.mapNotNull { boneId -> + firstActiveFallbacksByBoneId[boneId]?.let { (contribution, fallback) -> + boneId to fallback.sources.map { resolveFallbackBone(it, contribution, registry, diagnostics) } + } } if (diagnostics.isNotEmpty()) throw ResourcePackCompilationException(diagnostics) - return CompiledSkeleton(registry, proportions, tailOffsets, headOffsets) + return CompiledSkeleton(registry, proportions, tailOffsets, headOffsets, constraints, copyRotationFallbacks, firstActiveRotationFallbacks) +} + +private fun compileConstraint(constraint: PackConstraint): Constraint = when (constraint) { + is PackTwistSwingConstraint -> TwistSwingConstraint( + twist = constraint.twistDegrees * degToRad, + swing = constraint.swingDegrees * degToRad, + allowedDeviation = (constraint.allowedDeviationDegrees ?: 0f) * degToRad, + ) + + is PackHingeConstraint -> HingeConstraint( + min = constraint.minDegrees * degToRad, + max = constraint.maxDegrees * degToRad, + hingeAxis = Vector3(constraint.axis.x, constraint.axis.y, constraint.axis.z), + ) + + is PackLooseHingeConstraint -> LooseHingeConstraint( + min = constraint.minDegrees * degToRad, + max = constraint.maxDegrees * degToRad, + allowedDeviation = constraint.allowedDeviationDegrees * degToRad, + hingeAxis = Vector3(constraint.axis.x, constraint.axis.y, constraint.axis.z), + ) +} + +/** Resolves one rotation-fallback source key (or the `"parent"` shorthand) to a [BoneId]. */ +private fun resolveFallbackBone( + key: String, + contribution: BoneContribution, + registry: BoneRegistry, + diagnostics: MutableList, +): BoneId { + val target = if (key == "parent") contribution.resource.value.parent else key + val boneId = target?.let { registry[it] } + if (boneId != null) return boneId + diagnostics += ResourcePackCompilationDiagnostic(contribution.pack.manifest.value.id, contribution.resource.path, "Unknown bone '$key' in rotationFallback") + return BoneId(0u) } private fun compileOffset( diff --git a/server/core/src/main/java/dev/slimevr/resourcepacks/resource-models.kt b/server/core/src/main/java/dev/slimevr/resourcepacks/resource-models.kt index abecfcf35..15e935970 100644 --- a/server/core/src/main/java/dev/slimevr/resourcepacks/resource-models.kt +++ b/server/core/src/main/java/dev/slimevr/resourcepacks/resource-models.kt @@ -17,22 +17,19 @@ data class Offset(val base: Vector3? = null, val terms: List? = null @Serializable @JsonClassDiscriminator("type") -sealed interface RotationFallback { - val before: List? - val after: List? -} +sealed interface RotationFallback @Serializable @SerialName("none") -data class NoRotationFallback(override val before: List? = null, override val after: List? = null) : RotationFallback +data object NoRotationFallback : RotationFallback @Serializable @SerialName("copy") -data class CopyRotationFallback(val source: String, override val before: List? = null, override val after: List? = null) : RotationFallback +data class CopyRotationFallback(val source: String) : RotationFallback @Serializable @SerialName("firstActive") -data class FirstActiveRotationFallback(val sources: List, override val before: List? = null, override val after: List? = null) : RotationFallback +data class FirstActiveRotationFallback(val sources: List) : RotationFallback @Serializable @JsonClassDiscriminator("type") diff --git a/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt b/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt index b8ab90d2e..751e857dc 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt @@ -6,7 +6,6 @@ import dev.slimevr.bones.BoneSet import dev.slimevr.bones.CompiledSkeleton import dev.slimevr.bones.boneId import dev.slimevr.bones.mutateCopy -import dev.slimevr.bones.resolveToBoneIds import dev.slimevr.config.Settings import dev.slimevr.config.UserConfig import dev.slimevr.logging.AppLogger @@ -172,6 +171,7 @@ private class TickTimings(private val hz: Int, private val window: Duration, pri class ComputedSkeletonBehaviour( val hz: Int, + val definition: CompiledSkeleton, val inputProcessors: List = emptyList(), val fkComputedProcessors: List = emptyList(), val fkProcessors: List = emptyList(), @@ -181,7 +181,7 @@ class ComputedSkeletonBehaviour( ) : SkeletonBehaviour { private val intervalDuration = (1.0 / hz).seconds private val headId = BodyPart.HEAD.boneId - private val constraints = BODY_PART_CONSTRAINT_MAP.resolveToBoneIds() + private val constraints = definition.constraints private val ikChains = resolveIkChains() /** Shortest gap between two tick starts before the later one is pushed to the next slot */ diff --git a/server/core/src/main/java/dev/slimevr/skeleton/bodypart-constraints.kt b/server/core/src/main/java/dev/slimevr/skeleton/bodypart-constraints.kt deleted file mode 100644 index 6800b32fa..000000000 --- a/server/core/src/main/java/dev/slimevr/skeleton/bodypart-constraints.kt +++ /dev/null @@ -1,151 +0,0 @@ -package dev.slimevr.skeleton - -import com.jme3.math.FastMath -import dev.slimevr.bones.BodyPart -import dev.slimevr.bones.BodyPartMap -import dev.slimevr.bones.BoneId -import io.github.axisangles.ktmath.Quaternion - -// TODO Actually figure out good values for these constraints, maybe a source would be -// good? -val BODY_PART_CONSTRAINT_MAP: BodyPartMap = BodyPartMap( - mapOf( - BodyPart.LEFT_SHOULDER to TwistSwingConstraint( - 0f * FastMath.DEG_TO_RAD, - 30f * FastMath.DEG_TO_RAD, - ), - BodyPart.LEFT_UPPER_ARM to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 180f * FastMath.DEG_TO_RAD, - ), - BodyPart.LEFT_LOWER_ARM to LooseHingeConstraint( - -180f * FastMath.DEG_TO_RAD, - 0f * FastMath.DEG_TO_RAD, - 40f * FastMath.DEG_TO_RAD, - ), - BodyPart.LEFT_HAND to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 120f * FastMath.DEG_TO_RAD, - ), - - BodyPart.RIGHT_SHOULDER to TwistSwingConstraint( - 0f * FastMath.DEG_TO_RAD, - 30f * FastMath.DEG_TO_RAD, - ), - BodyPart.RIGHT_UPPER_ARM to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 180f * FastMath.DEG_TO_RAD, - ), - BodyPart.RIGHT_LOWER_ARM to LooseHingeConstraint( - -180f * FastMath.DEG_TO_RAD, - 0f * FastMath.DEG_TO_RAD, - 40f * FastMath.DEG_TO_RAD, - ), - BodyPart.RIGHT_HAND to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 120f * FastMath.DEG_TO_RAD, - ), - - BodyPart.UPPER_CHEST to TwistSwingConstraint( - 90f * FastMath.DEG_TO_RAD, - 120f * FastMath.DEG_TO_RAD, - ), - BodyPart.LOWER_CHEST to TwistSwingConstraint( - 60f * FastMath.DEG_TO_RAD, - 120f * FastMath.DEG_TO_RAD, - ), - 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, - ), - BodyPart.HIP to TwistSwingConstraint( - 60f * FastMath.DEG_TO_RAD, - 120f * FastMath.DEG_TO_RAD, - ), - - BodyPart.LEFT_UPPER_LEG to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 170f * FastMath.DEG_TO_RAD, - ), - BodyPart.LEFT_LOWER_LEG to LooseHingeConstraint( - -5f * FastMath.DEG_TO_RAD, - 180f * FastMath.DEG_TO_RAD, - 10f * FastMath.DEG_TO_RAD, - ), - BodyPart.LEFT_FOOT to LooseHingeConstraint( - -60f * FastMath.DEG_TO_RAD, - 90f * FastMath.DEG_TO_RAD, - 60f * FastMath.DEG_TO_RAD, - ), - - BodyPart.RIGHT_UPPER_LEG to TwistSwingConstraint( - 120f * FastMath.DEG_TO_RAD, - 170f * FastMath.DEG_TO_RAD, - ), - BodyPart.RIGHT_LOWER_LEG to LooseHingeConstraint( - -5f * FastMath.DEG_TO_RAD, - 180f * FastMath.DEG_TO_RAD, - 10f * FastMath.DEG_TO_RAD, - ), - BodyPart.RIGHT_FOOT to LooseHingeConstraint( - -60f * FastMath.DEG_TO_RAD, - 90f * FastMath.DEG_TO_RAD, - 60f * FastMath.DEG_TO_RAD, - ), - ), -) - -fun constrainOffset( - constraint: Constraint, - parent: Quaternion, - bone: Quaternion, - offset: Quaternion, -): Quaternion { - // TODO: Ensure the quaternion multiplication order is correct here - return constraint.apply(parent, offset * bone) * bone.inv() -} - -fun constrainOffsetWithSkeleton( - boneId: BoneId, - offset: Quaternion, - bones: ComputedSkeleton, - constraints: Map, -): Quaternion { - val registry = bones.registry - val constraint = constraints[boneId] ?: return offset - val boneRot = bones[boneId]?.rotation ?: return offset - val parentRot = registry.parentOf(boneId)?.let { parent -> - bones[parent]?.rotation - } ?: Quaternion.IDENTITY - - return constrainOffset( - constraint, - parentRot, - boneRot, - offset, - ) -} - -fun constrainSkeleton( - bones: InputSkeleton, - constraints: Map, -): InputSkeleton { - val registry = bones.registry - // Apply constraints top-down, from the root - for ((parentId, boneId) in registry.hierarchyFrom(registry.root)) { - val bone = bones[boneId] ?: continue - val constraint = constraints[boneId] ?: continue - val parentRotation = parentId?.let { bones[it]?.rotation } ?: Quaternion.IDENTITY - bones[boneId] = bone.copy( - rotation = constraint.apply( - parentRotation, - bone.rotation, - ), - ) - } - return bones -} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/constraint-application.kt b/server/core/src/main/java/dev/slimevr/skeleton/constraint-application.kt new file mode 100644 index 000000000..eff7cadb1 --- /dev/null +++ b/server/core/src/main/java/dev/slimevr/skeleton/constraint-application.kt @@ -0,0 +1,56 @@ +package dev.slimevr.skeleton + +import dev.slimevr.bones.BoneId +import dev.slimevr.bones.Constraint +import io.github.axisangles.ktmath.Quaternion + +fun constrainOffset( + constraint: Constraint, + parent: Quaternion, + bone: Quaternion, + offset: Quaternion, +): Quaternion { + // TODO: Ensure the quaternion multiplication order is correct here + return constraint.apply(parent, offset * bone) * bone.inv() +} + +fun constrainOffsetWithSkeleton( + boneId: BoneId, + offset: Quaternion, + bones: ComputedSkeleton, + constraints: Map, +): Quaternion { + val registry = bones.registry + val constraint = constraints[boneId] ?: return offset + val boneRot = bones[boneId]?.rotation ?: return offset + val parentRot = registry.parentOf(boneId)?.let { parent -> + bones[parent]?.rotation + } ?: Quaternion.IDENTITY + + return constrainOffset( + constraint, + parentRot, + boneRot, + offset, + ) +} + +fun constrainSkeleton( + bones: InputSkeleton, + constraints: Map, +): InputSkeleton { + val registry = bones.registry + // Apply constraints top-down, from the root + for ((parentId, boneId) in registry.hierarchyFrom(registry.root)) { + val bone = bones[boneId] ?: continue + val constraint = constraints[boneId] ?: continue + val parentRotation = parentId?.let { bones[it]?.rotation } ?: Quaternion.IDENTITY + bones[boneId] = bone.copy( + rotation = constraint.apply( + parentRotation, + bone.rotation, + ), + ) + } + return bones +} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/ik.kt b/server/core/src/main/java/dev/slimevr/skeleton/ik.kt index 57d47a460..66754c460 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/ik.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/ik.kt @@ -3,6 +3,7 @@ package dev.slimevr.skeleton import com.jme3.math.FastMath import dev.slimevr.bones.BoneId import dev.slimevr.bones.BoneSet +import dev.slimevr.bones.Constraint import io.github.axisangles.ktmath.Quaternion import io.github.axisangles.ktmath.Vector3 diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-direct-link.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-direct-link.kt deleted file mode 100644 index 388bbc8da..000000000 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/bone-direct-link.kt +++ /dev/null @@ -1,49 +0,0 @@ -package dev.slimevr.skeleton.inputprocessors - -import dev.slimevr.bones.BodyPart -import dev.slimevr.bones.BoneId -import dev.slimevr.bones.boneId -import dev.slimevr.skeleton.InputSkeleton -import dev.slimevr.skeleton.SkeletonInputProcessor - -/** - * Handles setting the rotation of an inactive bone with its source bone. - */ -class BoneDirectLinkInputProcessor : SkeletonInputProcessor { - /** - * First element is the linked bone. - * - * Second element is the bone the first element is linked to. - */ - private val linkedToSource: Array> = arrayOf( - BodyPart.HEAD to BodyPart.NECK, - BodyPart.NECK to BodyPart.HEAD, - - BodyPart.LEFT_FOOT to BodyPart.LEFT_LOWER_LEG, - BodyPart.RIGHT_FOOT to BodyPart.RIGHT_LOWER_LEG, - - BodyPart.LEFT_SHOULDER to BodyPart.UPPER_CHEST, - BodyPart.RIGHT_SHOULDER to BodyPart.UPPER_CHEST, - - BodyPart.LEFT_UPPER_ARM to BodyPart.LEFT_SHOULDER, - BodyPart.RIGHT_UPPER_ARM to BodyPart.RIGHT_SHOULDER, - - BodyPart.LEFT_LOWER_ARM to BodyPart.LEFT_UPPER_ARM, - BodyPart.RIGHT_LOWER_ARM to BodyPart.RIGHT_UPPER_ARM, - - BodyPart.LEFT_HAND to BodyPart.LEFT_LOWER_ARM, - BodyPart.RIGHT_HAND to BodyPart.RIGHT_LOWER_ARM, - ).map { (bodyPart, source) -> bodyPart.boneId to source.boneId }.toTypedArray() - - override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { - for ((boneId, sourceId) in linkedToSource) { - val bone = mutableInputSkeleton[boneId] ?: continue - if (bone.isRotationActive) continue - - val rotation = mutableInputSkeleton[sourceId]?.rotation ?: continue - if (rotation == bone.rotation) continue - - mutableInputSkeleton[boneId] = bone.copy(rotation = rotation) - } - } -} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/constraint.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/constraint.kt index 506d5cb08..ddcbc095a 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/constraint.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/constraint.kt @@ -1,18 +1,16 @@ package dev.slimevr.skeleton.inputprocessors -import dev.slimevr.bones.BoneId -import dev.slimevr.bones.resolveToBoneIds +import dev.slimevr.bones.CompiledSkeleton import dev.slimevr.config.Settings -import dev.slimevr.skeleton.BODY_PART_CONSTRAINT_MAP -import dev.slimevr.skeleton.Constraint import dev.slimevr.skeleton.InputSkeleton import dev.slimevr.skeleton.SkeletonInputProcessor import dev.slimevr.skeleton.constrainSkeleton class ConstraintInputProcessor( val settings: Settings, + definition: CompiledSkeleton, ) : SkeletonInputProcessor { - private val constraints: Map = BODY_PART_CONSTRAINT_MAP.resolveToBoneIds() + private val constraints = definition.constraints override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { val skeletonConfig = settings.context.state.value.data.skeletonConfig diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/copy-rotation-fallback.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/copy-rotation-fallback.kt new file mode 100644 index 000000000..8a6772cae --- /dev/null +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/copy-rotation-fallback.kt @@ -0,0 +1,23 @@ +package dev.slimevr.skeleton.inputprocessors + +import dev.slimevr.bones.BoneId +import dev.slimevr.skeleton.InputSkeleton +import dev.slimevr.skeleton.SkeletonInputProcessor + +/** + * Copies another bone's rotation onto a bone that has no live tracker of its own. [schedule] pairs + * a bone with its source, in ancestor-before-descendant order, so a source that itself needed + * copying this pass is already resolved by the time it's read. + */ +class CopyRotationFallbackInputProcessor( + private val schedule: List>, +) : SkeletonInputProcessor { + override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { + for ((boneId, source) in schedule) { + val bone = mutableInputSkeleton[boneId] ?: continue + if (bone.isRotationActive) continue + val rotation = mutableInputSkeleton[source]?.rotation ?: continue + mutableInputSkeleton[boneId] = bone.copy(rotation = rotation) + } + } +} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/first-active-rotation-fallback.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/first-active-rotation-fallback.kt new file mode 100644 index 000000000..f7bb34e98 --- /dev/null +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/first-active-rotation-fallback.kt @@ -0,0 +1,23 @@ +package dev.slimevr.skeleton.inputprocessors + +import dev.slimevr.bones.BoneId +import dev.slimevr.skeleton.InputSkeleton +import dev.slimevr.skeleton.SkeletonInputProcessor + +/** + * Sets an untracked bone's rotation from the first actively-tracked bone in its source list, + * falling back to the list's last entry regardless of its activity if none are active. + */ +class FirstActiveRotationFallbackInputProcessor( + private val schedule: List>>, +) : SkeletonInputProcessor { + override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { + for ((boneId, sources) in schedule) { + val bone = mutableInputSkeleton[boneId] ?: continue + if (bone.isRotationActive) continue + val active = sources.firstNotNullOfOrNull { mutableInputSkeleton[it]?.takeIf { b -> b.isRotationActive } } + val rotation = (active ?: sources.lastOrNull()?.let { mutableInputSkeleton[it] })?.rotation ?: continue + mutableInputSkeleton[boneId] = bone.copy(rotation = rotation) + } + } +} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt deleted file mode 100644 index 12db4150f..000000000 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/toe-active-link.kt +++ /dev/null @@ -1,48 +0,0 @@ -package dev.slimevr.skeleton.inputprocessors - -import dev.slimevr.bones.BodyPart -import dev.slimevr.bones.BoneId -import dev.slimevr.bones.boneId -import dev.slimevr.skeleton.InputSkeleton -import dev.slimevr.skeleton.SkeletonInputProcessor - -/** - * Handles setting the rotation of an inactive toe bone with the first active toe bone in its sources, or keeps - * the old rotation if none of them are active. - */ -class ToeActiveLinkInputProcessor : SkeletonInputProcessor { - /** - * First element is the bone whose BoneInput is not actively receiving data. - * - * Second element contains a list of bones whose rotation should be used as a fallback prioritized from first to last. - * First active bone will be prioritized. If none are active, the last bone is used. - */ - private val toeToSources: Array>> = arrayOf( - 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), - BodyPart.LEFT_MIDDLE_TOE to arrayOf(BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), - BodyPart.LEFT_RING_TOE to arrayOf(BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_LITTLE_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), - BodyPart.LEFT_LITTLE_TOE to arrayOf(BodyPart.LEFT_RING_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_FOOT), - - BodyPart.RIGHT_BIG_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_FOOT), - BodyPart.RIGHT_INDEX_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), - BodyPart.RIGHT_MIDDLE_TOE to arrayOf(BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), - BodyPart.RIGHT_RING_TOE to arrayOf(BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_LITTLE_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), - BodyPart.RIGHT_LITTLE_TOE to arrayOf(BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_FOOT), - ).map { (bodyPart, sources) -> - bodyPart.boneId to sources.map { it.boneId }.toTypedArray() - }.toTypedArray() - - override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { - for ((boneId, sources) in toeToSources) { - val bone = mutableInputSkeleton[boneId] ?: continue - if (bone.isRotationActive) continue - - val closestActiveBoneOrLast = sources.firstNotNullOfOrNull { id -> - mutableInputSkeleton[id]?.takeIf { it.isRotationActive } - } ?: sources.lastOrNull()?.let { mutableInputSkeleton[it] } ?: continue - - mutableInputSkeleton[boneId] = bone.copy(rotation = closestActiveBoneOrLast.rotation) - } - } -} diff --git a/server/core/src/main/java/dev/slimevr/skeleton/module.kt b/server/core/src/main/java/dev/slimevr/skeleton/module.kt index b43b89c23..a9ac856ee 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/module.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/module.kt @@ -15,16 +15,16 @@ import dev.slimevr.skeleton.computedprocessors.VelocityComputedProcessor import dev.slimevr.skeleton.fkprocessors.FootPlantFkProcessor import dev.slimevr.skeleton.fkprocessors.LocalizerFkProcessor import dev.slimevr.skeleton.fkprocessors.ToeSnapFkProcessor -import dev.slimevr.skeleton.inputprocessors.BoneDirectLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.BoneYawFallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.ConstraintInputProcessor +import dev.slimevr.skeleton.inputprocessors.CopyRotationFallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.FingerImputeInputProcessor +import dev.slimevr.skeleton.inputprocessors.FirstActiveRotationFallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackProcessor import dev.slimevr.skeleton.inputprocessors.HipYawRollAlignInputProcessor import dev.slimevr.skeleton.inputprocessors.PredictionInputProcessor import dev.slimevr.skeleton.inputprocessors.SmoothingInputProcessor import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor -import dev.slimevr.skeleton.inputprocessors.ToeActiveLinkInputProcessor import dev.slimevr.skeleton.inputprocessors.UpperLegsRollAlignInputProcessor import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor import dev.slimevr.skeleton.targetprocessors.SkatingCorrectionTargetProcessor @@ -234,6 +234,7 @@ class Skeleton( // YouSpinMeRightRoundBehaviour(inputHz = 50f), ComputedSkeletonBehaviour( hz = hz, + definition = definition, waiter = waiter, inputProcessors = listOf( PredictionInputProcessor(settings).also { resettableSkeletonProcessors.add(it) }, @@ -243,10 +244,10 @@ class Skeleton( SpineInputProcessor(settings), HipYawRollAlignInputProcessor(settings), UpperLegsRollAlignInputProcessor(settings), - BoneDirectLinkInputProcessor(), + CopyRotationFallbackInputProcessor(definition.copyRotationFallbacks), FingerImputeInputProcessor(), - ToeActiveLinkInputProcessor(), - ConstraintInputProcessor(settings), + FirstActiveRotationFallbackInputProcessor(definition.firstActiveRotationFallbacks), + ConstraintInputProcessor(settings, definition), ), fkComputedProcessors = listOf( VelocityComputedProcessor().also { resettableSkeletonProcessors.add(it) }, diff --git a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/data/bones/head.json b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/data/bones/head.json index 4c1fe7591..4fc81fbb8 100644 --- a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/data/bones/head.json +++ b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/data/bones/head.json @@ -3,7 +3,7 @@ "key": "slimevr:head", "nameKey": "slimevr:bone.head", "tailOffset": {"terms": [{"proportion": "slimevr:head", "direction": {"x": 0, "y": 0, "z": 1}}]}, - "rotationFallback": {"type": "copy", "source": "slimevr:neck", "before": ["slimevr:neck"]}, + "rotationFallback": {"type": "copy", "source": "slimevr:neck"}, "outputs": { "vmc": {"name": "Head"}, "vrchat": { diff --git a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/bone.schema.json b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/bone.schema.json index c0b73e47c..69bf51fb9 100644 --- a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/bone.schema.json +++ b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/bone.schema.json @@ -74,14 +74,6 @@ "source": { "description": "Bone to copy from when this bone is untracked. `parent` refers to this bone's own `parent` field rather than repeating its key.", "anyOf": [{"const": "parent"}, {"$ref": "common.schema.json#/$defs/key"}] - }, - "before": { - "description": "Run this bone's fallback before the fallbacks owned by these bones, when both participate in the same order-dependent write cycle (e.g. two bones whose fallbacks copy each other).", - "$ref": "common.schema.json#/$defs/orderReferences" - }, - "after": { - "description": "Run this bone's fallback after the fallbacks owned by these bones, when both participate in the same order-dependent write cycle.", - "$ref": "common.schema.json#/$defs/orderReferences" } } }, @@ -100,14 +92,6 @@ "uniqueItems": true, "description": "Ordered candidates. The first one with a live, active tracker is used. If none are active, the final entry is used unconditionally, so a bone intended as the ultimate fallback (e.g. the parent foot for a toe) belongs last.", "items": {"anyOf": [{"const": "parent"}, {"$ref": "common.schema.json#/$defs/key"}]} - }, - "before": { - "description": "Run this bone's fallback before the fallbacks owned by these bones, when both participate in the same order-dependent write cycle.", - "$ref": "common.schema.json#/$defs/orderReferences" - }, - "after": { - "description": "Run this bone's fallback after the fallbacks owned by these bones, when both participate in the same order-dependent write cycle.", - "$ref": "common.schema.json#/$defs/orderReferences" } } } diff --git a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/common.schema.json b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/common.schema.json index a2336e8eb..472fda40c 100644 --- a/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/common.schema.json +++ b/server/core/src/main/resources/dev/slimevr/resourcepacks/core/schemas/v1/common.schema.json @@ -3,12 +3,6 @@ "$defs": { "key": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_./-]*$"}, "translationKey": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_.-]*$"}, - "orderReferences": { - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items": {"$ref": "#/$defs/key"} - }, "vector": { "type": "object", "additionalProperties": false, diff --git a/server/core/src/test/java/dev/slimevr/skeleton/ConstraintTest.kt b/server/core/src/test/java/dev/slimevr/bones/ConstraintTest.kt similarity index 98% rename from server/core/src/test/java/dev/slimevr/skeleton/ConstraintTest.kt rename to server/core/src/test/java/dev/slimevr/bones/ConstraintTest.kt index 5d83fdccd..66fb2a5b1 100644 --- a/server/core/src/test/java/dev/slimevr/skeleton/ConstraintTest.kt +++ b/server/core/src/test/java/dev/slimevr/bones/ConstraintTest.kt @@ -1,4 +1,4 @@ -package dev.slimevr.skeleton +package dev.slimevr.bones import com.jme3.math.FastMath import dev.slimevr.quaternionAssertEquals diff --git a/server/core/src/test/java/dev/slimevr/bones/ResourcePackCompilerTest.kt b/server/core/src/test/java/dev/slimevr/bones/ResourcePackCompilerTest.kt index 7027f0239..89fbf7b7f 100644 --- a/server/core/src/test/java/dev/slimevr/bones/ResourcePackCompilerTest.kt +++ b/server/core/src/test/java/dev/slimevr/bones/ResourcePackCompilerTest.kt @@ -1,11 +1,13 @@ package dev.slimevr.bones +import com.jme3.math.FastMath.DEG_TO_RAD import dev.slimevr.resourcepacks.ClasspathResourcePackSource import dev.slimevr.resourcepacks.InMemoryResourcePackSource import dev.slimevr.resourcepacks.ResourcePackCatalog import dev.slimevr.resourcepacks.ResourcePackParser import io.github.axisangles.ktmath.Vector3 import kotlinx.coroutines.test.runTest +import solarxr_protocol.datatypes.BodyPart import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -84,6 +86,103 @@ class ResourcePackCompilerTest { for (key in defaults.keys) assertFloatEquals(defaults.getValue(key), recovered.getValue(key), key) } + @Test + fun `bundled core pack compiles constraints matching the retired hardcoded table`() = runTest { + val core = ResourcePackParser().parse(ClasspathResourcePackSource.core(javaClass.classLoader)) + val definition = compileResourcePacks(catalog(core)) + val constraints = definition.constraints + assertEquals(19, constraints.entries.size) + + fun twistSwing(part: BodyPart, twist: Float, swing: Float) { + val c = constraints[definition.registry[part.key]!!] as TwistSwingConstraint + assertFloatEquals(twist * DEG_TO_RAD, c.twist, "${part.key} twist") + assertFloatEquals(swing * DEG_TO_RAD, c.swing, "${part.key} swing") + } + fun looseHinge(part: BodyPart, min: Float, max: Float, allowedDeviation: Float) { + val c = constraints[definition.registry[part.key]!!] as LooseHingeConstraint + assertFloatEquals(min * DEG_TO_RAD, c.min, "${part.key} min") + assertFloatEquals(max * DEG_TO_RAD, c.max, "${part.key} max") + assertFloatEquals(allowedDeviation * DEG_TO_RAD, c.allowedDeviation, "${part.key} allowedDeviation") + } + + twistSwing(BodyPart.LEFT_SHOULDER, 0f, 30f) + twistSwing(BodyPart.LEFT_UPPER_ARM, 120f, 180f) + looseHinge(BodyPart.LEFT_LOWER_ARM, -180f, 0f, 40f) + twistSwing(BodyPart.LEFT_HAND, 120f, 120f) + twistSwing(BodyPart.UPPER_CHEST, 90f, 120f) + twistSwing(BodyPart.LOWER_CHEST, 60f, 120f) + twistSwing(BodyPart.UPPER_WAIST, 60f, 120f) + twistSwing(BodyPart.LOWER_WAIST, 60f, 120f) + twistSwing(BodyPart.HIP, 60f, 120f) + twistSwing(BodyPart.LEFT_UPPER_LEG, 120f, 170f) + looseHinge(BodyPart.LEFT_LOWER_LEG, -5f, 180f, 10f) + looseHinge(BodyPart.LEFT_FOOT, -60f, 90f, 60f) + } + + @Test + fun `bundled core pack's copy rotation-fallback schedule matches the retired BoneDirectLinkInputProcessor table`() = runTest { + val core = ResourcePackParser().parse(ClasspathResourcePackSource.core(javaClass.classLoader)) + val definition = compileResourcePacks(catalog(core)) + val schedule = definition.copyRotationFallbacks + val registry = definition.registry + + val expectedBones = setOf( + BodyPart.HEAD, BodyPart.NECK, + BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT, + BodyPart.LEFT_SHOULDER, BodyPart.RIGHT_SHOULDER, + BodyPart.LEFT_UPPER_ARM, BodyPart.RIGHT_UPPER_ARM, + BodyPart.LEFT_LOWER_ARM, BodyPart.RIGHT_LOWER_ARM, + BodyPart.LEFT_HAND, BodyPart.RIGHT_HAND, + ).map { registry[it.key]!! }.toSet() + assertEquals(expectedBones, schedule.map { it.first }.toSet()) + + val order = schedule.map { it.first } + fun indexOf(part: BodyPart) = order.indexOf(registry[part.key]!!) + + assertTrue(indexOf(BodyPart.HEAD) < indexOf(BodyPart.NECK), "head before neck") + assertTrue(indexOf(BodyPart.LEFT_SHOULDER) < indexOf(BodyPart.LEFT_UPPER_ARM), "shoulder before upper_arm") + assertTrue(indexOf(BodyPart.LEFT_UPPER_ARM) < indexOf(BodyPart.LEFT_LOWER_ARM), "upper_arm before lower_arm") + assertTrue(indexOf(BodyPart.LEFT_LOWER_ARM) < indexOf(BodyPart.LEFT_HAND), "lower_arm before hand") + + val headFallback = schedule.first { it.first == registry[BodyPart.HEAD.key]!! } + assertEquals(registry[BodyPart.NECK.key]!!, headFallback.second) + } + + @Test + fun `bundled core pack's firstActive rotation-fallback schedule matches the retired ToeActiveLinkInputProcessor table`() = runTest { + val core = ResourcePackParser().parse(ClasspathResourcePackSource.core(javaClass.classLoader)) + val definition = compileResourcePacks(catalog(core)) + val schedule = definition.firstActiveRotationFallbacks + val registry = definition.registry + + val expectedBones = setOf( + BodyPart.LEFT_BIG_TOE, BodyPart.LEFT_INDEX_TOE, BodyPart.LEFT_MIDDLE_TOE, BodyPart.LEFT_RING_TOE, BodyPart.LEFT_LITTLE_TOE, + BodyPart.RIGHT_BIG_TOE, BodyPart.RIGHT_INDEX_TOE, BodyPart.RIGHT_MIDDLE_TOE, BodyPart.RIGHT_RING_TOE, BodyPart.RIGHT_LITTLE_TOE, + ).map { registry[it.key]!! }.toSet() + assertEquals(expectedBones, schedule.map { it.first }.toSet()) + + // left_foot itself is copy-type, not firstActive, so it's resolved by + // CopyRotationFallbackInputProcessor before this schedule ever runs. + val bigToeFallback = schedule.first { it.first == registry[BodyPart.LEFT_BIG_TOE.key]!! } + assertEquals(registry[BodyPart.LEFT_FOOT.key]!!, bigToeFallback.second.last()) + } + + @Test + fun `compiler reports an unknown bone named in a rotation fallback`() = runTest { + val core = ResourcePackParser().parse(ClasspathResourcePackSource.core(javaClass.classLoader)) + val user = ResourcePackParser().parse( + InMemoryResourcePackSource( + mapOf( + "manifest.json" to manifest("example:extra"), + "data/bones/extra.json" to """{"key":"example:extra","nameKey":"example:bone.extra","parent":"slimevr:head","rotationFallback":{"type":"copy","source":"example:missing"}}""", + "assets/lang/en.json" to """{"example:bone.extra":"Extra bone"}""", + ), + ), + ) + val error = assertFailsWith { compileResourcePacks(catalog(core, user)) } + assertTrue(error.diagnostics.any { "Unknown bone" in it.message && "rotationFallback" in it.message }) + } + @Test fun `compiler includes user-pack bones after the core registry`() = runTest { val core = ResourcePackParser().parse(ClasspathResourcePackSource.core(javaClass.classLoader)) diff --git a/server/core/src/test/java/dev/slimevr/resourcepacks/ResourcePackParserTest.kt b/server/core/src/test/java/dev/slimevr/resourcepacks/ResourcePackParserTest.kt index 9283e5a4d..5750e6612 100644 --- a/server/core/src/test/java/dev/slimevr/resourcepacks/ResourcePackParserTest.kt +++ b/server/core/src/test/java/dev/slimevr/resourcepacks/ResourcePackParserTest.kt @@ -137,7 +137,7 @@ class ResourcePackParserTest { "manifest.json" to manifest("example:branches"), "data/bones/branch.json" to """ {"key":"example:branch","nameKey":"example:name", - "rotationFallback":{"type":"firstActive","sources":["example:first","example:last"],"after":["example:after"]}, + "rotationFallback":{"type":"firstActive","sources":["example:first","example:last"]}, "constraint":{"type":"hinge","minDegrees":-1,"maxDegrees":1,"axis":{"x":1,"y":0,"z":0}}, "outputs":{"vrchat":{"emit":{"/example":{"from":"rotation","value":[ {"euler":"x"},{"euler":{"order":"YXZ","unit":"radians"}},{"scale":2},{"divide":{"x":2}},{"offset":{"z":1}},{"clamp":[-1,1]},{"greaterThan":0},{"lessThan":2} diff --git a/server/core/src/test/java/dev/slimevr/skeleton/IKTest.kt b/server/core/src/test/java/dev/slimevr/skeleton/IKTest.kt index 973d90c27..01404c584 100644 --- a/server/core/src/test/java/dev/slimevr/skeleton/IKTest.kt +++ b/server/core/src/test/java/dev/slimevr/skeleton/IKTest.kt @@ -4,7 +4,7 @@ import dev.slimevr.bones.BodyPart import dev.slimevr.bones.BoneMap import dev.slimevr.bones.BoneRegistry import dev.slimevr.bones.boneId -import dev.slimevr.bones.resolveToBoneIds +import dev.slimevr.testCompiledSkeleton import io.github.axisangles.ktmath.EulerOrder import io.github.axisangles.ktmath.Vector3 import kotlin.test.Test @@ -54,7 +54,7 @@ class IKTest { target, ) - val ikOut = ccdIk(boneInputs, bones, listOf(goal), BODY_PART_CONSTRAINT_MAP.resolveToBoneIds(), 0.01f, 100) + val ikOut = ccdIk(boneInputs, bones, listOf(goal), testCompiledSkeleton.constraints, 0.01f, 100) assert(ikOut.goalsReached.all { it.value }) { val boneRots = ikOut.bones.values.joinToString { "${it.boneId}: ${it.rotation.toEulerAngles(EulerOrder.YZX)}"