Remove BodyPart fully from solarxr, implement new connection sequence

This commit is contained in:
loucass003 committed 2026-09-15 00:12:06 +02:00
1 parent ee38e9f6ba
commit 65cdc83e3c
120 files changed
+605 -377

No files matched your search

@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { useEffect, useMemo, useRef, useState } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { PersonFrontIcon } from './PersonFrontIcon';
import {
boneRegistryAtom,
@@ -9,7 +9,7 @@ import {
useRef,
useState,
} from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { useBreakpoint } from '@/hooks/breakpoint';
const DOT_HIT_PADDING = 12;
@@ -20,10 +20,10 @@ export interface BodySideNames {
}
const bodyPartFromName = (name: string): BodyPart | null => {
const part = (BodyPart as unknown as Record<string, number | undefined>)[
const part = (BodyPart as unknown as Record<string, string | undefined>)[
name
];
return typeof part === 'number' ? part : null;
return typeof part === 'string' ? (part as BodyPart) : null;
};
const boxOf = (el: HTMLElement, offset: { left: number; top: number }) => {
@@ -1,4 +1,5 @@
import { BoardType, BodyPart, DeviceDataT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BoardType, DeviceDataT } from 'solarxr-protocol';
import { useLocaleConfig } from '@/i18n/config';
import { AnkleIcon } from './icon/AnkleIcon';
import { ButterflyIcon } from './icon/ButterflyIcon';
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import {
ExtremityFigureSpec,
ExtremityParts,
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
export const SIDES = [
{
@@ -2,8 +2,8 @@ import { Localized, ReactLocalization, useLocalization } from '@fluent/react';
import { Typography } from '@/components/commons/Typography';
import { getLocalizedTrackerName } from '@/hooks/tracker';
import { ComponentProps, useEffect, useMemo, useRef, useState } from 'react';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
BoardType,
DeviceDataT,
FirmwareDeviceIdTableT,
@@ -7,7 +7,7 @@ import {
useMemo,
} from 'react';
import { useAtomValue } from 'jotai';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import {
BodyInteractions,
BodyInteractionsProps,
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { ExtremityDescriptor } from '@/utils/extremities';
import {
Digit,
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { ExtremityDescriptor } from '@/utils/extremities';
import {
Digit,
@@ -1,7 +1,7 @@
import { Control, Controller, useForm } from 'react-hook-form';
import { Clickable } from '@/components/commons/Clickable';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
ChangeSkeletonProportionsRequestT,
ResetType,
RpcMessage,
@@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { Localized } from '@fluent/react';
import { useOnboarding } from '@/hooks/onboarding';
import { useMountingSelection } from '@/hooks/tracker-mounting';
@@ -1,5 +1,6 @@
import classNames from 'classnames';
import { BodyPart, QuatT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { QuatT } from 'solarxr-protocol';
import { Typography } from '@/components/commons/Typography';
import { ArrowUpIcon } from '@/components/commons/icon/ArrowIcons';
import {
@@ -8,7 +8,7 @@ import { FootIcon } from '@/components/commons/icon/FootIcon';
import { rotationToQuatMap, similarQuaternions } from '@/maths/quaternion';
import { Quaternion } from 'three';
import { SlimeUpIcon } from '@/components/commons/icon/SlimeUpIcon';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { useLocaleConfig } from '@/i18n/config';
import { FingersIcon } from '@/components/commons/icon/FingersIcon';
import {
@@ -2,7 +2,7 @@ import classNames from 'classnames';
import { useLocalization } from '@fluent/react';
import { Clickable } from '@/components/commons/Clickable';
import { HTMLAttributes, ReactNode, useCallback, useMemo } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { MirrorLegend } from '@/components/onboarding/BodyAssignment';
import {
BodyPartAssignment,
@@ -2,7 +2,7 @@ import type { FluentVariable } from '@fluent/bundle';
import { useLocalization } from '@fluent/react';
import classNames from 'classnames';
import { CSSProperties, ReactNode, useMemo } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { Button } from '@/components/commons/Button';
import { ProgressBar } from '@/components/commons/ProgressBar';
import { Typography } from '@/components/commons/Typography';
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { createPortal } from 'react-dom';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BaseModal } from '@/components/commons/BaseModal';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
@@ -2,7 +2,8 @@ import classNames from 'classnames';
import { Clickable } from '@/components/commons/Clickable';
import { useLocalization } from '@fluent/react';
import { CSSProperties, ReactNode, useMemo } from 'react';
import { BodyPart, DeviceDataT, TrackerDataT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { DeviceDataT, TrackerDataT } from 'solarxr-protocol';
import { BodyPartIcon } from '@/components/commons/BodyPartIcon';
import { Button } from '@/components/commons/Button';
import { LoaderIcon, SlimeState } from '@/components/commons/icon/LoaderIcon';
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { Fragment, ReactNode } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BodyPartIcon } from '@/components/commons/BodyPartIcon';
import { Tooltip } from '@/components/commons/Tooltip';
import { Typography } from '@/components/commons/Typography';
@@ -2,8 +2,8 @@ import { useLocalization } from '@fluent/react';
import { Clickable } from '@/components/commons/Clickable';
import classNames from 'classnames';
import { ReactNode, useEffect, useMemo, useState } from 'react';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
BoneRouteT,
BoneRoutingSettingsRequestT,
BoneRoutingSettingsResponseT,
@@ -1,8 +1,8 @@
import { useLocalization } from '@fluent/react';
import { useEffect } from 'react';
import { DefaultValues, useForm } from 'react-hook-form';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
ChangeTapDetectionSettingsRequestT,
RpcMessage,
TapDetectionSettingsRequestT,
@@ -81,7 +81,7 @@ export function TapDetectionSettings() {
});
const bodyParts: { value: string; label: string }[] = Object.values(BodyPart)
.filter((v): v is BodyPart => typeof v === 'number')
.filter((v): v is BodyPart => typeof v === 'string')
.filter((v) => TAP_DETECTION_BODY_PARTS.includes(v as BodyPart))
.map((value) => ({
value: String(value),
@@ -104,12 +104,16 @@ export function TapDetectionSettings() {
settingsReq.yawResetEnabled = values.yawResetEnabled;
settingsReq.yawResetTaps = values.yawResetTaps;
settingsReq.yawResetBoneId =
boneIdOfBodyPart(boneIdRegistry, Number(values.yawResetTracker)) ?? null;
settingsReq.mountingResetBoneId =
boneIdOfBodyPart(boneIdRegistry, Number(values.mountingResetTracker)) ??
boneIdOfBodyPart(boneIdRegistry, values.yawResetTracker as BodyPart) ??
null;
settingsReq.mountingResetBoneId =
boneIdOfBodyPart(
boneIdRegistry,
values.mountingResetTracker as BodyPart
) ?? null;
settingsReq.fullResetBoneId =
boneIdOfBodyPart(boneIdRegistry, Number(values.fullResetTracker)) ?? null;
boneIdOfBodyPart(boneIdRegistry, values.fullResetTracker as BodyPart) ??
null;
settingsReq.mountingResetEnabled = values.mountingResetEnabled;
settingsReq.mountingResetDelay = values.mountingResetDelay;
settingsReq.mountingResetTaps = values.mountingResetTaps;
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { useEffect, useRef } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BaseModal } from '@/components/commons/BaseModal';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import { Clickable } from '@/components/commons/Clickable';
import { MouseEventHandler } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { getTrackerName } from '@/hooks/tracker';
import { Typography } from '@/components/commons/Typography';
import { useLocalization } from '@fluent/react';
@@ -4,10 +4,10 @@ import { IPv4 } from 'ip-num';
import { useEffect, useMemo, useState } from 'react';
import { useForm } from 'react-hook-form';
import { useParams } from 'react-router-dom';
import { BodyPart } from '@/utils/body-part';
import {
AssignTrackerRequestT,
BoardType,
BodyPart,
ForgetDeviceRequestT,
ImuType,
MagnetometerStatus,
@@ -40,8 +40,8 @@ import { StayAlignedInfo } from '@/components/stay-aligned/StayAlignedInfo';
import { Tooltip } from '@/components/commons/Tooltip';
import { WarningIcon } from '@/components/commons/icon/WarningIcon';
import { FirmwareIcon } from '@/components/commons/FirmwareIcon';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
DeviceDataT,
TrackerDataT,
TrackerStatus as TrackerStatusEnum,
@@ -6,6 +6,7 @@ import {
} from '@/hooks/tracking-checklist';
import classNames from 'classnames';
import { Clickable } from '@/components/commons/Clickable';
import { BodyPart } from '@/utils/body-part';
import {
EnableSteamVRDriverRequestT,
ResetType,
@@ -13,7 +14,6 @@ import {
TrackingChecklistPublicNetworksT,
TrackingChecklistSteamVRDisconnectedT,
TrackingChecklistStepId,
BodyPart,
RoutingOutput,
BoneRoutingSettingsRequestT,
BoneRoutingSettingsResponseT,
@@ -27,7 +27,8 @@ import {
Vector3,
WebGLRenderer,
} from 'three';
import { BodyPart, BoneT, MountingMethod } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BoneT, MountingMethod } from 'solarxr-protocol';
import { QuaternionFromQuatT } from '@/maths/quaternion';
import { Vector3FromVec3fT } from '@/maths/vector3';
import classNames from 'classnames';
+1 -1
View File
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
export const SPINE_BODY_PARTS = [
BodyPart.HEAD,
+1 -1
View File
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
/**
* I dedicate this hook to @uriel ;)
+1 -1
View File
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
ResetRequestT,
ResetResponseT,
ResetStatus,
+1 -1
View File
@@ -1,7 +1,7 @@
import { createContext, useContext, useEffect, useState } from 'react';
import { BodyPart } from '@/utils/body-part';
import {
AssignTrackerRequestT,
BodyPart,
QuatT,
ResetTrackerAssignmentsT,
RpcMessage,
+4 -4
View File
@@ -1,6 +1,6 @@
import { useAtomValue } from 'jotai';
import { selectAtom } from 'jotai/utils';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { createPointerDrag } from './pointer-drag';
export interface TrackerDragPayload {
@@ -10,10 +10,10 @@ export interface TrackerDragPayload {
export const trackerDrag = createPointerDrag<TrackerDragPayload, BodyPart>({
attribute: 'data-drop-body-part',
serialize: (part) => BodyPart[part],
serialize: (part) => part,
parse: (raw) => {
const part = (BodyPart as unknown as Record<string, number>)[raw];
return typeof part === 'number' ? part : null;
const part = (BodyPart as unknown as Record<string, string>)[raw];
return typeof part === 'string' ? (part as BodyPart) : null;
},
});
+1 -1
View File
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { Quaternion } from 'three';
import * as Sentry from '@sentry/react';
import {
+1 -1
View File
@@ -1,6 +1,6 @@
import { useLocalization } from '@fluent/react';
import { createContext, useContext, useMemo, useState } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { useAtomValue } from 'jotai';
import { useConfig } from './config';
import {
+2 -1
View File
@@ -1,5 +1,6 @@
import { CSSProperties, useEffect, useMemo, useRef, useState } from 'react';
import { BodyPart, TrackerDataT, TrackerInfoT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { TrackerDataT, TrackerInfoT } from 'solarxr-protocol';
import { QuaternionFromQuatT, QuaternionToEulerDegrees } from '@/maths/quaternion';
import { ReactLocalization, useLocalization } from '@fluent/react';
import { useDataFeedConfig } from './datafeed-config';
+40 -43
View File
@@ -1,10 +1,10 @@
import { createContext, useContext, useEffect, useRef, useState } from 'react';
import {
BodyPart,
BoneRegistryRequestT,
BoneRegistryT,
ClientHello,
ConfigurationAcknowledgedT,
ClientHelloT,
ConfigurationDoneT,
ConnectionMessage,
ConnectionMessageHeaderT,
DataFeedMessage,
@@ -14,7 +14,7 @@ import {
MessageBundleT,
RpcMessage,
RpcMessageHeaderT,
ServerHello,
ServerHelloT,
} from 'solarxr-protocol';
import { Builder, ByteBuffer } from 'flatbuffers';
@@ -22,9 +22,10 @@ import { useStore } from 'jotai';
import { useInterval, useTimeout } from './timeout';
import { log } from '@/utils/logging';
import { boneRegistryAtom } from '@/store/app-store';
import { bodyPartOfKey } from '@/utils/body-part';
// Must match SOLARXR_PROTOCOL_VERSION in server/core/.../solarxr/protocol.kt
const SOLARXR_PROTOCOL_VERSION = 2;
const SOLARXR_PROTOCOL_VERSION = 3;
type ConnectionPhase = 'awaiting-hello' | 'configuring' | 'ready';
@@ -66,25 +67,6 @@ export function useProvideWebsocketApi(): WebSocketApi {
}
}, 3000);
const onConnected = () => {
if (!webSocketRef.current) return;
setTimedOut(false);
const fbb = new Builder(64);
ClientHello.finishClientHelloBuffer(
fbb,
ClientHello.createClientHello(fbb, SOLARXR_PROTOCOL_VERSION)
);
webSocketRef.current.send(fbb.asUint8Array());
};
const onConnectionClose = () => {
phaseRef.current = 'awaiting-hello';
store.set(boneRegistryAtom, new Map());
setConnected(false);
rpcPacketCounterRef.current = 0;
};
const sendConnectionMessage = (
message: ConnectionMessageHeaderT['message'],
messageType: ConnectionMessage
@@ -97,28 +79,47 @@ export function useProvideWebsocketApi(): WebSocketApi {
webSocketRef.current.send(fbb.asUint8Array());
};
const onConnected = () => {
if (!webSocketRef.current) return;
setTimedOut(false);
sendConnectionMessage(
new ClientHelloT(SOLARXR_PROTOCOL_VERSION),
ConnectionMessage.ClientHello
);
};
const onConnectionClose = () => {
phaseRef.current = 'awaiting-hello';
store.set(boneRegistryAtom, new Map());
setConnected(false);
rpcPacketCounterRef.current = 0;
};
const onMessage = async (event: { data: Blob }) => {
if (!event.data.arrayBuffer) return;
const buffer = await event.data.arrayBuffer();
const fbb = new ByteBuffer(new Uint8Array(buffer));
if (phaseRef.current === 'awaiting-hello') {
if (!ServerHello.bufferHasIdentifier(fbb)) return;
const hello = ServerHello.getRootAsServerHello(fbb);
if (hello.status() !== HelloStatus.ACCEPTED) {
log(`SolarXR handshake rejected (status ${hello.status()}), reconnecting`);
reconnect();
return;
}
phaseRef.current = 'configuring';
return;
}
if (!MessageBundle.bufferHasIdentifier(fbb)) return;
const message = MessageBundle.getRootAsMessageBundle(fbb).unpack();
message.connectionMsgs.forEach((connectionHeader) => {
switch (connectionHeader.messageType) {
case ConnectionMessage.ServerHello: {
const hello = connectionHeader.message as ServerHelloT;
if (hello.status !== HelloStatus.ACCEPTED) {
log(`SolarXR handshake rejected (status ${hello.status}), reconnecting`);
reconnect();
return;
}
phaseRef.current = 'configuring';
sendConnectionMessage(
new BoneRegistryRequestT(),
ConnectionMessage.BoneRegistryRequest
);
sendConnectionMessage(new ConfigurationDoneT(), ConnectionMessage.ConfigurationDone);
break;
}
case ConnectionMessage.BoneRegistry: {
const registry = connectionHeader.message as BoneRegistryT;
store.set(
@@ -126,17 +127,13 @@ export function useProvideWebsocketApi(): WebSocketApi {
new Map(
registry.bones.map((bone) => [
bone.id,
bone.standardBodyPart ?? BodyPart.NONE,
bodyPartOfKey(bone.key?.toString() ?? ''),
])
)
);
break;
}
case ConnectionMessage.FinishConfiguration:
sendConnectionMessage(
new ConfigurationAcknowledgedT(),
ConnectionMessage.ConfigurationAcknowledged
);
case ConnectionMessage.ConfigurationDone:
phaseRef.current = 'ready';
setFirstConnection(false);
setConnected(true);
+1 -1
View File
@@ -1,6 +1,6 @@
import { atom } from 'jotai';
import { BodyPart } from '@/utils/body-part';
import {
BodyPart,
BoneT,
DataFeedUpdateT,
DeviceDataT,
+79
View File
@@ -0,0 +1,79 @@
// SolarXR has no BodyPart type on the wire: bones are opaque registry ids and string
// keys. This mirrors the server's own definition (server/core/.../bones/BodyPart.kt)
// by name, not by number, so a bone's id can be renumbered without breaking the GUI.
export enum BodyPart {
NONE = 'NONE',
HEAD = 'HEAD',
NECK = 'NECK',
UPPER_CHEST = 'UPPER_CHEST',
LOWER_CHEST = 'LOWER_CHEST',
UPPER_WAIST = 'UPPER_WAIST',
LOWER_WAIST = 'LOWER_WAIST',
HIP = 'HIP',
LEFT_UPPER_LEG = 'LEFT_UPPER_LEG',
RIGHT_UPPER_LEG = 'RIGHT_UPPER_LEG',
LEFT_LOWER_LEG = 'LEFT_LOWER_LEG',
RIGHT_LOWER_LEG = 'RIGHT_LOWER_LEG',
LEFT_FOOT = 'LEFT_FOOT',
RIGHT_FOOT = 'RIGHT_FOOT',
LEFT_UPPER_ARM = 'LEFT_UPPER_ARM',
RIGHT_UPPER_ARM = 'RIGHT_UPPER_ARM',
LEFT_LOWER_ARM = 'LEFT_LOWER_ARM',
RIGHT_LOWER_ARM = 'RIGHT_LOWER_ARM',
LEFT_HAND = 'LEFT_HAND',
RIGHT_HAND = 'RIGHT_HAND',
LEFT_SHOULDER = 'LEFT_SHOULDER',
RIGHT_SHOULDER = 'RIGHT_SHOULDER',
LEFT_THUMB_METACARPAL = 'LEFT_THUMB_METACARPAL',
LEFT_THUMB_PROXIMAL = 'LEFT_THUMB_PROXIMAL',
LEFT_THUMB_DISTAL = 'LEFT_THUMB_DISTAL',
LEFT_INDEX_PROXIMAL = 'LEFT_INDEX_PROXIMAL',
LEFT_INDEX_INTERMEDIATE = 'LEFT_INDEX_INTERMEDIATE',
LEFT_INDEX_DISTAL = 'LEFT_INDEX_DISTAL',
LEFT_MIDDLE_PROXIMAL = 'LEFT_MIDDLE_PROXIMAL',
LEFT_MIDDLE_INTERMEDIATE = 'LEFT_MIDDLE_INTERMEDIATE',
LEFT_MIDDLE_DISTAL = 'LEFT_MIDDLE_DISTAL',
LEFT_RING_PROXIMAL = 'LEFT_RING_PROXIMAL',
LEFT_RING_INTERMEDIATE = 'LEFT_RING_INTERMEDIATE',
LEFT_RING_DISTAL = 'LEFT_RING_DISTAL',
LEFT_LITTLE_PROXIMAL = 'LEFT_LITTLE_PROXIMAL',
LEFT_LITTLE_INTERMEDIATE = 'LEFT_LITTLE_INTERMEDIATE',
LEFT_LITTLE_DISTAL = 'LEFT_LITTLE_DISTAL',
RIGHT_THUMB_METACARPAL = 'RIGHT_THUMB_METACARPAL',
RIGHT_THUMB_PROXIMAL = 'RIGHT_THUMB_PROXIMAL',
RIGHT_THUMB_DISTAL = 'RIGHT_THUMB_DISTAL',
RIGHT_INDEX_PROXIMAL = 'RIGHT_INDEX_PROXIMAL',
RIGHT_INDEX_INTERMEDIATE = 'RIGHT_INDEX_INTERMEDIATE',
RIGHT_INDEX_DISTAL = 'RIGHT_INDEX_DISTAL',
RIGHT_MIDDLE_PROXIMAL = 'RIGHT_MIDDLE_PROXIMAL',
RIGHT_MIDDLE_INTERMEDIATE = 'RIGHT_MIDDLE_INTERMEDIATE',
RIGHT_MIDDLE_DISTAL = 'RIGHT_MIDDLE_DISTAL',
RIGHT_RING_PROXIMAL = 'RIGHT_RING_PROXIMAL',
RIGHT_RING_INTERMEDIATE = 'RIGHT_RING_INTERMEDIATE',
RIGHT_RING_DISTAL = 'RIGHT_RING_DISTAL',
RIGHT_LITTLE_PROXIMAL = 'RIGHT_LITTLE_PROXIMAL',
RIGHT_LITTLE_INTERMEDIATE = 'RIGHT_LITTLE_INTERMEDIATE',
RIGHT_LITTLE_DISTAL = 'RIGHT_LITTLE_DISTAL',
LEFT_BIG_TOE = 'LEFT_BIG_TOE',
LEFT_INDEX_TOE = 'LEFT_INDEX_TOE',
LEFT_MIDDLE_TOE = 'LEFT_MIDDLE_TOE',
LEFT_RING_TOE = 'LEFT_RING_TOE',
LEFT_LITTLE_TOE = 'LEFT_LITTLE_TOE',
RIGHT_BIG_TOE = 'RIGHT_BIG_TOE',
RIGHT_INDEX_TOE = 'RIGHT_INDEX_TOE',
RIGHT_MIDDLE_TOE = 'RIGHT_MIDDLE_TOE',
RIGHT_RING_TOE = 'RIGHT_RING_TOE',
RIGHT_LITTLE_TOE = 'RIGHT_LITTLE_TOE',
}
// Standard bones are keyed `slimevr:<lowercase name>` (BoneRegistry.standard on the
// server); this is the only way a wire BoneDefinition resolves back to a BodyPart.
const KEY_TO_BODY_PART: ReadonlyMap<string, BodyPart> = new Map(
Object.values(BodyPart)
.filter((value) => value !== BodyPart.NONE)
.map((value) => [`slimevr:${value.toLowerCase()}`, value])
);
export function bodyPartOfKey(key: string): BodyPart {
return KEY_TO_BODY_PART.get(key) ?? BodyPart.NONE;
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
export type ExtremitySide = 'left' | 'right';
+1 -1
View File
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
export const bodypartToString = (id: BodyPart) => BodyPart[id].replace(/_/g, ' ');
+2 -1
View File
@@ -10,7 +10,8 @@ import {
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2';
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial.js';
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry.js';
import { BodyPart, BoneT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BoneT } from 'solarxr-protocol';
import { QuaternionFromQuatT } from '@/maths/quaternion';
import { Vector3FromVec3fT } from '@/maths/vector3';
import { FINGER_BODY_PARTS, TOE_BODY_PARTS } from '@/hooks/body-parts';
+2 -1
View File
@@ -15,7 +15,8 @@ import {
SkeletonRenderPart,
TrackerPreviewData,
} from './skeletonHelper';
import { BodyPart, BoneT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BoneT } from 'solarxr-protocol';
import { QuaternionFromQuatT } from '@/maths/quaternion';
import { Vector3FromVec3fT } from '@/maths/vector3';
import {
+1 -1
View File
@@ -1,4 +1,4 @@
import { BodyPart } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import {
Color,
DoubleSide,
+2 -1
View File
@@ -1,4 +1,5 @@
import { BodyPart, BoneT } from 'solarxr-protocol';
import { BodyPart } from '@/utils/body-part';
import { BoneT } from 'solarxr-protocol';
import { EYE_HEIGHT_TO_HEIGHT_RATIO } from '@/hooks/height';
/**
@@ -3,13 +3,12 @@ package dev.slimevr.android.ipc
import com.google.flatbuffers.FlatBufferBuilder
import dev.slimevr.AppContextProvider
import dev.slimevr.VRServerActions
import dev.slimevr.fbscodegen.runtime.JvmFlatBufferReader
import dev.slimevr.fbscodegen.runtime.JvmFlatBufferWriter
import dev.slimevr.logging.AppLogger
import dev.slimevr.solarxr.SOLARXR_PROTOCOL_VERSION
import dev.slimevr.solarxr.OutboundFrame
import dev.slimevr.solarxr.SolarXRBridge
import dev.slimevr.solarxr.checkedSolarXRFrame
import dev.slimevr.solarxr.onSolarXRMessage
import dev.slimevr.solarxr.writeSolarXRBundle
import io.ktor.server.application.install
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer
@@ -25,10 +24,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.launch
import solarxr_protocol.ClientHello
import solarxr_protocol.HelloStatus
import solarxr_protocol.MessageBundle
import solarxr_protocol.ServerHello
import java.nio.ByteBuffer
import kotlin.time.Duration.Companion.seconds
@@ -50,10 +46,14 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
AppLogger.ipc.info("SolarXR[${bridge.id}] connected (websocket)")
appContext.server.context.dispatch(VRServerActions.SolarXRConnected(bridge))
bridge.outbound.on<MessageBundle> { bundle ->
bridge.outbound.on<OutboundFrame> { frame ->
val fbb = FlatBufferBuilder(256)
bundle.finish(JvmFlatBufferWriter(fbb))
writeSolarXRBundle(fbb, frame.bundle)
send(Frame.Binary(fin = true, data = fbb.dataBuffer().moveToByteArray()))
if (frame.closeReason != null) {
AppLogger.ipc.warn("SolarXR[${bridge.id}] closing (websocket): ${frame.closeReason}")
this@coroutineScope.cancel()
}
}.launchIn(this)
val initTimeout = launch {
@@ -65,7 +65,6 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
}
try {
var awaitingHello = true
flow {
for (frame in incoming) {
when (frame) {
@@ -76,22 +75,9 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
}
}.collect { bytes ->
val buffer = ByteBuffer.wrap(bytes)
if (awaitingHello) {
val reader = checkedSolarXRFrame(buffer, ClientHello.FILE_IDENTIFIER)
val hello = ClientHello.fromByteBuffer(reader)
val accepted = hello.protocolVersion == SOLARXR_PROTOCOL_VERSION
val fbb = FlatBufferBuilder(64)
ServerHello(if (accepted) HelloStatus.ACCEPTED else HelloStatus.REJECTED_UNSUPPORTED_VERSION, SOLARXR_PROTOCOL_VERSION)
.finish(JvmFlatBufferWriter(fbb))
send(Frame.Binary(fin = true, data = fbb.dataBuffer().moveToByteArray()))
require(accepted) { "Unsupported SolarXR protocol version ${hello.protocolVersion}" }
awaitingHello = false
bridge.beginConfiguration()
} else {
val reader = checkedSolarXRFrame(buffer, MessageBundle.FILE_IDENTIFIER)
onSolarXRMessage(MessageBundle.fromByteBuffer(reader), bridge)
if (bridge.isReady) initTimeout.cancel()
}
val reader = checkedSolarXRFrame(buffer)
onSolarXRMessage(MessageBundle.fromByteBuffer(reader), bridge)
if (bridge.isReady) initTimeout.cancel()
}
} finally {
AppLogger.ipc.info("SolarXR[${bridge.id}] disconnected (websocket)")
@@ -3,7 +3,7 @@ package dev.slimevr.autobone
import dev.slimevr.bones.boneId
import dev.slimevr.skeleton.ComputedSkeleton
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
fun slideContributionWeight(ankleA: Vector3, ankleB: Vector3, localBoneTailA: Vector3, localBoneTailB: Vector3): Float {
val ankleAToB = ankleB - ankleA
@@ -0,0 +1,74 @@
package dev.slimevr.bones
/**
* The standard body parts a bone in a [BoneRegistry] may represent. Not a wire type: SolarXR
* only ever carries a bone's numeric id and string key, so nothing on the wire needs this.
*/
enum class BodyPart(val value: UByte) {
NONE(0u),
HEAD(1u),
NECK(2u),
UPPER_CHEST(3u),
LOWER_CHEST(4u),
UPPER_WAIST(5u),
LOWER_WAIST(6u),
HIP(7u),
LEFT_UPPER_LEG(8u),
RIGHT_UPPER_LEG(9u),
LEFT_LOWER_LEG(10u),
RIGHT_LOWER_LEG(11u),
LEFT_FOOT(12u),
RIGHT_FOOT(13u),
LEFT_UPPER_ARM(14u),
RIGHT_UPPER_ARM(15u),
LEFT_LOWER_ARM(16u),
RIGHT_LOWER_ARM(17u),
LEFT_HAND(18u),
RIGHT_HAND(19u),
LEFT_SHOULDER(20u),
RIGHT_SHOULDER(21u),
LEFT_THUMB_METACARPAL(22u),
LEFT_THUMB_PROXIMAL(23u),
LEFT_THUMB_DISTAL(24u),
LEFT_INDEX_PROXIMAL(25u),
LEFT_INDEX_INTERMEDIATE(26u),
LEFT_INDEX_DISTAL(27u),
LEFT_MIDDLE_PROXIMAL(28u),
LEFT_MIDDLE_INTERMEDIATE(29u),
LEFT_MIDDLE_DISTAL(30u),
LEFT_RING_PROXIMAL(31u),
LEFT_RING_INTERMEDIATE(32u),
LEFT_RING_DISTAL(33u),
LEFT_LITTLE_PROXIMAL(34u),
LEFT_LITTLE_INTERMEDIATE(35u),
LEFT_LITTLE_DISTAL(36u),
RIGHT_THUMB_METACARPAL(37u),
RIGHT_THUMB_PROXIMAL(38u),
RIGHT_THUMB_DISTAL(39u),
RIGHT_INDEX_PROXIMAL(40u),
RIGHT_INDEX_INTERMEDIATE(41u),
RIGHT_INDEX_DISTAL(42u),
RIGHT_MIDDLE_PROXIMAL(43u),
RIGHT_MIDDLE_INTERMEDIATE(44u),
RIGHT_MIDDLE_DISTAL(45u),
RIGHT_RING_PROXIMAL(46u),
RIGHT_RING_INTERMEDIATE(47u),
RIGHT_RING_DISTAL(48u),
RIGHT_LITTLE_PROXIMAL(49u),
RIGHT_LITTLE_INTERMEDIATE(50u),
RIGHT_LITTLE_DISTAL(51u),
LEFT_BIG_TOE(52u),
LEFT_INDEX_TOE(53u),
LEFT_MIDDLE_TOE(54u),
LEFT_RING_TOE(55u),
LEFT_LITTLE_TOE(56u),
RIGHT_BIG_TOE(57u),
RIGHT_INDEX_TOE(58u),
RIGHT_MIDDLE_TOE(59u),
RIGHT_RING_TOE(60u),
RIGHT_LITTLE_TOE(61u);
companion object {
fun fromValue(value: UByte): BodyPart? = entries.firstOrNull { it.value == value }
}
}
@@ -1,6 +1,5 @@
package dev.slimevr.bones
import solarxr_protocol.datatypes.BodyPart
import java.util.EnumMap
/** A registry-local bone handle. `0` is reserved and never resolves to a definition. */
@@ -1,7 +1,5 @@
package dev.slimevr.bones
import solarxr_protocol.datatypes.BodyPart
val BODY_PART_HIERARCHY_MAP: Map<BodyPart, Array<BodyPart>> = mapOf(
BodyPart.HEAD to arrayOf(BodyPart.NECK),
BodyPart.NECK to arrayOf(BodyPart.UPPER_CHEST, BodyPart.LEFT_SHOULDER, BodyPart.RIGHT_SHOULDER),
@@ -5,15 +5,11 @@ import solarxr_protocol.connection.BoneRegistry as WireBoneRegistry
/**
* Assigns each of [incoming] a fresh ID above every ID [registry] already has, preserving order.
* A `parent` must reference a bone [registry] already defines; contributing two new bones that
* are parent and child of each other in the same batch isn't supported. A `standardBodyPart` is
* rejected here too, since only the initial [BoneRegistry.standard] registry may claim those IDs,
* which is what keeps [BodyPart.boneId][dev.slimevr.bones.boneId] safe to use with no lookup.
* A `parent` must reference a bone [registry] already defines
*/
private fun assignIds(registry: BoneRegistry, incoming: List<BoneDefinition>): List<BoneDefinition> {
var nextId = registry.maxId
return incoming.map { definition ->
require(definition.standardBodyPart == null) { "Extension bone \"${definition.key}\" cannot claim a standard body part" }
require(definition.parent == 0.toUShort() || registry[BoneId(definition.parent)] != null) {
"Extension bone \"${definition.key}\" has an unknown parent"
}
@@ -1,20 +1,18 @@
package dev.slimevr.bones
import solarxr_protocol.connection.BoneDefinition
import solarxr_protocol.datatypes.BodyPart
import solarxr_protocol.connection.BoneRegistry as WireBoneRegistry
private val BODY_PART_BY_VALUE: Array<BodyPart?> = arrayOfNulls<BodyPart>(UByte.MAX_VALUE.toInt() + 1).also { array ->
for (bodyPart in BodyPart.entries) array[bodyPart.value.toInt()] = bodyPart
}
/**
* The server's bone identity and hierarchy. IDs are dense (`1..maxId`),
* so [BoneMap]/[BoneSet] can use a plain array instead of a hash table.
*
* [BodyPart] is only used at the edges: to seed [standard], and to resolve specific bones by
* name. Everything else is [BoneId]-keyed, so a bone with no standard body part still works.
*
* Invariant: a definition with a [BoneDefinition.standardBodyPart] always has
* `id == standardBodyPart.value`, checked below. That is what lets [BodyPart.boneId] convert
* without a registry lookup, so extension bones (added via `BoneRegistryManager.register`) must
* never be assigned a standard body part, and standard IDs are never reassigned.
*/
class BoneRegistry private constructor(
val value: WireBoneRegistry,
@@ -22,20 +20,26 @@ class BoneRegistry private constructor(
val root: BoneId,
private val byId: Array<BoneDefinition?>,
private val byKey: Map<String, BoneDefinition>,
private val standardIds: Array<BoneId?>,
private val childIds: Array<IntArray>,
) {
operator fun get(id: BoneId): BoneDefinition? = byId.getOrNull(id.value.toInt())
/** Constant-time lookup with no per-call allocation. */
operator fun get(bodyPart: BodyPart): BoneId? = standardIds[bodyPart.value.toInt()]
operator fun get(bodyPart: BodyPart): BoneId? {
if (bodyPart == BodyPart.NONE) return null
val id = BoneId(bodyPart.value.toUShort())
return id.takeIf { this[it] != null }
}
fun byKey(key: String): BoneDefinition? = byKey[key]
/** The registry key is stable across a registry rebuild; a [BoneId] is not. */
operator fun get(key: String): BoneId? = byKey(key)?.let { BoneId(it.id) }
/** Inverse of `get(BodyPart)`; null when the ID is unknown or not a standardized bone. */
fun bodyPartOf(id: BoneId): BodyPart? = this[id]?.standardBodyPart
/** Inverse of `get(BodyPart)`; null when the ID is unknown or outside the standard `BodyPart` range. */
fun bodyPartOf(id: BoneId): BodyPart? {
if (this[id] == null) return null
return BODY_PART_BY_VALUE.getOrNull(id.value.toInt())?.takeIf { it != BodyPart.NONE }
}
/** Inverse of `get(String)`. */
fun keyOf(id: BoneId): String? = this[id]?.key
@@ -99,7 +103,6 @@ class BoneRegistry private constructor(
key = bodyPart.key,
displayName = bodyPart.name.replace('_', ' ').lowercase(),
parent = parentPartOf[bodyPart]?.boneId?.value ?: 0.toUShort(),
standardBodyPart = bodyPart,
)
},
),
@@ -115,9 +118,6 @@ class BoneRegistry private constructor(
"Bone registry IDs must be exactly 1..$n"
}
require(registry.bones.all { it.parent == 0.toUShort() || it.parent in definitions }) { "Bone registry has an unknown parent" }
require(registry.bones.all { definition -> definition.standardBodyPart?.let { it.value.toUShort() == definition.id } ?: true }) {
"A standard body part's ID must equal its BodyPart value"
}
val visited = mutableSetOf<UShort>()
fun root(id: UShort): UShort {
require(visited.add(id)) { "Bone registry contains a cycle" }
@@ -132,7 +132,6 @@ class BoneRegistry private constructor(
val byId = arrayOfNulls<BoneDefinition>(n + 1)
val children = Array(n + 1) { mutableListOf<Int>() }
var root: BoneId? = null
val standardIds = arrayOfNulls<BoneId>(UByte.MAX_VALUE.toInt() + 1)
for (definition in registry.bones) {
val id = definition.id.toInt()
byId[id] = definition
@@ -142,10 +141,6 @@ class BoneRegistry private constructor(
} else {
children[definition.parent.toInt()] += id
}
definition.standardBodyPart?.let { bodyPart ->
require(standardIds[bodyPart.value.toInt()] == null) { "Duplicate standard bone $bodyPart" }
standardIds[bodyPart.value.toInt()] = BoneId(definition.id)
}
}
return BoneRegistry(
value = registry,
@@ -153,7 +148,6 @@ class BoneRegistry private constructor(
root = requireNotNull(root) { "Bone registry has no root" },
byId = byId,
byKey = registry.bones.associateBy { it.key },
standardIds = standardIds,
childIds = Array(children.size) { children[it].toIntArray() },
)
}
@@ -14,7 +14,7 @@ import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.intOrNull
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.MountingMethod
import solarxr_protocol.rpc.ArmsResetMode
import solarxr_protocol.rpc.FilteringType
@@ -17,7 +17,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.flow.takeWhile
import kotlinx.coroutines.withTimeoutOrNull
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.UserHeightCalibrationStatus
import kotlin.math.PI
import kotlin.math.cos
@@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.TrackerStatus
import solarxr_protocol.rpc.UserHeightCalibrationStatus
@@ -5,7 +5,7 @@ import dev.slimevr.hid.HIDReceiver
import dev.slimevr.hid.HIDReceiverBehaviour
import dev.slimevr.hid.HIDSensorInfo
import dev.slimevr.tracker.TrackerActions
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
class HIDSensorInfoBehaviour : HIDReceiverBehaviour {
override fun observe(receiver: HIDReceiver) {
@@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.KeybindId
import solarxr_protocol.rpc.ResetType
@@ -1,6 +1,6 @@
package dev.slimevr.resets
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
object ResetBodyParts {
val UPPER_LEGS = setOf(
@@ -22,7 +22,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.MountingMethod
import solarxr_protocol.rpc.ArmsResetMode
import solarxr_protocol.rpc.ResetResponse
@@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.DeviceOrigin
import solarxr_protocol.rpc.RoutingOutput
import solarxr_protocol.rpc.RoutingOutputState
@@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.ResetType
import java.util.concurrent.Executors
import kotlin.math.cos
@@ -4,7 +4,7 @@ import com.jme3.math.FastMath
import dev.slimevr.bones.BodyPartMap
import dev.slimevr.bones.BoneId
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
// TODO Actually figure out good values for these constraints, maybe a source would be
// good?
@@ -3,7 +3,7 @@ package dev.slimevr.skeleton
import dev.slimevr.bones.BodyPartMap
import dev.slimevr.bones.BoneId
import dev.slimevr.bones.boneId
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
typealias BodyPartChain = List<BodyPart>
@@ -4,7 +4,7 @@ import dev.slimevr.bones.BoneId
import dev.slimevr.bones.boneId
import dev.slimevr.util.inFloatingSeconds
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import kotlin.time.ComparableTimeMark
// TODO Where are these numbers from?
@@ -8,7 +8,7 @@ import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonFkProcessor
import dev.slimevr.tracker.eulerHeading
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
// The max height to plant feet by
const val ROTATION_CORRECTION_VERTICAL = 0.1f
@@ -19,7 +19,7 @@ import dev.slimevr.util.MonotonicValueTimeMark
import dev.slimevr.util.inFloatingSeconds
import dev.slimevr.util.timeSource
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.ResetType
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
@@ -8,7 +8,7 @@ import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonFkProcessor
import dev.slimevr.tracker.eulerHeading
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import kotlin.math.abs
import kotlin.math.asin
@@ -4,7 +4,7 @@ import dev.slimevr.bones.BoneId
import dev.slimevr.bones.boneId
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Handles setting the rotation of an inactive bone with its source bone.
@@ -4,7 +4,7 @@ import dev.slimevr.bones.BoneId
import dev.slimevr.bones.boneId
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
private const val INTERMEDIATE_FROM_PROXIMAL = 2.12f
private const val DISTAL_FROM_PROXIMAL = 3.03f
@@ -5,7 +5,7 @@ import dev.slimevr.config.Settings
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Moves the head input to the skeleton height. Else, it would default to (0, 0, 0).
@@ -5,7 +5,7 @@ import dev.slimevr.config.Settings
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Rotates the first Quaternion to match its yaw and roll to the rotation of
@@ -9,7 +9,7 @@ import dev.slimevr.skeleton.SkeletonInputProcessor
import dev.slimevr.util.MonotonicValueTimeMark
import dev.slimevr.util.timeSource
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.FilteringType
import solarxr_protocol.rpc.ResetType
import kotlin.time.Duration.Companion.milliseconds
@@ -7,7 +7,7 @@ import dev.slimevr.config.Settings
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import kotlin.enums.enumEntries
// At this default value, the user's spine should behave as we meant it to.
@@ -4,7 +4,7 @@ import dev.slimevr.bones.BoneId
import dev.slimevr.bones.boneId
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import solarxr_protocol.datatypes.BodyPart
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
@@ -6,7 +6,7 @@ import dev.slimevr.config.Settings
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.SkeletonInputProcessor
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Rotates the first Quaternion to match its roll to the rotation of
@@ -6,7 +6,7 @@ import dev.slimevr.bones.BoneRegistry
import dev.slimevr.bones.boneId
import io.github.axisangles.ktmath.Vector3
import io.github.axisangles.ktmath.times
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.SkeletonBone
import kotlin.collections.map
import kotlin.collections.plus
@@ -5,7 +5,7 @@ import dev.slimevr.bones.mapValues
import dev.slimevr.bones.mutateCopy
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
fun reduce(state: SkeletonState, action: SkeletonActions): SkeletonState = when (action) {
is SkeletonActions.SetBoneRotation -> {
@@ -7,7 +7,7 @@ import dev.slimevr.skeleton.ComputedSkeleton
import dev.slimevr.skeleton.IKTargets
import dev.slimevr.skeleton.SkeletonTargetProcessor
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
class FloorClipTargetProcessor(
val settings: Settings,
@@ -14,7 +14,7 @@ import dev.slimevr.skeleton.computeComState
import dev.slimevr.skeleton.resolveMasses
import dev.slimevr.util.timeSource
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.ResetType
data class LockState(
@@ -0,0 +1,44 @@
package dev.slimevr.solarxr
import solarxr_protocol.connection.BoneRegistryRequest
import solarxr_protocol.connection.ClientHello
import solarxr_protocol.connection.ConfigurationDone
import solarxr_protocol.connection.ConnectionError
import solarxr_protocol.connection.ConnectionMessage
import solarxr_protocol.connection.HelloStatus
import solarxr_protocol.connection.InitializationRequiredError
import solarxr_protocol.connection.ServerHello
import solarxr_protocol.connection.UnsupportedRequestError
suspend fun onConnectionMessage(message: ConnectionMessage?, bridge: SolarXRBridge) {
when (bridge.context.state.value.phase) {
ConnectionPhase.HELLO -> {
val hello = message as? ClientHello
if (hello == null) {
bridge.sendConnectionMessage(
ConnectionError(message = "The first message on a connection must be ClientHello", data = InitializationRequiredError()),
closeReason = "First message was not ClientHello",
)
return
}
val accepted = hello.protocolVersion == SOLARXR_PROTOCOL_VERSION
bridge.sendConnectionMessage(
ServerHello(if (accepted) HelloStatus.ACCEPTED else HelloStatus.REJECTED_UNSUPPORTED_VERSION, SOLARXR_PROTOCOL_VERSION),
closeReason = if (accepted) null else "Unsupported SolarXR protocol version ${hello.protocolVersion}",
)
if (accepted) bridge.context.dispatch(SolarXRBridgeActions.SetPhase(ConnectionPhase.CONFIGURING))
}
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
}
ConnectionPhase.READY -> Unit
}
}
@@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.DeviceOrigin
import solarxr_protocol.driver_protocol.BoneBatteryUpdate
import solarxr_protocol.driver_protocol.SkeletonUpdate
@@ -0,0 +1,42 @@
package dev.slimevr.solarxr
import solarxr_protocol.MessageBundle
import solarxr_protocol.connection.ConnectionError
import solarxr_protocol.connection.InitializationRequiredError
suspend fun onSolarXRMessage(message: MessageBundle, context: SolarXRBridge) {
val wasReady = context.isReady
message.connectionMsgs?.forEach { header -> onConnectionMessage(header.message, context) }
if (!wasReady) {
if (message.dataFeedMsgs != null || message.rpcMsgs != null || message.driverMsgs != null) {
context.sendConnectionMessage(ConnectionError(message = "Configuration has not completed", data = InitializationRequiredError()))
}
return
}
message.dataFeedMsgs?.forEach {
val msg = it.message ?: return
context.dataFeedDispatcher.emit(msg)
}
message.rpcMsgs?.forEach {
val msg = it.message ?: return
val replyTo = it.replyTo
if (replyTo != 0u) {
context.rpcRequests.tryResolve(replyTo, msg)
return@forEach
}
context.rpcReplies.record(msg, it.txId)
context.rpcDispatcher.emit(msg)
}
message.driverMsgs?.forEach {
val msg = it.message ?: return
val replyTo = it.replyTo
if (replyTo != 0u) {
context.driverRequests.tryResolve(replyTo, msg)
return@forEach
}
context.driverReplies.record(msg, it.txId)
context.driverDispatcher.emit(msg)
}
}
@@ -44,12 +44,8 @@ import dev.slimevr.util.timeSource
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import solarxr_protocol.MessageBundle
import solarxr_protocol.connection.ConfigurationAcknowledged
import solarxr_protocol.connection.ConnectionError
import solarxr_protocol.connection.ConnectionErrorCode
import solarxr_protocol.connection.ConnectionMessage
import solarxr_protocol.connection.ConnectionMessageHeader
import solarxr_protocol.connection.FinishConfiguration
import solarxr_protocol.data_feed.DataFeedConfig
import solarxr_protocol.data_feed.DataFeedMessage
import solarxr_protocol.data_feed.DataFeedMessageHeader
@@ -63,67 +59,27 @@ import solarxr_protocol.rpc.RpcMessageHeader
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
enum class ConnectionPhase { HELLO, CONFIGURING, READY }
data class SolarXRBridgeState(
val dataFeedConfigs: List<DataFeedConfig> = emptyList(),
val driverName: String? = null,
val boneMask: BoneMask? = null,
val isReady: Boolean = false,
val phase: ConnectionPhase = ConnectionPhase.HELLO,
val observing: Boolean = false,
)
sealed interface SolarXRBridgeActions {
data class SetConfig(val configs: List<DataFeedConfig>) : SolarXRBridgeActions
data class SetDriverInfo(val name: String?, val boneMask: BoneMask?) : SolarXRBridgeActions
data object SetReady : SolarXRBridgeActions
data class SetPhase(val phase: ConnectionPhase) : SolarXRBridgeActions
data object SetObserving : SolarXRBridgeActions
}
typealias SolarXRBridgeContext = Context<SolarXRBridgeState, SolarXRBridgeActions>
typealias SolarXRBridgeBehaviour = Behaviour<SolarXRBridge>
suspend fun onSolarXRMessage(message: MessageBundle, context: SolarXRBridge) {
// Connection messages are a barrier: configuration must be consumed before
// any application bundle is dispatched.
val wasReady = context.isReady
message.connectionMsgs?.forEach { header ->
when (header.message) {
is ConfigurationAcknowledged -> context.completeConfiguration()
else -> Unit
}
}
if (!wasReady) {
if (message.dataFeedMsgs != null || message.rpcMsgs != null || message.driverMsgs != null) {
context.sendConnectionMessage(ConnectionError(ConnectionErrorCode.INITIALIZATION_REQUIRED, "Configuration has not completed"))
}
return
}
message.dataFeedMsgs?.forEach {
val msg = it.message ?: return
context.dataFeedDispatcher.emit(msg)
}
message.rpcMsgs?.forEach {
val msg = it.message ?: return
val replyTo = it.replyTo
if (replyTo != 0u) {
context.rpcRequests.tryResolve(replyTo, msg)
return@forEach
}
context.rpcReplies.record(msg, it.txId)
context.rpcDispatcher.emit(msg)
}
message.driverMsgs?.forEach {
val msg = it.message ?: return
val replyTo = it.replyTo
if (replyTo != 0u) {
context.driverRequests.tryResolve(replyTo, msg)
return@forEach
}
context.driverReplies.record(msg, it.txId)
context.driverDispatcher.emit(msg)
}
}
data class OutboundFrame(val bundle: MessageBundle, val closeReason: String? = null)
class SolarXRBridge(
val id: Int,
@@ -132,10 +88,10 @@ class SolarXRBridge(
val dataFeedDispatcher: EventDispatcher<DataFeedMessage> = EventDispatcher("SolarXR[$id].dataFeed", context.scope, capacity = 32),
val rpcDispatcher: EventDispatcher<RpcMessage> = EventDispatcher("SolarXR[$id].rpc", context.scope, capacity = 64),
val driverDispatcher: EventDispatcher<DriverMessage> = EventDispatcher("SolarXR[$id].driver", context.scope, capacity = 64),
val outbound: EventDispatcher<MessageBundle> = EventDispatcher("SolarXR[$id].outbound", context.scope, capacity = 64),
val outbound: EventDispatcher<OutboundFrame> = EventDispatcher("SolarXR[$id].outbound", context.scope, capacity = 64),
private val managedContext: ManagedContext<SolarXRBridgeState, SolarXRBridgeActions>? = null,
) {
val isReady: Boolean get() = context.state.value.isReady
val isReady: Boolean get() = context.state.value.phase == ConnectionPhase.READY
val registry: BoneRegistry get() = appContext.bones.current
// Jobs are mutable handles with no meaningful equality; storing them in state
@@ -162,23 +118,18 @@ class SolarXRBridge(
return driverDispatcher.on<P> { msg -> action(msg, driverTxIdFor(msg)) }
}
suspend fun sendRpc(message: RpcMessage, replyTo: UInt? = null, txId: UInt? = null) = outbound.emit(MessageBundle(rpcMsgs = listOf(RpcMessageHeader(txId = txId ?: 0u, replyTo = replyTo ?: 0u, message = message))))
suspend fun sendDriverMessage(message: DriverMessage, replyTo: UInt? = null, txId: UInt? = null) = outbound.emit(MessageBundle(driverMsgs = listOf(DriverMessageHeader(txId = txId ?: 0u, replyTo = replyTo ?: 0u, message = message))))
suspend fun sendRpc(message: RpcMessage, replyTo: UInt? = null, txId: UInt? = null) = outbound.emit(OutboundFrame(MessageBundle(rpcMsgs = listOf(RpcMessageHeader(txId = txId ?: 0u, replyTo = replyTo ?: 0u, message = message)))))
suspend fun sendDriverMessage(message: DriverMessage, replyTo: UInt? = null, txId: UInt? = null) = outbound.emit(OutboundFrame(MessageBundle(driverMsgs = listOf(DriverMessageHeader(txId = txId ?: 0u, replyTo = replyTo ?: 0u, message = message)))))
suspend inline fun <reified R : RpcMessage> requestRpc(message: RpcMessage, timeout: Duration = 10.seconds): R = rpcRequests.request(timeout, message) { msg, newTxId -> sendRpc(msg, txId = newTxId) }
suspend inline fun <reified R : DriverMessage> requestDriverMessage(message: DriverMessage, timeout: Duration = 10.seconds): R = driverRequests.request(timeout, message) { msg, newTxId -> sendDriverMessage(msg, txId = newTxId) }
suspend fun sendDataFeed(frame: DataFeedMessageHeader) = outbound.emit(MessageBundle(dataFeedMsgs = listOf(frame)))
suspend fun sendConnectionMessage(message: ConnectionMessage) = outbound.emit(MessageBundle(connectionMsgs = listOf(ConnectionMessageHeader(message))))
suspend fun beginConfiguration() {
sendConnectionMessage(registry.value)
sendConnectionMessage(FinishConfiguration())
}
suspend fun sendDataFeed(frame: DataFeedMessageHeader) = outbound.emit(OutboundFrame(MessageBundle(dataFeedMsgs = listOf(frame))))
suspend fun sendConnectionMessage(message: ConnectionMessage, closeReason: String? = null) = outbound.emit(OutboundFrame(MessageBundle(connectionMsgs = listOf(ConnectionMessageHeader(message))), closeReason))
fun completeConfiguration() {
if (context.state.value.isReady) return
context.dispatch(SolarXRBridgeActions.SetReady)
if (context.state.value.phase == ConnectionPhase.READY) return
context.dispatch(SolarXRBridgeActions.SetPhase(ConnectionPhase.READY))
if (!context.state.value.observing) {
context.dispatch(SolarXRBridgeActions.SetObserving)
startObserving()
@@ -1,17 +1,20 @@
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
const val SOLARXR_PROTOCOL_VERSION: UInt = 2u
const val SOLARXR_MAX_FRAME_SIZE = 256 * 1024
/** Checks framing before generated code reads a FlatBuffer root. */
fun checkedSolarXRFrame(bytes: ByteBuffer, identifier: String): JvmFlatBufferReader {
fun checkedSolarXRFrame(bytes: ByteBuffer): JvmFlatBufferReader {
require(bytes.remaining() in 8..SOLARXR_MAX_FRAME_SIZE) { "Invalid SolarXR frame length" }
val position = bytes.position()
require((0 until 4).all { bytes.get(position + 4 + it).toInt().toChar() == identifier[it] }) {
"Unexpected SolarXR file identifier"
}
return JvmFlatBufferReader(bytes)
}
fun writeSolarXRBundle(fbb: FlatBufferBuilder, bundle: MessageBundle) {
val writer = JvmFlatBufferWriter(fbb)
writer.finish(bundle.encode(writer))
}
@@ -3,6 +3,6 @@ package dev.slimevr.solarxr
fun reduce(state: SolarXRBridgeState, action: SolarXRBridgeActions): SolarXRBridgeState = when (action) {
is SolarXRBridgeActions.SetConfig -> state.copy(dataFeedConfigs = action.configs)
is SolarXRBridgeActions.SetDriverInfo -> state.copy(driverName = action.name, boneMask = action.boneMask)
is SolarXRBridgeActions.SetReady -> state.copy(isReady = true)
is SolarXRBridgeActions.SetPhase -> state.copy(phase = action.phase)
is SolarXRBridgeActions.SetObserving -> state.copy(observing = true)
}
@@ -17,7 +17,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.TrackerStatus
import solarxr_protocol.rpc.ResetType
import solarxr_protocol.rpc.TapDetectionSetupNotification
@@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.MountingMethod
class TrackerDefaultMountingOrientationBehaviour(private val registry: BoneRegistry) : TrackerBehaviour {
@@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.ArmsResetMode
/**
@@ -2,7 +2,7 @@ package dev.slimevr.tracker
import dev.slimevr.bones.boneId
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.MountingMethod
import kotlin.time.Duration
@@ -1,7 +1,7 @@
package dev.slimevr.tracker.stayaligned
import dev.slimevr.util.Side
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Body parts used by Stay Aligned with some utils.
@@ -8,7 +8,7 @@ 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 solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
class RelaxedPose(
val upperLeg: Angle,
@@ -17,7 +17,7 @@ import dev.slimevr.tracker.stayaligned.poses.RelaxedPose
import dev.slimevr.util.Side
import dev.slimevr.util.side
import io.github.axisangles.ktmath.Quaternion
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Entry point for Stay Aligned. More specifically, computeYawCorrection is.
@@ -32,7 +32,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.DeviceOrigin
import solarxr_protocol.datatypes.MountingMethod
import solarxr_protocol.datatypes.TrackerStatus
@@ -1,6 +1,6 @@
package dev.slimevr.util
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
/**
* Used to represent the side of the skeleton a bone is on.
@@ -19,7 +19,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.DeviceOrigin
import solarxr_protocol.datatypes.TrackerStatus
import solarxr_protocol.rpc.VMCOSCInputState
@@ -5,7 +5,7 @@ import dev.slimevr.bones.BodyPartMap
import dev.slimevr.resets.ResetBodyParts
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
// TODO how to handle UPPER_WAIST?
val BODY_PART_TO_UNITY_BONE: BodyPartMap<Array<String>> = BodyPartMap(
@@ -10,7 +10,7 @@ import dev.slimevr.skeleton.BoneState
import dev.slimevr.skeleton.ComputedSkeleton
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import kotlin.time.Duration
internal fun buildOutgoingBundle(
@@ -17,7 +17,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.RoutingOutput
import solarxr_protocol.rpc.VMCOSCOutputState
import kotlin.time.Duration.Companion.seconds
@@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.VMCOSCVrmState
private val vrmJsonParser = Json { ignoreUnknownKeys = true }
@@ -8,7 +8,7 @@ import dev.slimevr.context.Context
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.rpc.VRCAvatarMeasurementType
import solarxr_protocol.rpc.VRCConfigRecommendedValues
import solarxr_protocol.rpc.VRCConfigValidity
@@ -18,7 +18,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import solarxr_protocol.datatypes.DeviceOrigin
import solarxr_protocol.datatypes.TrackerStatus
import solarxr_protocol.rpc.VRCOSCInputState
@@ -9,7 +9,7 @@ import dev.slimevr.skeleton.ComputedSkeleton
import io.github.axisangles.ktmath.EulerOrder
import io.github.axisangles.ktmath.Quaternion
import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import dev.slimevr.bones.BodyPart
import kotlin.math.PI
private val trackerIdsByBodyPart = mapOf(
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff. Show more