mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-02 06:42:36 -08:00
allow a single spine tracker to control the whole spine without warning
This commit is contained in:
1 parent
c30efd2317
commit
753fdb527e
3 files changed
+9
-13
No files matched your search
@@ -97,7 +97,7 @@ const SETUP_REGIONS: {
|
||||
}[] = [
|
||||
{ id: 'legs', parts: [...LEGS_PARTS], needs: [] },
|
||||
{ id: 'chest', parts: [BodyPart.UPPER_CHEST], needs: [] },
|
||||
{ id: 'hip', parts: [BodyPart.HIP], needs: ['chest'] },
|
||||
{ id: 'hip', parts: [BodyPart.HIP], needs: [] },
|
||||
// one spine point at a time, each halving the largest remaining gap
|
||||
{ id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['hip'] },
|
||||
{ id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['lowerWaist'] },
|
||||
|
||||
@@ -78,11 +78,10 @@ fun bodyPartPrerequisites(bodyPart: BodyPart, ikSolved: Set<BodyPart> = emptySet
|
||||
requirementGroups(bodyPart).filterNot { group -> group.all { it in ikSolved } }
|
||||
|
||||
private fun requirementGroups(bodyPart: BodyPart): List<List<BodyPart>> {
|
||||
val spineIndex = SPINE_IMPUTED_PARTS.indexOf(bodyPart)
|
||||
if (spineIndex >= 0) return listOfNotNull(SPINE_IMPUTED_PARTS.take(spineIndex).ifEmpty { null })
|
||||
|
||||
// The head roots the skeleton and the neck hangs off it, so neither waits on anything.
|
||||
if (bodyPart == BodyPart.HEAD || bodyPart == BodyPart.NECK) return emptyList()
|
||||
val standsAlone = bodyPart in SPINE_IMPUTED_PARTS ||
|
||||
bodyPart == BodyPart.HEAD ||
|
||||
bodyPart == BodyPart.NECK
|
||||
if (standsAlone) return emptyList()
|
||||
|
||||
return limbPrerequisites(bodyPart) + listOf(SPINE_IMPUTED_PARTS)
|
||||
}
|
||||
|
||||
@@ -74,13 +74,10 @@ class BodyPartPrerequisitesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the top of the spine stands on its own and the rest of it looks upwards`() {
|
||||
assertEquals(emptyList(), bodyPartPrerequisites(BodyPart.UPPER_CHEST))
|
||||
assertEquals(listOf(listOf(BodyPart.UPPER_CHEST)), bodyPartPrerequisites(BodyPart.LOWER_CHEST))
|
||||
assertEquals(
|
||||
listOf(listOf(BodyPart.UPPER_CHEST, BodyPart.LOWER_CHEST, BodyPart.UPPER_WAIST, BodyPart.LOWER_WAIST)),
|
||||
bodyPartPrerequisites(BodyPart.HIP),
|
||||
)
|
||||
fun `a spine bone stands on its own`() {
|
||||
for (bodyPart in spineParts) {
|
||||
assertEquals(emptyList(), bodyPartPrerequisites(bodyPart), "$bodyPart should stand alone")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user