mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
Add testing local NetIK pass.
i wanted to compare proper lowerleg fix vs funni netik pass fix.
This commit is contained in:
parent
a3cee41021
commit
e070d86894
2 changed files with 37 additions and 0 deletions
|
@ -6,6 +6,7 @@ using ABI_RC.Systems.MovementSystem;
|
|||
using HarmonyLib;
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace NAK.IKFixes.HarmonyPatches;
|
||||
|
||||
|
@ -263,6 +264,38 @@ internal static class IKSystemPatches
|
|||
__instance.applyOriginalHipPosition = true;
|
||||
__instance.applyOriginalHipRotation = true;
|
||||
}
|
||||
|
||||
static HumanPose _enforcementPose;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(IKSystem), nameof(IKSystem.InitializeHalfBodyIK))]
|
||||
static void Prefix_IKSystem_InitializeHalfBodyIK(IKSystem __instance)
|
||||
{
|
||||
if (IKSystem._vrik != null)
|
||||
{
|
||||
UnityAction onPostSolverUpdate = null;
|
||||
onPostSolverUpdate = () =>
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
IKSystem._vrik.onPostSolverUpdate.AddListener(onPostSolverUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class VRIKPatches
|
||||
|
|
|
@ -28,6 +28,10 @@ public class IKFixes : MelonMod
|
|||
public static readonly MelonPreferences_Entry<bool> 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<bool> EntryNetIKPass =
|
||||
Category.CreateEntry("Network IK Pass", true, description: "Should NetIK pass be run?");
|
||||
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
ApplyPatches(typeof(HarmonyPatches.VRIKPatches));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue