mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
Add Prone Thrust option & Fix scaling disabling IK without AMT
Add Prone Thrust option & Fix scaling disabling IK without AMT
This commit is contained in:
parent
57e7cfd35a
commit
b4aab6bf4a
3 changed files with 20 additions and 12 deletions
|
@ -125,6 +125,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
public bool Setting_Enabled = true;
|
public bool Setting_Enabled = true;
|
||||||
public bool Setting_PlantFeet;
|
public bool Setting_PlantFeet;
|
||||||
public bool Setting_ResetFootsteps;
|
public bool Setting_ResetFootsteps;
|
||||||
|
public bool Setting_ProneThrusting;
|
||||||
public float Setting_BodyLeanWeight;
|
public float Setting_BodyLeanWeight;
|
||||||
public float Setting_BodyHeadingLimit;
|
public float Setting_BodyHeadingLimit;
|
||||||
public float Setting_PelvisHeadingWeight;
|
public float Setting_PelvisHeadingWeight;
|
||||||
|
@ -177,6 +178,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
float _ikWeightLerp = 1f;
|
float _ikWeightLerp = 1f;
|
||||||
float _ikSimulatedRootAngle = 0f;
|
float _ikSimulatedRootAngle = 0f;
|
||||||
float _locomotionWeight = 1f;
|
float _locomotionWeight = 1f;
|
||||||
|
float _scaleDifference = 1f;
|
||||||
|
|
||||||
// Last Movement Parent Info
|
// Last Movement Parent Info
|
||||||
Vector3 _movementPosition;
|
Vector3 _movementPosition;
|
||||||
|
@ -198,7 +200,7 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
|
|
||||||
DesktopVRIKMod.UpdateAllSettings();
|
DesktopVRIKMod.UpdateAllSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (avatarVRIK == null) return;
|
if (avatarVRIK == null) return;
|
||||||
|
@ -241,10 +243,11 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
// Get Upright value
|
// Get Upright value
|
||||||
Vector3 delta = avatarIKSolver.spine.headPosition - avatarTransform.position;
|
Vector3 delta = avatarIKSolver.spine.headPosition - avatarTransform.position;
|
||||||
Vector3 deltaRotated = Quaternion.Euler(0, avatarTransform.rotation.eulerAngles.y, 0) * delta;
|
Vector3 deltaRotated = Quaternion.Euler(0, avatarTransform.rotation.eulerAngles.y, 0) * delta;
|
||||||
float upright = Mathf.InverseLerp(0f, avatarIKSolver.spine.headHeight, deltaRotated.y);
|
float upright = Mathf.InverseLerp(0f, avatarIKSolver.spine.headHeight * _scaleDifference, deltaRotated.y);
|
||||||
return upright > 0.85f;
|
return upright > 0.85f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdateLocomotionWeight()
|
void UpdateLocomotionWeight()
|
||||||
{
|
{
|
||||||
float targetWeight = BodySystem.TrackingEnabled && BodySystem.TrackingLocomotionEnabled ? 1.0f : 0.0f;
|
float targetWeight = BodySystem.TrackingEnabled && BodySystem.TrackingLocomotionEnabled ? 1.0f : 0.0f;
|
||||||
|
@ -319,6 +322,8 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
scaleDifference
|
scaleDifference
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_scaleDifference = scaleDifference;
|
||||||
|
|
||||||
avatarIKSolver.Reset();
|
avatarIKSolver.Reset();
|
||||||
ResetDesktopVRIK();
|
ResetDesktopVRIK();
|
||||||
return true;
|
return true;
|
||||||
|
@ -383,31 +388,29 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
avatarIKSolver.plantFeet = Setting_PlantFeet;
|
avatarIKSolver.plantFeet = Setting_PlantFeet;
|
||||||
|
|
||||||
// Apply custom VRIK solving effects
|
// Apply custom VRIK solving effects
|
||||||
if (_ikWeightLerp > 0)
|
IKBodyLeaningOffset(_ikWeightLerp);
|
||||||
{
|
IKBodyHeadingOffset(_ikWeightLerp);
|
||||||
IKBodyLeaningOffset();
|
|
||||||
IKBodyHeadingOffset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IKBodyLeaningOffset()
|
void IKBodyLeaningOffset(float weight)
|
||||||
{
|
{
|
||||||
// Emulate old VRChat hip movement
|
// Emulate old VRChat hip movement
|
||||||
if (Setting_BodyLeanWeight <= 0) return;
|
if (Setting_BodyLeanWeight <= 0) return;
|
||||||
|
|
||||||
float weightedAngle = Setting_BodyLeanWeight * _ikWeightLerp;
|
if (Setting_ProneThrusting) weight = 1f;
|
||||||
|
float weightedAngle = Setting_BodyLeanWeight * weight;
|
||||||
float angle = _cameraTransform.localEulerAngles.x;
|
float angle = _cameraTransform.localEulerAngles.x;
|
||||||
angle = angle > 180 ? angle - 360 : angle;
|
angle = angle > 180 ? angle - 360 : angle;
|
||||||
Quaternion rotation = Quaternion.AngleAxis(angle * weightedAngle, avatarTransform.right);
|
Quaternion rotation = Quaternion.AngleAxis(angle * weightedAngle, avatarTransform.right);
|
||||||
avatarIKSolver.spine.headRotationOffset *= rotation;
|
avatarIKSolver.spine.headRotationOffset *= rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IKBodyHeadingOffset()
|
void IKBodyHeadingOffset(float weight)
|
||||||
{
|
{
|
||||||
// Make root heading follow within a set limit
|
// Make root heading follow within a set limit
|
||||||
if (Setting_BodyHeadingLimit <= 0) return;
|
if (Setting_BodyHeadingLimit <= 0) return;
|
||||||
|
|
||||||
float weightedAngleLimit = Setting_BodyHeadingLimit * _ikWeightLerp;
|
float weightedAngleLimit = Setting_BodyHeadingLimit * weight;
|
||||||
float deltaAngleRoot = Mathf.DeltaAngle(transform.eulerAngles.y, _ikSimulatedRootAngle);
|
float deltaAngleRoot = Mathf.DeltaAngle(transform.eulerAngles.y, _ikSimulatedRootAngle);
|
||||||
float absDeltaAngleRoot = Mathf.Abs(deltaAngleRoot);
|
float absDeltaAngleRoot = Mathf.Abs(deltaAngleRoot);
|
||||||
|
|
||||||
|
@ -581,6 +584,8 @@ internal class DesktopVRIKSystem : MonoBehaviour
|
||||||
|
|
||||||
void ConfigureVRIK()
|
void ConfigureVRIK()
|
||||||
{
|
{
|
||||||
|
// Reset scale diffrence
|
||||||
|
_scaleDifference = 1f;
|
||||||
VRIKUtils.ApplyScaleToVRIK
|
VRIKUtils.ApplyScaleToVRIK
|
||||||
(
|
(
|
||||||
avatarVRIK,
|
avatarVRIK,
|
||||||
|
|
|
@ -39,6 +39,9 @@ public class DesktopVRIKMod : MelonMod
|
||||||
public static readonly MelonPreferences_Entry<float> EntryIKLerpSpeed =
|
public static readonly MelonPreferences_Entry<float> EntryIKLerpSpeed =
|
||||||
CategoryDesktopVRIK.CreateEntry("IK Lerp Speed", 10f, description: "Determines fast the IK & Locomotion weights blend after entering idle. Set to 0 to disable.");
|
CategoryDesktopVRIK.CreateEntry("IK Lerp Speed", 10f, description: "Determines fast the IK & Locomotion weights blend after entering idle. Set to 0 to disable.");
|
||||||
|
|
||||||
|
public static readonly MelonPreferences_Entry<bool> EntryProneThrusting =
|
||||||
|
CategoryDesktopVRIK.CreateEntry("Prone Thrusting", false, description: "Allows Body Lean Weight to take affect while crouched or prone.");
|
||||||
|
|
||||||
public static readonly MelonPreferences_Entry<bool> EntryIntegrationAMT =
|
public static readonly MelonPreferences_Entry<bool> EntryIntegrationAMT =
|
||||||
CategoryDesktopVRIK.CreateEntry("AMT Integration", true, description: "Relies on AvatarMotionTweaker to handle VRIK Locomotion weights if available.");
|
CategoryDesktopVRIK.CreateEntry("AMT Integration", true, description: "Relies on AvatarMotionTweaker to handle VRIK Locomotion weights if available.");
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,6 @@ using System.Reflection;
|
||||||
namespace NAK.Melons.DesktopVRIK.Properties;
|
namespace NAK.Melons.DesktopVRIK.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "4.1.4";
|
public const string Version = "4.1.5";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue