mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-28 21:06:31 -08:00
MonotonicValueTimeMark
This commit is contained in:
1 parent
9f0cf6554d
commit
bcfe86e8ac
5 files changed
+14
-9
No files matched your search
@@ -2,6 +2,7 @@ package dev.slimevr.skeleton
|
||||
|
||||
import dev.slimevr.config.UserConfig
|
||||
import dev.slimevr.logging.AppLogger
|
||||
import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
@@ -24,7 +25,6 @@ import kotlin.math.sin
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.TimeSource
|
||||
import kotlin.time.measureTime
|
||||
|
||||
class ProportionsBehaviour(private val userConfig: UserConfig) : SkeletonBehaviour {
|
||||
@@ -113,7 +113,7 @@ private class TickTimings(private val hz: Int, private val window: Duration, pri
|
||||
private var nextOverrunReport = timeSource.markNow() + OVERRUN_WINDOW
|
||||
|
||||
/** Called with the start of a tick, so the gap between two starts is what gets measured */
|
||||
fun started(at: TimeSource.Monotonic.ValueTimeMark) {
|
||||
fun started(at: MonotonicValueTimeMark) {
|
||||
sinceLastStart = at - lastStart
|
||||
lastStart = at
|
||||
}
|
||||
@@ -180,7 +180,7 @@ class ComputedSkeletonBehaviour(
|
||||
* measured from when the tick actually ran, which always trails its deadline by the wake
|
||||
* latency, so only a materially short gap costs a slot.
|
||||
*/
|
||||
private fun slotAfter(slot: TimeSource.Monotonic.ValueTimeMark, tickStart: TimeSource.Monotonic.ValueTimeMark): TimeSource.Monotonic.ValueTimeMark {
|
||||
private fun slotAfter(slot: MonotonicValueTimeMark, tickStart: MonotonicValueTimeMark): MonotonicValueTimeMark {
|
||||
var next = slot
|
||||
while (next - tickStart < minimumGap) next += intervalDuration
|
||||
return next
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import dev.slimevr.skeleton.bodyPartMap
|
||||
import dev.slimevr.skeleton.forEachBone
|
||||
import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
@@ -23,7 +24,7 @@ class BonePredictionInputProcessor(val settings: Settings) : SkeletonInputProces
|
||||
private data class BoneVelocity(
|
||||
val lastRotation: Quaternion,
|
||||
val rotationDelta: Quaternion,
|
||||
val lastChange: TimeSource.Monotonic.ValueTimeMark,
|
||||
val lastChange: MonotonicValueTimeMark,
|
||||
)
|
||||
|
||||
private var velocities: BodyPartMap<BoneVelocity> = bodyPartMap()
|
||||
|
||||
@@ -8,6 +8,8 @@ import kotlin.time.TimeSource
|
||||
*/
|
||||
val timeSource = TimeSource.Monotonic
|
||||
|
||||
typealias MonotonicValueTimeMark = TimeSource.Monotonic.ValueTimeMark
|
||||
|
||||
const val millisecondsInSecond = 1_000L
|
||||
const val microsecondsInSecond = 1_000_000L
|
||||
const val nanosecondsInSecond = 1_000_000_000L
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.slimevr.osc.OscSender
|
||||
import dev.slimevr.routing.BoneRoutingManager
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.Skeleton
|
||||
import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.formatExceptionMessage
|
||||
import dev.slimevr.util.timeSource
|
||||
import kotlinx.coroutines.flow.combine
|
||||
@@ -35,10 +36,10 @@ class VMCOutputBehaviour(
|
||||
var sender: OscSender? = null
|
||||
var vrm: VrmGeometry? = null
|
||||
var sendFailing = false
|
||||
var nextFrameRetryAt: TimeSource.Monotonic.ValueTimeMark? = null
|
||||
var nextFrameRetryAt: MonotonicValueTimeMark? = null
|
||||
|
||||
/** Start of the current unbroken run of successful sends, null while sends are failing. */
|
||||
var healthySince: TimeSource.Monotonic.ValueTimeMark? = null
|
||||
var healthySince: MonotonicValueTimeMark? = null
|
||||
}
|
||||
|
||||
override fun observe(receiver: VMCManager) {
|
||||
@@ -163,7 +164,7 @@ class VMCOutputBehaviour(
|
||||
bones: ComputedSkeleton,
|
||||
routedBones: Set<BodyPart>,
|
||||
config: VMCConfig,
|
||||
startedAt: TimeSource.Monotonic.ValueTimeMark,
|
||||
startedAt: MonotonicValueTimeMark,
|
||||
) {
|
||||
val sender = runtime.sender ?: return
|
||||
val status = receiver.context.state.value.status
|
||||
|
||||
@@ -8,6 +8,7 @@ import dev.slimevr.routing.BoneRoutingManager
|
||||
import dev.slimevr.skeleton.BoneState
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.Skeleton
|
||||
import dev.slimevr.util.MonotonicValueTimeMark
|
||||
import dev.slimevr.util.formatExceptionMessage
|
||||
import dev.slimevr.util.timeSource
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
@@ -38,8 +39,8 @@ class VRCOSCOutputBehaviour(
|
||||
private class OutputRuntime {
|
||||
var sender: OscSender? = null
|
||||
var sendFailing = false
|
||||
var nextFrameRetryAt: TimeSource.Monotonic.ValueTimeMark? = null
|
||||
var healthySince: TimeSource.Monotonic.ValueTimeMark? = null
|
||||
var nextFrameRetryAt: MonotonicValueTimeMark? = null
|
||||
var healthySince: MonotonicValueTimeMark? = null
|
||||
}
|
||||
|
||||
override fun observe(receiver: VRCOSCManager) {
|
||||
|
||||
Reference in new issue
Block a user