diff --git a/ml_bft/FingerSystem.cs b/ml_bft/FingerSystem.cs index 47e190b..32a0a47 100644 --- a/ml_bft/FingerSystem.cs +++ b/ml_bft/FingerSystem.cs @@ -129,7 +129,7 @@ namespace ml_bft OnAvatarSetup(); } - internal void OnIKSystemLateUpdate(HumanPoseHandler p_handler) + internal void OnIKSystemLateUpdate(HumanPoseHandler p_handler, Transform p_hips) { if(m_ready && MetaPort.Instance.isUsingVr && (p_handler != null) && Settings.SkeletalInput) { @@ -188,6 +188,15 @@ namespace ml_bft m_lastValues[37] = m_pose.muscles[(int)MuscleIndex.RightLittle2Stretched]; m_lastValues[38] = m_pose.muscles[(int)MuscleIndex.RightLittle3Stretched]; m_lastValues[39] = m_pose.muscles[(int)MuscleIndex.RightLittleSpread]; + + if(Settings.MechanimFilter && (p_hips != null)) + { + // Yoinked from IKSystem.OnPostSolverUpdateGeneral + Vector3 l_pos = p_hips.position; + Quaternion l_rot = p_hips.rotation; + p_handler.SetHumanPose(ref m_pose); + p_hips.SetPositionAndRotation(l_pos, l_rot); + } } } } diff --git a/ml_bft/HandHandlerVR.cs b/ml_bft/HandHandlerVR.cs index 2b0adec..341fcba 100644 --- a/ml_bft/HandHandlerVR.cs +++ b/ml_bft/HandHandlerVR.cs @@ -238,7 +238,7 @@ namespace ml_bft } if(m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] != null) - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root].rotation = p_base * (m_left ? Quaternion.Euler(0f, -90f, 0f) : Quaternion.Euler(0f, 90f, 0f)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root].rotation = p_base * (m_left ? Quaternion.Euler(0f, -90f, -90f) : Quaternion.Euler(0f, 90f, 90f)); } void OnMotionRangeChange(Settings.MotionRangeType p_mode) diff --git a/ml_bft/Main.cs b/ml_bft/Main.cs index 0c632e6..87b5a6c 100644 --- a/ml_bft/Main.cs +++ b/ml_bft/Main.cs @@ -125,12 +125,12 @@ namespace ml_bft } } - static void OnIKSystemLateUpdate_Postfix(HumanPoseHandler ____humanPoseHandler) => ms_instance?.OnIKSystemLateUpdate(____humanPoseHandler); - void OnIKSystemLateUpdate(HumanPoseHandler p_handler) + static void OnIKSystemLateUpdate_Postfix(HumanPoseHandler ____humanPoseHandler, Transform ____hipTransform) => ms_instance?.OnIKSystemLateUpdate(____humanPoseHandler, ____hipTransform); + void OnIKSystemLateUpdate(HumanPoseHandler p_handler, Transform p_hips) { try { - m_fingerSystem?.OnIKSystemLateUpdate(p_handler); + m_fingerSystem?.OnIKSystemLateUpdate(p_handler, p_hips); } catch(Exception e) { diff --git a/ml_bft/README.md b/ml_bft/README.md index dd00f0b..56e39d3 100644 --- a/ml_bft/README.md +++ b/ml_bft/README.md @@ -10,6 +10,8 @@ Mod that overhauls behaviour of fingers tracking. Available mod's settings in `Settings - Input & Key-Bindings - Better Fingers Tracking`: * **Force SteamVR skeletal input:** forced usage of SteamVR skeletal input (works as long as controllers' driver supplies skeletal pose throught OpenVR interfaces); `false` by default * **Motion range:** fingers tracking motion range/mode/type; `With controller` by default +* **Filter humanoid limits:** Limits fingers rotations to be valid for Unity's Mechanim; `false` by default + * Note: Enabling this option ensures that visual representation of your fingers will be same for you and remote players, but it cancels out additional finger segments rotations that can be better visually in most cases. * **Show hands model:** shows transparent hands model (mostly as debug option); `false` by default # Notes diff --git a/ml_bft/Settings.cs b/ml_bft/Settings.cs index 6da9205..45c1c3d 100644 --- a/ml_bft/Settings.cs +++ b/ml_bft/Settings.cs @@ -15,12 +15,14 @@ namespace ml_bft { SkeletalInput = 0, MotionRange, - ShowHands + ShowHands, + MechanimFilter } public static bool SkeletalInput { get; private set; } = false; public static MotionRangeType MotionRange { get; private set; } = MotionRangeType.WithController; public static bool ShowHands { get; private set; } = false; + public static bool MechanimFilter { get; private set; } = false; static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; @@ -28,6 +30,7 @@ namespace ml_bft public static event Action SkeletalInputChange; public static event Action MotionRangeChange; public static event Action ShowHandsChange; + public static event Action MechanimFilterChange; internal static void Init() { @@ -37,7 +40,8 @@ namespace ml_bft { ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput), ms_category.CreateEntry(ModSetting.MotionRange.ToString(), (int)MotionRange), - ms_category.CreateEntry(ModSetting.ShowHands.ToString(), ShowHands) + ms_category.CreateEntry(ModSetting.ShowHands.ToString(), ShowHands), + ms_category.CreateEntry(ModSetting.MechanimFilter.ToString(), MechanimFilter) }; SkeletalInput = (bool)ms_entries[(int)ModSetting.SkeletalInput].BoxedValue; @@ -89,6 +93,13 @@ namespace ml_bft ShowHandsChange?.Invoke(ShowHands); } break; + + case ModSetting.MechanimFilter: + { + MechanimFilter = bool.Parse(p_value); + MechanimFilterChange?.Invoke(MechanimFilter); + } + break; } ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value); diff --git a/ml_bft/resources/mod_menu.js b/ml_bft/resources/mod_menu.js index 2e78036..a8eb618 100644 --- a/ml_bft/resources/mod_menu.js +++ b/ml_bft/resources/mod_menu.js @@ -20,6 +20,13 @@ +
+
Filter humanoid limits:
+
+
+
+
+
Show hands model:
diff --git a/ml_bft/resources/ovr_fingers.asset b/ml_bft/resources/ovr_fingers.asset index 73cec84..9e52c60 100644 Binary files a/ml_bft/resources/ovr_fingers.asset and b/ml_bft/resources/ovr_fingers.asset differ