Fingers values reset

Hips transform restore after pose modification
This commit is contained in:
SDraw 2023-04-24 22:18:30 +03:00
parent 7ef112d02c
commit 0440baa84f
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
5 changed files with 96 additions and 6 deletions

View file

@ -15,6 +15,8 @@ namespace ml_lme
bool m_inVR = false; bool m_inVR = false;
bool m_gripToGrab = true; bool m_gripToGrab = true;
bool m_handVisibleLeft = false;
bool m_handVisibleRight = false;
ControllerRay m_handRayLeft = null; ControllerRay m_handRayLeft = null;
ControllerRay m_handRayRight = null; ControllerRay m_handRayRight = null;
LineRenderer m_lineLeft = null; LineRenderer m_lineLeft = null;
@ -121,10 +123,32 @@ namespace ml_lme
if(Settings.Enabled) if(Settings.Enabled)
{ {
if(l_data.m_leftHand.m_present) if(l_data.m_leftHand.m_present)
{
SetFingersInput(l_data.m_leftHand, true); 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) if(l_data.m_rightHand.m_present)
{
SetFingersInput(l_data.m_rightHand, false); SetFingersInput(l_data.m_rightHand, false);
m_handVisibleRight = true;
}
else
{
if(m_handVisibleRight)
{
ResetFingers(false);
m_handVisibleRight = false;
}
}
if(m_inVR) if(m_inVR)
{ {
@ -209,6 +233,8 @@ namespace ml_lme
{ {
OnInputChange(p_state && Settings.Input); OnInputChange(p_state && Settings.Input);
UpdateFingerTracking(); UpdateFingerTracking();
m_handVisibleLeft &= p_state;
m_handVisibleRight &= p_state;
} }
void OnInputChange(bool p_state) void OnInputChange(bool p_state)
@ -251,6 +277,12 @@ namespace ml_lme
{ {
m_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && Utils.AreKnucklesInUse() && !m_steamVrModule.GetIndexGestureToggle())); m_inputManager.individualFingerTracking = (Settings.Enabled || (m_inVR && Utils.AreKnucklesInUse() && !m_steamVrModule.GetIndexGestureToggle()));
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking; IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
if(!Settings.Enabled)
{
ResetFingers(true);
ResetFingers(false);
}
} }
void SetFingersInput(GestureMatcher.HandData p_hand, bool p_left) void SetFingersInput(GestureMatcher.HandData p_hand, bool p_left)
@ -283,6 +315,36 @@ namespace ml_lme
} }
} }
void ResetFingers(bool p_left)
{
if(p_left)
{
m_inputManager.fingerCurlLeftThumb = 0f;
m_inputManager.fingerCurlLeftIndex = 0f;
m_inputManager.fingerCurlLeftMiddle = 0f;
m_inputManager.fingerCurlLeftRing = 0f;
m_inputManager.fingerCurlLeftPinky = 0f;
IKSystem.Instance.FingerSystem.leftThumbCurl = 0f;
IKSystem.Instance.FingerSystem.leftIndexCurl = 0f;
IKSystem.Instance.FingerSystem.leftMiddleCurl = 0f;
IKSystem.Instance.FingerSystem.leftRingCurl = 0f;
IKSystem.Instance.FingerSystem.leftPinkyCurl = 0f;
}
else
{
m_inputManager.fingerCurlRightThumb = 0f;
m_inputManager.fingerCurlRightIndex = 0f;
m_inputManager.fingerCurlRightMiddle = 0f;
m_inputManager.fingerCurlRightRing = 0f;
m_inputManager.fingerCurlRightPinky = 0f;
IKSystem.Instance.FingerSystem.rightThumbCurl = 0f;
IKSystem.Instance.FingerSystem.rightIndexCurl = 0f;
IKSystem.Instance.FingerSystem.rightMiddleCurl = 0f;
IKSystem.Instance.FingerSystem.rightRingCurl = 0f;
IKSystem.Instance.FingerSystem.rightPinkyCurl = 0f;
}
}
// Game settings // Game settings
void OnGameSettingBoolChange(string p_name, bool p_state) void OnGameSettingBoolChange(string p_name, bool p_state)
{ {

View file

@ -232,7 +232,14 @@ namespace ml_lme
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
Vector3 l_hipsPos = Vector3.zero;
Quaternion l_hipsRot = Quaternion.identity;
m_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips); m_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips);
if(m_hips != null)
{
l_hipsPos = m_hips.localPosition;
l_hipsRot = m_hips.localRotation;
}
if(!m_inVR) if(!m_inVR)
{ {
@ -308,6 +315,12 @@ namespace ml_lme
m_vrIK.solver.OnPreUpdate += this.OnIKPreUpdate; m_vrIK.solver.OnPreUpdate += this.OnIKPreUpdate;
m_vrIK.solver.OnPostUpdate += this.OnIKPostUpdate; m_vrIK.solver.OnPostUpdate += this.OnIKPostUpdate;
} }
if(m_hips != null)
{
m_hips.localPosition = l_hipsPos;
m_hips.localRotation = l_hipsRot;
}
} }
} }

View file

@ -1,10 +1,10 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyTitle("LeapMotionExtension")] [assembly: AssemblyTitle("LeapMotionExtension")]
[assembly: AssemblyVersion("1.3.4")] [assembly: AssemblyVersion("1.3.5")]
[assembly: AssemblyFileVersion("1.3.4")] [assembly: AssemblyFileVersion("1.3.5")]
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] [assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]

View file

@ -132,6 +132,15 @@ namespace ml_pam
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
Vector3 l_hipsPos = Vector3.zero;
Quaternion l_hipsRot = Quaternion.identity;
Transform l_hips = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Hips);
if(l_hips != null)
{
l_hipsPos = l_hips.localPosition;
l_hipsRot = l_hips.localRotation;
}
HumanPose l_currentPose = new HumanPose(); HumanPose l_currentPose = new HumanPose();
HumanPoseHandler l_poseHandler = null; HumanPoseHandler l_poseHandler = null;
@ -190,6 +199,12 @@ namespace ml_pam
l_poseHandler?.SetHumanPose(ref l_currentPose); l_poseHandler?.SetHumanPose(ref l_currentPose);
l_poseHandler?.Dispose(); l_poseHandler?.Dispose();
if(l_hips != null)
{
l_hips.localPosition = l_hipsPos;
l_hips.localRotation = l_hipsRot;
}
} }
if(m_enabled) if(m_enabled)

View file

@ -1,10 +1,10 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyTitle("PickupArmMovement")] [assembly: AssemblyTitle("PickupArmMovement")]
[assembly: AssemblyVersion("1.0.3")] [assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.3")] [assembly: AssemblyFileVersion("1.0.4")]
[assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.0.3", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonInfo(typeof(ml_pam.PickupArmMovement), "PickupArmMovement", "1.0.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPriority(1)] [assembly: MelonLoader.MelonPriority(1)]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]