Transformation fixes

More checks for non-flying worlds
This commit is contained in:
SDraw 2023-05-28 16:47:04 +03:00
parent 9159946de6
commit 732b15a6a9
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
9 changed files with 43 additions and 35 deletions

View file

@ -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<br>**Retired** | Superseded by `Extended Game Notifications`
| Avatar Motion Tweaker | ml_amt | 1.2.8 | ✔ Yes<br>⏱ 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<br>**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<br>⏱ Update review |
| Leap Motion Extension | ml_lme | 1.3.7 | ✔ Yes<br>⏱ Update review |
| Pickup Arm Movement | ml_pam | 1.0.5 | ✔ Yes<br>⏱ Update review |
| Player Movement Copycat | ml_pmc | 1.0.0 | ✔ Yes |
| Player Ragdoll Mod | ml_prm | 1.0.5 | ✔ Yes<br>⏱ Update review |
| Server Connection Info | ml_sci | 1.0.2 | ✔ Yes<br>**Retired** | Superseded by `Extended Game Notifications`

View file

@ -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;
}
}
}

View file

@ -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)]

View file

@ -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)

View file

@ -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)]

View file

@ -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")]

View file

@ -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,8 +341,11 @@ 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;

View file

@ -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)
{