From 1103caa730fe2e77a2fd0747b7340db3afa8972f Mon Sep 17 00:00:00 2001 From: Collin Kees Date: Tue, 23 Apr 2024 17:29:53 -0700 Subject: [PATCH] Add toggle for using position information --- gui/public/i18n/en/translation.ftl | 3 ++ .../settings/pages/GeneralSettings.tsx | 28 +++++++++++++++++++ .../rpc/settings/RPCSettingsBuilder.java | 3 +- .../rpc/settings/RPCSettingsHandler.kt | 1 + .../config/SkeletonConfigToggles.java | 3 +- .../processor/skeleton/HumanSkeleton.kt | 2 ++ .../tracking/processor/skeleton/IKSolver.kt | 3 +- 7 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index ce4026ce68..c540cbfda9 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -352,6 +352,9 @@ settings-general-fk_settings-leg_tweak-foot_plant-description = Foot-plant rotat settings-general-fk_settings-leg_fk = Leg tracking settings-general-fk_settings-leg_fk-reset_mounting_feet-description = Enable feet Mounting Reset by tiptoeing. settings-general-fk_settings-leg_fk-reset_mounting_feet = Feet Mounting Reset +settings-general-fk_settings-ik = Position data +settings-general-fk_settings-ik-use_position = Use Position data +settings-general-fk_settings-ik-use_position-description = Enables the use of position data from trackers that provide it. When enabling this make sure to full reset and recalibrate in game. settings-general-fk_settings-arm_fk = Arm tracking settings-general-fk_settings-arm_fk-description = Force arms to be tracked from the headset (HMD) even if positional hand data is available. settings-general-fk_settings-arm_fk-force_arms = Force arms from HMD diff --git a/gui/src/components/settings/pages/GeneralSettings.tsx b/gui/src/components/settings/pages/GeneralSettings.tsx index ebc9c3057c..ee46927870 100644 --- a/gui/src/components/settings/pages/GeneralSettings.tsx +++ b/gui/src/components/settings/pages/GeneralSettings.tsx @@ -66,6 +66,7 @@ interface SettingsForm { toeSnap: boolean; footPlant: boolean; selfLocalization: boolean; + usePosition: boolean; }; ratios: { imputeWaistFromChestHip: number; @@ -124,6 +125,7 @@ const defaultValues: SettingsForm = { toeSnap: false, footPlant: true, selfLocalization: false, + usePosition: true, }, ratios: { imputeWaistFromChestHip: 0.3, @@ -229,6 +231,7 @@ export function GeneralSettings() { toggles.toeSnap = values.toggles.toeSnap; toggles.footPlant = values.toggles.footPlant; toggles.selfLocalization = values.toggles.selfLocalization; + toggles.usePosition = values.toggles.usePosition; modelSettings.toggles = toggles; } @@ -900,6 +903,31 @@ export function GeneralSettings() { /> + +
+ + {l10n.getString('settings-general-fk_settings-ik')} + + + {l10n.getString( + 'settings-general-fk_settings-ik-use_position-description' + )} + +
+
+ +
+ + + {l10n.getString( 'settings-general-fk_settings-arm_fk-reset_mode-description' diff --git a/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java b/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java index eb5e28f475..ea27ae146e 100644 --- a/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java +++ b/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsBuilder.java @@ -188,7 +188,8 @@ public static int createModelSettings( humanPoseManager.getToggle(SkeletonConfigToggles.VIVE_EMULATION), humanPoseManager.getToggle(SkeletonConfigToggles.TOE_SNAP), humanPoseManager.getToggle(SkeletonConfigToggles.FOOT_PLANT), - humanPoseManager.getToggle(SkeletonConfigToggles.SELF_LOCALIZATION) + humanPoseManager.getToggle(SkeletonConfigToggles.SELF_LOCALIZATION), + humanPoseManager.getToggle(SkeletonConfigToggles.USE_POSITION) ); int ratiosOffset = ModelRatios .createModelRatios( diff --git a/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.kt b/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.kt index 8ca8d79dba..ede94ecc19 100644 --- a/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.kt +++ b/server/core/src/main/java/dev/slimevr/protocol/rpc/settings/RPCSettingsHandler.kt @@ -251,6 +251,7 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) { hpm.setToggle(SkeletonConfigToggles.TOE_SNAP, toggles.toeSnap()) hpm.setToggle(SkeletonConfigToggles.FOOT_PLANT, toggles.footPlant()) hpm.setToggle(SkeletonConfigToggles.SELF_LOCALIZATION, toggles.selfLocalization()) + hpm.setToggle(SkeletonConfigToggles.USE_POSITION, toggles.usePosition()) } if (ratios != null) { diff --git a/server/core/src/main/java/dev/slimevr/tracking/processor/config/SkeletonConfigToggles.java b/server/core/src/main/java/dev/slimevr/tracking/processor/config/SkeletonConfigToggles.java index cffec046b0..ac008acf59 100644 --- a/server/core/src/main/java/dev/slimevr/tracking/processor/config/SkeletonConfigToggles.java +++ b/server/core/src/main/java/dev/slimevr/tracking/processor/config/SkeletonConfigToggles.java @@ -15,7 +15,8 @@ public enum SkeletonConfigToggles { VIVE_EMULATION(7, "Vive emulation", "viveEmulation", false), TOE_SNAP(8, "Toe Snap", "toeSnap", false), FOOT_PLANT(9, "Foot Plant", "footPlant", true), - SELF_LOCALIZATION(10, "Self Localization", "selfLocalization", false),; + SELF_LOCALIZATION(10, "Self Localization", "selfLocalization", false), + USE_POSITION(11, "Use Position", "usePosition", true),; public static final SkeletonConfigToggles[] values = values(); private static final Map byStringVal = new HashMap<>(); diff --git a/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/HumanSkeleton.kt b/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/HumanSkeleton.kt index 863598dd99..2a58dc74fc 100644 --- a/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/HumanSkeleton.kt +++ b/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/HumanSkeleton.kt @@ -869,6 +869,8 @@ class HumanSkeleton( SkeletonConfigToggles.FOOT_PLANT -> legTweaks.footPlantEnabled = newValue SkeletonConfigToggles.SELF_LOCALIZATION -> localizer.setEnabled(newValue) + + SkeletonConfigToggles.USE_POSITION -> ikSolver.enabled = newValue } } diff --git a/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/IKSolver.kt b/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/IKSolver.kt index b93b78d419..f9c98969e6 100644 --- a/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/IKSolver.kt +++ b/server/core/src/main/java/dev/slimevr/tracking/processor/skeleton/IKSolver.kt @@ -19,6 +19,7 @@ class IKSolver(private val root: Bone) { const val TOLERANCE_STEP = 2f } + var enabled = true private var chainList = mutableListOf() private var rootChain: IKChain? = null private var needsReset = false @@ -216,7 +217,7 @@ class IKSolver(private val root: Bone) { } fun solve() { - if (rootChain == null) return + if (rootChain == null || !enabled) return var solved: Boolean if (needsReset) {