diff --git a/ml_amt/Main.cs b/ml_amt/Main.cs index ff51ec3..57e99e2 100644 --- a/ml_amt/Main.cs +++ b/ml_amt/Main.cs @@ -1,6 +1,5 @@ using ABI_RC.Core.Player; using ABI_RC.Systems.IK; -using ABI_RC.Systems.IK.SubSystems; using System; using System.Collections; using System.Reflection; @@ -98,7 +97,7 @@ namespace ml_amt if(m_localTweaker != null) m_localTweaker.OnAvatarReinitialize(); } - catch(System.Exception e) + catch(Exception e) { MelonLoader.MelonLogger.Error(e); } diff --git a/ml_amt/MotionTweaker.cs b/ml_amt/MotionTweaker.cs index 2ac9cee..c4469e8 100644 --- a/ml_amt/MotionTweaker.cs +++ b/ml_amt/MotionTweaker.cs @@ -1,5 +1,4 @@ using ABI_RC.Core.Player; -using ABI_RC.Systems.IK; using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.Movement; using RootMotion.FinalIK; @@ -125,6 +124,8 @@ namespace ml_amt internal void OnSetupAvatar() { + Utils.SetAvatarTPose(); + m_vrIk = PlayerSetup.Instance._avatar.GetComponent(); m_locomotionLayer = PlayerSetup.Instance._animator.GetLayerIndex("Locomotion/Emotes"); m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y); @@ -179,6 +180,8 @@ namespace ml_amt internal void OnAvatarReinitialize() { // Old VRIK is destroyed by game + Utils.SetAvatarTPose(); + m_vrIk = PlayerSetup.Instance._animator.GetComponent(); if(m_vrIk != null) { @@ -242,25 +245,25 @@ namespace ml_amt } // Settings - internal void SetCrouchLimit(float p_value) + void SetCrouchLimit(float p_value) { if(m_ikLimits == null) BetterBetterCharacterController.Instance.avatarCrouchLimit = Mathf.Clamp01(p_value); } - internal void SetProneLimit(float p_value) + void SetProneLimit(float p_value) { if(m_ikLimits == null) BetterBetterCharacterController.Instance.avatarProneLimit = Mathf.Clamp01(p_value); } - internal void SetIKOverrideFly(bool p_state) + void SetIKOverrideFly(bool p_state) { m_ikOverrideFly = p_state; } - internal void SetIKOverrideJump(bool p_state) + void SetIKOverrideJump(bool p_state) { m_ikOverrideJump = p_state; } - internal void SetDetectEmotes(bool p_state) + void SetDetectEmotes(bool p_state) { m_detectEmotes = p_state; } diff --git a/ml_amt/Settings.cs b/ml_amt/Settings.cs index 0253865..b4c3404 100644 --- a/ml_amt/Settings.cs +++ b/ml_amt/Settings.cs @@ -26,12 +26,12 @@ namespace ml_amt static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action CrouchLimitChange; - static public event Action ProneLimitChange; - static public event Action IKOverrideFlyChange; - static public event Action IKOverrideJumpChange; - static public event Action DetectEmotesChange; - static public event Action MassCenterChange; + public static event Action CrouchLimitChange; + public static event Action ProneLimitChange; + public static event Action IKOverrideFlyChange; + public static event Action IKOverrideJumpChange; + public static event Action DetectEmotesChange; + public static event Action MassCenterChange; internal static void Init() { diff --git a/ml_amt/Utils.cs b/ml_amt/Utils.cs index e9aca84..2e892da 100644 --- a/ml_amt/Utils.cs +++ b/ml_amt/Utils.cs @@ -1,6 +1,8 @@ using ABI.CCK.Components; +using ABI_RC.Core.Player; using ABI_RC.Core.Savior; using ABI_RC.Core.UI; +using ABI_RC.Systems.IK; using RootMotion.FinalIK; using System.Reflection; using UnityEngine; @@ -30,7 +32,14 @@ namespace ml_amt return l_result; } - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + + public static void SetAvatarTPose() + { + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + } // Engine extensions public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) diff --git a/ml_asl/Settings.cs b/ml_asl/Settings.cs index 251d8ae..52ba124 100644 --- a/ml_asl/Settings.cs +++ b/ml_asl/Settings.cs @@ -16,7 +16,7 @@ namespace ml_asl static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action EnabledChange; + public static event Action EnabledChange; internal static void Init() { diff --git a/ml_asl/Utils.cs b/ml_asl/Utils.cs index 2266e47..fe7a1a8 100644 --- a/ml_asl/Utils.cs +++ b/ml_asl/Utils.cs @@ -7,6 +7,6 @@ namespace ml_asl { static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); } } diff --git a/ml_bft/FingerSystem.cs b/ml_bft/FingerSystem.cs index 4b9d5b0..47e190b 100644 --- a/ml_bft/FingerSystem.cs +++ b/ml_bft/FingerSystem.cs @@ -70,9 +70,7 @@ namespace ml_bft { if(PlayerSetup.Instance._animator.isHuman) { - IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); - PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; - PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + Utils.SetAvatarTPose(); InputHandler.Instance?.Rebind(PlayerSetup.Instance.transform.rotation); m_leftHandOffset.m_source = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); @@ -135,8 +133,6 @@ namespace ml_bft { if(m_ready && MetaPort.Instance.isUsingVr && (p_handler != null) && Settings.SkeletalInput) { - // Virtually allign controllers wrist bone to avatar hands with offset and apply global rotation to avatar finger bones with individial offset - // This is done to apply rotation changes from controller bones to avatar finger bones as in local space if(CVRInputManager.Instance._leftController != ABI_RC.Systems.InputManagement.XR.eXRControllerType.None) { Quaternion l_turnBack = (m_leftHandOffset.m_source.rotation * m_leftHandOffset.m_offset) * Quaternion.Inverse(m_leftHandOffset.m_target.rotation); @@ -151,7 +147,6 @@ namespace ml_bft l_offset.m_target.rotation = l_turnBack * (l_offset.m_source.rotation * l_offset.m_offset); } - // No matter if hands are tracked, fill muscles values p_handler.GetHumanPose(ref m_pose); m_lastValues[0] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched]; m_lastValues[1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched]; diff --git a/ml_bft/HandHandlerOVR.cs b/ml_bft/HandHandlerVR.cs similarity index 87% rename from ml_bft/HandHandlerOVR.cs rename to ml_bft/HandHandlerVR.cs index d0fa6f0..2b0adec 100644 --- a/ml_bft/HandHandlerOVR.cs +++ b/ml_bft/HandHandlerVR.cs @@ -3,14 +3,14 @@ using Valve.VR; namespace ml_bft { - class HandHandlerOVR : HandHandler + class HandHandlerVR : HandHandler { // 31 bones in each hand, get index at Valve.VR.SteamVR_Skeleton_JointIndexes or SteamVR_Skeleton_JointIndexEnum const int c_fingerBonesCount = (int)SteamVR_Skeleton_JointIndexEnum.pinkyAux + 1; SteamVR_Action_Skeleton m_skeletonAction; - public HandHandlerOVR(Transform p_root, bool p_left) : base(p_left) + public HandHandlerVR(Transform p_root, bool p_left) : base(p_left) { for(int i = 0; i < c_fingerBonesCount; i++) { @@ -20,7 +20,7 @@ namespace ml_bft // Fill finger transforms m_prefabRoot = AssetsHandler.GetAsset(string.Format("assets/steamvr/models/[openvr] {0}.prefab", m_left ? "left" : "right")).transform; - m_prefabRoot.name = "[FingersTracking_OVR]"; + m_prefabRoot.name = "[FingersTracking_VR]"; m_prefabRoot.parent = p_root; m_prefabRoot.localPosition = Vector3.zero; m_prefabRoot.localRotation = Quaternion.identity; @@ -28,42 +28,43 @@ namespace ml_bft m_prefabRoot.GetComponentsInChildren(true, m_renderers); // Ah yes, the stupid code + char l_side = (m_left ? 'l' : 'r'); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] = m_prefabRoot.Find("Root"); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.wrist] = m_prefabRoot.Find(string.Format("Root/wrist_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}/finger_thumb_{0}_end", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.wrist] = m_prefabRoot.Find(string.Format("Root/wrist_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}/finger_thumb_{0}_end", l_side)); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}/finger_index_{0}_end", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}/finger_index_{0}_end", l_side)); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}/finger_middle_{0}_end", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}/finger_middle_{0}_end", l_side)); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}/finger_ring_{0}_end", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}/finger_ring_{0}_end", l_side)); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}/finger_pinky_{0}_end", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}/finger_pinky_{0}_end", l_side)); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbAux] = m_prefabRoot.Find(string.Format("Root/finger_thumb_{0}_aux", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexAux] = m_prefabRoot.Find(string.Format("Root/finger_index_{0}_aux", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleAux] = m_prefabRoot.Find(string.Format("Root/finger_middle_{0}_aux", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringAux] = m_prefabRoot.Find(string.Format("Root/finger_ring_{0}_aux", m_left ? 'l' : 'r')); - m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyAux] = m_prefabRoot.Find(string.Format("Root/finger_pinky_{0}_aux", m_left ? 'l' : 'r')); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbAux] = m_prefabRoot.Find(string.Format("Root/finger_thumb_{0}_aux", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexAux] = m_prefabRoot.Find(string.Format("Root/finger_index_{0}_aux", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleAux] = m_prefabRoot.Find(string.Format("Root/finger_middle_{0}_aux", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringAux] = m_prefabRoot.Find(string.Format("Root/finger_ring_{0}_aux", l_side)); + m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyAux] = m_prefabRoot.Find(string.Format("Root/finger_pinky_{0}_aux", l_side)); // Remember local rotations for(int i = 0; i < c_fingerBonesCount; i++) @@ -75,6 +76,9 @@ namespace ml_bft m_skeletonAction = SteamVR_Input.GetAction(p_left ? "SkeletonLeftHand" : "SkeletonRightHand"); base.OnShowHandsChange(Settings.ShowHands); + OnMotionRangeChange(Settings.MotionRange); + + Settings.MotionRangeChange += this.OnMotionRangeChange; } public override void Cleanup() @@ -82,6 +86,8 @@ namespace ml_bft base.Cleanup(); m_skeletonAction = null; + + Settings.MotionRangeChange -= this.OnMotionRangeChange; } public override void Update() @@ -234,5 +240,18 @@ namespace ml_bft 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)); } + + void OnMotionRangeChange(Settings.MotionRangeType p_mode) + { + switch(p_mode) + { + case Settings.MotionRangeType.WithController: + m_skeletonAction?.SetRangeOfMotion(EVRSkeletalMotionRange.WithController); + break; + case Settings.MotionRangeType.WithoutController: + m_skeletonAction?.SetRangeOfMotion(EVRSkeletalMotionRange.WithoutController); + break; + } + } } } diff --git a/ml_bft/HandHandlerXR.cs b/ml_bft/HandHandlerXR.cs index 00f72e6..1ac278c 100644 --- a/ml_bft/HandHandlerXR.cs +++ b/ml_bft/HandHandlerXR.cs @@ -1,6 +1,7 @@ using UnityEngine; using UnityEngine.XR.OpenXR; using UnityEngine.XR.Hands; +using UnityEngine.XR; namespace ml_bft { @@ -26,36 +27,37 @@ namespace ml_bft m_prefabRoot.GetComponentsInChildren(true, m_renderers); // Ah yes, the stupid code - m_bones[(int)XRHandJointID.Wrist - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.Palm - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_Palm", m_left ? 'L' : 'R')); + char l_side = (m_left ? 'L' : 'R'); + m_bones[(int)XRHandJointID.Wrist - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist", l_side)); + m_bones[(int)XRHandJointID.Palm - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_Palm", l_side)); - m_bones[(int)XRHandJointID.ThumbMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.ThumbProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.ThumbDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.ThumbTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal/{0}_ThumbTip", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.IndexMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.IndexProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.IndexIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.IndexDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.IndexTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal/{0}_IndexTip", m_left ? 'L' : 'R')); + m_bones[(int)XRHandJointID.ThumbMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal", l_side)); + m_bones[(int)XRHandJointID.ThumbProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal", l_side)); + m_bones[(int)XRHandJointID.ThumbDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal", l_side)); + m_bones[(int)XRHandJointID.ThumbTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal/{0}_ThumbTip", l_side)); + m_bones[(int)XRHandJointID.IndexMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal", l_side)); + m_bones[(int)XRHandJointID.IndexProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal", l_side)); + m_bones[(int)XRHandJointID.IndexIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate", l_side)); + m_bones[(int)XRHandJointID.IndexDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal", l_side)); + m_bones[(int)XRHandJointID.IndexTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal/{0}_IndexTip", l_side)); - m_bones[(int)XRHandJointID.MiddleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.MiddleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.MiddleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.MiddleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.MiddleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal/{0}_MiddleTip", m_left ? 'L' : 'R')); + m_bones[(int)XRHandJointID.MiddleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal", l_side)); + m_bones[(int)XRHandJointID.MiddleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal", l_side)); + m_bones[(int)XRHandJointID.MiddleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate", l_side)); + m_bones[(int)XRHandJointID.MiddleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal", l_side)); + m_bones[(int)XRHandJointID.MiddleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal/{0}_MiddleTip", l_side)); - m_bones[(int)XRHandJointID.RingMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.RingProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.RingIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.RingDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.RingTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal/{0}_RingTip", m_left ? 'L' : 'R')); + m_bones[(int)XRHandJointID.RingMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal", l_side)); + m_bones[(int)XRHandJointID.RingProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal", l_side)); + m_bones[(int)XRHandJointID.RingIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate", l_side)); + m_bones[(int)XRHandJointID.RingDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal", l_side)); + m_bones[(int)XRHandJointID.RingTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal/{0}_RingTip", l_side)); - m_bones[(int)XRHandJointID.LittleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.LittleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.LittleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.LittleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal", m_left ? 'L' : 'R')); - m_bones[(int)XRHandJointID.LittleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal/{0}_LittleTip", m_left ? 'L' : 'R')); + m_bones[(int)XRHandJointID.LittleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal", l_side)); + m_bones[(int)XRHandJointID.LittleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal", l_side)); + m_bones[(int)XRHandJointID.LittleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate", l_side)); + m_bones[(int)XRHandJointID.LittleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal", l_side)); + m_bones[(int)XRHandJointID.LittleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal/{0}_LittleTip", l_side)); for(int i = 0; i < c_fingerBonesCount; i++) { @@ -191,21 +193,23 @@ namespace ml_bft public override void Update() { var l_tracking = OpenXRSettings.Instance.GetFeature(); - if(l_tracking != null) + var l_device = InputDevices.GetDeviceAtXRNode(m_left ? XRNode.LeftHand : XRNode.RightHand); + if((l_device != null) && l_device.TryGetFeatureValue(CommonUsages.deviceRotation, out Quaternion l_deviceRot) && (l_tracking != null)) { - // Bones from API are in playspace, not local in comparison with OpenVR - l_tracking.GetHandJoints(m_left ? HandTrackingFeature.Hand_Index.L : HandTrackingFeature.Hand_Index.R, out var l_positions, out var l_rotations, out var l_radius); + Quaternion l_handInv = Quaternion.Inverse(l_deviceRot); + l_tracking.GetHandJoints(m_left ? HandTrackingFeature.Hand_Index.L : HandTrackingFeature.Hand_Index.R, out var l_positions, out var l_rotations, out _); if(l_positions.Length >= c_fingerBonesCount) { - // This stuff rotates debug hands in a weird way, but it doesn't matter because of funny math in new FingerSystem - Quaternion l_rot = m_prefabRoot.rotation; - m_prefabRoot.rotation = Quaternion.identity; + // Joints rotations are in global space, locations are in local space ... wth is wrong with OpenXR? + Quaternion l_prefabRot = m_prefabRoot.rotation; for(int i = 0; i < c_fingerBonesCount; i++) { if(m_bones[i] != null) - m_bones[i].rotation = l_rotations[i]; + { + m_bones[i].localPosition = l_positions[i]; + m_bones[i].rotation = l_prefabRot * (l_handInv * l_rotations[i]); + } } - m_prefabRoot.rotation = l_rot; } } } diff --git a/ml_bft/InputHandler.cs b/ml_bft/InputHandler.cs index 52d3f5a..d4f1dbe 100644 --- a/ml_bft/InputHandler.cs +++ b/ml_bft/InputHandler.cs @@ -42,10 +42,15 @@ namespace ml_bft { if(!CheckVR.Instance.forceOpenXr) { - m_leftHandHandler = new HandHandlerOVR(CVRInputManager.Instance.leftHandTransform, true); - m_rightHandHandler = new HandHandlerOVR(CVRInputManager.Instance.rightHandTransform, false); - m_active = true; + m_leftHandHandler = new HandHandlerVR(CVRInputManager.Instance.leftHandTransform, true); + m_rightHandHandler = new HandHandlerVR(CVRInputManager.Instance.rightHandTransform, false); } + else + { + m_leftHandHandler = new HandHandlerXR(CVRInputManager.Instance.leftHandTransform, true); + m_rightHandHandler = new HandHandlerXR(CVRInputManager.Instance.rightHandTransform, false); + } + m_active = true; } void RemoveHandlers() { diff --git a/ml_bft/Settings.cs b/ml_bft/Settings.cs index f1b7658..6da9205 100644 --- a/ml_bft/Settings.cs +++ b/ml_bft/Settings.cs @@ -6,20 +6,28 @@ namespace ml_bft { static class Settings { + public enum MotionRangeType + { + WithController = 0, + WithoutController + } enum ModSetting { SkeletalInput = 0, + MotionRange, ShowHands } public static bool SkeletalInput { get; private set; } = false; + public static MotionRangeType MotionRange { get; private set; } = MotionRangeType.WithController; public static bool ShowHands { get; private set; } = false; static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action SkeletalInputChange; - static public event Action ShowHandsChange; + public static event Action SkeletalInputChange; + public static event Action MotionRangeChange; + public static event Action ShowHandsChange; internal static void Init() { @@ -28,10 +36,12 @@ namespace ml_bft ms_entries = new List() { ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput), + ms_category.CreateEntry(ModSetting.MotionRange.ToString(), (int)MotionRange), ms_category.CreateEntry(ModSetting.ShowHands.ToString(), ShowHands) }; SkeletalInput = (bool)ms_entries[(int)ModSetting.SkeletalInput].BoxedValue; + MotionRange = (MotionRangeType)(int)ms_entries[(int)ModSetting.MotionRange].BoxedValue; ShowHands = (bool)ms_entries[(int)ModSetting.ShowHands].BoxedValue; MelonLoader.MelonCoroutines.Start(WaitMainMenuUi()); @@ -49,6 +59,7 @@ namespace ml_bft ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () => { ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action(OnToggleUpdate)); + ViewManager.Instance.gameMenuView.View.BindCall("OnDropdownUpdate_" + ms_category.Identifier, new Action(OnDropdownUpdate)); }; ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) => { @@ -71,7 +82,7 @@ namespace ml_bft SkeletalInputChange?.Invoke(SkeletalInput); } break; - + case ModSetting.ShowHands: { ShowHands = bool.Parse(p_value); @@ -83,5 +94,23 @@ namespace ml_bft ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value); } } + + static void OnDropdownUpdate(string p_name, string p_value) + { + if(Enum.TryParse(p_name, out ModSetting l_setting)) + { + switch(l_setting) + { + case ModSetting.MotionRange: + { + MotionRange = (MotionRangeType)int.Parse(p_value); + MotionRangeChange?.Invoke(MotionRange); + } + break; + } + + ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value); + } + } } } diff --git a/ml_bft/Utils.cs b/ml_bft/Utils.cs index 6026364..340630f 100644 --- a/ml_bft/Utils.cs +++ b/ml_bft/Utils.cs @@ -1,6 +1,9 @@ -using ABI_RC.Core.UI; +using ABI_RC.Core.Player; +using ABI_RC.Core.UI; +using ABI_RC.Systems.IK; using ABI_RC.Systems.InputManagement; using System.Reflection; +using UnityEngine; namespace ml_bft { @@ -8,8 +11,15 @@ namespace ml_bft { static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static bool AreKnucklesInUse() => ((CVRInputManager.Instance._leftController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index) || (CVRInputManager.Instance._rightController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index)); + + public static void SetAvatarTPose() + { + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + } } } diff --git a/ml_bft/ml_bft.csproj b/ml_bft/ml_bft.csproj index c42e450..b399ead 100644 --- a/ml_bft/ml_bft.csproj +++ b/ml_bft/ml_bft.csproj @@ -60,6 +60,11 @@ false false + + D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.XR.OpenVR.dll + false + false + D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.XR.OpenXR.dll false diff --git a/ml_bft/resources/mod_menu.js b/ml_bft/resources/mod_menu.js index 65468d3..8a578e3 100644 --- a/ml_bft/resources/mod_menu.js +++ b/ml_bft/resources/mod_menu.js @@ -7,11 +7,18 @@
-
Force SteamVR skeletal input:
+
Force SteamVR/OpenXR skeletal input:
+ +
+
Motion range (SteamVR only):
+
+
+
+
Show hands model:
@@ -25,4 +32,8 @@ // Toggles for (let l_toggle of l_block.querySelectorAll('.inp_toggle')) modsExtension.addSetting('BFT', l_toggle.id, modsExtension.createToggle(l_toggle, 'OnToggleUpdate_BFT')); + + // Dropdowns + for (let l_dropdown of l_block.querySelectorAll('.inp_dropdown')) + modsExtension.addSetting('BFT', l_dropdown.id, modsExtension.createDropdown(l_dropdown, 'OnDropdownUpdate_BFT')); } diff --git a/ml_dht/HeadTracked.cs b/ml_dht/HeadTracked.cs index 93811a8..434a825 100644 --- a/ml_dht/HeadTracked.cs +++ b/ml_dht/HeadTracked.cs @@ -2,7 +2,6 @@ using ABI_RC.Core.Player; using ABI_RC.Core.Player.EyeMovement; using ABI_RC.Systems.FaceTracking; -using ABI_RC.Systems.VRModeSwitch; using RootMotion.FinalIK; using System; using System.Reflection; @@ -99,13 +98,15 @@ namespace ml_dht // Game events internal void OnSetupAvatar() { + Utils.SetAvatarTPose(); + m_camera = PlayerSetup.Instance.GetActiveCamera().transform; m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent(); m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head); m_lookIK = PlayerSetup.Instance._avatar.GetComponent(); if(m_headBone != null) - m_bindRotation = (m_avatarDescriptor.transform.GetMatrix().inverse * m_headBone.GetMatrix()).rotation; + m_bindRotation = Quaternion.Inverse(m_avatarDescriptor.transform.rotation) * m_headBone.rotation; if(m_lookIK != null) m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); diff --git a/ml_dht/Settings.cs b/ml_dht/Settings.cs index 60bd767..c0ad6e9 100644 --- a/ml_dht/Settings.cs +++ b/ml_dht/Settings.cs @@ -28,14 +28,13 @@ namespace ml_dht static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action EnabledChange; - static public event Action HeadTrackingChange; - static public event Action EyeTrackingChange; - static public event Action FaceTrackingChange; - static public event Action BlinkingChange; - static public event Action MirroredChange; - static public event Action SmoothingChange; - + public static event Action EnabledChange; + public static event Action HeadTrackingChange; + public static event Action EyeTrackingChange; + public static event Action FaceTrackingChange; + public static event Action BlinkingChange; + public static event Action MirroredChange; + public static event Action SmoothingChange; internal static void Init() { diff --git a/ml_dht/TrackingData.cs b/ml_dht/TrackingData.cs index 43f9f97..45a881c 100644 --- a/ml_dht/TrackingData.cs +++ b/ml_dht/TrackingData.cs @@ -17,7 +17,7 @@ struct TrackingData public float m_mouthShape; // Range - [-1;1], -1 - wide, 1 - narrow public float m_brows; // Range - [-1;1], -1 - up, 1 - down; not used yet - static public byte[] ToBytes(TrackingData p_faceData) + public static byte[] ToBytes(TrackingData p_faceData) { int l_size = Marshal.SizeOf(p_faceData); byte[] l_arr = new byte[l_size]; @@ -29,7 +29,7 @@ struct TrackingData return l_arr; } - static public TrackingData ToObject(byte[] p_buffer) + public static TrackingData ToObject(byte[] p_buffer) { TrackingData l_faceData = new TrackingData(); diff --git a/ml_dht/Utils.cs b/ml_dht/Utils.cs index fc2681d..547ff32 100644 --- a/ml_dht/Utils.cs +++ b/ml_dht/Utils.cs @@ -1,5 +1,7 @@ using ABI.CCK.Components; +using ABI_RC.Core.Player; using ABI_RC.Core.UI; +using ABI_RC.Systems.IK; using System.Reflection; using UnityEngine; @@ -11,13 +13,15 @@ namespace ml_dht static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly MethodInfo ms_updateShapesLocal = typeof(CVRFaceTracking).GetMethod("UpdateShapesLocal", BindingFlags.NonPublic | BindingFlags.Instance); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); - static public void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray); + public static void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray); - public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) + public static void SetAvatarTPose() { - return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; } } } diff --git a/ml_lme/LeapHand.cs b/ml_lme/LeapHand.cs index 23f15b1..2fd20c2 100644 --- a/ml_lme/LeapHand.cs +++ b/ml_lme/LeapHand.cs @@ -91,7 +91,7 @@ namespace ml_lme { if(m_fingersBones[i] != null) { - //m_fingers[i].position = p_data.m_fingerPosition[i]; + //m_fingersBones[i].position = p_data.m_fingerPosition[i]; m_fingersBones[i].rotation = p_data.m_fingerRotation[i]; } } diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index 9d73b23..905a5b9 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -1,7 +1,6 @@ using ABI_RC.Core.Player; using ABI_RC.Systems.IK; using RootMotion.FinalIK; -using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -195,22 +194,17 @@ namespace ml_lme } m_poseHandler.GetHumanPose(ref m_pose); - if(l_data.m_leftHand.m_present) + if(l_data.m_leftHand.m_present || l_data.m_rightHand.m_present) { for(int i = 0; i < 5; i++) { int l_offset = i * 4; + ms_lastLeftFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched + l_offset]; ms_lastLeftFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched + l_offset]; ms_lastLeftFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.LeftThumb3Stretched + l_offset]; ms_lastLeftFingerBones[l_offset + 3] = m_pose.muscles[(int)MuscleIndex.LeftThumbSpread + l_offset]; - } - } - if(l_data.m_rightHand.m_present) - { - for(int i = 0; i < 5; i++) - { - int l_offset = i * 4; + ms_lastRightFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.RightThumb1Stretched + l_offset]; ms_lastRightFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.RightThumb2Stretched + l_offset]; ms_lastRightFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.RightThumb3Stretched + l_offset]; @@ -249,21 +243,14 @@ namespace ml_lme internal void OnAvatarSetup() { m_inVR = Utils.IsInVR(); - m_vrIK = PlayerSetup.Instance._animator.GetComponent(); if(PlayerSetup.Instance._animator.isHuman) { + Utils.SetAvatarTPose(); + m_poseHandler = new HumanPoseHandler(PlayerSetup.Instance._animator.avatar, PlayerSetup.Instance._animator.transform); m_poseHandler.GetHumanPose(ref m_pose); - if(m_inVR) - { - PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; - PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; - } - else - PoseHelper.ForceTPose(PlayerSetup.Instance._animator); - m_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); m_leftHandTarget.localRotation = ms_offsetLeft * (Quaternion.Inverse(PlayerSetup.Instance._avatar.transform.rotation) * m_leftHand.rotation); @@ -272,6 +259,7 @@ namespace ml_lme ParseFingersBones(); + m_vrIK = PlayerSetup.Instance._animator.GetComponent(); if(m_vrIK != null) { m_vrIK.onPreSolverUpdate.AddListener(this.OnIKPreUpdate); @@ -298,7 +286,7 @@ namespace ml_lme } else { - PoseHelper.ForceTPose(PlayerSetup.Instance._animator); + Utils.SetAvatarTPose(); SetupArmIK(); } } diff --git a/ml_lme/PoseHelper.cs b/ml_lme/PoseHelper.cs deleted file mode 100644 index 7982a2d..0000000 --- a/ml_lme/PoseHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; -using ABI_RC.Systems.IK; - -namespace ml_lme -{ - static class PoseHelper - { - public static void ForceTPose(Animator p_animator) - { - if(p_animator.isHuman) - { - HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); - HumanPose l_pose = new HumanPose(); - l_handler.GetHumanPose(ref l_pose); - - for(int i=0, j = Mathf.Min(l_pose.muscles.Length,MusclePoses.TPoseMuscles.Length); i < j; i++) - l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; - - l_pose.bodyPosition = Vector3.up; - l_pose.bodyRotation = Quaternion.identity; - l_handler.SetHumanPose(ref l_pose); - l_handler.Dispose(); - } - } - } -} diff --git a/ml_lme/Settings.cs b/ml_lme/Settings.cs index e93faf5..0599ce4 100644 --- a/ml_lme/Settings.cs +++ b/ml_lme/Settings.cs @@ -56,20 +56,20 @@ namespace ml_lme static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action EnabledChange; - static public event Action DesktopOffsetChange; - static public event Action FingersOnlyChange; - static public event Action ModelVisibilityChange; - static public event Action TrackingModeChange; - static public event Action RootAngleChange; - static public event Action HeadAttachChange; - static public event Action HeadOffsetChange; - static public event Action TrackElbowsChange; - static public event Action InteractionChange; - static public event Action GesturesChange; - static public event Action InteractThreadholdChange; - static public event Action GripThreadholdChange; - static public event Action VisualHandsChange; + public static event Action EnabledChange; + public static event Action DesktopOffsetChange; + public static event Action FingersOnlyChange; + public static event Action ModelVisibilityChange; + public static event Action TrackingModeChange; + public static event Action RootAngleChange; + public static event Action HeadAttachChange; + public static event Action HeadOffsetChange; + public static event Action TrackElbowsChange; + public static event Action InteractionChange; + public static event Action GesturesChange; + public static event Action InteractThreadholdChange; + public static event Action GripThreadholdChange; + public static event Action VisualHandsChange; internal static void Init() { diff --git a/ml_lme/Utils.cs b/ml_lme/Utils.cs index 1cb14f3..2638fb7 100644 --- a/ml_lme/Utils.cs +++ b/ml_lme/Utils.cs @@ -1,6 +1,8 @@ using ABI_RC.Core.InteractionSystem; +using ABI_RC.Core.Player; using ABI_RC.Core.Savior; using ABI_RC.Core.UI; +using ABI_RC.Systems.IK; using ABI_RC.Systems.InputManagement; using System.Collections.Generic; using System.Reflection; @@ -49,7 +51,14 @@ namespace ml_lme } } - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + + public static void SetAvatarTPose() + { + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + } public static void Swap(ref T lhs, ref T rhs) { diff --git a/ml_pam/ArmMover.cs b/ml_pam/ArmMover.cs index 7aa119c..b14dc40 100644 --- a/ml_pam/ArmMover.cs +++ b/ml_pam/ArmMover.cs @@ -332,8 +332,7 @@ namespace ml_pam if(PlayerSetup.Instance._animator.isHuman) { - if(!m_inVR) - PoseHelper.ForceTPose(PlayerSetup.Instance._animator); + Utils.SetAvatarTPose(); Transform l_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); if(l_leftHand != null) diff --git a/ml_pam/PoseHelper.cs b/ml_pam/PoseHelper.cs deleted file mode 100644 index 7ed7ba1..0000000 --- a/ml_pam/PoseHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using UnityEngine; -using ABI_RC.Systems.IK; - -namespace ml_pam -{ - static class PoseHelper - { - public static void ForceTPose(Animator p_animator) - { - if(p_animator.isHuman) - { - HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform); - HumanPose l_pose = new HumanPose(); - l_handler.GetHumanPose(ref l_pose); - - for(int i = 0, j = Mathf.Min(l_pose.muscles.Length, MusclePoses.TPoseMuscles.Length); i < j; i++) - l_pose.muscles[i] = MusclePoses.TPoseMuscles[i]; - - l_pose.bodyPosition = Vector3.up; - l_pose.bodyRotation = Quaternion.identity; - l_handler.SetHumanPose(ref l_pose); - l_handler.Dispose(); - } - } - } -} diff --git a/ml_pam/Settings.cs b/ml_pam/Settings.cs index ff841ac..c1562e4 100644 --- a/ml_pam/Settings.cs +++ b/ml_pam/Settings.cs @@ -28,10 +28,10 @@ namespace ml_pam static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action EnabledChange; - static public event Action GrabOffsetChange; - static public event Action LeadingHandChange; - static public event Action HandsExtensionChange; + public static event Action EnabledChange; + public static event Action GrabOffsetChange; + public static event Action LeadingHandChange; + public static event Action HandsExtensionChange; internal static void Init() { diff --git a/ml_pam/Utils.cs b/ml_pam/Utils.cs index 2ddbeef..39b9b3c 100644 --- a/ml_pam/Utils.cs +++ b/ml_pam/Utils.cs @@ -1,5 +1,7 @@ -using ABI_RC.Core.Savior; +using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; using ABI_RC.Core.UI; +using ABI_RC.Systems.IK; using System.Reflection; using UnityEngine; @@ -11,7 +13,14 @@ namespace ml_pam public static bool IsInVR() => ((MetaPort.Instance != null) && MetaPort.Instance.isUsingVr); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + + public static void SetAvatarTPose() + { + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + } // Extensions public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) diff --git a/ml_pin/Settings.cs b/ml_pin/Settings.cs index d8a45f9..a25cc10 100644 --- a/ml_pin/Settings.cs +++ b/ml_pin/Settings.cs @@ -33,12 +33,12 @@ namespace ml_pin static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action NotifyTypeChange; - static public event Action VolumeChange; - static public event Action NotifyInPublicChange; - static public event Action NotifyInFriendsChange; - static public event Action NotifyInPrivateChange; - static public event Action FriendsAlwaysChange; + public static event Action NotifyTypeChange; + public static event Action VolumeChange; + public static event Action NotifyInPublicChange; + public static event Action NotifyInFriendsChange; + public static event Action NotifyInPrivateChange; + public static event Action FriendsAlwaysChange; internal static void Init() { diff --git a/ml_pin/Utils.cs b/ml_pin/Utils.cs index 105f01a..f2e993b 100644 --- a/ml_pin/Utils.cs +++ b/ml_pin/Utils.cs @@ -7,6 +7,6 @@ namespace ml_pin { static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); } } diff --git a/ml_pmc/PoseCopycat.cs b/ml_pmc/PoseCopycat.cs index 3ccfeaa..59edb7c 100644 --- a/ml_pmc/PoseCopycat.cs +++ b/ml_pmc/PoseCopycat.cs @@ -3,7 +3,6 @@ using ABI_RC.Systems.IK; using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.Movement; -using ABI_RC.Systems.VRModeSwitch; using RootMotion.FinalIK; using UnityEngine; @@ -14,8 +13,8 @@ namespace ml_pmc { static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f); - static public PoseCopycat Instance { get; private set; } = null; - static internal System.Action OnActivityChange; + public static PoseCopycat Instance { get; private set; } = null; + internal static System.Action OnActivityChange; Animator m_animator = null; VRIK m_vrIk = null; @@ -372,29 +371,29 @@ namespace ml_pmc if(!CVRInputManager.Instance.individualFingerTracking) { // Left hand - CVRInputManager.Instance.finger1StretchedLeftThumb = -0.5f; - CVRInputManager.Instance.finger2StretchedLeftThumb = 0.7f; - CVRInputManager.Instance.finger3StretchedLeftThumb = 0.7f; + CVRInputManager.Instance.finger1StretchedLeftThumb = -0f; + CVRInputManager.Instance.finger2StretchedLeftThumb = 0f; + CVRInputManager.Instance.finger3StretchedLeftThumb = 0f; CVRInputManager.Instance.fingerSpreadLeftThumb = 0f; - CVRInputManager.Instance.finger1StretchedLeftIndex = 0.5f; - CVRInputManager.Instance.finger2StretchedLeftIndex = 0.7f; - CVRInputManager.Instance.finger3StretchedLeftIndex = 0.7f; + CVRInputManager.Instance.finger1StretchedLeftIndex = 0f; + CVRInputManager.Instance.finger2StretchedLeftIndex = 0f; + CVRInputManager.Instance.finger3StretchedLeftIndex = 0f; CVRInputManager.Instance.fingerSpreadLeftIndex = 0f; - CVRInputManager.Instance.finger1StretchedLeftMiddle = 0.5f; - CVRInputManager.Instance.finger2StretchedLeftMiddle = 0.7f; - CVRInputManager.Instance.finger3StretchedLeftMiddle = 0.7f; + CVRInputManager.Instance.finger1StretchedLeftMiddle = 0; + CVRInputManager.Instance.finger2StretchedLeftMiddle = 0f; + CVRInputManager.Instance.finger3StretchedLeftMiddle = 0f; CVRInputManager.Instance.fingerSpreadLeftMiddle = 0f; - CVRInputManager.Instance.finger1StretchedLeftRing = 0.5f; - CVRInputManager.Instance.finger2StretchedLeftRing = 0.7f; - CVRInputManager.Instance.finger3StretchedLeftRing = 0.7f; + CVRInputManager.Instance.finger1StretchedLeftRing = 0f; + CVRInputManager.Instance.finger2StretchedLeftRing = 0f; + CVRInputManager.Instance.finger3StretchedLeftRing = 0f; CVRInputManager.Instance.fingerSpreadLeftRing = 0f; - CVRInputManager.Instance.finger1StretchedLeftPinky = 0.5f; - CVRInputManager.Instance.finger2StretchedLeftPinky = 0.7f; - CVRInputManager.Instance.finger3StretchedLeftPinky = 0.7f; + CVRInputManager.Instance.finger1StretchedLeftPinky = 0f; + CVRInputManager.Instance.finger2StretchedLeftPinky = 0f; + CVRInputManager.Instance.finger3StretchedLeftPinky = 0f; CVRInputManager.Instance.fingerSpreadLeftPinky = 0f; CVRInputManager.Instance.fingerFullCurlNormalizedLeftThumb = 0f; @@ -404,29 +403,29 @@ namespace ml_pmc CVRInputManager.Instance.fingerFullCurlNormalizedLeftPinky = 0f; // Right hand - CVRInputManager.Instance.finger1StretchedRightThumb = -0.5f; - CVRInputManager.Instance.finger2StretchedRightThumb = 0.7f; - CVRInputManager.Instance.finger3StretchedRightThumb = 0.7f; + CVRInputManager.Instance.finger1StretchedRightThumb = 0f; + CVRInputManager.Instance.finger2StretchedRightThumb = 0f; + CVRInputManager.Instance.finger3StretchedRightThumb = 0f; CVRInputManager.Instance.fingerSpreadRightThumb = 0f; - CVRInputManager.Instance.finger1StretchedRightIndex = 0.5f; - CVRInputManager.Instance.finger2StretchedRightIndex = 0.7f; - CVRInputManager.Instance.finger3StretchedRightIndex = 0.7f; + CVRInputManager.Instance.finger1StretchedRightIndex = 0f; + CVRInputManager.Instance.finger2StretchedRightIndex = 0f; + CVRInputManager.Instance.finger3StretchedRightIndex = 0f; CVRInputManager.Instance.fingerSpreadRightIndex = 0f; - CVRInputManager.Instance.finger1StretchedRightMiddle = 0.5f; - CVRInputManager.Instance.finger2StretchedRightMiddle = 0.7f; - CVRInputManager.Instance.finger3StretchedRightMiddle = 0.7f; + CVRInputManager.Instance.finger1StretchedRightMiddle = 0f; + CVRInputManager.Instance.finger2StretchedRightMiddle = 0f; + CVRInputManager.Instance.finger3StretchedRightMiddle = 0f; CVRInputManager.Instance.fingerSpreadRightMiddle = 0f; - CVRInputManager.Instance.finger1StretchedRightRing = 0.5f; - CVRInputManager.Instance.finger2StretchedRightRing = 0.7f; - CVRInputManager.Instance.finger3StretchedRightRing = 0.7f; + CVRInputManager.Instance.finger1StretchedRightRing = 0f; + CVRInputManager.Instance.finger2StretchedRightRing = 0f; + CVRInputManager.Instance.finger3StretchedRightRing = 0f; CVRInputManager.Instance.fingerSpreadRightRing = 0f; - CVRInputManager.Instance.finger1StretchedRightPinky = 0.5f; - CVRInputManager.Instance.finger2StretchedRightPinky = 0.7f; - CVRInputManager.Instance.finger3StretchedRightPinky = 0.7f; + CVRInputManager.Instance.finger1StretchedRightPinky = 0f; + CVRInputManager.Instance.finger2StretchedRightPinky = 0f; + CVRInputManager.Instance.finger3StretchedRightPinky = 0f; CVRInputManager.Instance.fingerSpreadRightPinky = 0f; CVRInputManager.Instance.fingerFullCurlNormalizedRightThumb = 0f; diff --git a/ml_prm/ModUi.cs b/ml_prm/ModUi.cs index 98a36bb..56964a8 100644 --- a/ml_prm/ModUi.cs +++ b/ml_prm/ModUi.cs @@ -29,7 +29,7 @@ namespace ml_prm FallLimit } - static public event Action SwitchChange; + public static event Action SwitchChange; static List ms_uiElements = null; diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index c1b3e9b..dc38bc4 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -288,6 +288,8 @@ namespace ml_prm if(PlayerSetup.Instance._animator.isHuman) { + Utils.SetAvatarTPose(); + BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator); m_puppet = new GameObject("Root").transform; diff --git a/ml_prm/Settings.cs b/ml_prm/Settings.cs index 112dfae..b241af5 100644 --- a/ml_prm/Settings.cs +++ b/ml_prm/Settings.cs @@ -47,24 +47,24 @@ namespace ml_prm public static bool FallDamage { get; private set; } = true; public static float FallLimit { get; private set; } = 5f; - static public event Action HotkeyChange; - static public event Action HotkeyKeyChange; - static public event Action VelocityMultiplierChange; - static public event Action MovementDragChange; - static public event Action AngularDragChange; - static public event Action GravityChange; - static public event Action PointersReactionChange; - static public event Action IgnoreLocalChange; - static public event Action CombatReactionChange; - static public event Action AutoRecoverChange; - static public event Action RecoverDelayChange; - static public event Action SlipperinessChange; - static public event Action BouncinessChange; - static public event Action ViewVelocityChange; - static public event Action JumpRecoverChange; - static public event Action BuoyancyChange; - static public event Action FallDamageChange; - static public event Action FallLimitChange; + public static event Action HotkeyChange; + public static event Action HotkeyKeyChange; + public static event Action VelocityMultiplierChange; + public static event Action MovementDragChange; + public static event Action AngularDragChange; + public static event Action GravityChange; + public static event Action PointersReactionChange; + public static event Action IgnoreLocalChange; + public static event Action CombatReactionChange; + public static event Action AutoRecoverChange; + public static event Action RecoverDelayChange; + public static event Action SlipperinessChange; + public static event Action BouncinessChange; + public static event Action ViewVelocityChange; + public static event Action JumpRecoverChange; + public static event Action BuoyancyChange; + public static event Action FallDamageChange; + public static event Action FallLimitChange; static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; diff --git a/ml_prm/Utils.cs b/ml_prm/Utils.cs index 41b3ba0..52aacf9 100644 --- a/ml_prm/Utils.cs +++ b/ml_prm/Utils.cs @@ -1,5 +1,7 @@ using ABI.CCK.Components; +using ABI_RC.Core.Player; using ABI_RC.Core.Savior; +using ABI_RC.Systems.IK; using ABI_RC.Systems.Movement; using System.Collections.Generic; using System.Reflection; @@ -46,5 +48,12 @@ namespace ml_prm (ms_influencerTouchingVolumes.GetValue(p_instance) as List)?.Clear(); (ms_influencerSubmergedColliders.GetValue(p_instance) as Dictionary)?.Clear(); } + + public static void SetAvatarTPose() + { + IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); + PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero; + PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity; + } } } diff --git a/ml_vei/Settings.cs b/ml_vei/Settings.cs index 7a412c0..9f0f435 100644 --- a/ml_vei/Settings.cs +++ b/ml_vei/Settings.cs @@ -26,9 +26,9 @@ namespace ml_vei static MelonLoader.MelonPreferences_Category ms_category = null; static List ms_entries = null; - static public event Action GesturesChange; - static public event Action GripTriggerChange; - static public event Action AxisPriorityChange; + public static event Action GesturesChange; + public static event Action GripTriggerChange; + public static event Action AxisPriorityChange; internal static void Init() { diff --git a/ml_vei/Utils.cs b/ml_vei/Utils.cs index ad1851f..5da1fd9 100644 --- a/ml_vei/Utils.cs +++ b/ml_vei/Utils.cs @@ -7,6 +7,6 @@ namespace ml_vei { static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); - static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); + public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); } }