mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Features merge from experimental:
Settings rework Finger tracking networks sync only if hands are tracked Working fix for animator override controller Mass center offset calculations Steps scaling
This commit is contained in:
parent
8338fb758a
commit
971466da24
13 changed files with 474 additions and 451 deletions
|
@ -47,6 +47,11 @@ namespace ml_amt
|
|||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnCalibrate_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
// FBT detour
|
||||
HarmonyInstance.Patch(
|
||||
|
@ -70,16 +75,16 @@ namespace ml_amt
|
|||
null
|
||||
);
|
||||
|
||||
// AAS overriding "fix"
|
||||
// AAS overriding fix
|
||||
HarmonyInstance.Patch(
|
||||
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation), BindingFlags.Instance),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAnimationOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
null
|
||||
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
HarmonyInstance.Patch(
|
||||
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.RestoreOverrideAnimation)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAnimationOverrideRestore_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
null
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
|
@ -93,7 +98,7 @@ namespace ml_amt
|
|||
m_localTweaker = PlayerSetup.Instance.gameObject.AddComponent<MotionTweaker>();
|
||||
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideCrouch);
|
||||
m_localTweaker.SetCrouchLimit(Settings.CrouchLimit);
|
||||
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideProne);
|
||||
m_localTweaker.SetIKOverrideProne(Settings.IKOverrideProne);
|
||||
m_localTweaker.SetProneLimit(Settings.ProneLimit);
|
||||
m_localTweaker.SetPoseTransitions(Settings.PoseTransitions);
|
||||
m_localTweaker.SetAdjustedMovement(Settings.AdjustedMovement);
|
||||
|
@ -153,6 +158,20 @@ namespace ml_amt
|
|||
}
|
||||
}
|
||||
|
||||
static void OnPlayspaceScale_Postfix() => ms_instance?.OnPlayspaceScale();
|
||||
void OnPlayspaceScale()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(m_localTweaker != null)
|
||||
m_localTweaker.OnPlayspaceScale();
|
||||
}
|
||||
catch(System.Exception l_exception)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(l_exception);
|
||||
}
|
||||
}
|
||||
|
||||
// FBT detection override
|
||||
static void FBTDetour_Prefix()
|
||||
{
|
||||
|
@ -237,14 +256,38 @@ namespace ml_amt
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool OnAnimationOverride_Prefix()
|
||||
static void OnOverride_Prefix(ref CVRAnimatorManager __instance, ref bool __state)
|
||||
{
|
||||
return !Settings.OverrideFix;
|
||||
}
|
||||
|
||||
static bool OnAnimationOverrideRestore_Prefix()
|
||||
try
|
||||
{
|
||||
return !Settings.OverrideFix;
|
||||
if(Settings.OverrideFix && (__instance.animator != null))
|
||||
{
|
||||
__state = __instance.animator.enabled;
|
||||
if(__state)
|
||||
__instance.animator.enabled = false;
|
||||
__instance.animator.WriteDefaultValues();
|
||||
}
|
||||
}
|
||||
catch(System.Exception l_exception)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(l_exception);
|
||||
}
|
||||
}
|
||||
static void OnOverride_Postfix(ref CVRAnimatorManager __instance, bool __state)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Settings.OverrideFix && (__instance.animator != null))
|
||||
{
|
||||
__instance.animator.enabled = __state;
|
||||
if(__state)
|
||||
__instance.animator.Update(0f);
|
||||
}
|
||||
}
|
||||
catch(System.Exception l_exception)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(l_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.MovementSystem;
|
||||
using RootMotion.FinalIK;
|
||||
|
@ -44,6 +45,7 @@ namespace ml_amt
|
|||
bool m_grounded = false;
|
||||
bool m_groundedRaw = false;
|
||||
bool m_moving = false;
|
||||
bool m_locomotionOverride = false;
|
||||
|
||||
bool m_ikOverrideCrouch = true;
|
||||
float m_crouchLimit = 0.65f;
|
||||
|
@ -64,6 +66,7 @@ namespace ml_amt
|
|||
bool m_followHips = true;
|
||||
Vector3 m_hipsToPlayer = Vector3.zero;
|
||||
|
||||
Vector2 m_stepDistance = Vector2.zero;
|
||||
Vector3 m_massCenter = Vector3.zero;
|
||||
|
||||
readonly List<AvatarParameter> m_parameters = null;
|
||||
|
@ -73,6 +76,7 @@ namespace ml_amt
|
|||
m_parameters = new List<AvatarParameter>();
|
||||
}
|
||||
|
||||
// Unity events
|
||||
void Start()
|
||||
{
|
||||
m_inVR = Utils.IsInVR();
|
||||
|
@ -87,7 +91,8 @@ namespace ml_amt
|
|||
Settings.IKOverrideJumpChange += this.SetIKOverrideJump;
|
||||
Settings.DetectEmotesChange += this.SetDetectEmotes;
|
||||
Settings.FollowHipsChange += this.SetFollowHips;
|
||||
Settings.MassCenterChange += this.SetMassCenter;
|
||||
Settings.MassCenterChange += this.OnMassCenterChange;
|
||||
Settings.ScaledStepsChange += this.OnScaledStepsChange;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
|
@ -102,7 +107,7 @@ namespace ml_amt
|
|||
Settings.IKOverrideJumpChange -= this.SetIKOverrideJump;
|
||||
Settings.DetectEmotesChange -= this.SetDetectEmotes;
|
||||
Settings.FollowHipsChange -= this.SetFollowHips;
|
||||
Settings.MassCenterChange -= this.SetMassCenter;
|
||||
Settings.MassCenterChange -= this.OnMassCenterChange;
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -116,8 +121,7 @@ namespace ml_amt
|
|||
// Update upright
|
||||
Matrix4x4 l_hmdMatrix = PlayerSetup.Instance.transform.GetMatrix().inverse * (m_inVR ? PlayerSetup.Instance.vrHeadTracker.transform.GetMatrix() : PlayerSetup.Instance.desktopCameraRig.transform.GetMatrix());
|
||||
float l_currentHeight = Mathf.Clamp((l_hmdMatrix * ms_pointVector).y, 0f, float.MaxValue);
|
||||
float l_avatarScale = (m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f;
|
||||
float l_avatarViewHeight = Mathf.Clamp(m_viewPointHeight * l_avatarScale, 0f, float.MaxValue);
|
||||
float l_avatarViewHeight = Mathf.Clamp(m_viewPointHeight * GetRelativeScale(), 0f, float.MaxValue);
|
||||
m_upright = Mathf.Clamp01((l_avatarViewHeight > 0f) ? (l_currentHeight / l_avatarViewHeight) : 0f);
|
||||
m_poseState = (m_upright <= Mathf.Min(m_proneLimit, m_crouchLimit)) ? PoseState.Proning : ((m_upright <= Mathf.Max(m_proneLimit, m_crouchLimit)) ? PoseState.Crouching : PoseState.Standing);
|
||||
|
||||
|
@ -163,6 +167,7 @@ namespace ml_amt
|
|||
}
|
||||
}
|
||||
|
||||
// Game events
|
||||
internal void OnAvatarClear()
|
||||
{
|
||||
m_vrIk = null;
|
||||
|
@ -178,10 +183,12 @@ namespace ml_amt
|
|||
m_locomotionOffset = Vector3.zero;
|
||||
m_emoteActive = false;
|
||||
m_moving = false;
|
||||
m_locomotionOverride = false;
|
||||
m_hipsToPlayer = Vector3.zero;
|
||||
m_avatarHips = null;
|
||||
m_viewPointHeight = 1f;
|
||||
m_massCenter = Vector3.zero;
|
||||
m_stepDistance = Vector2.zero;
|
||||
m_parameters.Clear();
|
||||
}
|
||||
|
||||
|
@ -252,6 +259,8 @@ namespace ml_amt
|
|||
|
||||
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? m_massCenter : m_locomotionOffset);
|
||||
|
||||
m_stepDistance.Set(m_vrIk.solver.locomotion.stepThreshold, m_vrIk.solver.locomotion.footDistance);
|
||||
|
||||
m_vrIk.onPreSolverUpdate.AddListener(this.OnIKPreUpdate);
|
||||
m_vrIk.onPostSolverUpdate.AddListener(this.OnIKPostUpdate);
|
||||
}
|
||||
|
@ -273,9 +282,28 @@ namespace ml_amt
|
|||
}
|
||||
}
|
||||
|
||||
internal void OnPlayspaceScale()
|
||||
{
|
||||
if(m_vrIk != null)
|
||||
{
|
||||
if(Settings.MassCenter)
|
||||
m_vrIk.solver.locomotion.offset = m_massCenter * GetRelativeScale();
|
||||
|
||||
if(Settings.ScaledSteps)
|
||||
{
|
||||
m_vrIk.solver.locomotion.stepThreshold = m_stepDistance.x * GetRelativeScale();
|
||||
m_vrIk.solver.locomotion.footDistance = m_stepDistance.y * GetRelativeScale();
|
||||
|
||||
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
|
||||
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IK events
|
||||
void OnIKPreUpdate()
|
||||
{
|
||||
bool l_legsOverride = false;
|
||||
bool l_locomotionOverride = false;
|
||||
|
||||
m_ikWeight = m_vrIk.solver.IKPositionWeight;
|
||||
m_locomotionWeight = m_vrIk.solver.locomotion.weight;
|
||||
|
@ -286,35 +314,42 @@ namespace ml_amt
|
|||
if(m_detectEmotes && m_emoteActive)
|
||||
m_vrIk.solver.IKPositionWeight = 0f;
|
||||
|
||||
if(!BodySystem.isCalibratedAsFullBody)
|
||||
{
|
||||
if((m_ikOverrideCrouch && (m_poseState != PoseState.Standing)) || (m_ikOverrideProne && (m_poseState == PoseState.Proning)))
|
||||
{
|
||||
m_vrIk.solver.locomotion.weight = 0f;
|
||||
l_legsOverride = true;
|
||||
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
|
||||
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
|
||||
l_locomotionOverride = true;
|
||||
}
|
||||
if(m_ikOverrideFly && MovementSystem.Instance.flying)
|
||||
{
|
||||
m_vrIk.solver.locomotion.weight = 0f;
|
||||
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
|
||||
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
|
||||
l_legsOverride = true;
|
||||
l_locomotionOverride = true;
|
||||
}
|
||||
|
||||
if(m_ikOverrideJump && !m_grounded && !MovementSystem.Instance.flying)
|
||||
{
|
||||
m_vrIk.solver.locomotion.weight = 0f;
|
||||
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
|
||||
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
|
||||
l_legsOverride = true;
|
||||
l_locomotionOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool l_solverActive = !Mathf.Approximately(m_vrIk.solver.IKPositionWeight, 0f);
|
||||
|
||||
if(l_legsOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody)
|
||||
if(l_locomotionOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody)
|
||||
{
|
||||
m_vrIk.solver.plantFeet = false;
|
||||
ABI_RC.Systems.IK.IKSystem.VrikRootController.enabled = false;
|
||||
IKSystem.VrikRootController.enabled = false;
|
||||
PlayerSetup.Instance._avatar.transform.localPosition = m_hipsToPlayer;
|
||||
}
|
||||
|
||||
if(m_locomotionOverride && !l_locomotionOverride)
|
||||
m_vrIk.solver.Reset();
|
||||
m_locomotionOverride = l_locomotionOverride;
|
||||
}
|
||||
|
||||
void OnIKPostUpdate()
|
||||
|
@ -326,25 +361,26 @@ namespace ml_amt
|
|||
m_vrIk.solver.rightLeg.useAnimatedBendNormal = m_bendNormalRight;
|
||||
}
|
||||
|
||||
public void SetIKOverrideCrouch(bool p_state)
|
||||
// Settings
|
||||
internal void SetIKOverrideCrouch(bool p_state)
|
||||
{
|
||||
m_ikOverrideCrouch = p_state;
|
||||
}
|
||||
public void SetCrouchLimit(float p_value)
|
||||
internal void SetCrouchLimit(float p_value)
|
||||
{
|
||||
if(!m_customCrouchLimit)
|
||||
m_crouchLimit = Mathf.Clamp01(p_value);
|
||||
}
|
||||
public void SetIKOverrideProne(bool p_state)
|
||||
internal void SetIKOverrideProne(bool p_state)
|
||||
{
|
||||
m_ikOverrideProne = p_state;
|
||||
}
|
||||
public void SetProneLimit(float p_value)
|
||||
internal void SetProneLimit(float p_value)
|
||||
{
|
||||
if(!m_customProneLimit)
|
||||
m_proneLimit = Mathf.Clamp01(p_value);
|
||||
}
|
||||
public void SetPoseTransitions(bool p_state)
|
||||
internal void SetPoseTransitions(bool p_state)
|
||||
{
|
||||
m_poseTransitions = p_state;
|
||||
|
||||
|
@ -354,7 +390,7 @@ namespace ml_amt
|
|||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false);
|
||||
}
|
||||
}
|
||||
public void SetAdjustedMovement(bool p_state)
|
||||
internal void SetAdjustedMovement(bool p_state)
|
||||
{
|
||||
m_adjustedMovement = p_state;
|
||||
|
||||
|
@ -364,28 +400,54 @@ namespace ml_amt
|
|||
MovementSystem.Instance.ChangeProne(false);
|
||||
}
|
||||
}
|
||||
public void SetIKOverrideFly(bool p_state)
|
||||
internal void SetIKOverrideFly(bool p_state)
|
||||
{
|
||||
m_ikOverrideFly = p_state;
|
||||
}
|
||||
public void SetIKOverrideJump(bool p_state)
|
||||
internal void SetIKOverrideJump(bool p_state)
|
||||
{
|
||||
m_ikOverrideJump = p_state;
|
||||
}
|
||||
public void SetDetectEmotes(bool p_state)
|
||||
internal void SetDetectEmotes(bool p_state)
|
||||
{
|
||||
m_detectEmotes = p_state;
|
||||
}
|
||||
public void SetFollowHips(bool p_state)
|
||||
internal void SetFollowHips(bool p_state)
|
||||
{
|
||||
m_followHips = p_state;
|
||||
}
|
||||
public void SetMassCenter(bool p_state)
|
||||
void OnMassCenterChange(bool p_state)
|
||||
{
|
||||
if(m_vrIk != null)
|
||||
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? m_massCenter : m_locomotionOffset);
|
||||
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? (m_massCenter * GetRelativeScale()) : m_locomotionOffset);
|
||||
}
|
||||
void OnScaledStepsChange(bool p_state)
|
||||
{
|
||||
if(m_vrIk != null)
|
||||
{
|
||||
if(p_state)
|
||||
{
|
||||
m_vrIk.solver.locomotion.stepThreshold = m_stepDistance.x * GetRelativeScale();
|
||||
m_vrIk.solver.locomotion.footDistance = m_stepDistance.y * GetRelativeScale();
|
||||
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
|
||||
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
|
||||
}
|
||||
else
|
||||
{
|
||||
IKSystem.Instance.ApplyAvatarScaleToIk(PlayerSetup.Instance.GetAvatarHeight());
|
||||
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(0.03f);
|
||||
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(0.03f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Arbitrary
|
||||
float GetRelativeScale()
|
||||
{
|
||||
return ((m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f);
|
||||
}
|
||||
|
||||
// Parameters access
|
||||
public float GetUpright() => m_upright;
|
||||
public bool GetGroundedRaw() => m_groundedRaw;
|
||||
public bool GetMoving() => m_moving;
|
||||
|
|
|
@ -20,23 +20,25 @@ namespace ml_amt
|
|||
DetectEmotes,
|
||||
FollowHips,
|
||||
CollisionScale,
|
||||
ScaledSteps,
|
||||
MassCenter,
|
||||
OverrideFix
|
||||
};
|
||||
|
||||
static bool ms_ikOverrideCrouch = true;
|
||||
static float ms_crouchLimit = 0.65f;
|
||||
static bool ms_ikOverrideProne = true;
|
||||
static float ms_proneLimit = 0.3f;
|
||||
static bool ms_poseTransitions = true;
|
||||
static bool ms_adjustedMovement = true;
|
||||
static bool ms_ikOverrideFly = true;
|
||||
static bool ms_ikOverrideJump = true;
|
||||
static bool ms_detectEmotes = true;
|
||||
static bool ms_followHips = true;
|
||||
static bool ms_collisionScale = true;
|
||||
static bool ms_massCenter = true;
|
||||
static bool ms_overrideFix = false;
|
||||
public static bool IKOverrideCrouch { get; private set; } = true;
|
||||
public static float CrouchLimit { get; private set; } = 0.65f;
|
||||
public static bool IKOverrideProne { get; private set; } = true;
|
||||
public static float ProneLimit { get; private set; } = 0.3f;
|
||||
public static bool PoseTransitions { get; private set; } = true;
|
||||
public static bool AdjustedMovement { get; private set; } = true;
|
||||
public static bool IKOverrideFly { get; private set; } = true;
|
||||
public static bool IKOverrideJump { get; private set; } = true;
|
||||
public static bool DetectEmotes { get; private set; } = true;
|
||||
public static bool FollowHips { get; private set; } = true;
|
||||
public static bool MassCenter { get; private set; } = true;
|
||||
public static bool ScaledSteps { get; private set; } = true;
|
||||
public static bool CollisionScale { get; private set; } = true;
|
||||
public static bool OverrideFix { get; private set; } = true;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -51,8 +53,9 @@ namespace ml_amt
|
|||
static public event Action<bool> IKOverrideJumpChange;
|
||||
static public event Action<bool> DetectEmotesChange;
|
||||
static public event Action<bool> FollowHipsChange;
|
||||
static public event Action<bool> CollisionScaleChange;
|
||||
static public event Action<bool> MassCenterChange;
|
||||
static public event Action<bool> ScaledStepsChange;
|
||||
static public event Action<bool> CollisionScaleChange;
|
||||
static public event Action<bool> OverrideFixChange;
|
||||
|
||||
internal static void Init()
|
||||
|
@ -61,19 +64,20 @@ namespace ml_amt
|
|||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), 65),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), 30),
|
||||
ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.OverrideFix.ToString(), false)
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), IKOverrideCrouch),
|
||||
ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), (int)(CrouchLimit * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), IKOverrideProne),
|
||||
ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), (int)(ProneLimit * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), PoseTransitions),
|
||||
ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), AdjustedMovement),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), IKOverrideFly),
|
||||
ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), IKOverrideJump),
|
||||
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), DetectEmotes),
|
||||
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), FollowHips),
|
||||
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), MassCenter),
|
||||
ms_category.CreateEntry(ModSetting.ScaledSteps.ToString(), ScaledSteps),
|
||||
ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), CollisionScale),
|
||||
ms_category.CreateEntry(ModSetting.OverrideFix.ToString(), OverrideFix)
|
||||
};
|
||||
|
||||
Load();
|
||||
|
@ -105,19 +109,20 @@ namespace ml_amt
|
|||
|
||||
static void Load()
|
||||
{
|
||||
ms_ikOverrideCrouch = (bool)ms_entries[(int)ModSetting.IKOverrideCrouch].BoxedValue;
|
||||
ms_crouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
|
||||
ms_ikOverrideProne = (bool)ms_entries[(int)ModSetting.IKOverrideProne].BoxedValue;
|
||||
ms_proneLimit = ((int)ms_entries[(int)ModSetting.ProneLimit].BoxedValue) * 0.01f;
|
||||
ms_poseTransitions = (bool)ms_entries[(int)ModSetting.PoseTransitions].BoxedValue;
|
||||
ms_adjustedMovement = (bool)ms_entries[(int)ModSetting.AdjustedMovement].BoxedValue;
|
||||
ms_ikOverrideFly = (bool)ms_entries[(int)ModSetting.IKOverrideFly].BoxedValue;
|
||||
ms_ikOverrideJump = (bool)ms_entries[(int)ModSetting.IKOverrideJump].BoxedValue;
|
||||
ms_detectEmotes = (bool)ms_entries[(int)ModSetting.DetectEmotes].BoxedValue;
|
||||
ms_followHips = (bool)ms_entries[(int)ModSetting.FollowHips].BoxedValue;
|
||||
ms_collisionScale = (bool)ms_entries[(int)ModSetting.CollisionScale].BoxedValue;
|
||||
ms_massCenter = (bool)ms_entries[(int)ModSetting.MassCenter].BoxedValue;
|
||||
ms_overrideFix = (bool)ms_entries[(int)ModSetting.OverrideFix].BoxedValue;
|
||||
IKOverrideCrouch = (bool)ms_entries[(int)ModSetting.IKOverrideCrouch].BoxedValue;
|
||||
CrouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
|
||||
IKOverrideProne = (bool)ms_entries[(int)ModSetting.IKOverrideProne].BoxedValue;
|
||||
ProneLimit = ((int)ms_entries[(int)ModSetting.ProneLimit].BoxedValue) * 0.01f;
|
||||
PoseTransitions = (bool)ms_entries[(int)ModSetting.PoseTransitions].BoxedValue;
|
||||
AdjustedMovement = (bool)ms_entries[(int)ModSetting.AdjustedMovement].BoxedValue;
|
||||
IKOverrideFly = (bool)ms_entries[(int)ModSetting.IKOverrideFly].BoxedValue;
|
||||
IKOverrideJump = (bool)ms_entries[(int)ModSetting.IKOverrideJump].BoxedValue;
|
||||
DetectEmotes = (bool)ms_entries[(int)ModSetting.DetectEmotes].BoxedValue;
|
||||
FollowHips = (bool)ms_entries[(int)ModSetting.FollowHips].BoxedValue;
|
||||
MassCenter = (bool)ms_entries[(int)ModSetting.MassCenter].BoxedValue;
|
||||
ScaledSteps = (bool)ms_entries[(int)ModSetting.ScaledSteps].BoxedValue;
|
||||
CollisionScale = (bool)ms_entries[(int)ModSetting.CollisionScale].BoxedValue;
|
||||
OverrideFix = (bool)ms_entries[(int)ModSetting.OverrideFix].BoxedValue;
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
|
@ -128,15 +133,15 @@ namespace ml_amt
|
|||
{
|
||||
case ModSetting.CrouchLimit:
|
||||
{
|
||||
ms_crouchLimit = int.Parse(p_value) * 0.01f;
|
||||
CrouchLimitChange?.Invoke(ms_crouchLimit);
|
||||
CrouchLimit = int.Parse(p_value) * 0.01f;
|
||||
CrouchLimitChange?.Invoke(CrouchLimit);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.ProneLimit:
|
||||
{
|
||||
ms_proneLimit = int.Parse(p_value) * 0.01f;
|
||||
ProneLimitChange?.Invoke(ms_proneLimit);
|
||||
ProneLimit = int.Parse(p_value) * 0.01f;
|
||||
ProneLimitChange?.Invoke(ProneLimit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -153,78 +158,85 @@ namespace ml_amt
|
|||
{
|
||||
case ModSetting.IKOverrideCrouch:
|
||||
{
|
||||
ms_ikOverrideCrouch = bool.Parse(p_value);
|
||||
IKOverrideCrouchChange?.Invoke(ms_ikOverrideCrouch);
|
||||
IKOverrideCrouch = bool.Parse(p_value);
|
||||
IKOverrideCrouchChange?.Invoke(IKOverrideCrouch);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.IKOverrideProne:
|
||||
{
|
||||
ms_ikOverrideProne = bool.Parse(p_value);
|
||||
IKOverrideProneChange?.Invoke(ms_ikOverrideProne);
|
||||
IKOverrideProne = bool.Parse(p_value);
|
||||
IKOverrideProneChange?.Invoke(IKOverrideProne);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.PoseTransitions:
|
||||
{
|
||||
ms_poseTransitions = bool.Parse(p_value);
|
||||
PoseTransitionsChange?.Invoke(ms_poseTransitions);
|
||||
PoseTransitions = bool.Parse(p_value);
|
||||
PoseTransitionsChange?.Invoke(PoseTransitions);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AdjustedMovement:
|
||||
{
|
||||
ms_adjustedMovement = bool.Parse(p_value);
|
||||
AdjustedMovementChange?.Invoke(ms_adjustedMovement);
|
||||
AdjustedMovement = bool.Parse(p_value);
|
||||
AdjustedMovementChange?.Invoke(AdjustedMovement);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.IKOverrideFly:
|
||||
{
|
||||
ms_ikOverrideFly = bool.Parse(p_value);
|
||||
IKOverrideFlyChange?.Invoke(ms_ikOverrideFly);
|
||||
IKOverrideFly = bool.Parse(p_value);
|
||||
IKOverrideFlyChange?.Invoke(IKOverrideFly);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.IKOverrideJump:
|
||||
{
|
||||
ms_ikOverrideJump = bool.Parse(p_value);
|
||||
IKOverrideJumpChange?.Invoke(ms_ikOverrideJump);
|
||||
IKOverrideJump = bool.Parse(p_value);
|
||||
IKOverrideJumpChange?.Invoke(IKOverrideJump);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.DetectEmotes:
|
||||
{
|
||||
ms_detectEmotes = bool.Parse(p_value);
|
||||
DetectEmotesChange?.Invoke(ms_detectEmotes);
|
||||
DetectEmotes = bool.Parse(p_value);
|
||||
DetectEmotesChange?.Invoke(DetectEmotes);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FollowHips:
|
||||
{
|
||||
ms_followHips = bool.Parse(p_value);
|
||||
FollowHipsChange?.Invoke(ms_followHips);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.CollisionScale:
|
||||
{
|
||||
ms_collisionScale = bool.Parse(p_value);
|
||||
CollisionScaleChange?.Invoke(ms_collisionScale);
|
||||
FollowHips = bool.Parse(p_value);
|
||||
FollowHipsChange?.Invoke(FollowHips);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.MassCenter:
|
||||
{
|
||||
ms_massCenter = bool.Parse(p_value);
|
||||
MassCenterChange?.Invoke(ms_massCenter);
|
||||
MassCenter = bool.Parse(p_value);
|
||||
MassCenterChange?.Invoke(MassCenter);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.ScaledSteps:
|
||||
{
|
||||
ScaledSteps = bool.Parse(p_value);
|
||||
ScaledStepsChange?.Invoke(ScaledSteps);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.CollisionScale:
|
||||
{
|
||||
CollisionScale = bool.Parse(p_value);
|
||||
CollisionScaleChange?.Invoke(CollisionScale);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.OverrideFix:
|
||||
{
|
||||
ms_overrideFix = bool.Parse(p_value);
|
||||
OverrideFixChange?.Invoke(ms_overrideFix);
|
||||
OverrideFix = bool.Parse(p_value);
|
||||
OverrideFixChange?.Invoke(OverrideFix);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -232,58 +244,5 @@ namespace ml_amt
|
|||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IKOverrideCrouch
|
||||
{
|
||||
get => ms_ikOverrideCrouch;
|
||||
}
|
||||
public static float CrouchLimit
|
||||
{
|
||||
get => ms_crouchLimit;
|
||||
}
|
||||
public static bool IKOverrideProne
|
||||
{
|
||||
get => ms_ikOverrideProne;
|
||||
}
|
||||
public static float ProneLimit
|
||||
{
|
||||
get => ms_proneLimit;
|
||||
}
|
||||
public static bool PoseTransitions
|
||||
{
|
||||
get => ms_poseTransitions;
|
||||
}
|
||||
public static bool AdjustedMovement
|
||||
{
|
||||
get => ms_adjustedMovement;
|
||||
}
|
||||
public static bool IKOverrideFly
|
||||
{
|
||||
get => ms_ikOverrideFly;
|
||||
}
|
||||
public static bool IKOverrideJump
|
||||
{
|
||||
get => ms_ikOverrideJump;
|
||||
}
|
||||
public static bool DetectEmotes
|
||||
{
|
||||
get => ms_detectEmotes;
|
||||
}
|
||||
public static bool FollowHips
|
||||
{
|
||||
get => ms_followHips;
|
||||
}
|
||||
public static bool CollisionScale
|
||||
{
|
||||
get => ms_collisionScale;
|
||||
}
|
||||
public static bool MassCenter
|
||||
{
|
||||
get => ms_massCenter;
|
||||
}
|
||||
public static bool OverrideFix
|
||||
{
|
||||
get => ms_overrideFix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using UnityEngine;
|
||||
using ABI_RC.Systems.IK;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ml_amt
|
||||
{
|
||||
static class Utils
|
||||
{
|
||||
static MethodInfo ms_getSineKeyframes = typeof(RootMotion.FinalIK.IKSolverVR).GetMethod("GetSineKeyframes", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
|
||||
|
||||
// Extensions
|
||||
|
@ -12,5 +14,10 @@ namespace ml_amt
|
|||
{
|
||||
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one);
|
||||
}
|
||||
|
||||
public static Keyframe[] GetSineKeyframes(float p_mag)
|
||||
{
|
||||
return (Keyframe[])ms_getSineKeyframes.Invoke(null, new object[] { p_mag });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,6 +257,13 @@ function inp_toggle_mod_amt(_obj, _callbackName) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Scaled locomotion steps: </div>
|
||||
<div class ="option-input">
|
||||
<div id="ScaledSteps" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Alternative avatar collider scale: </div>
|
||||
<div class ="option-input">
|
||||
|
@ -265,9 +272,9 @@ function inp_toggle_mod_amt(_obj, _callbackName) {
|
|||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Prevent Unity animation override (chairs, etc.): </div>
|
||||
<div class ="option-caption">Fix animation overrides (chairs, etc.): </div>
|
||||
<div class ="option-input">
|
||||
<div id="OverrideFix" class ="inp_toggle no-scroll" data-current="false"></div>
|
||||
<div id="OverrideFix" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace ml_dht
|
|||
Quaternion m_bindRotation;
|
||||
Quaternion m_lastHeadRotation;
|
||||
|
||||
// Unity events
|
||||
void Start()
|
||||
{
|
||||
Settings.EnabledChange += this.SetEnabled;
|
||||
|
@ -56,6 +57,7 @@ namespace ml_dht
|
|||
Settings.FaceOverrideChange -= this.SetFaceOverride;
|
||||
}
|
||||
|
||||
// Tracking updates
|
||||
public void UpdateTrackingData(ref TrackingData p_data)
|
||||
{
|
||||
m_headPosition.Set(p_data.m_headPositionX * (m_mirrored ? -1f : 1f), p_data.m_headPositionY, p_data.m_headPositionZ);
|
||||
|
@ -77,6 +79,7 @@ namespace ml_dht
|
|||
}
|
||||
}
|
||||
|
||||
// Game events
|
||||
internal void OnEyeControllerUpdate(CVREyeController p_component)
|
||||
{
|
||||
if(m_enabled)
|
||||
|
@ -139,7 +142,8 @@ namespace ml_dht
|
|||
m_bindRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
public void SetEnabled(bool p_state)
|
||||
// Settings
|
||||
internal void SetEnabled(bool p_state)
|
||||
{
|
||||
if(m_enabled != p_state)
|
||||
{
|
||||
|
@ -148,7 +152,7 @@ namespace ml_dht
|
|||
m_lastHeadRotation = ((m_headBone != null) ? m_headBone.rotation : m_bindRotation);
|
||||
}
|
||||
}
|
||||
public void SetHeadTracking(bool p_state)
|
||||
internal void SetHeadTracking(bool p_state)
|
||||
{
|
||||
if(m_headTracking != p_state)
|
||||
{
|
||||
|
@ -157,23 +161,23 @@ namespace ml_dht
|
|||
m_lastHeadRotation = ((m_headBone != null) ? m_headBone.rotation : m_bindRotation);
|
||||
}
|
||||
}
|
||||
public void SetEyeTracking(bool p_state)
|
||||
internal void SetEyeTracking(bool p_state)
|
||||
{
|
||||
m_eyeTracking = p_state;
|
||||
}
|
||||
public void SetBlinking(bool p_state)
|
||||
internal void SetBlinking(bool p_state)
|
||||
{
|
||||
m_blinking = p_state;
|
||||
}
|
||||
public void SetSmoothing(float p_value)
|
||||
internal void SetSmoothing(float p_value)
|
||||
{
|
||||
m_smoothing = 1f - Mathf.Clamp(p_value, 0f, 0.99f);
|
||||
}
|
||||
public void SetMirrored(bool p_state)
|
||||
internal void SetMirrored(bool p_state)
|
||||
{
|
||||
m_mirrored = p_state;
|
||||
}
|
||||
public void SetFaceOverride(bool p_state)
|
||||
internal void SetFaceOverride(bool p_state)
|
||||
{
|
||||
m_faceOverride = p_state;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ namespace ml_dht
|
|||
FaceOverride
|
||||
}
|
||||
|
||||
static bool ms_enabled = false;
|
||||
static bool ms_headTracking = true;
|
||||
static bool ms_eyeTracking = true;
|
||||
static bool ms_blinking = true;
|
||||
static bool ms_mirrored = false;
|
||||
static float ms_smoothing = 0.5f;
|
||||
static bool ms_faceOverride = true;
|
||||
public static bool Enabled { get; private set; } = false;
|
||||
public static bool HeadTracking { get; private set; } = true;
|
||||
public static bool EyeTracking { get; private set; } = true;
|
||||
public static bool Blinking { get; private set; } = true;
|
||||
public static bool Mirrored { get; private set; } = false;
|
||||
public static float Smoothing { get; private set; } = 0.5f;
|
||||
public static bool FaceOverride { get; private set; } = true;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -43,13 +43,13 @@ namespace ml_dht
|
|||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), false),
|
||||
ms_category.CreateEntry(ModSetting.HeadTracking.ToString(), false),
|
||||
ms_category.CreateEntry(ModSetting.EyeTracking.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.Blinking.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.Mirrored.ToString(), false),
|
||||
ms_category.CreateEntry(ModSetting.Smoothing.ToString(), 50),
|
||||
ms_category.CreateEntry(ModSetting.FaceOverride.ToString(), true)
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled),
|
||||
ms_category.CreateEntry(ModSetting.HeadTracking.ToString(), HeadTracking),
|
||||
ms_category.CreateEntry(ModSetting.EyeTracking.ToString(), EyeTracking),
|
||||
ms_category.CreateEntry(ModSetting.Blinking.ToString(), Blinking),
|
||||
ms_category.CreateEntry(ModSetting.Mirrored.ToString(), Mirrored),
|
||||
ms_category.CreateEntry(ModSetting.Smoothing.ToString(), (int)(Smoothing * 50f)),
|
||||
ms_category.CreateEntry(ModSetting.FaceOverride.ToString(), FaceOverride)
|
||||
};
|
||||
|
||||
Load();
|
||||
|
@ -81,13 +81,13 @@ namespace ml_dht
|
|||
|
||||
static void Load()
|
||||
{
|
||||
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
ms_headTracking = (bool)ms_entries[(int)ModSetting.HeadTracking].BoxedValue;
|
||||
ms_eyeTracking = (bool)ms_entries[(int)ModSetting.EyeTracking].BoxedValue;
|
||||
ms_blinking = (bool)ms_entries[(int)ModSetting.Blinking].BoxedValue;
|
||||
ms_mirrored = (bool)ms_entries[(int)ModSetting.Mirrored].BoxedValue;
|
||||
ms_smoothing = ((int)ms_entries[(int)ModSetting.Smoothing].BoxedValue) * 0.01f;
|
||||
ms_faceOverride = (bool)ms_entries[(int)ModSetting.FaceOverride].BoxedValue;
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
HeadTracking = (bool)ms_entries[(int)ModSetting.HeadTracking].BoxedValue;
|
||||
EyeTracking = (bool)ms_entries[(int)ModSetting.EyeTracking].BoxedValue;
|
||||
Blinking = (bool)ms_entries[(int)ModSetting.Blinking].BoxedValue;
|
||||
Mirrored = (bool)ms_entries[(int)ModSetting.Mirrored].BoxedValue;
|
||||
Smoothing = ((int)ms_entries[(int)ModSetting.Smoothing].BoxedValue) * 0.01f;
|
||||
FaceOverride = (bool)ms_entries[(int)ModSetting.FaceOverride].BoxedValue;
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
|
@ -98,8 +98,8 @@ namespace ml_dht
|
|||
{
|
||||
case ModSetting.Smoothing:
|
||||
{
|
||||
ms_smoothing = int.Parse(p_value) * 0.01f;
|
||||
SmoothingChange?.Invoke(ms_smoothing);
|
||||
Smoothing = int.Parse(p_value) * 0.01f;
|
||||
SmoothingChange?.Invoke(Smoothing);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -116,43 +116,43 @@ namespace ml_dht
|
|||
{
|
||||
case ModSetting.Enabled:
|
||||
{
|
||||
ms_enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(ms_enabled);
|
||||
Enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(Enabled);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.HeadTracking:
|
||||
{
|
||||
ms_headTracking = bool.Parse(p_value);
|
||||
HeadTrackingChange?.Invoke(ms_headTracking);
|
||||
HeadTracking = bool.Parse(p_value);
|
||||
HeadTrackingChange?.Invoke(HeadTracking);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.EyeTracking:
|
||||
{
|
||||
ms_eyeTracking = bool.Parse(p_value);
|
||||
EyeTrackingChange?.Invoke(ms_eyeTracking);
|
||||
EyeTracking = bool.Parse(p_value);
|
||||
EyeTrackingChange?.Invoke(EyeTracking);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Blinking:
|
||||
{
|
||||
ms_blinking = bool.Parse(p_value);
|
||||
BlinkingChange?.Invoke(ms_blinking);
|
||||
Blinking = bool.Parse(p_value);
|
||||
BlinkingChange?.Invoke(Blinking);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Mirrored:
|
||||
{
|
||||
ms_mirrored = bool.Parse(p_value);
|
||||
MirroredChange?.Invoke(ms_mirrored);
|
||||
Mirrored = bool.Parse(p_value);
|
||||
MirroredChange?.Invoke(Mirrored);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FaceOverride:
|
||||
{
|
||||
ms_faceOverride = bool.Parse(p_value);
|
||||
FaceOverrideChange?.Invoke(ms_faceOverride);
|
||||
FaceOverride = bool.Parse(p_value);
|
||||
FaceOverrideChange?.Invoke(FaceOverride);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -160,34 +160,5 @@ namespace ml_dht
|
|||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get => ms_enabled;
|
||||
}
|
||||
public static bool HeadTracking
|
||||
{
|
||||
get => ms_headTracking;
|
||||
}
|
||||
public static bool EyeTracking
|
||||
{
|
||||
get => ms_eyeTracking;
|
||||
}
|
||||
public static bool Blinking
|
||||
{
|
||||
get => ms_blinking;
|
||||
}
|
||||
public static bool Mirrored
|
||||
{
|
||||
get => ms_mirrored;
|
||||
}
|
||||
public static float Smoothing
|
||||
{
|
||||
get => ms_smoothing;
|
||||
}
|
||||
public static bool FaceOverride
|
||||
{
|
||||
get => ms_faceOverride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ namespace ml_lme
|
|||
[DisallowMultipleComponent]
|
||||
class LeapInput : CVRInputModule
|
||||
{
|
||||
static readonly FieldInfo ms_indexGestureToggle = typeof(InputModuleSteamVR).GetField("_steamVrIndexGestureToggleValue", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
CVRInputManager m_inputManager = null;
|
||||
InputModuleSteamVR m_steamVrModule = null;
|
||||
bool m_inVR = false;
|
||||
|
@ -123,8 +121,18 @@ namespace ml_lme
|
|||
{
|
||||
if(l_data.m_leftHand.m_present)
|
||||
SetFingersInput(l_data.m_leftHand, true);
|
||||
|
||||
if(l_data.m_rightHand.m_present)
|
||||
SetFingersInput(l_data.m_rightHand, false);
|
||||
|
||||
if(m_inVR)
|
||||
{
|
||||
m_inputManager.individualFingerTracking = !m_steamVrModule.GetIndexGestureToggle();
|
||||
m_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
}
|
||||
else
|
||||
m_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
|
||||
}
|
||||
|
||||
m_handRayLeft.enabled = (l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly));
|
||||
|
@ -240,15 +248,12 @@ namespace ml_lme
|
|||
// Arbitrary
|
||||
void UpdateFingerTracking()
|
||||
{
|
||||
m_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && Utils.AreKnucklesInUse() && !(bool)ms_indexGestureToggle.GetValue(m_steamVrModule)));
|
||||
m_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && Utils.AreKnucklesInUse() && !m_steamVrModule.GetIndexGestureToggle()));
|
||||
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
|
||||
}
|
||||
|
||||
void SetFingersInput(GestureMatcher.HandData p_hand, bool p_left)
|
||||
{
|
||||
m_inputManager.individualFingerTracking = true;
|
||||
IKSystem.Instance.FingerSystem.controlActive = true;
|
||||
|
||||
if(p_left)
|
||||
{
|
||||
m_inputManager.fingerCurlLeftThumb = p_hand.m_bends[0];
|
||||
|
@ -256,11 +261,6 @@ namespace ml_lme
|
|||
m_inputManager.fingerCurlLeftMiddle = p_hand.m_bends[2];
|
||||
m_inputManager.fingerCurlLeftRing = p_hand.m_bends[3];
|
||||
m_inputManager.fingerCurlLeftPinky = p_hand.m_bends[4];
|
||||
IKSystem.Instance.FingerSystem.leftThumbCurl = p_hand.m_bends[0];
|
||||
IKSystem.Instance.FingerSystem.leftIndexCurl = p_hand.m_bends[1];
|
||||
IKSystem.Instance.FingerSystem.leftMiddleCurl = p_hand.m_bends[2];
|
||||
IKSystem.Instance.FingerSystem.leftRingCurl = p_hand.m_bends[3];
|
||||
IKSystem.Instance.FingerSystem.leftPinkyCurl = p_hand.m_bends[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -269,14 +269,10 @@ namespace ml_lme
|
|||
m_inputManager.fingerCurlRightMiddle = p_hand.m_bends[2];
|
||||
m_inputManager.fingerCurlRightRing = p_hand.m_bends[3];
|
||||
m_inputManager.fingerCurlRightPinky = p_hand.m_bends[4];
|
||||
IKSystem.Instance.FingerSystem.rightThumbCurl = p_hand.m_bends[0];
|
||||
IKSystem.Instance.FingerSystem.rightIndexCurl = p_hand.m_bends[1];
|
||||
IKSystem.Instance.FingerSystem.rightMiddleCurl = p_hand.m_bends[2];
|
||||
IKSystem.Instance.FingerSystem.rightRingCurl = p_hand.m_bends[3];
|
||||
IKSystem.Instance.FingerSystem.rightPinkyCurl = p_hand.m_bends[4];
|
||||
}
|
||||
}
|
||||
|
||||
// Game settings
|
||||
void OnGameSettingBoolChange(string p_name, bool p_state)
|
||||
{
|
||||
if(p_name == "ControlUseGripToGrab")
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace ml_lme
|
|||
bool m_leftTargetActive = false;
|
||||
bool m_rightTargetActive = false;
|
||||
|
||||
// Unity events
|
||||
void Start()
|
||||
{
|
||||
m_inVR = Utils.IsInVR();
|
||||
|
@ -51,51 +52,20 @@ namespace ml_lme
|
|||
m_rightHandTarget.localPosition = Vector3.zero;
|
||||
m_rightHandTarget.localRotation = Quaternion.identity;
|
||||
|
||||
Settings.EnabledChange += this.SetEnabled;
|
||||
Settings.FingersOnlyChange += this.SetFingersOnly;
|
||||
Settings.TrackElbowsChange += this.SetTrackElbows;
|
||||
Settings.EnabledChange += this.OnEnabledChange;
|
||||
Settings.FingersOnlyChange += this.OnFingersOnlyChange;
|
||||
Settings.TrackElbowsChange += this.OnTrackElbowsChange;
|
||||
|
||||
SetEnabled(Settings.Enabled);
|
||||
SetFingersOnly(Settings.FingersOnly);
|
||||
SetTrackElbows(Settings.TrackElbows);
|
||||
OnEnabledChange(Settings.Enabled);
|
||||
OnFingersOnlyChange(Settings.FingersOnly);
|
||||
OnTrackElbowsChange(Settings.TrackElbows);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Settings.EnabledChange -= this.SetEnabled;
|
||||
Settings.FingersOnlyChange -= this.SetFingersOnly;
|
||||
Settings.TrackElbowsChange -= this.SetTrackElbows;
|
||||
}
|
||||
|
||||
void SetEnabled(bool p_state)
|
||||
{
|
||||
m_enabled = p_state;
|
||||
|
||||
RefreshArmIK();
|
||||
if(!m_enabled || m_fingersOnly)
|
||||
RestoreVRIK();
|
||||
}
|
||||
|
||||
void SetFingersOnly(bool p_state)
|
||||
{
|
||||
m_fingersOnly = p_state;
|
||||
|
||||
RefreshArmIK();
|
||||
if(!m_enabled || m_fingersOnly)
|
||||
RestoreVRIK();
|
||||
}
|
||||
|
||||
void SetTrackElbows(bool p_state)
|
||||
{
|
||||
m_trackElbows = p_state;
|
||||
|
||||
if((m_leftArmIK != null) && (m_rightArmIK != null))
|
||||
{
|
||||
m_leftArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_rightArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
}
|
||||
|
||||
RestoreVRIK();
|
||||
Settings.EnabledChange -= this.OnEnabledChange;
|
||||
Settings.FingersOnlyChange -= this.OnFingersOnlyChange;
|
||||
Settings.TrackElbowsChange -= this.OnTrackElbowsChange;
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -159,15 +129,18 @@ namespace ml_lme
|
|||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
|
||||
Vector3 l_hipsLocalPos = m_hips.localPosition;
|
||||
Quaternion l_hipsLocalRot = m_hips.localRotation;
|
||||
|
||||
m_poseHandler.GetHumanPose(ref m_pose);
|
||||
UpdateFingers(l_data);
|
||||
m_poseHandler.SetHumanPose(ref m_pose);
|
||||
|
||||
m_hips.localPosition = l_hipsLocalPos;
|
||||
m_hips.localRotation = l_hipsLocalRot;
|
||||
}
|
||||
}
|
||||
|
||||
// Tracking update
|
||||
void UpdateFingers(GestureMatcher.LeapData p_data)
|
||||
{
|
||||
if(p_data.m_leftHand.m_present)
|
||||
|
@ -227,6 +200,7 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
// Game events
|
||||
internal void OnAvatarClear()
|
||||
{
|
||||
m_vrIK = null;
|
||||
|
@ -348,6 +322,7 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
// IK updates
|
||||
void OnIKPreUpdate()
|
||||
{
|
||||
m_armsWeights.Set(
|
||||
|
@ -376,6 +351,39 @@ namespace ml_lme
|
|||
m_vrIK.solver.rightArm.rotationWeight = m_armsWeights.w;
|
||||
}
|
||||
|
||||
// Settings
|
||||
void OnEnabledChange(bool p_state)
|
||||
{
|
||||
m_enabled = p_state;
|
||||
|
||||
RefreshArmIK();
|
||||
if(!m_enabled || m_fingersOnly)
|
||||
RestoreVRIK();
|
||||
}
|
||||
|
||||
void OnFingersOnlyChange(bool p_state)
|
||||
{
|
||||
m_fingersOnly = p_state;
|
||||
|
||||
RefreshArmIK();
|
||||
if(!m_enabled || m_fingersOnly)
|
||||
RestoreVRIK();
|
||||
}
|
||||
|
||||
void OnTrackElbowsChange(bool p_state)
|
||||
{
|
||||
m_trackElbows = p_state;
|
||||
|
||||
if((m_leftArmIK != null) && (m_rightArmIK != null))
|
||||
{
|
||||
m_leftArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_rightArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
}
|
||||
|
||||
RestoreVRIK();
|
||||
}
|
||||
|
||||
// Arbitrary
|
||||
void RestoreVRIK()
|
||||
{
|
||||
if(m_vrIK != null)
|
||||
|
|
|
@ -37,18 +37,18 @@ namespace ml_lme
|
|||
GripThreadhold
|
||||
};
|
||||
|
||||
static bool ms_enabled = false;
|
||||
static Vector3 ms_desktopOffset = new Vector3(0f, -0.45f, 0.3f);
|
||||
static bool ms_fingersOnly = false;
|
||||
static bool ms_modelVisibility = false;
|
||||
static LeapTrackingMode ms_trackingMode = LeapTrackingMode.Desktop;
|
||||
static Vector3 ms_rootAngle = Vector3.zero;
|
||||
static bool ms_headAttach = false;
|
||||
static Vector3 ms_headOffset = new Vector3(0f, -0.3f, 0.15f);
|
||||
static bool ms_trackElbows = true;
|
||||
static bool ms_input = true;
|
||||
static float ms_interactThreadhold = 0.8f;
|
||||
static float ms_gripThreadhold = 0.4f;
|
||||
public static bool Enabled { get; private set; } = false;
|
||||
public static Vector3 DesktopOffset { get; private set; } = new Vector3(0f, -0.45f, 0.3f);
|
||||
public static bool FingersOnly { get; private set; } = false;
|
||||
public static bool ModelVisibility { get; private set; } = false;
|
||||
public static LeapTrackingMode TrackingMode { get; private set; } = LeapTrackingMode.Desktop;
|
||||
public static Vector3 RootAngle { get; private set; } = Vector3.zero;
|
||||
public static bool HeadAttach { get; private set; } = false;
|
||||
public static Vector3 HeadOffset { get; private set; } = new Vector3(0f, -0.3f, 0.15f);
|
||||
public static bool TrackElbows { get; private set; } = true;
|
||||
public static bool Input { get; private set; } = true;
|
||||
public static float InteractThreadhold { get; private set; } = 0.8f;
|
||||
public static float GripThreadhold { get; private set; } = 0.4f;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -72,24 +72,24 @@ namespace ml_lme
|
|||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), ms_enabled),
|
||||
ms_category.CreateEntry(ModSetting.DesktopX.ToString(), 0),
|
||||
ms_category.CreateEntry(ModSetting.DesktopY.ToString(), -45),
|
||||
ms_category.CreateEntry(ModSetting.DesktopZ.ToString(), 30),
|
||||
ms_category.CreateEntry(ModSetting.FingersOnly.ToString(), ms_modelVisibility),
|
||||
ms_category.CreateEntry(ModSetting.Model.ToString(), ms_modelVisibility),
|
||||
ms_category.CreateEntry(ModSetting.Mode.ToString(), (int)ms_trackingMode),
|
||||
ms_category.CreateEntry(ModSetting.AngleX.ToString(), 0),
|
||||
ms_category.CreateEntry(ModSetting.AngleY.ToString(), 0),
|
||||
ms_category.CreateEntry(ModSetting.AngleZ.ToString(), 0),
|
||||
ms_category.CreateEntry(ModSetting.Head.ToString(), ms_headAttach),
|
||||
ms_category.CreateEntry(ModSetting.HeadX.ToString(), 0),
|
||||
ms_category.CreateEntry(ModSetting.HeadY.ToString(), -30),
|
||||
ms_category.CreateEntry(ModSetting.HeadZ.ToString(), 15),
|
||||
ms_category.CreateEntry(ModSetting.TrackElbows.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.Input.ToString(), true),
|
||||
ms_category.CreateEntry(ModSetting.InteractThreadhold.ToString(), 80),
|
||||
ms_category.CreateEntry(ModSetting.GripThreadhold.ToString(), 40),
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled),
|
||||
ms_category.CreateEntry(ModSetting.DesktopX.ToString(), (int)(DesktopOffset.x * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.DesktopY.ToString(), (int)(DesktopOffset.y * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.DesktopZ.ToString(), (int)(DesktopOffset.z * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.FingersOnly.ToString(), FingersOnly),
|
||||
ms_category.CreateEntry(ModSetting.Model.ToString(), ModelVisibility),
|
||||
ms_category.CreateEntry(ModSetting.Mode.ToString(), (int)TrackingMode),
|
||||
ms_category.CreateEntry(ModSetting.AngleX.ToString(), (int)(RootAngle.x * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.AngleY.ToString(), (int)(RootAngle.y * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.AngleZ.ToString(), (int)(RootAngle.z * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.Head.ToString(), HeadAttach),
|
||||
ms_category.CreateEntry(ModSetting.HeadX.ToString(), (int)(HeadOffset.x * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.HeadY.ToString(), (int)(HeadOffset.y * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.HeadZ.ToString(), (int)(HeadOffset.z * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.TrackElbows.ToString(), TrackElbows),
|
||||
ms_category.CreateEntry(ModSetting.Input.ToString(), Input),
|
||||
ms_category.CreateEntry(ModSetting.InteractThreadhold.ToString(), (int)(InteractThreadhold * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.GripThreadhold.ToString(), (int)(GripThreadhold * 100f)),
|
||||
};
|
||||
|
||||
Load();
|
||||
|
@ -122,30 +122,30 @@ namespace ml_lme
|
|||
|
||||
static void Load()
|
||||
{
|
||||
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
ms_desktopOffset = new Vector3(
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
DesktopOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.DesktopX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopZ].BoxedValue
|
||||
) * 0.01f;
|
||||
ms_fingersOnly = (bool)ms_entries[(int)ModSetting.FingersOnly].BoxedValue;
|
||||
ms_modelVisibility = (bool)ms_entries[(int)ModSetting.Model].BoxedValue;
|
||||
ms_trackingMode = (LeapTrackingMode)(int)ms_entries[(int)ModSetting.Mode].BoxedValue;
|
||||
ms_rootAngle = new Vector3(
|
||||
FingersOnly = (bool)ms_entries[(int)ModSetting.FingersOnly].BoxedValue;
|
||||
ModelVisibility = (bool)ms_entries[(int)ModSetting.Model].BoxedValue;
|
||||
TrackingMode = (LeapTrackingMode)(int)ms_entries[(int)ModSetting.Mode].BoxedValue;
|
||||
RootAngle = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.AngleX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleZ].BoxedValue
|
||||
);
|
||||
ms_headAttach = (bool)ms_entries[(int)ModSetting.Head].BoxedValue;
|
||||
ms_headOffset = new Vector3(
|
||||
HeadAttach = (bool)ms_entries[(int)ModSetting.Head].BoxedValue;
|
||||
HeadOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.HeadX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadZ].BoxedValue
|
||||
) * 0.01f;
|
||||
ms_trackElbows = (bool)ms_entries[(int)ModSetting.TrackElbows].BoxedValue;
|
||||
ms_input = (bool)ms_entries[(int)ModSetting.Input].BoxedValue;
|
||||
ms_interactThreadhold = (int)ms_entries[(int)ModSetting.InteractThreadhold].BoxedValue * 0.01f;
|
||||
ms_gripThreadhold = (int)ms_entries[(int)ModSetting.GripThreadhold].BoxedValue * 0.01f;
|
||||
TrackElbows = (bool)ms_entries[(int)ModSetting.TrackElbows].BoxedValue;
|
||||
Input = (bool)ms_entries[(int)ModSetting.Input].BoxedValue;
|
||||
InteractThreadhold = (int)ms_entries[(int)ModSetting.InteractThreadhold].BoxedValue * 0.01f;
|
||||
GripThreadhold = (int)ms_entries[(int)ModSetting.GripThreadhold].BoxedValue * 0.01f;
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
|
@ -156,43 +156,43 @@ namespace ml_lme
|
|||
{
|
||||
case ModSetting.Enabled:
|
||||
{
|
||||
ms_enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(ms_enabled);
|
||||
Enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(Enabled);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FingersOnly:
|
||||
{
|
||||
ms_fingersOnly = bool.Parse(p_value);
|
||||
FingersOnlyChange?.Invoke(ms_fingersOnly);
|
||||
FingersOnly = bool.Parse(p_value);
|
||||
FingersOnlyChange?.Invoke(FingersOnly);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Model:
|
||||
{
|
||||
ms_modelVisibility = bool.Parse(p_value);
|
||||
ModelVisibilityChange?.Invoke(ms_modelVisibility);
|
||||
ModelVisibility = bool.Parse(p_value);
|
||||
ModelVisibilityChange?.Invoke(ModelVisibility);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Head:
|
||||
{
|
||||
ms_headAttach = bool.Parse(p_value);
|
||||
HeadAttachChange?.Invoke(ms_headAttach);
|
||||
HeadAttach = bool.Parse(p_value);
|
||||
HeadAttachChange?.Invoke(HeadAttach);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.TrackElbows:
|
||||
{
|
||||
ms_trackElbows = bool.Parse(p_value);
|
||||
TrackElbowsChange?.Invoke(ms_trackElbows);
|
||||
TrackElbows = bool.Parse(p_value);
|
||||
TrackElbowsChange?.Invoke(TrackElbows);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Input:
|
||||
{
|
||||
ms_input = bool.Parse(p_value);
|
||||
InputChange?.Invoke(ms_input);
|
||||
Input = bool.Parse(p_value);
|
||||
InputChange?.Invoke(Input);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -209,72 +209,90 @@ namespace ml_lme
|
|||
{
|
||||
case ModSetting.DesktopX:
|
||||
{
|
||||
ms_desktopOffset.x = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopY:
|
||||
{
|
||||
ms_desktopOffset.y = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopZ:
|
||||
{
|
||||
ms_desktopOffset.z = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleX:
|
||||
{
|
||||
ms_rootAngle.x = int.Parse(p_value);
|
||||
RootAngleChange?.Invoke(ms_rootAngle);
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.x = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleY:
|
||||
{
|
||||
ms_rootAngle.y = int.Parse(p_value);
|
||||
RootAngleChange?.Invoke(ms_rootAngle);
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.y = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleZ:
|
||||
{
|
||||
ms_rootAngle.z = int.Parse(p_value);
|
||||
RootAngleChange?.Invoke(ms_rootAngle);
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.z = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.HeadX:
|
||||
{
|
||||
ms_headOffset.x = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadY:
|
||||
{
|
||||
ms_headOffset.y = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadZ:
|
||||
{
|
||||
ms_headOffset.z = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.InteractThreadhold:
|
||||
{
|
||||
ms_interactThreadhold = int.Parse(p_value) * 0.01f;
|
||||
InteractThreadholdChange?.Invoke(ms_interactThreadhold);
|
||||
InteractThreadhold = int.Parse(p_value) * 0.01f;
|
||||
InteractThreadholdChange?.Invoke(InteractThreadhold);
|
||||
}
|
||||
break;
|
||||
case ModSetting.GripThreadhold:
|
||||
{
|
||||
ms_gripThreadhold = int.Parse(p_value) * 0.01f;
|
||||
GripThreadholdChange?.Invoke(ms_gripThreadhold);
|
||||
GripThreadhold = int.Parse(p_value) * 0.01f;
|
||||
GripThreadholdChange?.Invoke(GripThreadhold);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -291,8 +309,8 @@ namespace ml_lme
|
|||
{
|
||||
case ModSetting.Mode:
|
||||
{
|
||||
ms_trackingMode = (LeapTrackingMode)int.Parse(p_value);
|
||||
TrackingModeChange?.Invoke(ms_trackingMode);
|
||||
TrackingMode = (LeapTrackingMode)int.Parse(p_value);
|
||||
TrackingModeChange?.Invoke(TrackingMode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -300,54 +318,5 @@ namespace ml_lme
|
|||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get => ms_enabled;
|
||||
}
|
||||
public static Vector3 DesktopOffset
|
||||
{
|
||||
get => ms_desktopOffset;
|
||||
}
|
||||
public static bool FingersOnly
|
||||
{
|
||||
get => ms_fingersOnly;
|
||||
}
|
||||
public static bool ModelVisibility
|
||||
{
|
||||
get => ms_modelVisibility;
|
||||
}
|
||||
public static LeapTrackingMode TrackingMode
|
||||
{
|
||||
get => ms_trackingMode;
|
||||
}
|
||||
public static Vector3 RootAngle
|
||||
{
|
||||
get => ms_rootAngle;
|
||||
}
|
||||
public static bool HeadAttach
|
||||
{
|
||||
get => ms_headAttach;
|
||||
}
|
||||
public static Vector3 HeadOffset
|
||||
{
|
||||
get => ms_headOffset;
|
||||
}
|
||||
public static bool TrackElbows
|
||||
{
|
||||
get => ms_trackElbows;
|
||||
}
|
||||
public static bool Input
|
||||
{
|
||||
get => ms_input;
|
||||
}
|
||||
public static float InteractThreadhold
|
||||
{
|
||||
get => ms_interactThreadhold;
|
||||
}
|
||||
public static float GripThreadhold
|
||||
{
|
||||
get => ms_gripThreadhold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.UI;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme
|
||||
|
@ -9,9 +11,11 @@ namespace ml_lme
|
|||
{
|
||||
static readonly Quaternion ms_hmdRotationFix = new Quaternion(0f, 0.7071068f, 0.7071068f, 0f);
|
||||
static readonly Quaternion ms_screentopRotationFix = new Quaternion(0f, 0f, -1f, 0f);
|
||||
static readonly FieldInfo ms_indexGestureToggle = typeof(InputModuleSteamVR).GetField("_steamVrIndexGestureToggleValue", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
|
||||
public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded);
|
||||
public static bool AreKnucklesInUse() => PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles");
|
||||
public static bool GetIndexGestureToggle(this InputModuleSteamVR p_module) => (bool)ms_indexGestureToggle.GetValue(p_module);
|
||||
public static bool IsLeftHandTracked() => ((VRTrackerManager.Instance.leftHand != null) && VRTrackerManager.Instance.leftHand.active);
|
||||
public static bool IsRightHandTracked() => ((VRTrackerManager.Instance.rightHand != null) && VRTrackerManager.Instance.rightHand.active);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace ml_pam
|
|||
Matrix4x4 m_offset = Matrix4x4.identity;
|
||||
bool m_targetActive = false;
|
||||
|
||||
// Unity events
|
||||
void Start()
|
||||
{
|
||||
m_inVR = Utils.IsInVR();
|
||||
|
@ -67,6 +68,7 @@ namespace ml_pam
|
|||
}
|
||||
}
|
||||
|
||||
// IK updates
|
||||
void OnIKPreUpdate()
|
||||
{
|
||||
m_armWeight.Set(m_vrIK.solver.rightArm.positionWeight, m_vrIK.solver.rightArm.rotationWeight);
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace ml_pam
|
|||
GrabOffset
|
||||
}
|
||||
|
||||
static bool ms_enabled = true;
|
||||
static float ms_grabOffset = 0.25f;
|
||||
public static bool Enabled { get; private set; } = true;
|
||||
public static float GrabOffset { get; private set; } = 0.25f;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -28,8 +28,8 @@ namespace ml_pam
|
|||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), ms_enabled),
|
||||
ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), 25),
|
||||
ms_category.CreateEntry(ModSetting.Enabled.ToString(), Enabled),
|
||||
ms_category.CreateEntry(ModSetting.GrabOffset.ToString(), (int)(GrabOffset * 100f)),
|
||||
};
|
||||
|
||||
Load();
|
||||
|
@ -61,8 +61,8 @@ namespace ml_pam
|
|||
|
||||
static void Load()
|
||||
{
|
||||
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
ms_grabOffset = (int)ms_entries[(int)ModSetting.GrabOffset].BoxedValue * 0.01f;
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
GrabOffset = (int)ms_entries[(int)ModSetting.GrabOffset].BoxedValue * 0.01f;
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
|
@ -73,8 +73,8 @@ namespace ml_pam
|
|||
{
|
||||
case ModSetting.Enabled:
|
||||
{
|
||||
ms_enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(ms_enabled);
|
||||
Enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(Enabled);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ namespace ml_pam
|
|||
{
|
||||
case ModSetting.GrabOffset:
|
||||
{
|
||||
ms_grabOffset = int.Parse(p_value) * 0.01f;
|
||||
GrabOffsetChange?.Invoke(ms_grabOffset);
|
||||
GrabOffset = int.Parse(p_value) * 0.01f;
|
||||
GrabOffsetChange?.Invoke(GrabOffset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -100,14 +100,5 @@ namespace ml_pam
|
|||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
{
|
||||
get => ms_enabled;
|
||||
}
|
||||
public static float GrabOffset
|
||||
{
|
||||
get => ms_grabOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue