mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 11:56:27 -08:00
Use OutputTrackerToggle for VRCOSC trackers
This commit is contained in:
1 parent
6378eb30cd
commit
20be49e4b0
5 files changed
+12
-21
No files matched your search
@@ -153,6 +153,7 @@ class ForegroundService : Service() {
|
||||
ctx = phase1,
|
||||
scope = scope,
|
||||
oscQueryAddress = resolveAndroidOscQueryAddress(),
|
||||
outputTrackerToggle = outputTrackerToggle,
|
||||
)
|
||||
val resetsManager = ResetsManager.create(ctx = phase1, scope = scope)
|
||||
val tapDetectionManager = TapDetectionManager.create(ctx = phase1, resetsManager = resetsManager, scope = scope)
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.slimevr.config.Settings
|
||||
import dev.slimevr.config.VRCOSCConfig
|
||||
import dev.slimevr.context.Behaviour
|
||||
import dev.slimevr.context.Context
|
||||
import dev.slimevr.outputtrackertoggle.OutputTrackerToggleManager
|
||||
import dev.slimevr.util.safeLaunch
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -96,6 +97,7 @@ class VRCOSCManager(
|
||||
val context: VRCOSCContext,
|
||||
val oscQueryAddress: String,
|
||||
val settings: Settings,
|
||||
val outputTrackerToggle: OutputTrackerToggleManager,
|
||||
) {
|
||||
val events: EventDispatcher<VRCOSCEvent> = EventDispatcher()
|
||||
|
||||
@@ -121,6 +123,7 @@ class VRCOSCManager(
|
||||
ctx: Phase1ContextProvider,
|
||||
scope: CoroutineScope,
|
||||
oscQueryAddress: String,
|
||||
outputTrackerToggle: OutputTrackerToggleManager,
|
||||
): VRCOSCManager {
|
||||
val settings = ctx.config.settings
|
||||
val context = Context.create(
|
||||
@@ -131,7 +134,7 @@ class VRCOSCManager(
|
||||
scope = scope,
|
||||
name = "VRCOSC",
|
||||
)
|
||||
return VRCOSCManager(context, oscQueryAddress, settings)
|
||||
return VRCOSCManager(context, oscQueryAddress, settings, outputTrackerToggle)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import dev.slimevr.osc.OscArg
|
||||
import dev.slimevr.osc.OscBundle
|
||||
import dev.slimevr.osc.OscContent
|
||||
import dev.slimevr.osc.OscMessage
|
||||
import dev.slimevr.outputtrackertoggle.OutputTrackerToggleManager
|
||||
import dev.slimevr.skeleton.BoneState
|
||||
import io.github.axisangles.ktmath.EulerOrder
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
@@ -18,18 +19,18 @@ private val trackerIdsByBodyPart = mapOf(
|
||||
BodyPart.RIGHT_FOOT to 3,
|
||||
BodyPart.LEFT_UPPER_LEG to 4,
|
||||
BodyPart.RIGHT_UPPER_LEG to 5,
|
||||
BodyPart.UPPER_CHEST to 6,
|
||||
BodyPart.CHEST to 6,
|
||||
BodyPart.LEFT_UPPER_ARM to 7,
|
||||
BodyPart.RIGHT_UPPER_ARM to 8,
|
||||
)
|
||||
|
||||
internal fun buildOutgoingBundle(
|
||||
bones: Map<BodyPart, BoneState>,
|
||||
config: VRCOSCConfig,
|
||||
outputTrackerToggle: OutputTrackerToggleManager,
|
||||
): OscBundle? {
|
||||
val messages = buildList {
|
||||
for ((bodyPart, trackerId) in trackerIdsByBodyPart) {
|
||||
if (!shouldSendTracker(bodyPart, config)) continue
|
||||
if (bodyPart !in outputTrackerToggle.context.state.value.trackers) continue
|
||||
|
||||
val bone = bones[bodyPart] ?: continue
|
||||
add(
|
||||
@@ -68,22 +69,6 @@ internal fun buildYawAlignMessage(headRotation: Quaternion): OscMessage {
|
||||
)
|
||||
}
|
||||
|
||||
// TODO read from Output Settings
|
||||
private fun shouldSendTracker(bodyPart: BodyPart, config: VRCOSCConfig): Boolean = when (bodyPart) {
|
||||
BodyPart.HIP -> true
|
||||
|
||||
BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT -> true
|
||||
|
||||
BodyPart.LEFT_UPPER_LEG, BodyPart.RIGHT_UPPER_LEG -> true
|
||||
|
||||
// TODO why UPPER_CHEST instead of CHEST?
|
||||
BodyPart.UPPER_CHEST -> true
|
||||
|
||||
BodyPart.LEFT_UPPER_ARM, BodyPart.RIGHT_UPPER_ARM -> false
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun positionMessage(address: String, position: Vector3) = OscMessage(
|
||||
address,
|
||||
listOf(
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.slimevr.vrcosc
|
||||
import dev.slimevr.AppLogger
|
||||
import dev.slimevr.config.VRCOSCConfig
|
||||
import dev.slimevr.osc.OscSender
|
||||
import dev.slimevr.outputtrackertoggle.OutputTrackerToggleManager
|
||||
import dev.slimevr.skeleton.BoneState
|
||||
import dev.slimevr.skeleton.Skeleton
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
@@ -148,7 +149,7 @@ class VRCOSCOutputBehaviour(
|
||||
val now = System.currentTimeMillis()
|
||||
if (runtime.frameSendFailureActive && now < runtime.nextFrameRetryAt) return
|
||||
|
||||
val bundle = buildOutgoingBundle(bones, vrcOscConfig) ?: return
|
||||
val bundle = buildOutgoingBundle(bones, receiver.outputTrackerToggle) ?: return
|
||||
|
||||
try {
|
||||
sender.send(bundle)
|
||||
|
||||
@@ -99,6 +99,7 @@ fun main(args: Array<String>) = runBlocking<Unit> {
|
||||
ctx = phase1,
|
||||
scope = this,
|
||||
oscQueryAddress = resolveDesktopOscQueryAddress(),
|
||||
outputTrackerToggle = outputTrackerToggle,
|
||||
)
|
||||
val resetsManager = ResetsManager.create(ctx = phase1, scope = this)
|
||||
val tapDetectionManager = TapDetectionManager.create(ctx = phase1, resetsManager = resetsManager, scope = this)
|
||||
|
||||
Reference in new issue
Block a user