Better T-posed bind hierarchy

Fingers rotation limits
Update README.md
This commit is contained in:
SDraw 2024-03-30 16:12:32 +00:00 committed by SDraw
parent 55d7aa465a
commit 5bec2fcdb1
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
7 changed files with 36 additions and 7 deletions

View file

@ -129,7 +129,7 @@ namespace ml_bft
OnAvatarSetup(); 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) 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[37] = m_pose.muscles[(int)MuscleIndex.RightLittle2Stretched];
m_lastValues[38] = m_pose.muscles[(int)MuscleIndex.RightLittle3Stretched]; m_lastValues[38] = m_pose.muscles[(int)MuscleIndex.RightLittle3Stretched];
m_lastValues[39] = m_pose.muscles[(int)MuscleIndex.RightLittleSpread]; 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);
}
} }
} }
} }

View file

@ -238,7 +238,7 @@ namespace ml_bft
} }
if(m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] != null) 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) void OnMotionRangeChange(Settings.MotionRangeType p_mode)

View file

@ -125,12 +125,12 @@ namespace ml_bft
} }
} }
static void OnIKSystemLateUpdate_Postfix(HumanPoseHandler ____humanPoseHandler) => ms_instance?.OnIKSystemLateUpdate(____humanPoseHandler); static void OnIKSystemLateUpdate_Postfix(HumanPoseHandler ____humanPoseHandler, Transform ____hipTransform) => ms_instance?.OnIKSystemLateUpdate(____humanPoseHandler, ____hipTransform);
void OnIKSystemLateUpdate(HumanPoseHandler p_handler) void OnIKSystemLateUpdate(HumanPoseHandler p_handler, Transform p_hips)
{ {
try try
{ {
m_fingerSystem?.OnIKSystemLateUpdate(p_handler); m_fingerSystem?.OnIKSystemLateUpdate(p_handler, p_hips);
} }
catch(Exception e) catch(Exception e)
{ {

View file

@ -10,6 +10,8 @@ Mod that overhauls behaviour of fingers tracking.
Available mod's settings in `Settings - Input & Key-Bindings - Better 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 * **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 * **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 * **Show hands model:** shows transparent hands model (mostly as debug option); `false` by default
# Notes # Notes

View file

@ -15,12 +15,14 @@ namespace ml_bft
{ {
SkeletalInput = 0, SkeletalInput = 0,
MotionRange, MotionRange,
ShowHands ShowHands,
MechanimFilter
} }
public static bool SkeletalInput { get; private set; } = false; public static bool SkeletalInput { get; private set; } = false;
public static MotionRangeType MotionRange { get; private set; } = MotionRangeType.WithController; public static MotionRangeType MotionRange { get; private set; } = MotionRangeType.WithController;
public static bool ShowHands { get; private set; } = false; public static bool ShowHands { get; private set; } = false;
public static bool MechanimFilter { get; private set; } = false;
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
@ -28,6 +30,7 @@ namespace ml_bft
public static event Action<bool> SkeletalInputChange; public static event Action<bool> SkeletalInputChange;
public static event Action<MotionRangeType> MotionRangeChange; public static event Action<MotionRangeType> MotionRangeChange;
public static event Action<bool> ShowHandsChange; public static event Action<bool> ShowHandsChange;
public static event Action<bool> MechanimFilterChange;
internal static void Init() internal static void Init()
{ {
@ -37,7 +40,8 @@ namespace ml_bft
{ {
ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput), ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput),
ms_category.CreateEntry(ModSetting.MotionRange.ToString(), (int)MotionRange), 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; SkeletalInput = (bool)ms_entries[(int)ModSetting.SkeletalInput].BoxedValue;
@ -89,6 +93,13 @@ namespace ml_bft
ShowHandsChange?.Invoke(ShowHands); ShowHandsChange?.Invoke(ShowHands);
} }
break; break;
case ModSetting.MechanimFilter:
{
MechanimFilter = bool.Parse(p_value);
MechanimFilterChange?.Invoke(MechanimFilter);
}
break;
} }
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value); ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);

View file

@ -20,6 +20,13 @@
</div> </div>
</div> </div>
<div class ="row-wrapper">
<div class ="option-caption">Filter humanoid limits: </div>
<div class ="option-input">
<div id="MechanimFilter" class ="inp_toggle no-scroll" data-current="false"></div>
</div>
</div>
<div class ="row-wrapper"> <div class ="row-wrapper">
<div class ="option-caption">Show hands model: </div> <div class ="option-caption">Show hands model: </div>
<div class ="option-input"> <div class ="option-input">

Binary file not shown.