diff --git a/server/android/src/main/java/dev/slimevr/android/ForegroundService.kt b/server/android/src/main/java/dev/slimevr/android/ForegroundService.kt index e9269b381..181c67c75 100644 --- a/server/android/src/main/java/dev/slimevr/android/ForegroundService.kt +++ b/server/android/src/main/java/dev/slimevr/android/ForegroundService.kt @@ -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) diff --git a/server/core/src/main/java/dev/slimevr/vrcosc/module.kt b/server/core/src/main/java/dev/slimevr/vrcosc/module.kt index f30232474..f1c812f2c 100644 --- a/server/core/src/main/java/dev/slimevr/vrcosc/module.kt +++ b/server/core/src/main/java/dev/slimevr/vrcosc/module.kt @@ -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 = 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) } } } diff --git a/server/core/src/main/java/dev/slimevr/vrcosc/output-encoder.kt b/server/core/src/main/java/dev/slimevr/vrcosc/output-encoder.kt index 458592f23..059260adf 100644 --- a/server/core/src/main/java/dev/slimevr/vrcosc/output-encoder.kt +++ b/server/core/src/main/java/dev/slimevr/vrcosc/output-encoder.kt @@ -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, - 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( diff --git a/server/core/src/main/java/dev/slimevr/vrcosc/output.kt b/server/core/src/main/java/dev/slimevr/vrcosc/output.kt index ddf053792..730387236 100644 --- a/server/core/src/main/java/dev/slimevr/vrcosc/output.kt +++ b/server/core/src/main/java/dev/slimevr/vrcosc/output.kt @@ -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) diff --git a/server/desktop/src/main/java/dev/slimevr/desktop/Main.kt b/server/desktop/src/main/java/dev/slimevr/desktop/Main.kt index f674935ec..8a0f02429 100644 --- a/server/desktop/src/main/java/dev/slimevr/desktop/Main.kt +++ b/server/desktop/src/main/java/dev/slimevr/desktop/Main.kt @@ -99,6 +99,7 @@ fun main(args: Array) = runBlocking { 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)