From a8bf0ef7f95cfb519f571ef805ad58e0bd75a7a9 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Fri, 19 May 2023 04:30:36 -0500 Subject: [PATCH] [IKFixes] NetIKPass test --- IKFixes/HarmonyPatches.cs | 39 +++++++-------------------------------- IKFixes/Main.cs | 5 +---- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/IKFixes/HarmonyPatches.cs b/IKFixes/HarmonyPatches.cs index ce04070..c112dac 100644 --- a/IKFixes/HarmonyPatches.cs +++ b/IKFixes/HarmonyPatches.cs @@ -55,29 +55,12 @@ internal static class BodySystemPatches // Apply additional offset based on the assigned role Vector3 additionalOffset = IKSystem.vrik.references.root.forward * offsetDistance; - - if (IKFixes.EntryAltElbowDirection.Value) - { - switch (trackingPoint.assignedRole) - { - case TrackingPoint.TrackingRole.LeftElbow: - additionalOffset += IKSystem.vrik.references.root.up * -0.15f; - break; - case TrackingPoint.TrackingRole.RightElbow: - additionalOffset += IKSystem.vrik.references.root.up * -0.15f; - break; - default: - break; - } - } - trackingPoint.offsetTransform.position += additionalOffset; // Game originally sets them to about half a meter out, which fucks with slime tracker users and // makes the bendGoals less responsive/less accurate. //Funny thing is that IKTweaks specifically made this an option, which should be added to both CVR & Standable for the same reason. - /// Elbow / knee / chest bend goal offset - controls how far bend goal targets will be away from the actual joint. /// Lower values should produce better precision with bent joint, higher values - better stability with straight joint. /// Sensible range of values is between 0 and 1. @@ -265,8 +248,6 @@ internal static class IKSystemPatches __instance.applyOriginalHipRotation = true; } - static HumanPose _enforcementPose; - [HarmonyPrefix] [HarmonyPatch(typeof(IKSystem), nameof(IKSystem.InitializeHalfBodyIK))] static void Prefix_IKSystem_InitializeHalfBodyIK(IKSystem __instance) @@ -278,19 +259,13 @@ internal static class IKSystemPatches { if (!IKFixes.EntryNetIKPass.Value) return; - // This will enforce locally what we see over the network - if (__instance._poseHandler == null) - __instance._poseHandler = new HumanPoseHandler(__instance.animator.avatar, __instance.animator.transform); - - Transform hipTransform = __instance.animator.GetBoneTransform(HumanBodyBones.Hips); - Vector3 hipPosition = hipTransform.position; - Quaternion hipRotation = hipTransform.rotation; - - __instance._poseHandler.GetHumanPose(ref _enforcementPose); - __instance._poseHandler.SetHumanPose(ref _enforcementPose); - - hipTransform.position = hipPosition; - hipTransform.rotation = hipRotation; + Transform hips = __instance.animator.GetBoneTransform(HumanBodyBones.Hips); + __instance._referenceRootPosition = hips.position; + __instance._referenceRootRotation = hips.rotation; + __instance._poseHandler.GetHumanPose(ref __instance.humanPose); + __instance._poseHandler.SetHumanPose(ref __instance.humanPose); + hips.position = __instance._referenceRootPosition; + hips.rotation = __instance._referenceRootRotation; }; IKSystem._vrik.onPostSolverUpdate.AddListener(onPostSolverUpdate); diff --git a/IKFixes/Main.cs b/IKFixes/Main.cs index 5e8388e..2584934 100644 --- a/IKFixes/Main.cs +++ b/IKFixes/Main.cs @@ -25,11 +25,8 @@ public class IKFixes : MelonMod public static readonly MelonPreferences_Entry EntryAssignRemainingTrackers = Category.CreateEntry("Assign Remaining Trackers", true, description: "Should the game calibrate any additional trackers as secondary trackers for already-tracked points?"); - public static readonly MelonPreferences_Entry EntryAltElbowDirection = - Category.CreateEntry("Alt Elbow Direction", true, description: "Should bodyRotation be reset to identity when muscleupdate happens? Should fix chest tracking & tpose while running."); - public static readonly MelonPreferences_Entry EntryNetIKPass = - Category.CreateEntry("Network IK Pass", true, description: "Should NetIK pass be run?"); + Category.CreateEntry("Network IK Pass", true, description: "Should NetIK pass be applied? This fixes a bunch of small rotation errors after VRIK is run."); public override void OnInitializeMelon() {