From 3f1a794148478b8df751cecbddbc90e5eeea0b6d Mon Sep 17 00:00:00 2001 From: Butterscotch! Date: Sun, 16 Mar 2025 10:24:22 -0400 Subject: [PATCH] Full height for manual configuration (#1329) Co-authored-by: lucas lelievre --- gui/public/i18n/en/translation.ftl | 14 ++++---- .../ProportionsResetModal.tsx | 4 +-- .../autobone-steps/CheckFloorHeight.tsx | 5 +-- .../scaled-steps/ManualHeightStep.tsx | 24 +++++++++---- gui/src/hooks/height.ts | 5 +++ .../autobone/errors/BodyProportionError.kt | 5 ++- .../dev/slimevr/protocol/rpc/RPCHandler.kt | 4 ++- .../processor/config/SkeletonConfigManager.kt | 35 ++++++++++--------- 8 files changed, 59 insertions(+), 37 deletions(-) diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index 702e0352c..9795eb85f 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -130,14 +130,13 @@ skeleton_bone-ELBOW_OFFSET = Elbow Offset ## Tracker reset buttons reset-reset_all = Reset all proportions -reset-reset_all_warning = - Warning: This will reset your proportions to being just based on your height. +reset-reset_all_warning-v2 = + Warning: Your proportions will be reset to defaults scaled to your configured height. Are you sure you want to do this? reset-reset_all_warning-reset = Reset proportions reset-reset_all_warning-cancel = Cancel -reset-reset_all_warning_default = - Warning: You currently don't have your height defined, which - will make the proportions be based on a default height. +reset-reset_all_warning_default-v2 = + Warning: Your height has not been configured, your proportions will be reset to defaults with the default height. Are you sure you want to do this? reset-full = Full Reset @@ -1078,9 +1077,10 @@ onboarding-automatic_proportions-smol_warning-cancel = Go back onboarding-scaled_proportions-title = Scaled proportions onboarding-scaled_proportions-description = For SlimeVR trackers to work, we need to know the length of your bones. This will use an average proportion and scale it based on your height. onboarding-scaled_proportions-manual_height-title = Configure your height -onboarding-scaled_proportions-manual_height-description = Your headset (HMD) height should be slightly less than your full height, as headsets measure your eye height. This height will be used as a baseline for your body proportions. +onboarding-scaled_proportions-manual_height-description-v2 = This height will be used as a baseline for your body proportions. onboarding-scaled_proportions-manual_height-missing_steamvr = SteamVR is not currently connected to SlimeVR, so measurements can't be based on your headset. Proceed at your own risk or check the docs! -onboarding-scaled_proportions-manual_height-height = Your headset height is +onboarding-scaled_proportions-manual_height-height-v2 = Your full height is +onboarding-scaled_proportions-manual_height-estimated_height = Your estimated headset height is: onboarding-scaled_proportions-manual_height-next_step = Continue and save ## Tracker scaled proportions reset diff --git a/gui/src/components/onboarding/pages/body-proportions/ProportionsResetModal.tsx b/gui/src/components/onboarding/pages/body-proportions/ProportionsResetModal.tsx index 233bdfb14..b60861b50 100644 --- a/gui/src/components/onboarding/pages/body-proportions/ProportionsResetModal.tsx +++ b/gui/src/components/onboarding/pages/body-proportions/ProportionsResetModal.tsx @@ -55,8 +55,8 @@ export function ProportionsResetModal({ }} > diff --git a/gui/src/components/onboarding/pages/body-proportions/autobone-steps/CheckFloorHeight.tsx b/gui/src/components/onboarding/pages/body-proportions/autobone-steps/CheckFloorHeight.tsx index 075c12886..71dc968b5 100644 --- a/gui/src/components/onboarding/pages/body-proportions/autobone-steps/CheckFloorHeight.tsx +++ b/gui/src/components/onboarding/pages/body-proportions/autobone-steps/CheckFloorHeight.tsx @@ -12,7 +12,7 @@ import { Typography } from '@/components/commons/Typography'; import { Localized, useLocalization } from '@fluent/react'; import { useEffect, useMemo, useState } from 'react'; import { useLocaleConfig } from '@/i18n/config'; -import { useHeightContext } from '@/hooks/height'; +import { EYE_HEIGHT_TO_HEIGHT_RATIO, useHeightContext } from '@/hooks/height'; import { useInterval } from '@/hooks/timeout'; import { TooSmolModal } from './TooSmolModal'; @@ -137,7 +137,8 @@ export function CheckFloorHeightStep({ {mFormat.format( - ((hmdHeight ?? 0) - (floorHeight ?? 0)) / 0.936 + ((hmdHeight ?? 0) - (floorHeight ?? 0)) / + EYE_HEIGHT_TO_HEIGHT_RATIO )} diff --git a/gui/src/components/onboarding/pages/body-proportions/scaled-steps/ManualHeightStep.tsx b/gui/src/components/onboarding/pages/body-proportions/scaled-steps/ManualHeightStep.tsx index 6ef146f4c..3f96b0097 100644 --- a/gui/src/components/onboarding/pages/body-proportions/scaled-steps/ManualHeightStep.tsx +++ b/gui/src/components/onboarding/pages/body-proportions/scaled-steps/ManualHeightStep.tsx @@ -4,7 +4,7 @@ import { Typography } from '@/components/commons/Typography'; import { Localized, useLocalization } from '@fluent/react'; import { useMemo } from 'react'; import { useLocaleConfig } from '@/i18n/config'; -import { useHeightContext } from '@/hooks/height'; +import { EYE_HEIGHT_TO_HEIGHT_RATIO, useHeightContext } from '@/hooks/height'; import { useForm } from 'react-hook-form'; import { ChangeSettingsRequestT, @@ -36,12 +36,13 @@ export function ManualHeightStep({ const { state } = useOnboarding(); const { l10n } = useLocalization(); const { setHmdHeight } = useHeightContext(); - const { control, handleSubmit, formState } = useForm({ + const { control, handleSubmit, formState, watch } = useForm({ defaultValues: { height: 1.5 }, }); const { sendRPCPacket } = useWebsocketAPI(); const { currentLocales } = useLocaleConfig(); const { statuses } = useStatusContext(); + const height = watch('height'); const missingSteamConnection = useMemo( () => @@ -65,13 +66,14 @@ export function ManualHeightStep({ ); const submitHmdHeight = (values: HeightForm) => { - setHmdHeight(values.height); + const newHeight = values.height * EYE_HEIGHT_TO_HEIGHT_RATIO; + setHmdHeight(newHeight); const settingsRequest = new ChangeSettingsRequestT(); settingsRequest.modelSettings = new ModelSettingsT( null, null, null, - new SkeletonHeightT(values.height, 0) + new SkeletonHeightT(newHeight, 0) ); sendRPCPacket(RpcMessage.ChangeSettingsRequest, settingsRequest); nextStep(); @@ -92,7 +94,7 @@ export function ManualHeightStep({
{l10n.getString( - 'onboarding-scaled_proportions-manual_height-description' + 'onboarding-scaled_proportions-manual_height-description-v2' )} {missingSteamConnection && ( @@ -112,7 +114,7 @@ export function ManualHeightStep({ control={control} name="height" label={l10n.getString( - 'onboarding-scaled_proportions-manual_height-height' + 'onboarding-scaled_proportions-manual_height-height-v2' )} valueLabelFormat={(value) => isNaN(value) @@ -128,6 +130,16 @@ export function ManualHeightStep({ doubleStep={0.1} />
+
+ + {l10n.getString( + 'onboarding-scaled_proportions-manual_height-estimated_height' + )} + + + {mFormat.format(height * EYE_HEIGHT_TO_HEIGHT_RATIO)} + +
diff --git a/gui/src/hooks/height.ts b/gui/src/hooks/height.ts index 1b990e047..cdd9d47e3 100644 --- a/gui/src/hooks/height.ts +++ b/gui/src/hooks/height.ts @@ -56,3 +56,8 @@ export function useHeightContext() { } return context; } + +// The headset height is not the full height! This value compensates for the +// offset from the headset height to the user full height +// From Drillis and Contini (1966) +export const EYE_HEIGHT_TO_HEIGHT_RATIO = 0.936; diff --git a/server/core/src/main/java/dev/slimevr/autobone/errors/BodyProportionError.kt b/server/core/src/main/java/dev/slimevr/autobone/errors/BodyProportionError.kt index 71c70a3d9..d5f876969 100644 --- a/server/core/src/main/java/dev/slimevr/autobone/errors/BodyProportionError.kt +++ b/server/core/src/main/java/dev/slimevr/autobone/errors/BodyProportionError.kt @@ -27,10 +27,9 @@ class BodyProportionError : IAutoBoneError { } companion object { - // TODO hip tracker stuff... Hip tracker should be around 3 to 5 - // centimeters. // The headset height is not the full height! This value compensates for the - // offset from the headset height to the user height + // offset from the headset height to the user full height + // From Drillis and Contini (1966) @JvmField var eyeHeightToHeightRatio = 0.936f diff --git a/server/core/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.kt b/server/core/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.kt index db7764a9f..81d5554a8 100644 --- a/server/core/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.kt +++ b/server/core/src/main/java/dev/slimevr/protocol/rpc/RPCHandler.kt @@ -18,6 +18,7 @@ import dev.slimevr.protocol.rpc.setup.RPCUtil.getLocalIp import dev.slimevr.protocol.rpc.status.RPCStatusHandler import dev.slimevr.protocol.rpc.trackingpause.RPCTrackingPause import dev.slimevr.tracking.processor.config.SkeletonConfigOffsets +import dev.slimevr.tracking.trackers.TrackerPosition import dev.slimevr.tracking.trackers.TrackerPosition.Companion.getByBodyPart import dev.slimevr.tracking.trackers.TrackerStatus import dev.slimevr.tracking.trackers.TrackerUtils.getTrackerForSkeleton @@ -490,7 +491,8 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler