mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Update to build 2023r171ex7p2
This commit is contained in:
parent
6f8fa13c94
commit
d210ed4636
76 changed files with 3349 additions and 1220 deletions
|
@ -2,20 +2,19 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
class LeapInput : CVRInputModule
|
||||
{
|
||||
CVRInputManager m_inputManager = null;
|
||||
InputModuleOpenXR m_openXrModule = null;
|
||||
bool m_inVR = false;
|
||||
bool m_gripToGrab = true;
|
||||
|
||||
bool m_handVisibleLeft = false;
|
||||
bool m_handVisibleRight = false;
|
||||
ControllerRay m_handRayLeft = null;
|
||||
ControllerRay m_handRayRight = null;
|
||||
LineRenderer m_lineLeft = null;
|
||||
|
@ -25,22 +24,31 @@ namespace ml_lme
|
|||
bool m_gripLeft = false;
|
||||
bool m_gripRight = false;
|
||||
|
||||
public new void Start()
|
||||
~LeapInput()
|
||||
{
|
||||
base.Start();
|
||||
Settings.EnabledChange -= this.OnEnableChange;
|
||||
Settings.InputChange -= this.OnInputChange;
|
||||
|
||||
MetaPort.Instance.settings.settingBoolChanged.RemoveListener(this.OnGameSettingBoolChange);
|
||||
}
|
||||
|
||||
public override void ModuleAdded()
|
||||
{
|
||||
base.ModuleAdded();
|
||||
|
||||
InputEnabled = Settings.Enabled;
|
||||
HapticFeedback = false;
|
||||
|
||||
m_inputManager = CVRInputManager.Instance; // _inputManager is stripped out, cool beans
|
||||
m_openXrModule = m_inputManager.GetComponent<InputModuleOpenXR>();
|
||||
m_inVR = Utils.IsInVR();
|
||||
|
||||
m_handRayLeft = LeapTracking.GetInstance().GetLeftHand().gameObject.AddComponent<ControllerRay>();
|
||||
m_handRayLeft = LeapTracking.Instance.GetLeftHand().gameObject.AddComponent<ControllerRay>();
|
||||
m_handRayLeft.hand = true;
|
||||
m_handRayLeft.generalMask = -1485;
|
||||
m_handRayLeft.isInteractionRay = true;
|
||||
m_handRayLeft.triggerGazeEvents = false;
|
||||
m_handRayLeft.holderRoot = m_handRayLeft.gameObject;
|
||||
|
||||
m_handRayRight = LeapTracking.GetInstance().GetRightHand().gameObject.AddComponent<ControllerRay>();
|
||||
m_handRayRight = LeapTracking.Instance.GetRightHand().gameObject.AddComponent<ControllerRay>();
|
||||
m_handRayRight.hand = false;
|
||||
m_handRayRight.generalMask = -1485;
|
||||
m_handRayRight.isInteractionRay = true;
|
||||
|
@ -107,43 +115,64 @@ namespace ml_lme
|
|||
m_lineRight.gameObject.layer = PlayerSetup.Instance.leftRay.gameObject.layer;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
Settings.EnabledChange -= this.OnEnableChange;
|
||||
Settings.InputChange -= this.OnInputChange;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
|
||||
if(Settings.Enabled)
|
||||
{
|
||||
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_openXrModule.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));
|
||||
m_handRayRight.enabled = (l_data.m_rightHand.m_present && (!m_inVR || !Utils.IsRightHandTracked() || !Settings.FingersOnly));
|
||||
}
|
||||
|
||||
public override void UpdateInput()
|
||||
{
|
||||
if(Settings.Enabled && Settings.Input)
|
||||
if(InputEnabled)
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if(l_data.m_leftHand.m_present)
|
||||
{
|
||||
SetFingersInput(l_data.m_leftHand, true);
|
||||
m_handVisibleLeft = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_handVisibleLeft)
|
||||
{
|
||||
ResetFingers(true);
|
||||
m_handVisibleLeft = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(l_data.m_rightHand.m_present)
|
||||
{
|
||||
SetFingersInput(l_data.m_rightHand, false);
|
||||
m_handVisibleRight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_handVisibleRight)
|
||||
{
|
||||
ResetFingers(false);
|
||||
m_handVisibleRight = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!ModSupporter.SkipFingersOverride())
|
||||
{
|
||||
if(m_inVR)
|
||||
{
|
||||
_inputManager.individualFingerTracking = !CVRInputManager._moduleXR.GestureToggleValue;
|
||||
_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
}
|
||||
else
|
||||
_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
IKSystem.Instance.FingerSystem.controlActive = _inputManager.individualFingerTracking;
|
||||
}
|
||||
|
||||
m_handRayLeft.enabled = (l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly));
|
||||
m_handRayRight.enabled = (l_data.m_rightHand.m_present && (!m_inVR || !Utils.IsRightHandTracked() || !Settings.FingersOnly));
|
||||
|
||||
base.UpdateInput();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update_Interaction()
|
||||
{
|
||||
if(Settings.Input)
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if(l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly))
|
||||
{
|
||||
|
@ -154,22 +183,22 @@ namespace ml_lme
|
|||
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength));
|
||||
else
|
||||
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(0f, Settings.InteractThreadhold, l_strength));
|
||||
m_inputManager.interactLeftValue = Mathf.Max(l_interactValue, m_inputManager.interactLeftValue);
|
||||
_inputManager.interactLeftValue = Mathf.Max(l_interactValue, _inputManager.interactLeftValue);
|
||||
|
||||
if(m_interactLeft != (l_strength > Settings.InteractThreadhold))
|
||||
{
|
||||
m_interactLeft = (l_strength > Settings.InteractThreadhold);
|
||||
m_inputManager.interactLeftDown |= m_interactLeft;
|
||||
m_inputManager.interactLeftUp |= !m_interactLeft;
|
||||
_inputManager.interactLeftDown |= m_interactLeft;
|
||||
_inputManager.interactLeftUp |= !m_interactLeft;
|
||||
}
|
||||
|
||||
float l_gripValue = Mathf.Clamp01(Mathf.InverseLerp(0f, Settings.GripThreadhold, l_strength));
|
||||
m_inputManager.gripLeftValue = Mathf.Max(l_gripValue, m_inputManager.gripLeftValue);
|
||||
_inputManager.gripLeftValue = Mathf.Max(l_gripValue, _inputManager.gripLeftValue);
|
||||
if(m_gripLeft != (l_strength > Settings.GripThreadhold))
|
||||
{
|
||||
m_gripLeft = (l_strength > Settings.GripThreadhold);
|
||||
m_inputManager.gripLeftDown |= m_gripLeft;
|
||||
m_inputManager.gripLeftUp |= !m_gripLeft;
|
||||
_inputManager.gripLeftDown |= m_gripLeft;
|
||||
_inputManager.gripLeftUp |= !m_gripLeft;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,22 +211,22 @@ namespace ml_lme
|
|||
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength));
|
||||
else
|
||||
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(0f, Settings.InteractThreadhold, l_strength));
|
||||
m_inputManager.interactRightValue = Mathf.Max(l_interactValue, m_inputManager.interactRightValue);
|
||||
_inputManager.interactRightValue = Mathf.Max(l_interactValue, _inputManager.interactRightValue);
|
||||
|
||||
if(m_interactRight != (l_strength > Settings.InteractThreadhold))
|
||||
{
|
||||
m_interactRight = (l_strength > Settings.InteractThreadhold);
|
||||
m_inputManager.interactRightDown |= m_interactRight;
|
||||
m_inputManager.interactRightUp |= !m_interactRight;
|
||||
_inputManager.interactRightDown |= m_interactRight;
|
||||
_inputManager.interactRightUp |= !m_interactRight;
|
||||
}
|
||||
|
||||
float l_gripValue = Mathf.Clamp01(Mathf.InverseLerp(0f, Settings.GripThreadhold, l_strength));
|
||||
m_inputManager.gripRightValue = Mathf.Max(l_gripValue, m_inputManager.gripRightValue);
|
||||
_inputManager.gripRightValue = Mathf.Max(l_gripValue, _inputManager.gripRightValue);
|
||||
if(m_gripRight != (l_strength > Settings.GripThreadhold))
|
||||
{
|
||||
m_gripRight = (l_strength > Settings.GripThreadhold);
|
||||
m_inputManager.gripRightDown |= m_gripRight;
|
||||
m_inputManager.gripRightUp |= !m_gripRight;
|
||||
_inputManager.gripRightDown |= m_gripRight;
|
||||
_inputManager.gripRightUp |= !m_gripRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,8 +235,12 @@ namespace ml_lme
|
|||
// Settings changes
|
||||
void OnEnableChange(bool p_state)
|
||||
{
|
||||
InputEnabled = p_state;
|
||||
|
||||
OnInputChange(p_state && Settings.Input);
|
||||
UpdateFingerTracking();
|
||||
m_handVisibleLeft &= p_state;
|
||||
m_handVisibleRight &= p_state;
|
||||
}
|
||||
|
||||
void OnInputChange(bool p_state)
|
||||
|
@ -248,27 +281,73 @@ namespace ml_lme
|
|||
// Arbitrary
|
||||
void UpdateFingerTracking()
|
||||
{
|
||||
m_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && m_openXrModule.AreKnucklesInUse() && !m_openXrModule.GetIndexGestureToggle()));
|
||||
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
|
||||
_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && Utils.AreKnucklesInUse() && !CVRInputManager._moduleXR.GestureToggleValue));
|
||||
IKSystem.Instance.FingerSystem.controlActive = _inputManager.individualFingerTracking;
|
||||
|
||||
if(!Settings.Enabled)
|
||||
{
|
||||
ResetFingers(true);
|
||||
ResetFingers(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SetFingersInput(GestureMatcher.HandData p_hand, bool p_left)
|
||||
{
|
||||
if(p_left)
|
||||
{
|
||||
m_inputManager.fingerCurlLeftThumb = p_hand.m_bends[0];
|
||||
m_inputManager.fingerCurlLeftIndex = p_hand.m_bends[1];
|
||||
m_inputManager.fingerCurlLeftMiddle = p_hand.m_bends[2];
|
||||
m_inputManager.fingerCurlLeftRing = p_hand.m_bends[3];
|
||||
m_inputManager.fingerCurlLeftPinky = p_hand.m_bends[4];
|
||||
_inputManager.fingerCurlLeftThumb = p_hand.m_bends[0];
|
||||
_inputManager.fingerCurlLeftIndex = p_hand.m_bends[1];
|
||||
_inputManager.fingerCurlLeftMiddle = p_hand.m_bends[2];
|
||||
_inputManager.fingerCurlLeftRing = p_hand.m_bends[3];
|
||||
_inputManager.fingerCurlLeftPinky = p_hand.m_bends[4];
|
||||
_inputManager.fingerSpreadLeftThumb = p_hand.m_spreads[0];
|
||||
_inputManager.fingerSpreadLeftIndex = p_hand.m_spreads[1];
|
||||
_inputManager.fingerSpreadLeftMiddle = p_hand.m_spreads[2];
|
||||
_inputManager.fingerSpreadLeftRing = p_hand.m_spreads[3];
|
||||
_inputManager.fingerSpreadLeftPinky = p_hand.m_spreads[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_inputManager.fingerCurlRightThumb = p_hand.m_bends[0];
|
||||
m_inputManager.fingerCurlRightIndex = p_hand.m_bends[1];
|
||||
m_inputManager.fingerCurlRightMiddle = p_hand.m_bends[2];
|
||||
m_inputManager.fingerCurlRightRing = p_hand.m_bends[3];
|
||||
m_inputManager.fingerCurlRightPinky = p_hand.m_bends[4];
|
||||
_inputManager.fingerCurlRightThumb = p_hand.m_bends[0];
|
||||
_inputManager.fingerCurlRightIndex = p_hand.m_bends[1];
|
||||
_inputManager.fingerCurlRightMiddle = p_hand.m_bends[2];
|
||||
_inputManager.fingerCurlRightRing = p_hand.m_bends[3];
|
||||
_inputManager.fingerCurlRightPinky = p_hand.m_bends[4];
|
||||
_inputManager.fingerSpreadRightThumb = p_hand.m_spreads[0];
|
||||
_inputManager.fingerSpreadRightIndex = p_hand.m_spreads[1];
|
||||
_inputManager.fingerSpreadRightMiddle = p_hand.m_spreads[2];
|
||||
_inputManager.fingerSpreadRightRing = p_hand.m_spreads[3];
|
||||
_inputManager.fingerSpreadRightPinky = p_hand.m_spreads[4];
|
||||
}
|
||||
}
|
||||
|
||||
void ResetFingers(bool p_left)
|
||||
{
|
||||
if(p_left)
|
||||
{
|
||||
_inputManager.fingerCurlLeftThumb = 0f;
|
||||
_inputManager.fingerCurlLeftIndex = 0f;
|
||||
_inputManager.fingerCurlLeftMiddle = 0f;
|
||||
_inputManager.fingerCurlLeftRing = 0f;
|
||||
_inputManager.fingerCurlLeftPinky = 0f;
|
||||
_inputManager.fingerSpreadLeftThumb = 0f;
|
||||
_inputManager.fingerSpreadLeftIndex = 0f;
|
||||
_inputManager.fingerSpreadLeftMiddle = 0f;
|
||||
_inputManager.fingerSpreadLeftRing = 0f;
|
||||
_inputManager.fingerSpreadLeftPinky = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_inputManager.fingerCurlRightThumb = 0f;
|
||||
_inputManager.fingerCurlRightIndex = 0f;
|
||||
_inputManager.fingerCurlRightMiddle = 0f;
|
||||
_inputManager.fingerCurlRightRing = 0f;
|
||||
_inputManager.fingerCurlRightPinky = 0f;
|
||||
_inputManager.fingerSpreadRightThumb = 0f;
|
||||
_inputManager.fingerSpreadRightIndex = 0f;
|
||||
_inputManager.fingerSpreadRightMiddle = 0f;
|
||||
_inputManager.fingerSpreadRightRing = 0f;
|
||||
_inputManager.fingerSpreadRightPinky = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -8,32 +9,22 @@ namespace ml_lme
|
|||
[DisallowMultipleComponent]
|
||||
class LeapManager : MonoBehaviour
|
||||
{
|
||||
static LeapManager ms_instance = null;
|
||||
public static LeapManager Instance { get; private set; } = null;
|
||||
|
||||
readonly Leap.Controller m_leapController = null;
|
||||
readonly GestureMatcher.LeapData m_leapData = null;
|
||||
Leap.Controller m_leapController = null;
|
||||
GestureMatcher.LeapData m_leapData = null;
|
||||
|
||||
LeapTracking m_leapTracking = null;
|
||||
LeapTracked m_leapTracked = null;
|
||||
LeapInput m_leapInput = null;
|
||||
|
||||
public static LeapManager GetInstance() => ms_instance;
|
||||
|
||||
internal LeapManager()
|
||||
void Awake()
|
||||
{
|
||||
if(Instance == null)
|
||||
Instance = this;
|
||||
|
||||
m_leapController = new Leap.Controller();
|
||||
m_leapData = new GestureMatcher.LeapData();
|
||||
}
|
||||
~LeapManager()
|
||||
{
|
||||
m_leapController.StopConnection();
|
||||
m_leapController.Dispose();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(ms_instance == null)
|
||||
ms_instance = this;
|
||||
|
||||
DontDestroyOnLoad(this);
|
||||
|
||||
|
@ -49,41 +40,44 @@ namespace ml_lme
|
|||
m_leapTracking = new GameObject("[LeapTrackingRoot]").AddComponent<LeapTracking>();
|
||||
m_leapTracking.transform.parent = this.transform;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForInputManager());
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
|
||||
OnEnableChange(Settings.Enabled);
|
||||
OnTrackingModeChange(Settings.TrackingMode);
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForObjects());
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if(ms_instance == this)
|
||||
ms_instance = null;
|
||||
if(Instance == this)
|
||||
Instance = null;
|
||||
|
||||
m_leapController.StopConnection();
|
||||
m_leapController.Device -= this.OnLeapDeviceInitialized;
|
||||
m_leapController.DeviceFailure -= this.OnLeapDeviceFailure;
|
||||
m_leapController.DeviceLost -= this.OnLeapDeviceLost;
|
||||
m_leapController.Connect -= this.OnLeapServiceConnect;
|
||||
m_leapController.Disconnect -= this.OnLeapServiceDisconnect;
|
||||
m_leapController.Dispose();
|
||||
m_leapController = null;
|
||||
|
||||
Settings.EnabledChange -= this.OnEnableChange;
|
||||
Settings.TrackingModeChange -= this.OnTrackingModeChange;
|
||||
}
|
||||
|
||||
IEnumerator WaitForInputManager()
|
||||
IEnumerator WaitForObjects()
|
||||
{
|
||||
while(CVRInputManager.Instance == null)
|
||||
yield return null;
|
||||
|
||||
m_leapInput = CVRInputManager.Instance.gameObject.AddComponent<LeapInput>();
|
||||
}
|
||||
|
||||
IEnumerator WaitForLocalPlayer()
|
||||
{
|
||||
while(PlayerSetup.Instance == null)
|
||||
yield return null;
|
||||
|
||||
while(LeapTracking.Instance == null)
|
||||
yield return null;
|
||||
|
||||
m_leapInput = new LeapInput();
|
||||
CVRInputManager.Instance.AddInputModule(m_leapInput);
|
||||
|
||||
m_leapTracked = PlayerSetup.Instance.gameObject.AddComponent<LeapTracked>();
|
||||
}
|
||||
|
||||
|
@ -168,8 +162,9 @@ namespace ml_lme
|
|||
{
|
||||
if(m_leapTracking != null)
|
||||
m_leapTracking.OnAvatarSetup();
|
||||
if(m_leapInput != null)
|
||||
m_leapInput.OnAvatarSetup();
|
||||
|
||||
m_leapInput?.OnAvatarSetup();
|
||||
|
||||
if(m_leapTracked != null)
|
||||
m_leapTracked.OnAvatarSetup();
|
||||
}
|
||||
|
@ -182,8 +177,7 @@ namespace ml_lme
|
|||
|
||||
internal void OnRayScale(float p_scale)
|
||||
{
|
||||
if(m_leapInput != null)
|
||||
m_leapInput.OnRayScale(p_scale);
|
||||
m_leapInput?.OnRayScale(p_scale);
|
||||
}
|
||||
|
||||
internal void OnPlayspaceScale(float p_relation)
|
||||
|
|
|
@ -43,12 +43,12 @@ namespace ml_lme
|
|||
m_inVR = Utils.IsInVR();
|
||||
|
||||
m_leftHandTarget = new GameObject("RotationTarget").transform;
|
||||
m_leftHandTarget.parent = LeapTracking.GetInstance().GetLeftHand();
|
||||
m_leftHandTarget.parent = LeapTracking.Instance.GetLeftHand();
|
||||
m_leftHandTarget.localPosition = Vector3.zero;
|
||||
m_leftHandTarget.localRotation = Quaternion.identity;
|
||||
|
||||
m_rightHandTarget = new GameObject("RotationTarget").transform;
|
||||
m_rightHandTarget.parent = LeapTracking.GetInstance().GetRightHand();
|
||||
m_rightHandTarget.parent = LeapTracking.Instance.GetRightHand();
|
||||
m_rightHandTarget.localPosition = Vector3.zero;
|
||||
m_rightHandTarget.localRotation = Quaternion.identity;
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace ml_lme
|
|||
{
|
||||
if(m_enabled)
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if((m_leftArmIK != null) && (m_rightArmIK != null))
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ namespace ml_lme
|
|||
if(l_data.m_leftHand.m_present && !m_leftTargetActive)
|
||||
{
|
||||
m_vrIK.solver.leftArm.target = m_leftHandTarget;
|
||||
m_vrIK.solver.leftArm.bendGoal = LeapTracking.GetInstance().GetLeftElbow();
|
||||
m_vrIK.solver.leftArm.bendGoal = LeapTracking.Instance.GetLeftElbow();
|
||||
m_vrIK.solver.leftArm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_leftTargetActive = true;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace ml_lme
|
|||
if(l_data.m_rightHand.m_present && !m_rightTargetActive)
|
||||
{
|
||||
m_vrIK.solver.rightArm.target = m_rightHandTarget;
|
||||
m_vrIK.solver.rightArm.bendGoal = LeapTracking.GetInstance().GetRightElbow();
|
||||
m_vrIK.solver.rightArm.bendGoal = LeapTracking.Instance.GetRightElbow();
|
||||
m_vrIK.solver.rightArm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_rightTargetActive = true;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace ml_lme
|
|||
{
|
||||
if(m_enabled && !m_inVR && (m_poseHandler != null))
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
Vector3 l_hipsLocalPos = m_hips.localPosition;
|
||||
Quaternion l_hipsLocalRot = m_hips.localRotation;
|
||||
|
@ -232,7 +232,10 @@ namespace ml_lme
|
|||
|
||||
if(PlayerSetup.Instance._animator.isHuman)
|
||||
{
|
||||
Vector3 l_hipsPos = Vector3.zero;
|
||||
m_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips);
|
||||
if(m_hips != null)
|
||||
l_hipsPos = m_hips.localPosition;
|
||||
|
||||
if(!m_inVR)
|
||||
{
|
||||
|
@ -278,7 +281,7 @@ namespace ml_lme
|
|||
PlayerSetup.Instance._animator.transform
|
||||
);
|
||||
m_leftArmIK.solver.arm.target = m_leftHandTarget;
|
||||
m_leftArmIK.solver.arm.bendGoal = LeapTracking.GetInstance().GetLeftElbow();
|
||||
m_leftArmIK.solver.arm.bendGoal = LeapTracking.Instance.GetLeftElbow();
|
||||
m_leftArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_leftArmIK.enabled = (m_enabled && !m_fingersOnly);
|
||||
|
||||
|
@ -293,7 +296,7 @@ namespace ml_lme
|
|||
PlayerSetup.Instance._animator.transform
|
||||
);
|
||||
m_rightArmIK.solver.arm.target = m_rightHandTarget;
|
||||
m_rightArmIK.solver.arm.bendGoal = LeapTracking.GetInstance().GetRightElbow();
|
||||
m_rightArmIK.solver.arm.bendGoal = LeapTracking.Instance.GetRightElbow();
|
||||
m_rightArmIK.solver.arm.bendGoalWeight = (m_trackElbows ? 1f : 0f);
|
||||
m_rightArmIK.enabled = (m_enabled && !m_fingersOnly);
|
||||
|
||||
|
@ -308,6 +311,9 @@ namespace ml_lme
|
|||
m_vrIK.solver.OnPreUpdate += this.OnIKPreUpdate;
|
||||
m_vrIK.solver.OnPostUpdate += this.OnIKPostUpdate;
|
||||
}
|
||||
|
||||
if(m_hips != null)
|
||||
m_hips.localPosition = l_hipsPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace ml_lme
|
|||
[DisallowMultipleComponent]
|
||||
class LeapTracking : MonoBehaviour
|
||||
{
|
||||
static LeapTracking ms_instance = null;
|
||||
public static LeapTracking Instance { get; private set; } = null;
|
||||
static Quaternion ms_identityRotation = Quaternion.identity;
|
||||
|
||||
bool m_inVR = false;
|
||||
|
@ -20,12 +20,10 @@ namespace ml_lme
|
|||
|
||||
float m_scaleRelation = 1f;
|
||||
|
||||
public static LeapTracking GetInstance() => ms_instance;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(ms_instance == null)
|
||||
ms_instance = this;
|
||||
if(Instance == null)
|
||||
Instance = this;
|
||||
|
||||
m_inVR = Utils.IsInVR();
|
||||
|
||||
|
@ -82,8 +80,8 @@ namespace ml_lme
|
|||
|
||||
void OnDestroy()
|
||||
{
|
||||
if(ms_instance == this)
|
||||
ms_instance = null;
|
||||
if(Instance == this)
|
||||
Instance = null;
|
||||
|
||||
Settings.DesktopOffsetChange -= this.OnDesktopOffsetChange;
|
||||
Settings.ModelVisibilityChange -= this.OnModelVisibilityChange;
|
||||
|
@ -97,7 +95,7 @@ namespace ml_lme
|
|||
{
|
||||
if(Settings.Enabled)
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.GetInstance().GetLatestData();
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if(l_data.m_leftHand.m_present)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace ml_lme
|
|||
new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
ModSupporter.Init();
|
||||
MelonLoader.MelonCoroutines.Start(WaitForRootLogic());
|
||||
}
|
||||
|
||||
|
|
37
ml_lme/ModSupporter.cs
Normal file
37
ml_lme/ModSupporter.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ml_lme
|
||||
{
|
||||
static class ModSupporter
|
||||
{
|
||||
static bool ms_copycatMod = false;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if(MelonLoader.MelonMod.RegisteredMelons.FirstOrDefault(m => m.Info.Name == "PlayerMovementCopycat") != null)
|
||||
MelonLoader.MelonCoroutines.Start(WaitForCopycatInstance());
|
||||
}
|
||||
|
||||
// PlayerMovementCopycat support
|
||||
static IEnumerator WaitForCopycatInstance()
|
||||
{
|
||||
while(ml_pmc.PoseCopycat.Instance == null)
|
||||
yield return null;
|
||||
|
||||
ms_copycatMod = true;
|
||||
}
|
||||
static bool IsCopycating() => (ml_pmc.PoseCopycat.Instance.IsActive() && ml_pmc.PoseCopycat.Instance.IsFingerTrackingActive());
|
||||
|
||||
public static bool SkipFingersOverride()
|
||||
{
|
||||
bool l_result = false;
|
||||
l_result |= (ms_copycatMod && IsCopycating());
|
||||
return l_result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.2-ex", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
using System.Reflection;
|
||||
|
||||
[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)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
using cohtml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
@ -67,7 +68,7 @@ namespace ml_lme
|
|||
|
||||
internal static void Init()
|
||||
{
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("LME");
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("LME", null, true);
|
||||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.UI;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace ml_lme
|
||||
{
|
||||
|
@ -10,25 +12,19 @@ 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_leftControllerName = typeof(InputModuleOpenXR).GetField("_leftHandControllerName", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
static readonly FieldInfo ms_rightControllerName = typeof(InputModuleOpenXR).GetField("_rightHandControllerName", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
static readonly FieldInfo ms_indexGestureToggle = typeof(InputModuleOpenXR).GetField("_steamVrIndexGestureToggleValue", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
static FieldInfo ms_cohtmlView = typeof(CohtmlControlledViewDisposable).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded);
|
||||
public static bool AreKnucklesInUse(this InputModuleOpenXR p_module) => (((string)ms_leftControllerName.GetValue(p_module)).Contains("Index") || ((string)ms_rightControllerName.GetValue(p_module)).Contains("Index"));
|
||||
public static bool GetIndexGestureToggle(this InputModuleOpenXR p_module) => (bool)ms_indexGestureToggle.GetValue(p_module);
|
||||
public static bool IsLeftHandTracked() => InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).isValid;
|
||||
public static bool IsRightHandTracked() => InputDevices.GetDeviceAtXRNode(XRNode.RightHand).isValid;
|
||||
|
||||
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 bool IsLeftHandTracked() => (CVRInputManager.Instance._leftController != ABI_RC.Systems.InputManagement.XR.EXRControllerType.None);
|
||||
public static bool IsRightHandTracked() => (CVRInputManager.Instance._rightController != ABI_RC.Systems.InputManagement.XR.EXRControllerType.None);
|
||||
|
||||
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)
|
||||
{
|
||||
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.lossyScale : Vector3.one);
|
||||
}
|
||||
|
||||
public static void ExecuteScript(this CohtmlControlledViewDisposable p_viewDisposable, string p_script) => ((cohtml.Net.View)ms_cohtmlView.GetValue(p_viewDisposable))?.ExecuteScript(p_script);
|
||||
|
||||
public static void ShowHUDNotification(string p_title, string p_message, string p_small = "", bool p_immediate = false)
|
||||
{
|
||||
if(CohtmlHud.Instance != null)
|
||||
|
@ -40,6 +36,8 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
public static void ExecuteScript(this CohtmlControlledViewDisposable p_instance, string p_script) => ((cohtml.Net.View)ms_cohtmlView.GetValue(p_instance))?.ExecuteScript(p_script);
|
||||
|
||||
public static void LeapToUnity(ref Vector3 p_pos, ref Quaternion p_rot, Settings.LeapTrackingMode p_mode)
|
||||
{
|
||||
p_pos *= 0.001f;
|
||||
|
@ -50,20 +48,20 @@ namespace ml_lme
|
|||
switch(p_mode)
|
||||
{
|
||||
case Settings.LeapTrackingMode.Screentop:
|
||||
{
|
||||
p_pos.x *= -1f;
|
||||
p_pos.y *= -1f;
|
||||
p_rot = (ms_screentopRotationFix * p_rot);
|
||||
}
|
||||
break;
|
||||
{
|
||||
p_pos.x *= -1f;
|
||||
p_pos.y *= -1f;
|
||||
p_rot = (ms_screentopRotationFix * p_rot);
|
||||
}
|
||||
break;
|
||||
|
||||
case Settings.LeapTrackingMode.HMD:
|
||||
{
|
||||
p_pos.x *= -1f;
|
||||
Swap(ref p_pos.y, ref p_pos.z);
|
||||
p_rot = (ms_hmdRotationFix * p_rot);
|
||||
}
|
||||
break;
|
||||
{
|
||||
p_pos.x *= -1f;
|
||||
Swap(ref p_pos.y, ref p_pos.z);
|
||||
p_rot = (ms_hmdRotationFix * p_rot);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<PackageId>LeapMotionExtension</PackageId>
|
||||
<Version>1.3.2</Version>
|
||||
<Version>1.3.7</Version>
|
||||
<Authors>SDraw</Authors>
|
||||
<Company>None</Company>
|
||||
<Product>LeapMotionExtension</Product>
|
||||
|
@ -37,8 +37,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
|
@ -57,8 +56,10 @@
|
|||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="MelonLoader">
|
||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\net35\MelonLoader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ml_pmc">
|
||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\Mods\ml_pmc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.dll</HintPath>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue