mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[DesktopVRIK] Fixed an issue where tracking status would update a frame late
This commit is contained in:
parent
02d6c7ec89
commit
d3db894acf
6 changed files with 61 additions and 35 deletions
|
@ -120,4 +120,19 @@ internal class PlayerSetupPatches
|
|||
DesktopVRIK.Logger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Update))]
|
||||
private static void Postfix_PlayerSetup_Update()
|
||||
{
|
||||
try
|
||||
{
|
||||
IKManager.Instance?.OnPlayerUpdate();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DesktopVRIK.Logger.Error($"Error during the patched method {nameof(Postfix_PlayerSetup_Update)}");
|
||||
DesktopVRIK.Logger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,11 +80,12 @@ internal abstract class IKHandler
|
|||
Update_PelvisWeight();
|
||||
|
||||
Update_LocomotionWeight();
|
||||
ResetSolverIfNeeded();
|
||||
|
||||
Update_IKPositionWeight();
|
||||
}
|
||||
|
||||
public virtual void UpdateTracking() { }
|
||||
|
||||
protected virtual void Update_HeadWeight()
|
||||
{
|
||||
// There is no Head tracking setting
|
||||
|
@ -153,17 +154,5 @@ internal abstract class IKHandler
|
|||
return isTracking && hasTarget ? 1f : 0f;
|
||||
}
|
||||
|
||||
private void ResetSolverIfNeeded()
|
||||
{
|
||||
if (_wasTrackingLocomotion == BodySystem.TrackingLocomotionEnabled)
|
||||
return;
|
||||
|
||||
_wasTrackingLocomotion = BodySystem.TrackingLocomotionEnabled;
|
||||
if (ModSettings.EntryResetFootstepsOnIdle.Value)
|
||||
VRIKUtils.ResetToInitialFootsteps(_vrik, _locomotionData, _scaleDifference);
|
||||
|
||||
_solver.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.MovementSystem;
|
||||
using NAK.DesktopVRIK.IK.VRIKHelpers;
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -31,11 +32,16 @@ internal class IKHandlerDesktop : IKHandler
|
|||
_vrik.transform.localPosition = Vector3.zero;
|
||||
_vrik.transform.localRotation = Quaternion.identity;
|
||||
|
||||
UpdateBodySystemTracking();
|
||||
|
||||
base.UpdateWeights();
|
||||
}
|
||||
|
||||
public override void UpdateTracking()
|
||||
{
|
||||
BodySystem.TrackingEnabled = ShouldTrackAll();
|
||||
BodySystem.TrackingLocomotionEnabled = BodySystem.TrackingEnabled && ShouldTrackLocomotion();
|
||||
ResetSolverIfNeeded();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VRIK Solver Events
|
||||
|
@ -86,12 +92,6 @@ internal class IKHandlerDesktop : IKHandler
|
|||
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateBodySystemTracking()
|
||||
{
|
||||
BodySystem.TrackingEnabled = ShouldTrackAll();
|
||||
BodySystem.TrackingLocomotionEnabled = ShouldTrackLocomotion();
|
||||
}
|
||||
|
||||
private bool ShouldTrackAll()
|
||||
{
|
||||
return !PlayerSetup.Instance._emotePlaying;
|
||||
|
@ -111,5 +111,17 @@ internal class IKHandlerDesktop : IKHandler
|
|||
return !(isMoving || isCrouching || isProne || isFlying || isSitting || !isGrounded || !isStanding);
|
||||
}
|
||||
|
||||
private void ResetSolverIfNeeded()
|
||||
{
|
||||
if (_wasTrackingLocomotion == BodySystem.TrackingLocomotionEnabled)
|
||||
return;
|
||||
|
||||
_wasTrackingLocomotion = BodySystem.TrackingLocomotionEnabled;
|
||||
if (ModSettings.EntryResetFootstepsOnIdle.Value)
|
||||
VRIKUtils.ResetToInitialFootsteps(_vrik, _locomotionData, _scaleDifference);
|
||||
|
||||
_solver.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using NAK.DesktopVRIK.IK.IKHandlers;
|
||||
using NAK.DesktopVRIK.IK.VRIKHelpers;
|
||||
using RootMotion.FinalIK;
|
||||
|
@ -25,6 +26,7 @@ public class IKManager : MonoBehaviour
|
|||
// Player Info
|
||||
internal Transform _desktopCamera;
|
||||
internal Transform _vrCamera;
|
||||
private bool _isEmotePlaying;
|
||||
|
||||
// Avatar Info
|
||||
private Animator _animator;
|
||||
|
@ -60,10 +62,10 @@ public class IKManager : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (!_isAvatarInitialized)
|
||||
if (_ikHandler == null)
|
||||
return;
|
||||
|
||||
_ikHandler?.UpdateWeights();
|
||||
_ikHandler.UpdateWeights();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -126,39 +128,47 @@ public class IKManager : MonoBehaviour
|
|||
|
||||
public bool OnPlayerScaled(float scaleDifference)
|
||||
{
|
||||
if (!_isAvatarInitialized)
|
||||
if (_ikHandler == null)
|
||||
return false;
|
||||
|
||||
_ikHandler?.OnPlayerScaled(scaleDifference);
|
||||
_ikHandler.OnPlayerScaled(scaleDifference);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnPlayerSeatedStateChanged(bool isSitting)
|
||||
{
|
||||
if (!_isAvatarInitialized)
|
||||
if (_ikHandler == null)
|
||||
return;
|
||||
|
||||
_ikHandler?.Reset();
|
||||
_ikHandler.Reset();
|
||||
}
|
||||
|
||||
public bool OnPlayerHandleMovementParent(CVRMovementParent movementParent)
|
||||
{
|
||||
if (!_isAvatarInitialized)
|
||||
if (_ikHandler == null)
|
||||
return false;
|
||||
|
||||
_ikHandler?.OnPlayerHandleMovementParent(movementParent, GetPlayerPosition());
|
||||
_ikHandler.OnPlayerHandleMovementParent(movementParent, GetPlayerPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnPlayerTeleported()
|
||||
{
|
||||
if (!_isAvatarInitialized)
|
||||
if (_ikHandler == null)
|
||||
return false;
|
||||
|
||||
_ikHandler?.Reset();
|
||||
_ikHandler.Reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnPlayerUpdate()
|
||||
{
|
||||
if (_ikHandler == null)
|
||||
return;
|
||||
|
||||
_ikHandler.UpdateTracking();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IK Initialization
|
||||
|
|
|
@ -28,6 +28,6 @@ using System.Reflection;
|
|||
namespace NAK.DesktopVRIK.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "4.2.2";
|
||||
public const string Version = "4.2.3";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_id": 117,
|
||||
"name": "DesktopVRIK",
|
||||
"modversion": "4.2.2",
|
||||
"modversion": "4.2.3",
|
||||
"gameversion": "2023r171",
|
||||
"loaderversion": "0.6.1",
|
||||
"modtype": "Mod",
|
||||
|
@ -17,8 +17,8 @@
|
|||
"requirements": [
|
||||
"BTKUILib"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r15/DesktopVRIK.dll",
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r17/DesktopVRIK.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DesktopVRIK/",
|
||||
"changelog": "- Reverted to old way of setting up head ik target. This fixes horrid armatures being bent and broken.",
|
||||
"changelog": "- Fixed an issue where tracking status would update a frame late.",
|
||||
"embedcolor": "#9b59b6"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue