Merge branch 'server-rewrite' into maya/onboarding-middleware

This commit is contained in:
JovannMC committed 2026-11-25 20:04:48 +03:00
commit 5e06df1458
15 files changed
+213 -122

No files matched your search

+1
View File
@@ -1154,6 +1154,7 @@ settings-home-table_columns-desc = Choose which columns are shown in the tracker
settings-home-display_group = Display
settings-home-tracker_display = Tracker info
settings-home-tracker_display-desc = Choose which extra details are shown on trackers
settings-home-tracker_display-battery_runtime_estimate = Battery runtime estimate
settings-home-tracker_display-battery_voltage = Battery voltage
settings-home-tracker_display-numeric_signal = Numeric signal strength
@@ -74,14 +74,14 @@ export function PersonFrontIcon({
<circle
className="body-part-circle"
cx="82"
cy="140"
cy="155"
r={CIRCLE_RADIUS}
id={BodyPart[BodyPart.UPPER_WAIST]}
/>
<circle
className="body-part-circle"
cx="82"
cy="155"
cy="169"
r={CIRCLE_RADIUS}
id={BodyPart[BodyPart.LOWER_WAIST]}
/>
@@ -277,26 +277,8 @@ export function HeightSelectionInput({
};
const handleUnitChange = (newUnit: 'meter' | 'foot') => {
if (!headHeight || newUnit === unit) return;
if (newUnit === unit) return;
const fullHeight = headHeight / EYE_HEIGHT_TO_HEIGHT_RATIO;
let snappedHeight;
if (newUnit === 'foot') {
// Snap to nearest inch
const totalInches = Math.round(convert(fullHeight, 'meter').to('inch'));
snappedHeight = convert(totalInches, 'inch').to('meter');
} else {
// Snap to nearest centimeter
const totalCm = Math.round(convert(fullHeight, 'meter').to('cm'));
snappedHeight = convert(totalCm, 'cm').to('meter');
}
const newEyeHeight = round4Digit(
snappedHeight * EYE_HEIGHT_TO_HEIGHT_RATIO
);
setHeadHeight(newEyeHeight);
onUnitChange(newUnit);
};
@@ -123,11 +123,14 @@ export function TrackersTableColumnsSettings({
}
const trackerDisplayToggleOrder: (keyof TrackerDisplayConfig)[] = [
'showBatteryRuntimeEstimate',
'showBatteryVoltage',
'showNumericSignal',
];
const trackerDisplayToggleLabel: Record<keyof TrackerDisplayConfig, string> = {
showBatteryRuntimeEstimate:
'settings-home-tracker_display-battery_runtime_estimate',
showBatteryVoltage: 'settings-home-tracker_display-battery_voltage',
showNumericSignal: 'settings-home-tracker_display-numeric_signal',
};
@@ -33,14 +33,17 @@ export function TrackerBattery({
});
const charging = (voltage || 0) > 4.3;
const debug = config?.debug;
const showRuntime =
config?.trackerDisplay?.showBatteryRuntimeEstimate &&
runtime != null &&
runtime > 0;
const showVoltage = voltage && config?.trackerDisplay?.showBatteryVoltage;
const pct = value > 2 ? 0 : Math.min(Math.max(value, 0), 1);
return (
<Tooltip
disabled={charging || !runtime || debug}
disabled={charging || !showRuntime}
preferedDirection="left"
content={<Typography>{percentFormatter.format(pct)}</Typography>}
>
@@ -50,7 +53,7 @@ export function TrackerBattery({
</div>
{((!charging || showVoltage) && (
<div className="w-15">
{!charging && runtime != null && runtime > 0 && (
{!charging && showRuntime && (
<Typography color={textColor}>
{(runtime / BigInt(3600000000)).toString() +
'h ' +
@@ -61,7 +64,7 @@ export function TrackerBattery({
'min'}
</Typography>
)}
{!charging && (!runtime || debug) && (
{!charging && !showRuntime && (
<Typography color={textColor}>
{percentFormatter.format(pct)}
</Typography>
+2
View File
@@ -69,11 +69,13 @@ export const trackersTableColumnOrder = [
export type TrackersTableOptionalColumn = (typeof trackersTableColumnOrder)[number];
export interface TrackerDisplayConfig {
showBatteryRuntimeEstimate: boolean;
showBatteryVoltage: boolean;
showNumericSignal: boolean;
}
export const defaultTrackerDisplay: TrackerDisplayConfig = {
showBatteryRuntimeEstimate: true,
showBatteryVoltage: false,
showNumericSignal: false,
};
+7 -7
View File
@@ -75,7 +75,7 @@ const ASSIGNABLE_PARTS = new Set(ALL_ASSIGNABLE_PARTS);
type SetupRegionName =
| 'legs'
| 'chest'
| 'upperChest'
| 'hip'
| 'feet'
| 'upperArms'
@@ -96,12 +96,12 @@ const SETUP_REGIONS: {
needs: SetupRegionName[];
}[] = [
{ id: 'legs', parts: [...LEGS_PARTS], needs: [] },
{ id: 'chest', parts: [BodyPart.UPPER_CHEST], needs: [] },
{ id: 'hip', parts: [BodyPart.HIP], needs: ['chest'] },
{ id: 'upperChest', parts: [BodyPart.UPPER_CHEST], needs: [] },
{ id: 'hip', parts: [BodyPart.HIP], needs: ['upperChest'] },
// 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'] },
{ id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['lowerChest'] },
{ id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['hip'] },
{ id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['upperWaist'] },
{ id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['lowerChest'] },
{
id: 'feet',
parts: [BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT],
@@ -110,7 +110,7 @@ const SETUP_REGIONS: {
{
id: 'upperArms',
parts: [BodyPart.LEFT_UPPER_ARM, BodyPart.RIGHT_UPPER_ARM],
needs: ['legs', 'chest'],
needs: ['legs', 'upperChest'],
},
{
id: 'lowerArms',
+12 -5
View File
@@ -178,7 +178,8 @@ export function captureServerExit(
const eventId = Sentry.captureMessage('server_exit_nonzero', {
...serverScope,
level: 'error',
extra: { code, signal, outputTail },
tags: { code, signal },
extra: { outputTail },
});
lastServerFailure = { eventId, code, signal, outputTail };
}
@@ -192,10 +193,16 @@ export function sendCrashReport(kind: CrashReportKind) {
event_id: failure?.eventId,
message: failure ? 'server_exit_nonzero' : `server_${kind}`,
level: 'error',
tags: serverScope.tags,
extra: failure
? { code: failure.code, signal: failure.signal, outputTail: failure.outputTail }
: { outputTail: serverOutputTail() },
tags: failure
? {
...serverScope.tags,
code: failure.code,
signal: failure.signal,
}
: serverScope.tags,
extra: {
outputTail: failure?.outputTail ?? serverOutputTail(),
},
});
});
return true;
@@ -0,0 +1,29 @@
package dev.slimevr.autobone
class WeightedAverage {
var value: Float = 0f
private set
var weight: Float = 0f
private set
fun average() = if (weight > 0f) {
value / weight
} else {
0f
}
fun addValue(value: Float, weight: Float) {
this.value += value * weight
this.weight += weight
}
fun subtractValue(value: Float, weight: Float) {
this.value -= value * weight
this.weight -= weight
}
fun reset() {
value = 0f
weight = 0f
}
}
@@ -0,0 +1,106 @@
package dev.slimevr.autobone
import dev.slimevr.skeleton.BodyPartMap
import dev.slimevr.skeleton.ComputedSkeleton
import dev.slimevr.skeleton.bodyPartMap
import dev.slimevr.skeleton.mapValues
import dev.slimevr.util.Side
import dev.slimevr.util.side
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
val BODY_PARTS_TO_ADJUST = arrayOf(
BodyPart.NECK,
BodyPart.UPPER_CHEST,
BodyPart.LOWER_CHEST,
BodyPart.UPPER_WAIST,
BodyPart.LOWER_WAIST,
BodyPart.HIP,
BodyPart.LEFT_UPPER_LEG,
BodyPart.LEFT_LOWER_LEG,
BodyPart.RIGHT_UPPER_LEG,
BodyPart.RIGHT_LOWER_LEG,
)
// TODO This should probably be every bone excluding arms, feet, and toes?
val CONTRIBUTING_BODY_PARTS = BODY_PARTS_TO_ADJUST.plus(
arrayOf(
BodyPart.HEAD,
),
)
data class TrackerFrame(
val rotation: Quaternion,
val position: Vector3?,
)
typealias AutoBoneRecording = List<TrackerFrame>
// TODO Figure out actually doing the recording
typealias BoneContribution = WeightedAverage
typealias BoneContributions = BodyPartMap<BoneContribution>
fun process(recording: BodyPartMap<AutoBoneRecording>) {
// TODO Actually make skeletons
val skeletonA: ComputedSkeleton = bodyPartMap()
val skeletonB: ComputedSkeleton = bodyPartMap()
val contributions: BoneContributions = bodyPartMap()
val recordingLength = recording.minOf { it.value.size }
for (i in 0 until recordingLength) {
val trackers = recording.mapValues { _, frames -> frames[i] }
// TODO Apply trackers to skeletons A and B somehow
computeContributions(contributions, skeletonA, skeletonB)
// TODO Figure out how to choose adjustment scale
// TODO Test new config to see if it actually reduces error
}
}
fun boneContribution(contribution: BoneContribution, ankleAToB: Vector3, localBoneTailAToB: Vector3) {
val boneToSlideDirectionRatio = ankleAToB.unit().dot(localBoneTailAToB.unit())
// - if bone is too short, + if bone is too long
contribution.addValue(boneToSlideDirectionRatio, localBoneTailAToB.len())
}
fun computeContributions(contributions: BoneContributions, skeletonA: ComputedSkeleton, skeletonB: ComputedSkeleton) {
val leftAnkleA = skeletonA[BodyPart.LEFT_LOWER_LEG]?.tailPosition ?: error("Missing left ankle position A")
val leftAnkleB = skeletonB[BodyPart.LEFT_LOWER_LEG]?.tailPosition ?: error("Missing left ankle position B")
val leftAnkleAToB = leftAnkleB - leftAnkleA
val rightAnkleA = skeletonA[BodyPart.RIGHT_LOWER_LEG]?.tailPosition ?: error("Missing right ankle position A")
val rightAnkleB = skeletonB[BodyPart.RIGHT_LOWER_LEG]?.tailPosition ?: error("Missing right ankle position B")
val rightAnkleAToB = rightAnkleB - rightAnkleA
// TODO Consider headset sliding; if HMD consistently aligns with sliding, then
// either height is wrong, or the headset has weird movement
CONTRIBUTING_BODY_PARTS.forEach { bodyPart ->
val boneA = skeletonA[bodyPart] ?: return@forEach
val boneB = skeletonB[bodyPart] ?: return@forEach
val contribution = contributions.getOrPut(bodyPart) { BoneContribution() }
val localBoneTailAToB = boneB.localTailPosition - boneA.localTailPosition
val side = bodyPart.side
// LEFT (or both)
if (side != Side.RIGHT) {
boneContribution(
contribution,
leftAnkleAToB,
localBoneTailAToB,
)
}
// RIGHT (or both)
if (side != Side.LEFT) {
boneContribution(
contribution,
rightAnkleAToB,
localBoneTailAToB,
)
}
}
}
@@ -1,68 +0,0 @@
package dev.slimevr.autobone
import dev.slimevr.skeleton.ComputedSkeleton
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
fun slideContributionWeight(ankleA: Vector3, ankleB: Vector3, localBoneTailA: Vector3, localBoneTailB: Vector3): Float {
val ankleAToB = ankleB - ankleA
val localBoneTailAToB = localBoneTailB - localBoneTailA
val boneToSlideDirectionRatio = ankleAToB.unit().dot(localBoneTailAToB.unit())
// if +, shorten bone, if -, lengthen bone
// sum all contribution weights, divide each bone's weight by the sum, then multiply
// by the slide magnitude in order to find the corresponding bone change
return localBoneTailAToB.len() * boneToSlideDirectionRatio
}
// TODO This is a placeholder
val PLACEHOLDER_BODY_PARTS_TO_ADJUST = arrayOf(
BodyPart.UPPER_CHEST,
BodyPart.LOWER_CHEST,
BodyPart.UPPER_WAIST,
BodyPart.LOWER_WAIST,
BodyPart.HIP,
// etc.
)
fun step(skeletonA: ComputedSkeleton, skeletonB: ComputedSkeleton) {
// TODO We need to consider both ankles, there are two... We can do contribution per
// ankle
// TODO This is a placeholder
val ankleA = Vector3.ZERO
// TODO This is a placeholder
val ankleB = Vector3.ZERO
// TODO Consider headset sliding; if HMD consistently aligns with sliding, then
// either height is wrong, or the headset has weird movement
val contributions = PLACEHOLDER_BODY_PARTS_TO_ADJUST.map { bodyPart ->
val boneA = skeletonA[bodyPart] ?: return@map 0f
val boneB = skeletonB[bodyPart] ?: return@map 0f
slideContributionWeight(
ankleA,
ankleB,
boneA.localTailPosition,
boneB.localTailPosition,
)
}.filter { it > 0f }
// TODO This is a placeholder
val slideMag = 1f
val contributionSum = contributions.sum()
val perBoneSlide = contributions.map {
(it * slideMag) / contributionSum
}
// TODO This is a placeholder
val config = 1f
val newConfigs = perBoneSlide.map {
config + it
}
// TODO Test new config to see if it actually reduces error? Or do we just
// accept the changes? The contribution scales for each frame and considers
// direction; we should be able to skip checking if it reduces error
}
@@ -1,23 +1,36 @@
package dev.slimevr.skeleton.fkprocessors
import com.jme3.math.FastMath
import dev.slimevr.skeleton.ComputedSkeleton
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.Skeleton
import dev.slimevr.skeleton.SkeletonFkProcessor
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import kotlin.math.abs
// The max height to plant feet by
const val ROTATION_CORRECTION_VERTICAL = 0.1f
private const val ROTATION_CORRECTION_VERTICAL = 0.1f
private const val ANKLE_DOWN_MIN = 0.35f
private const val ANKLE_DOWN_MAX = 0.63f
fun computeFootPlantRatio(
ankleHeight: Float,
floorLevel: Float,
ankleLocalPosition: Vector3,
): Float {
val ankleHeightAboveFloor = ankleHeight - floorLevel
val ratioOfRangeFromFloor = (ankleHeightAboveFloor / ROTATION_CORRECTION_VERTICAL).coerceIn(0f, 1f)
// Ratio of range *to* floor
return 1f - ratioOfRangeFromFloor
val rangeToFloorRatio = 1f - ratioOfRangeFromFloor
// Lessen the ratio as the ankle doesn't point down
val ankleDownDirection = abs(ankleLocalPosition.unit().y.coerceAtMost(0f))
val ankleDownRatio = FastMath.remapClamped(ankleDownDirection, ANKLE_DOWN_MIN, ANKLE_DOWN_MAX, 0f, 1f)
return rangeToFloorRatio * ankleDownRatio
}
fun correctFootAttitude(
@@ -27,21 +40,26 @@ fun correctFootAttitude(
): Quaternion = rotation.interpQ(rotation.eulerHeading(), correctionRatio)
class FootPlantFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
val bodyParts: Array<BodyPart> = arrayOf(BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT)
val bodyParts = arrayOf(
BodyPart.LEFT_LOWER_LEG to BodyPart.LEFT_FOOT,
BodyPart.RIGHT_LOWER_LEG to BodyPart.RIGHT_FOOT,
)
override fun process(mutableInputSkeleton: InputSkeleton, fk: ComputedSkeleton, floorLevel: Float) {
if (!skeleton.effectiveFootPlant) return
for (bodyPart in bodyParts) {
val input = mutableInputSkeleton[bodyPart] ?: continue
for ((anklePart, footPart) in bodyParts) {
val input = mutableInputSkeleton[footPart] ?: continue
if (input.isRotationActive) continue
val output = fk[bodyPart] ?: continue
mutableInputSkeleton[bodyPart] = input.copy(
val foot = fk[footPart] ?: continue
val ankle = fk[anklePart] ?: continue
mutableInputSkeleton[footPart] = input.copy(
rotation = correctFootAttitude(
input.rotation,
computeFootPlantRatio(
output.headPosition.y,
foot.headPosition.y,
floorLevel,
ankle.localTailPosition,
),
),
)
@@ -10,10 +10,10 @@ import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import kotlin.math.abs
const val TOE_SNAP_RANGE_MULTIPLIER = 2f
const val MAX_TOE_SNAP_RATIO = 0.8f
const val ANKLE_DOWN_MIN = 0.65f
const val ANKLE_DOWN_MAX = 0.85f
private const val TOE_SNAP_RANGE_MULTIPLIER = 1.64f
private const val MAX_TOE_SNAP_RATIO = 0.8f
private const val ANKLE_DOWN_MIN = 0.75f
private const val ANKLE_DOWN_MAX = 0.94f
fun computeToeSnapRatio(
ankleHeight: Float,
@@ -65,6 +65,7 @@ class ToeSnapFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
if (input.isRotationActive) continue
val length = input.offset.len()
if (length <= 0f) continue
val ankle = fk[anklePart] ?: continue
val foot = fk[footPart] ?: continue
mutableInputSkeleton[footPart] = input.copy(
@@ -43,7 +43,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-11.5f, -20f), // Itself
// To
SpineSource.LOWER_CHEST to Reliability(-6f, -15f, 0f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.4f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 5f, 0.4f),
SpineSource.HIP to Reliability(4f, 6.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 5f),
@@ -53,7 +53,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-18f, 40f),
SpineSource.LOWER_CHEST to Reliability(30f), // Itself
// To
SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.4f),
SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 8f, 0.4f),
SpineSource.HIP to Reliability(4f, 7.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 6f),
@@ -45,8 +45,15 @@ private val STEAMVR_WEB_SERVER_STARTUP = 1.seconds
// Retry delay doubles from 1s up to 2^step seconds (16s)
private const val DRIVERS_RETRY_MAX_BACKOFF_STEP = 4L
private fun isProcessRunning(name: String): Boolean = ProcessHandle.allProcesses().anyMatch { proc ->
proc.info().command().orElse(null)?.substringAfterLast(File.separatorChar) == name
private fun isProcessRunning(name: String): Boolean = try {
ProcessHandle.allProcesses().anyMatch { proc ->
proc.info().command().orElse(null)?.substringAfterLast(File.separatorChar) == name
}
} catch (_: Exception) {
// Implementation of ProcessHandle.allProcesses may throw
// RuntimeException("snapshot not available") on Windows if
// CreateToolhelp32Snapshot or Process32First fails, ignore it
false
}
// No OS event for process start/exit, so this polls