added compatibility mode

add compatibility mode that somehow fixes avatars with scuffed armatures and initial poses

gonna look into using a tpose animation
This commit is contained in:
NotAKidoS 2022-12-26 00:26:13 -06:00
parent 0dbe4ed149
commit c71036f74f
3 changed files with 39 additions and 3 deletions

View file

@ -17,6 +17,8 @@ public class DesktopVRIK : MonoBehaviour
public bool Setting_EmulateVRChatHipMovement; public bool Setting_EmulateVRChatHipMovement;
public bool Setting_EmoteVRIK; public bool Setting_EmoteVRIK;
public bool Setting_EmoteLookAtIK; public bool Setting_EmoteLookAtIK;
//fuck
public bool Setting_CompatibilityMode;
void Start() void Start()
{ {

View file

@ -5,12 +5,14 @@ using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
using HarmonyLib; using HarmonyLib;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using UnityEngine;
namespace DesktopVRIK; namespace DesktopVRIK;
[HarmonyPatch] [HarmonyPatch]
internal class HarmonyPatches internal class HarmonyPatches
{ {
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "SetupAvatarGeneral")] [HarmonyPatch(typeof(PlayerSetup), "SetupAvatarGeneral")]
private static void SetupDesktopIKSystem(ref CVRAvatar ____avatarDescriptor) private static void SetupDesktopIKSystem(ref CVRAvatar ____avatarDescriptor)
@ -24,12 +26,42 @@ internal class HarmonyPatches
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(IKSystem), "InitializeAvatar")] [HarmonyPatch(typeof(IKSystem), "InitializeAvatar")]
private static void InitializeDesktopAvatarVRIK(CVRAvatar avatar, ref VRIK ____vrik) private static void InitializeDesktopAvatarVRIK(CVRAvatar avatar, ref VRIK ____vrik, ref HumanPoseHandler ____poseHandler, ref float[] ___HandCalibrationPoseMuscles, ref Vector3 ____referenceRootPosition, ref Quaternion ____referenceRootRotation, ref HumanPose ___humanPose)
{ {
if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled) if (!MetaPort.Instance.isUsingVr && DesktopVRIK.Instance.Setting_Enabled)
{ {
//need IKSystem to see VRIK component for setup //need IKSystem to see VRIK component for setup
if (____vrik == null)
{
____vrik = avatar.gameObject.AddComponent<VRIK>(); ____vrik = avatar.gameObject.AddComponent<VRIK>();
}
//ChilloutVR stuffs that makes sure garbage armatures are supported
//this places heels in the ground... can i just use my own tpose animation
if (DesktopVRIK.Instance.Setting_CompatibilityMode)
{
if (____poseHandler == null)
{
____poseHandler = new HumanPoseHandler(IKSystem.Instance.animator.avatar, IKSystem.Instance.animator.transform);
}
____poseHandler.GetHumanPose(ref ___humanPose);
____referenceRootPosition = IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Hips).position;
____referenceRootRotation = IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Hips).rotation;
for (int i = 0; i < ___HandCalibrationPoseMuscles.Length; i++)
{
IKSystem.Instance.ApplyMuscleValue((MuscleIndex)i, ___HandCalibrationPoseMuscles[i], ref ___humanPose.muscles);
}
____poseHandler.SetHumanPose(ref ___humanPose);
if (IKSystem.Instance.applyOriginalHipPosition)
{
IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Hips).position = ____referenceRootPosition;
}
if (IKSystem.Instance.applyOriginalHipRotation)
{
IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Hips).rotation = ____referenceRootRotation;
}
}
//now I calibrate DesktopVRIK //now I calibrate DesktopVRIK
DesktopVRIK.Instance.CalibrateDesktopVRIK(avatar); DesktopVRIK.Instance.CalibrateDesktopVRIK(avatar);
} }

View file

@ -7,7 +7,7 @@ public class DesktopVRIKMod : MelonMod
{ {
internal const string SettingsCategory = "DesktopVRIK"; internal const string SettingsCategory = "DesktopVRIK";
private static MelonPreferences_Category m_categoryDesktopVRIK; private static MelonPreferences_Category m_categoryDesktopVRIK;
private static MelonPreferences_Entry<bool> m_entryEnabled, m_entryEmulateHipMovement, m_entryEmoteVRIK, m_entryEmoteLookAtIK; private static MelonPreferences_Entry<bool> m_entryEnabled, m_entryEmulateHipMovement, m_entryEmoteVRIK, m_entryEmoteLookAtIK, m_entryCompatibilityMode;
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {
m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory); m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory);
@ -15,6 +15,7 @@ public class DesktopVRIKMod : MelonMod
m_entryEmulateHipMovement = m_categoryDesktopVRIK.CreateEntry<bool>("Emulate Hip Movement", true, description: "Emulates VRChat-like hip movement when moving head up/down on desktop."); m_entryEmulateHipMovement = m_categoryDesktopVRIK.CreateEntry<bool>("Emulate Hip Movement", true, description: "Emulates VRChat-like hip movement when moving head up/down on desktop.");
m_entryEmoteVRIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote VRIK", true, description: "Disable VRIK while emoting. Only disable if you are ok with looking dumb."); m_entryEmoteVRIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote VRIK", true, description: "Disable VRIK while emoting. Only disable if you are ok with looking dumb.");
m_entryEmoteLookAtIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote LookAtIK", true, description: "Disable LookAtIK while emoting. This setting doesn't really matter, as LookAtIK isn't networked while doing an emote."); m_entryEmoteLookAtIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote LookAtIK", true, description: "Disable LookAtIK while emoting. This setting doesn't really matter, as LookAtIK isn't networked while doing an emote.");
m_entryCompatibilityMode = m_categoryDesktopVRIK.CreateEntry<bool>("Compatibility Mode", false, description: "Runs finger muscle calibration- which somehow makes bad armatures work better but also pushes heels into the ground."); ;
m_categoryDesktopVRIK.SaveToFile(false); m_categoryDesktopVRIK.SaveToFile(false);
foreach (var setting in m_categoryDesktopVRIK.Entries) foreach (var setting in m_categoryDesktopVRIK.Entries)
@ -42,6 +43,7 @@ public class DesktopVRIKMod : MelonMod
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value; DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value;
DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value; DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value; DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
DesktopVRIK.Instance.Setting_CompatibilityMode = m_entryCompatibilityMode.Value;
} }
private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings(); private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();