Skip to content

Commit

Permalink
Add toggle for using position information
Browse files Browse the repository at this point in the history
  • Loading branch information
Stermere committed Apr 24, 2024
1 parent 8bdb6c3 commit b2ad724
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 4 deletions.
3 changes: 3 additions & 0 deletions gui/public/i18n/en/translation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,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
Expand Down
28 changes: 28 additions & 0 deletions gui/src/components/settings/pages/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface SettingsForm {
toeSnap: boolean;
footPlant: boolean;
selfLocalization: boolean;
usePosition: boolean;
};
ratios: {
imputeWaistFromChestHip: number;
Expand Down Expand Up @@ -113,6 +114,7 @@ const defaultValues = {
toeSnap: false,
footPlant: true,
selfLocalization: false,
usePosition: true,
},
ratios: {
imputeWaistFromChestHip: 0.3,
Expand Down Expand Up @@ -198,6 +200,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;
}

Expand Down Expand Up @@ -781,6 +784,31 @@ export function GeneralSettings() {
/>
</div>


<div className="flex flex-col pt-2 pb-3">
<Typography bold>
{l10n.getString('settings-general-fk_settings-ik')}
</Typography>
<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-ik-use_position-description'
)}
</Typography>
</div>
<div className="grid sm:grid-cols-1 pb-3">
<CheckBox
variant="toggle"
outlined
control={control}
name="toggles.usePosition"
label={l10n.getString(
'settings-general-fk_settings-ik-use_position'
)}
/>
</div>



<Typography color="secondary">
{l10n.getString(
'settings-general-fk_settings-arm_fk-reset_mode-description'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, SkeletonConfigToggles> byStringVal = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ class HumanSkeleton(
SkeletonConfigToggles.FOOT_PLANT -> legTweaks.footPlantEnabled = newValue

SkeletonConfigToggles.SELF_LOCALIZATION -> localizer.setEnabled(newValue)

SkeletonConfigToggles.USE_POSITION -> ikSolver.enabled = newValue
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class IKSolver(private val root: Bone) {
const val TOLERANCE_STEP = 2f
}

var enabled = true
private var chainList = mutableListOf<IKChain>()
private var rootChain: IKChain? = null
private var needsReset = false
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b2ad724

Please sign in to comment.