From 732b15a6a9759080cc9bc4b19fa1998353888392 Mon Sep 17 00:00:00 2001 From: SDraw Date: Sun, 28 May 2023 16:47:04 +0300 Subject: [PATCH] Transformation fixes More checks for non-flying worlds --- README.md | 10 +++++----- ml_lme/LeapTracked.cs | 7 ------- ml_lme/Properties/AssemblyInfo.cs | 6 +++--- ml_pam/ArmMover.cs | 7 ------- ml_pam/Properties/AssemblyInfo.cs | 6 +++--- ml_prm/Main.cs | 4 ++-- ml_prm/Properties/AssemblyInfo.cs | 6 +++--- ml_prm/RagdollController.cs | 25 ++++++++++++++++++++++--- ml_prm/Utils.cs | 7 +++++-- 9 files changed, 43 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index ce2828b..667a2bb 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ Merged set of MelonLoader mods for ChilloutVR. | Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Notes | |:---------:|:----------:|:--------------:| :----------------------------------------------------------------|-------| | Avatar Change Info | ml_aci | 1.0.3 | ✔ Yes
⭕ **Retired** | Superseded by `Extended Game Notifications` -| Avatar Motion Tweaker | ml_amt | 1.2.8 | ✔ Yes
⏱ Update review | +| Avatar Motion Tweaker | ml_amt | 1.2.8 | ✔ Yes | | Desktop Head Tracking | ml_dht | 1.1.3 | ✔ Yes | | Desktop Reticle Switch | ml_drs | 1.0.0 | ✔ Yes | | Extended Game Notifications | ml_egn | 1.0.2 | ✔ Yes | | Four Point Tracking | ml_fpt | 1.0.9 | ✔ Yes
⭕ **Retired** | In-game feature since 2022r170 update -| Leap Motion Extension | ml_lme | 1.3.6 | ✔ Yes | -| Pickup Arm Movement | ml_pam | 1.0.4 | ✔ Yes | -| Player Movement Copycat | ml_pmc | 1.0.0 | ⏱ On review | -| Player Ragdoll Mod | ml_prm | 1.0.4 | ✔ Yes
⏱ Update review | +| Leap Motion Extension | ml_lme | 1.3.7 | ✔ Yes
⏱ Update review | +| Pickup Arm Movement | ml_pam | 1.0.5 | ✔ Yes
⏱ Update review | +| Player Movement Copycat | ml_pmc | 1.0.0 | ✔ Yes | +| Player Ragdoll Mod | ml_prm | 1.0.5 | ✔ Yes
⏱ Update review | | Server Connection Info | ml_sci | 1.0.2 | ✔ Yes
⭕ **Retired** | Superseded by `Extended Game Notifications` diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index 21ce9cb..10c720d 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -233,13 +233,9 @@ namespace ml_lme if(PlayerSetup.Instance._animator.isHuman) { Vector3 l_hipsPos = Vector3.zero; - Quaternion l_hipsRot = Quaternion.identity; m_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips); if(m_hips != null) - { l_hipsPos = m_hips.localPosition; - l_hipsRot = m_hips.localRotation; - } if(!m_inVR) { @@ -317,10 +313,7 @@ namespace ml_lme } if(m_hips != null) - { m_hips.localPosition = l_hipsPos; - m_hips.localRotation = l_hipsRot; - } } } diff --git a/ml_lme/Properties/AssemblyInfo.cs b/ml_lme/Properties/AssemblyInfo.cs index 8fdeb25..48dc288 100644 --- a/ml_lme/Properties/AssemblyInfo.cs +++ b/ml_lme/Properties/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: AssemblyTitle("LeapMotionExtension")] -[assembly: AssemblyVersion("1.3.6")] -[assembly: AssemblyFileVersion("1.3.6")] +[assembly: AssemblyVersion("1.3.7")] +[assembly: AssemblyFileVersion("1.3.7")] -[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.6", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.7", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonOptionalDependencies("ml_pmc")] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] diff --git a/ml_pam/ArmMover.cs b/ml_pam/ArmMover.cs index 68d0fe4..6091e3b 100644 --- a/ml_pam/ArmMover.cs +++ b/ml_pam/ArmMover.cs @@ -133,13 +133,9 @@ namespace ml_pam if(PlayerSetup.Instance._animator.isHuman) { Vector3 l_hipsPos = Vector3.zero; - Quaternion l_hipsRot = Quaternion.identity; Transform l_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips); if(l_hips != null) - { l_hipsPos = l_hips.localPosition; - l_hipsRot = l_hips.localRotation; - } HumanPose l_currentPose = new HumanPose(); HumanPoseHandler l_poseHandler = null; @@ -201,10 +197,7 @@ namespace ml_pam l_poseHandler?.Dispose(); if(l_hips != null) - { l_hips.localPosition = l_hipsPos; - l_hips.localRotation = l_hipsRot; - } } if(m_enabled) diff --git a/ml_pam/Properties/AssemblyInfo.cs b/ml_pam/Properties/AssemblyInfo.cs index 2bdb677..9ed68ec 100644 --- a/ml_pam/Properties/AssemblyInfo.cs +++ b/ml_pam/Properties/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: AssemblyTitle("PickupArmMovement")] -[assembly: AssemblyVersion("1.0.4")] -[assembly: AssemblyFileVersion("1.0.4")] +[assembly: AssemblyVersion("1.0.5")] +[assembly: AssemblyFileVersion("1.0.5")] -[assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.0.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.0.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(1)] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] diff --git a/ml_prm/Main.cs b/ml_prm/Main.cs index d997fb6..0cd764d 100644 --- a/ml_prm/Main.cs +++ b/ml_prm/Main.cs @@ -130,10 +130,10 @@ namespace ml_prm { try { - if (m_localController != null) + if(m_localController != null) m_localController.OnAvatarScaling(1f + p_scaleDifference); } - catch (Exception e) + catch(Exception e) { MelonLoader.MelonLogger.Error(e); } diff --git a/ml_prm/Properties/AssemblyInfo.cs b/ml_prm/Properties/AssemblyInfo.cs index 64fe343..4f1e779 100644 --- a/ml_prm/Properties/AssemblyInfo.cs +++ b/ml_prm/Properties/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: AssemblyTitle("PlayerRagdollMod")] -[assembly: AssemblyVersion("1.0.4")] -[assembly: AssemblyFileVersion("1.0.4")] +[assembly: AssemblyVersion("1.0.5")] +[assembly: AssemblyFileVersion("1.0.5")] -[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.0.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_prm.PlayerRagdollMod), "PlayerRagdollMod", "1.0.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPriority(2)] [assembly: MelonLoader.MelonOptionalDependencies("BTKUILib")] diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 77998c1..f51625b 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -41,6 +41,7 @@ namespace ml_prm readonly PhysicMaterial m_physicsMaterial = null; bool m_reachedGround = true; + float m_groundedTime = 0f; float m_downTime = float.MinValue; internal RagdollController() @@ -115,10 +116,14 @@ namespace ml_prm Vector3 l_pos = PlayerSetup.Instance.transform.position; m_velocity = (m_velocity + (l_pos - m_lastPosition) / Time.deltaTime) * 0.5f; m_lastPosition = l_pos; - } - if(m_avatarReady && !m_reachedGround) - m_reachedGround = MovementSystem.Instance.IsGrounded(); + if(!m_reachedGround && MovementSystem.Instance.IsGrounded()) + { + m_groundedTime += Time.deltaTime; + if(m_groundedTime >= 0.25f) + m_reachedGround = true; + } + } if(m_avatarReady && m_enabled && !BodySystem.isCalibrating) BodySystem.TrackingPositionWeight = 0f; @@ -189,6 +194,7 @@ namespace ml_prm m_boneLinks.Clear(); m_jointAnchors.Clear(); m_reachedGround = true; + m_groundedTime = 0f; m_downTime = float.MinValue; m_puppetRoot.localScale = Vector3.one; } @@ -335,7 +341,10 @@ namespace ml_prm internal void OnCombatDown() { if(m_avatarReady && !m_enabled && Settings.CombatReaction) + { + m_reachedGround = true; SwitchRagdoll(); + } } internal void OnToggleFlight() @@ -451,7 +460,10 @@ namespace ml_prm BodySystem.TrackingPositionWeight = 0f; if(!Utils.IsWorldSafe()) + { m_reachedGround = false; // Force player to unragdoll and reach ground first + m_groundedTime = 0f; + } m_puppetRoot.gameObject.SetActive(true); @@ -485,6 +497,13 @@ namespace ml_prm if(IsSafeToUnragdoll()) { MovementSystem.Instance.SetImmobilized(false); + if(!Utils.IsWorldSafe()) + { + Vector3 l_vec = MovementSystem.Instance.GetAppliedGravity(); + l_vec.y = Mathf.Clamp(l_vec.y, float.MinValue, 0f); + MovementSystem.Instance.SetAppliedGravity(l_vec); + } + m_ragdolledParameter.SetValue(false); if(!BodySystem.isCalibrating) BodySystem.TrackingPositionWeight = 1f; diff --git a/ml_prm/Utils.cs b/ml_prm/Utils.cs index d4aa8f0..b9d1e48 100644 --- a/ml_prm/Utils.cs +++ b/ml_prm/Utils.cs @@ -8,7 +8,8 @@ namespace ml_prm { static class Utils { - static readonly FieldInfo ms_grounded = typeof(MovementSystem).GetField("_isGrounded", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance); + static readonly FieldInfo ms_appliedGravity = typeof(MovementSystem).GetField("_appliedGravity", BindingFlags.NonPublic | BindingFlags.Instance); public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded); public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying); @@ -25,7 +26,9 @@ namespace ml_prm return l_result; } - public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_grounded.GetValue(p_instance); + public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(p_instance); + public static Vector3 GetAppliedGravity(this MovementSystem p_instance) => (Vector3)ms_appliedGravity.GetValue(p_instance); + public static void SetAppliedGravity(this MovementSystem p_instance, Vector3 p_vec) => ms_appliedGravity.SetValue(p_instance, p_vec); public static void CopyGlobal(this Transform p_source, Transform p_target) {