From d1547e2e92f07443565617669932dbab463e5ab3 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Sat, 23 Sep 2023 19:36:06 -0500 Subject: [PATCH] [IKFixes] Movement Parent IK handling now respects new orientation mode. --- IKFixes/HarmonyPatches.cs | 12 +++++++----- IKFixes/format.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/IKFixes/HarmonyPatches.cs b/IKFixes/HarmonyPatches.cs index 5640eb9..f65c2a5 100644 --- a/IKFixes/HarmonyPatches.cs +++ b/IKFixes/HarmonyPatches.cs @@ -296,13 +296,15 @@ internal static class PlayerSetupPatches currentPosition.y = IKSystem.vrik.transform.position.y; // set pivot to floor Quaternion currentRotation = Quaternion.Euler(0f, currentParent.transform.rotation.eulerAngles.y, 0f); - // Convert to delta position (how much changed since last frame) - Vector3 deltaPosition = currentPosition - lastMovementPosition; - Quaternion deltaRotation = Quaternion.Inverse(lastMovementRotation) * currentRotation; - // Prevent targeting previous movement parent - if (lastMovementParent == currentParent || lastMovementParent == null) + if (lastMovementParent != null && lastMovementParent == currentParent) { + Vector3 deltaPosition = currentPosition - lastMovementPosition; + Quaternion deltaRotation = Quaternion.identity; + + if (currentParent.orientationMode == CVRMovementParent.OrientationMode.RotateWithParent) + deltaRotation = Quaternion.Inverse(lastMovementRotation) * currentRotation; + IKSystem.vrik.solver.AddPlatformMotion(deltaPosition, deltaRotation, currentPosition); BodySystemPatches.OffsetSimulatedRootAngle(deltaRotation.eulerAngles.y); } diff --git a/IKFixes/format.json b/IKFixes/format.json index fb824c0..65db988 100644 --- a/IKFixes/format.json +++ b/IKFixes/format.json @@ -19,6 +19,6 @@ ], "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r21/IKFixes.dll", "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/IKFixes/", - "changelog": "- Updates for 2023r172\n- Removed unneeded settings (IKPose & NetIKPass).\n- Fixed halfbody fake root angle option.\n- Added Reset Settings UIExpansionKit button.\n- Fixed issue with MelonPref identifiers containing illegal characters.", + "changelog": "- Updates for 2023r172\n- Removed unneeded settings (IKPose & NetIKPass).\n- Fixed halfbody fake root angle option.\n- Added Reset Settings UIExpansionKit button.\n- Fixed issue with MelonPref identifiers containing illegal characters.\n- Movement Parent IK handling now respects new orientation mode.", "embedcolor": "f46e49" } \ No newline at end of file