Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
IKT: add an option to enable viewpoint drift, update README.md with n…
Browse files Browse the repository at this point in the history
…ew options
  • Loading branch information
knah committed Dec 28, 2021
1 parent 54a7a76 commit 7c9ded0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
5 changes: 4 additions & 1 deletion IKTweaks/CustomSpineSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ private void SolvePelvis() {
Quaternion.FromToRotation(head.solverPosition - pelvis.solverPosition,
headSolverPosition - IKPositionPelvis));

delta = headSolverPosition - head.solverPosition;
var deltaHead = headSolverPosition - head.solverPosition;
var deltaHips = IKPositionPelvis - pelvis.solverPosition;
var mix = IkTweaksSettings.GetHeadDriftFactor();
delta = deltaHips * mix + deltaHead * (1f - mix);
foreach (VirtualBone bone in bones) bone.solverPosition += delta;

var currentDistance = (head.solverPosition - pelvis.solverPosition).magnitude;
Expand Down
4 changes: 4 additions & 0 deletions IKTweaks/IKTweaksMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ private static void AddUixActions()
(nameof(MeasureAvatarMode.ImprovedWingspan), "Wingspan (accurate)"),
(nameof(MeasureAvatarMode.Height), "Height"),
});

var updateVisibility = ExpansionKitApi.RegisterSettingsVisibilityCallback(IkTweaksSettings.IkTweaksCategory,
nameof(IkTweaksSettings.DriftMix), () => IkTweaksSettings.DriftMode.Value == DriftPreference.Custom);
IkTweaksSettings.DriftMode.OnValueChangedUntyped += updateVisibility;
}

private static void ShowIKTweaksMenu()
Expand Down
22 changes: 22 additions & 0 deletions IKTweaks/IkTweaksSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ internal static void RegisterSettings()
OneHandedCalibration = category.CreateEntry(nameof(OneHandedCalibration), false, "One-handed calibration");

NoWallFreeze = category.CreateEntry(nameof(NoWallFreeze), true, "Don't freeze head/hands inside walls");
DriftMode = category.CreateEntry(nameof(DriftMode), DriftPreference.Hips, "Which body part will drift?");
DriftMix = category.CreateEntry(nameof(DriftMix), 0.5f, "Drift mix (0=hips, 1=viewpoint, 0.5=both equally)");

HandAngleOffset = category.CreateEntry(nameof(HandAngleOffset), DefaultHandAngle, "Hand angle offset", null, true);
HandPositionOffset = category.CreateEntry(nameof(HandPositionOffset), DefaultHandOffset, "Hand position offset", null, true);
Expand Down Expand Up @@ -116,12 +118,25 @@ private static void UpdateIgnoreAnimationMode(string value)
public static MelonPreferences_Entry<float> WingspanMeasurementAdjustFactor;
public static MelonPreferences_Entry<bool> OneHandedCalibration;
public static MelonPreferences_Entry<bool> NoWallFreeze;
public static MelonPreferences_Entry<DriftPreference> DriftMode;
public static MelonPreferences_Entry<float> DriftMix;

public static MelonPreferences_Entry<Vector3> HandAngleOffset;
public static MelonPreferences_Entry<Vector3> HandPositionOffset;

public static IgnoreAnimationsMode IgnoreAnimationsModeParsed;
public static MeasureAvatarMode MeasureModeParsed;

public static float GetHeadDriftFactor()
{
return DriftMode.Value switch
{
DriftPreference.Hips => 0,
DriftPreference.Viewpoint => 1,
DriftPreference.Custom => DriftMix.Value,
_ => throw new ArgumentOutOfRangeException()
};
}
}

[Flags]
Expand All @@ -141,4 +156,11 @@ public enum MeasureAvatarMode
Height,
ImprovedWingspan
}

public enum DriftPreference
{
Hips,
Viewpoint,
Custom
}
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ Given that this mod is still work in progress, these are subject to change.
* Freeze avatar on one trigger hold in follow head mode - if you have previous setting enabled, holding one trigger when calibrating will stop your avatar from following your head. You can use this to align your feet.
* Use universal calibration (requires follow head mode) - allows you to calibrate once for all avatars. No more standing up to switch avatars!
* Store calibration per avatar (when not using universal calibration) - if you don't want universal calibration, enable this to save calibration per-avatar.
* Disable FBT even if trackers are present - you can enable this if you plug your trackers into your PC to charge but don't want to use FBT while doing so
* Enforce hip rotation match - if enabled, avatar's hip rotation will exactly match tracker's rotation. Otherwise, IK may rotate the hip to bend the spine more.
* Shift hip pivot (support inverted hip) - if enabled, the hip will be rotated around the midpoint of two leg bones (where the hip bone should be normally). This greatly improves IK on avatars with the inverted hip rig hack.
* Pre-straighten spine (improve IK stability) - if enabled, you avatar's spine will be forcefully straightened before solving it. This reduces flippiness/jitter on avatars that have spine bent backwards by default.
Expand All @@ -259,6 +258,9 @@ Given that this mod is still work in progress, these are subject to change.
* Allow more head rotation in 3/4-point tracking - ever tried to look up when close to the ground in 3/4-point tracking? Now you can, even if it breaks your neck.
* Improved wingspan adjustment factor - your wingspan is adjusted by this factor in "Improved wingspan" scaling mode. If you consistently get avatar arms too long/short, consider tweaking this a tiny bit (to like 1.05 or 1.15)
* One-handed calibration - pressing one trigger will be enough to calibrate. Holding the trigger slightly pressed will freeze the avatar (if enabled).
* Don't freeze head/hands inside walls - prevents your hands/head from freezing if your head gets inside a wall.
* Which body part will drift? - in case you want your viewpoint drift back, you monster.
* Drift mix - if the previous setting is set to custom, decides how much viewpoint and hips can drift. 0 means viewpoint/head is fixed to the headset, 1 means hip is fixed to the tracker, values inbetween make both drift in different proportions.
* Hand angles/offsets (found in VRChat Settings menu -> left blue panel -> More IKTweaks -> Adjust hand angles/offsets) - you can configure how avatar hands are positioned relative to controllers. Defaults were tuned for Index controllers, but should be applicable to most other controllers too.

### Partial source code
Expand All @@ -272,6 +274,7 @@ If you want to build the mod yourself, you'll need to do the following:
* Rename `RootMotionNew.FinalIK.IKSolverVR.Leg.ApplyOffsets` to `ApplyOffsetsOld`, remove `override` from it
* Add `ApplyBendGoal();` to the second line of `RootMotionNew.FinalIK.IKSolverVR.Leg.Solve(bool)`
* Rename `Update`, `FixedUpdate` and `LateUpdate` on VRIK_New by adding `_ManualDrive` suffix to them and make them `internal` instead of `private`
* In `IKSolverVR.Solve` comment out `spine.InverseTranslateToHead` in legs section
* Fix compilation if broken

## JoinNotifier
Expand Down
12 changes: 3 additions & 9 deletions ReleaseChangelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
Read the [Malicious Mods and you](https://github.com/knah/VRCMods/blob/master/Malicious-Mods.md) doc!

Changes:
* Advanced Safety: added protection for uncommon skid crashes (contributed by Requi and Ben)
* Lag Free Screenshots: added screenshot taken event for other mods (contributed by @DragonPlayerX in #178)
* Mirror Resolution Unlimiter: added an option to show UI in mirrors when using Optimize/Beautify buttons, support new UI layer
* Styletor: added export for default menu audio clips (replacement is not supported yet)
* Styletor: added support for Action Menu recoloring (the round one)
* Styletor: added support for UI laser pointers and cursor recoloring (just like SparkleBeGone!)
* Styletor: removed lags when opening quick menu for the first time
* UI Expansion Kit: added APIs to dynamically show or hide mod settings entries
* UI Expansion Kit: fixed compatibility with build 1160
* IKTweaks: fix calibration not saving often/recalibrating randomly
* IKTweaks: added detection of AFK state
* IKTweaks: added an option to bring viewpoint drift back


**USE IT AT YOUR OWN RISK.** Modding the client is against VRChat ToS. I am not responsible for any bans or other punishments you may get by using these mods!

0 comments on commit 7c9ded0

Please sign in to comment.