mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
WIP fixing centaur and run spotless
This commit is contained in:
1 parent
be2c16d827
commit
82e48cbad4
66 files changed
+165
-130
No files matched your search
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.autobone
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
fun slideContributionWeight(ankleA: Vector3, ankleB: Vector3, localBoneTailA: Vector3, localBoneTailB: Vector3): Float {
|
||||
val ankleAToB = ankleB - ankleA
|
||||
|
||||
@@ -66,7 +66,8 @@ enum class BodyPart(val value: UByte) {
|
||||
RIGHT_INDEX_TOE(58u),
|
||||
RIGHT_MIDDLE_TOE(59u),
|
||||
RIGHT_RING_TOE(60u),
|
||||
RIGHT_LITTLE_TOE(61u);
|
||||
RIGHT_LITTLE_TOE(61u),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromValue(value: UByte): BodyPart? = entries.firstOrNull { it.value == value }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.key
|
||||
import dev.slimevr.context.Behaviour
|
||||
import dev.slimevr.context.Context
|
||||
@@ -14,7 +15,6 @@ import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import kotlinx.serialization.json.intOrNull
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
import solarxr_protocol.rpc.ArmsResetMode
|
||||
import solarxr_protocol.rpc.FilteringType
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
package dev.slimevr.heightcalibration
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.UserConfig
|
||||
import dev.slimevr.config.UserConfigActions
|
||||
@@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import kotlinx.coroutines.flow.takeWhile
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.UserHeightCalibrationStatus
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
|
||||
@@ -4,6 +4,7 @@ package dev.slimevr.heightcalibration
|
||||
|
||||
import dev.slimevr.Phase1ContextProvider
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.UserConfig
|
||||
import dev.slimevr.context.Behaviour
|
||||
@@ -18,7 +19,6 @@ import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
import solarxr_protocol.rpc.UserHeightCalibrationStatus
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.hid.behaviours.v3
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.hid.HIDReceiver
|
||||
import dev.slimevr.hid.HIDReceiverBehaviour
|
||||
import dev.slimevr.hid.HIDSensorInfo
|
||||
import dev.slimevr.tracker.TrackerActions
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
class HIDSensorInfoBehaviour : HIDReceiverBehaviour {
|
||||
override fun observe(receiver: HIDReceiver) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.slimevr.keybind
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.EventDispatcher
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.KeybindConfig
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -18,7 +19,6 @@ import kotlinx.coroutines.flow.distinctUntilChangedBy
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.KeybindId
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.slimevr.resets
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.Phase1ContextProvider
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.bones.boneId
|
||||
@@ -22,7 +23,6 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
import solarxr_protocol.rpc.ArmsResetMode
|
||||
import solarxr_protocol.rpc.ResetResponse
|
||||
@@ -158,7 +158,7 @@ class ResetsManager(val context: ResetsContext, val server: VRServer, val settin
|
||||
.map { it.context.state.value }
|
||||
.filter { it.position != null }
|
||||
.getFirstActiveFor(BodyPart.HEAD.boneId)
|
||||
?.rawRotation ?: Quaternion.IDENTITY
|
||||
?.rawRotation?.twinNearest(Quaternion.IDENTITY) ?: Quaternion.IDENTITY
|
||||
|
||||
// Dispatch the reset action to the trackers
|
||||
trackers.forEach {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.routing
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.config.BoneRoutingConfig
|
||||
@@ -15,7 +16,6 @@ import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.map
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.rpc.RoutingOutput
|
||||
import solarxr_protocol.rpc.RoutingOutputState
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneMap
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.bones.BoneSet
|
||||
@@ -24,7 +25,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.cos
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
// TODO Actually figure out good values for these constraints, maybe a source would be
|
||||
// good?
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BodyPartMap
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
typealias BodyPartChain = List<BodyPart>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.util.inFloatingSeconds
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import kotlin.time.ComparableTimeMark
|
||||
|
||||
// TODO Where are these numbers from?
|
||||
|
||||
@@ -98,12 +98,13 @@ fun decomposeToSwingTwist(
|
||||
rotation: Quaternion,
|
||||
twistAxis: Vector3,
|
||||
): Pair<Quaternion, Quaternion> {
|
||||
// TODO simplify this?
|
||||
val projection = rotation.project(twistAxis).unit()
|
||||
val twist = Quaternion(
|
||||
sqrt(1.0f - projection.xyz.lenSq()).withSign(rotation.w),
|
||||
projection.xyz,
|
||||
)
|
||||
val swing = (rotation * twist.inv())
|
||||
val swing = (rotation / twist)
|
||||
return Pair(swing, twist)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package dev.slimevr.skeleton.fkprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonFkProcessor
|
||||
import dev.slimevr.tracker.eulerHeading
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
// The max height to plant feet by
|
||||
const val ROTATION_CORRECTION_VERTICAL = 0.1f
|
||||
@@ -27,7 +26,7 @@ fun correctFootAttitude(
|
||||
rotation: Quaternion,
|
||||
correctionRatio: Float,
|
||||
// eulerHeading is already twinNearest, so we can just use interpQ
|
||||
): Quaternion = rotation.interpQ(eulerHeading(rotation), correctionRatio)
|
||||
): Quaternion = rotation.interpQ(rotation.eulerHeading(), correctionRatio)
|
||||
|
||||
class FootPlantFkProcessor(val settings: Settings) : SkeletonFkProcessor {
|
||||
private val boneIds: Array<BoneId> = arrayOf(BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT).map { it.boneId }.toTypedArray()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.skeleton.fkprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -19,7 +20,6 @@ import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.inFloatingSeconds
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package dev.slimevr.skeleton.fkprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonFkProcessor
|
||||
import dev.slimevr.tracker.eulerHeading
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.asin
|
||||
|
||||
@@ -40,7 +39,7 @@ fun snapToes(
|
||||
correctionRatio: Float,
|
||||
): Quaternion {
|
||||
// TODO Do we want to retain roll?
|
||||
val heading = eulerHeading(rotation)
|
||||
val heading = rotation.eulerHeading()
|
||||
// TODO Not yet tested if this is the right method & math
|
||||
val maxPitch = Quaternion.rotationAroundXAxis(MAX_TOE_SNAP_ANGLE * correctionRatio)
|
||||
// Pitch must be applied first
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Handles setting the rotation of an inactive bone with its source bone.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
private const val INTERMEDIATE_FROM_PROXIMAL = 2.12f
|
||||
private const val DISTAL_FROM_PROXIMAL = 3.03f
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Moves the head input to the skeleton height. Else, it would default to (0, 0, 0).
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Rotates the first Quaternion to match its yaw and roll to the rotation of
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -9,7 +10,6 @@ import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.FilteringType
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import kotlin.enums.enumEntries
|
||||
|
||||
// At this default value, the user's spine should behave as we meant it to.
|
||||
@@ -137,9 +137,9 @@ private fun interpolateAbsTwist(fromRotation: Quaternion, toRotation: Quaternion
|
||||
if (ratio >= 0f) return fromRotation.interpQ(toRotation, ratio)
|
||||
|
||||
// Deconstruct the twist and swing of the rotations
|
||||
val fromTwist = fromRotation.twist()
|
||||
val fromTwist = fromRotation.twistY()
|
||||
val fromSwing = fromRotation / fromTwist
|
||||
val toTwist = toRotation.twist()
|
||||
val toTwist = toRotation.twistY()
|
||||
val toSwing = toRotation / toTwist
|
||||
|
||||
// Interpolate each part separately
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Handles setting the rotation of an inactive toe bone with the first active toe bone in its sources, or keeps
|
||||
|
||||
+1
-1
@@ -1,12 +1,12 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Rotates the first Quaternion to match its roll to the rotation of
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BodyPartMap
|
||||
import dev.slimevr.bones.BoneMap
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.bones.boneId
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import io.github.axisangles.ktmath.times
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.SkeletonBone
|
||||
import kotlin.collections.map
|
||||
import kotlin.collections.plus
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.bones.mapValues
|
||||
import dev.slimevr.bones.mutateCopy
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
fun reduce(state: SkeletonState, action: SkeletonActions): SkeletonState = when (action) {
|
||||
is SkeletonActions.SetBoneRotation -> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.skeleton.targetprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -7,7 +8,6 @@ import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.IKTargets
|
||||
import dev.slimevr.skeleton.SkeletonTargetProcessor
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
class FloorClipTargetProcessor(
|
||||
val settings: Settings,
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.skeleton.targetprocessors
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -14,7 +15,6 @@ import dev.slimevr.skeleton.computeComState
|
||||
import dev.slimevr.skeleton.resolveMasses
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
|
||||
data class LockState(
|
||||
|
||||
@@ -31,11 +31,14 @@ suspend fun onConnectionMessage(message: ConnectionMessage?, bridge: SolarXRBrid
|
||||
|
||||
ConnectionPhase.CONFIGURING -> when (message) {
|
||||
is BoneRegistryRequest -> bridge.sendConnectionMessage(bridge.registry.value)
|
||||
|
||||
is ConfigurationDone -> {
|
||||
bridge.sendConnectionMessage(ConfigurationDone())
|
||||
bridge.completeConfiguration()
|
||||
}
|
||||
|
||||
null -> bridge.sendConnectionMessage(ConnectionError(message = "Unrecognized connection message", data = UnsupportedRequestError()))
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.solarxr.driver
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BodyPartMap
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
@@ -18,7 +19,6 @@ import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.driver_protocol.BoneBatteryUpdate
|
||||
import solarxr_protocol.driver_protocol.SkeletonUpdate
|
||||
|
||||
@@ -3,8 +3,8 @@ package dev.slimevr.solarxr
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
import dev.slimevr.fbscodegen.runtime.JvmFlatBufferReader
|
||||
import dev.slimevr.fbscodegen.runtime.JvmFlatBufferWriter
|
||||
import java.nio.ByteBuffer
|
||||
import solarxr_protocol.MessageBundle
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
const val SOLARXR_PROTOCOL_VERSION: UInt = 2u
|
||||
const val SOLARXR_MAX_FRAME_SIZE = 256 * 1024
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.tapdetection
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.TapDetectionConfig
|
||||
@@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.merge
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import solarxr_protocol.rpc.TapDetectionSetupNotification
|
||||
|
||||
+1
-1
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.tracker.behaviours
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.tracker.Tracker
|
||||
import dev.slimevr.tracker.TrackerActions
|
||||
@@ -10,7 +11,6 @@ import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
|
||||
class TrackerDefaultMountingOrientationBehaviour(private val registry: BoneRegistry) : TrackerBehaviour {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.tracker.behaviours
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.resets.ResetBodyParts
|
||||
@@ -15,7 +16,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.ArmsResetMode
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package dev.slimevr.tracker
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
import kotlin.time.Duration
|
||||
|
||||
@@ -22,11 +22,12 @@ fun reduce(
|
||||
val accumulatedTicks = if (action.newData && action.rotation != null) (state.accumulatedTicks + 1u).toUShort() else state.accumulatedTicks
|
||||
|
||||
// Rotation
|
||||
val rawPolarityTrackedRotation: RawRotation = action.rotation?.twinNearest(state.rawRotation) ?: state.rawRotation
|
||||
val rawRotation: RawRotation = action.rotation ?: state.rawRotation
|
||||
val correctedRawRotation = if (state.stayAlignedData.enabled) {
|
||||
Quaternion.rotationAroundYAxis(state.stayAlignedData.yawCorrection.toRad()) * rawPolarityTrackedRotation
|
||||
// Apply stay aligned yaw correction
|
||||
Quaternion.rotationAroundYAxis(state.stayAlignedData.yawCorrection.toRad()) * rawRotation
|
||||
} else {
|
||||
rawPolarityTrackedRotation
|
||||
rawRotation
|
||||
}
|
||||
|
||||
// Other inputs
|
||||
@@ -40,6 +41,7 @@ fun reduce(
|
||||
val rotation: CalibratedRotation =
|
||||
if (action.rotation != null) {
|
||||
applyCalibration(correctedRawRotation, cal.headingCorrection, cal.attitudeAlignment, cal.headingAlignment, state.restOrientation)
|
||||
.twinNearest(state.rotation)
|
||||
} else {
|
||||
state.rotation
|
||||
}
|
||||
@@ -53,7 +55,7 @@ fun reduce(
|
||||
}
|
||||
|
||||
state.copy(
|
||||
rawRotation = rawPolarityTrackedRotation,
|
||||
rawRotation = rawRotation,
|
||||
rotation = rotation,
|
||||
rawAcceleration = rawAcceleration,
|
||||
acceleration = acceleration,
|
||||
@@ -84,13 +86,10 @@ fun reduce(
|
||||
val shouldAlignAttitude = !isHead || !isPositional || action.resetPositionalHeadAttitude
|
||||
val shouldAlignHeadingWithReference = !isHead && isPositional
|
||||
|
||||
// Use the shortest rotation/default polarity
|
||||
val shortestRawRotation = state.rawRotation.twinNearest(Quaternion.IDENTITY)
|
||||
|
||||
val headingCorrection =
|
||||
if (shouldAlignAttitude) {
|
||||
estimateHeadingCorrect(
|
||||
shortestRawRotation,
|
||||
state.rawRotation,
|
||||
action.referenceRotation,
|
||||
)
|
||||
} else {
|
||||
@@ -99,7 +98,7 @@ fun reduce(
|
||||
val attitudeAlignment =
|
||||
if (shouldAlignAttitude) {
|
||||
estimateAttitudeAlign(
|
||||
shortestRawRotation,
|
||||
state.rawRotation,
|
||||
headingCorrection,
|
||||
action.referenceRotation,
|
||||
)
|
||||
@@ -121,7 +120,7 @@ fun reduce(
|
||||
),
|
||||
// Full reset snaps: cancel any in-progress yaw smoothing.
|
||||
yawResetSmoothing = null,
|
||||
rawRotation = shortestRawRotation,
|
||||
rotation = state.rotation.twinNearest(action.referenceRotation),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -143,16 +142,19 @@ fun reduce(
|
||||
to = newHeading,
|
||||
duration = action.smoothTime,
|
||||
),
|
||||
rotation = state.rotation.twinNearest(state.rotation),
|
||||
)
|
||||
} else {
|
||||
// Snap: apply the new heading immediately (default, no smoothing configured).
|
||||
state.copy(
|
||||
sessionCalibration = cal.copy(headingCorrection = newHeading),
|
||||
yawResetSmoothing = null,
|
||||
rotation = state.rotation.twinNearest(action.referenceRotation),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: fix centaur on PoseMountingReset
|
||||
is TrackerActions.PoseMountingReset -> {
|
||||
val cal = state.sessionCalibration
|
||||
|
||||
@@ -169,6 +171,7 @@ fun reduce(
|
||||
state.copy(
|
||||
sessionCalibration = state.sessionCalibration.copy(headingAlignment = headingAlignment),
|
||||
lastMountingMethod = MountingMethod.POSE,
|
||||
rotation = state.rotation.twinNearest(action.referenceRotation),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -67,17 +67,14 @@ fun undoCalibration(
|
||||
): RawAcceleration = accelerationRotation(rawRotation, headingCorrect, headingAlign).inv()
|
||||
.sandwich(calibratedAcceleration)
|
||||
|
||||
// Used to get yaw. Works better for IMU trackers.
|
||||
fun eulerHeading(q: Quaternion): Quaternion = Quaternion.rotationAroundYAxis(q.toEulerAngles(EulerOrder.YZX).y).twinNearest(q)
|
||||
|
||||
// Used to get yaw. Works better on an HMD.
|
||||
fun inverseYProjection(q: Quaternion) = q.project(Vector3.POS_Y).unit().inv()
|
||||
// Used for referenceRotation since it works better on an HMD.
|
||||
private fun inverseYProjection(q: Quaternion) = q.twistY().inv()
|
||||
|
||||
fun estimateHeadingCorrect(
|
||||
rotation: Quaternion,
|
||||
referenceRotation: Quaternion,
|
||||
): HeadingCorrection = eulerHeading(inverseYProjection(referenceRotation) * rotation).inv()
|
||||
.twinNearest(referenceRotation)
|
||||
): HeadingCorrection = (inverseYProjection(referenceRotation) * rotation).eulerHeading().inv()
|
||||
.twinNearest(Quaternion.IDENTITY)
|
||||
|
||||
fun estimateAttitudeAlign(
|
||||
rotation: Quaternion,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.slimevr.tracker.stayaligned
|
||||
|
||||
import dev.slimevr.util.Side
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.util.Side
|
||||
|
||||
/**
|
||||
* Body parts used by Stay Aligned with some utils.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.tracker.stayaligned.poses
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.StayAlignedConfig
|
||||
import dev.slimevr.math.angle.Angle
|
||||
@@ -8,7 +9,6 @@ import dev.slimevr.tracker.getFirstActiveFor
|
||||
import dev.slimevr.tracker.stayaligned.StayAlignedBodyParts
|
||||
import dev.slimevr.tracker.stayaligned.StayAlignedDefaults
|
||||
import dev.slimevr.tracker.stayaligned.YawUtils.trackerYaw
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
class RelaxedPose(
|
||||
val upperLeg: Angle,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.tracker.stayaligned
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.StayAlignedConfig
|
||||
@@ -17,7 +18,6 @@ import dev.slimevr.tracker.stayaligned.poses.RelaxedPose
|
||||
import dev.slimevr.util.Side
|
||||
import dev.slimevr.util.side
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
/**
|
||||
* Entry point for Stay Aligned. More specifically, computeYawCorrection is.
|
||||
|
||||
@@ -4,6 +4,7 @@ package dev.slimevr.trackingchecklist
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.VRServerState
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -32,7 +33,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.update
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.datatypes.MountingMethod
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.slimevr.vmc
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.VRServerActions
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneId
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
@@ -19,7 +20,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
import solarxr_protocol.rpc.VMCOSCInputState
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dev.slimevr.vmc
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BodyPartMap
|
||||
import dev.slimevr.resets.ResetBodyParts
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
// TODO how to handle UPPER_WAIST?
|
||||
val BODY_PART_TO_UNITY_BONE: BodyPartMap<Array<String>> = BodyPartMap(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vmc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.VMCConfig
|
||||
import dev.slimevr.osc.OscArg
|
||||
@@ -10,7 +11,6 @@ import dev.slimevr.skeleton.BoneState
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import kotlin.time.Duration
|
||||
|
||||
internal fun buildOutgoingBundle(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vmc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.VMCConfig
|
||||
@@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.RoutingOutput
|
||||
import solarxr_protocol.rpc.VMCOSCOutputState
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vmc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BodyPartMap
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.logging.AppLogger
|
||||
@@ -12,7 +13,6 @@ import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.VMCOSCVrmState
|
||||
|
||||
private val vrmJsonParser = Json { ignoreUnknownKeys = true }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.slimevr.vrchat
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.AppConfig
|
||||
import dev.slimevr.context.Behaviour
|
||||
@@ -8,7 +9,6 @@ import dev.slimevr.context.Context
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.VRCAvatarMeasurementType
|
||||
import solarxr_protocol.rpc.VRCConfigRecommendedValues
|
||||
import solarxr_protocol.rpc.VRCConfigValidity
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.slimevr.vrcosc
|
||||
|
||||
import dev.slimevr.AppContextProvider
|
||||
import dev.slimevr.VRServerActions
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.device.Device
|
||||
@@ -18,7 +19,6 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.datatypes.DeviceOrigin
|
||||
import solarxr_protocol.datatypes.TrackerStatus
|
||||
import solarxr_protocol.rpc.VRCOSCInputState
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vrcosc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.osc.OscArg
|
||||
import dev.slimevr.osc.OscBundle
|
||||
@@ -9,7 +10,6 @@ import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import io.github.axisangles.ktmath.EulerOrder
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import kotlin.math.PI
|
||||
|
||||
private val trackerIdsByBodyPart = mapOf(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vrcosc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.BoneRegistry
|
||||
import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.VRCOSCConfig
|
||||
@@ -18,7 +19,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import solarxr_protocol.rpc.RoutingOutput
|
||||
import solarxr_protocol.rpc.VRCOSCOutputState
|
||||
import solarxr_protocol.rpc.VRCOSCTargetSource
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.vrcosc
|
||||
|
||||
import dev.slimevr.bones.BodyPart
|
||||
import dev.slimevr.bones.boneId
|
||||
import dev.slimevr.osc.OscArg
|
||||
import dev.slimevr.osc.OscContent
|
||||
@@ -9,7 +10,6 @@ import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.util.Side
|
||||
import dev.slimevr.util.opposite
|
||||
import io.github.axisangles.ktmath.EulerOrder
|
||||
import dev.slimevr.bones.BodyPart
|
||||
|
||||
private const val ABSOLUTE_SPLAY_THRESHOLD_ANGLE = 7
|
||||
private const val MINIMUM_TIP_TOE_PITCH = -14
|
||||
|
||||
@@ -395,7 +395,12 @@ class Quaternion(val w: Float, val x: Float, val y: Float, val z: Float) {
|
||||
/**
|
||||
* Returns the twist (rotation around the local y-axis of the Quaternion) unitized.
|
||||
*/
|
||||
fun twist() = Quaternion(this.w, 0f, this.y, 0f).unit()
|
||||
fun twistY() = Quaternion(this.w, 0f, this.y, 0f).unit()
|
||||
|
||||
/**
|
||||
* Returns a Quaternion representing the heading of this Quaternion using Euler angles and preserving polarity.
|
||||
*/
|
||||
fun eulerHeading() = rotationAroundYAxis(this.toEulerAngles(EulerOrder.YZX).y).twinNearest(this)
|
||||
|
||||
/**
|
||||
* applies this quaternion's rotation to that vector
|
||||
|
||||
Reference in new issue
Block a user