fix saved calibration on restart

This commit is contained in:
NotAKidoS 2023-04-08 00:15:56 -05:00
parent 6968b78f06
commit 7fdbac09e6
2 changed files with 38 additions and 35 deletions

View file

@ -45,45 +45,47 @@ internal static class BodySystemPatches
[HarmonyPatch(typeof(BodySystem), "Update")]
private static bool Prefix_BodySystem_Update(ref BodySystem __instance)
{
if (IKSystem.vrik == null) return false;
IKSolverVR solver = IKSystem.vrik.solver;
// Allow avatar to rotate seperatly from Player (Desktop&VR)
// FBT needs avatar root to follow head
solver.spine.maxRootAngle = BodySystem.isCalibratedAsFullBody ? 0f : 180f;
if (BodySystem.TrackingEnabled)
if (IKSystem.vrik != null)
{
IKSystem.vrik.enabled = true;
solver.IKPositionWeight = BodySystem.TrackingPositionWeight;
solver.locomotion.weight = BodySystem.TrackingLocomotionEnabled ? 1f : 0f;
IKSolverVR solver = IKSystem.vrik.solver;
// fixes arm weights not being set if leftArm & rightArm targets are null
// game handles TrackingLegs in PlayerSetup, but not for knee goals
SetArmWeight(solver.leftArm, BodySystem.TrackingLeftArmEnabled && solver.leftArm.target != null ? 1f : 0f);
SetArmWeight(solver.rightArm, BodySystem.TrackingRightArmEnabled && solver.rightArm.target != null ? 1f : 0f);
SetLegWeight(solver.leftLeg, BodySystem.TrackingLeftLegEnabled && solver.leftLeg.target != null ? 1f : 0f);
SetLegWeight(solver.rightLeg, BodySystem.TrackingRightLegEnabled && solver.leftLeg.target != null ? 1f : 0f);
SetPelvisWeight(solver.spine, solver.spine.pelvisTarget != null ? 1f : 0f);
// Allow avatar to rotate seperatly from Player (Desktop&VR)
// FBT needs avatar root to follow head
solver.spine.maxRootAngle = BodySystem.isCalibratedAsFullBody ? 0f : 180f;
// makes running animation look better
if (BodySystem.isCalibratedAsFullBody)
if (BodySystem.TrackingEnabled)
{
bool isRunning = BodySystem.PlayRunningAnimationInFullBody && MovementSystem.Instance.movementVector.magnitude > 0f;
SetPelvisWeight(solver.spine, isRunning ? 0f : 1f);
}
}
else
{
IKSystem.vrik.enabled = false;
solver.IKPositionWeight = 0f;
solver.locomotion.weight = 0f;
IKSystem.vrik.enabled = true;
solver.IKPositionWeight = BodySystem.TrackingPositionWeight;
solver.locomotion.weight = BodySystem.TrackingLocomotionEnabled ? 1f : 0f;
SetArmWeight(solver.leftArm, 0f);
SetArmWeight(solver.rightArm, 0f);
SetLegWeight(solver.leftLeg, 0f);
SetLegWeight(solver.rightLeg, 0f);
SetPelvisWeight(solver.spine, 0f);
// fixes arm weights not being set if leftArm & rightArm targets are null
// game handles TrackingLegs in PlayerSetup, but not for knee goals
SetArmWeight(solver.leftArm, BodySystem.TrackingLeftArmEnabled && solver.leftArm.target != null ? 1f : 0f);
SetArmWeight(solver.rightArm, BodySystem.TrackingRightArmEnabled && solver.rightArm.target != null ? 1f : 0f);
SetLegWeight(solver.leftLeg, BodySystem.TrackingLeftLegEnabled && solver.leftLeg.target != null ? 1f : 0f);
SetLegWeight(solver.rightLeg, BodySystem.TrackingRightLegEnabled && solver.leftLeg.target != null ? 1f : 0f);
SetPelvisWeight(solver.spine, solver.spine.pelvisTarget != null ? 1f : 0f);
// makes running animation look better
if (BodySystem.isCalibratedAsFullBody)
{
bool isRunning = BodySystem.PlayRunningAnimationInFullBody && MovementSystem.Instance.movementVector.magnitude > 0f;
SetPelvisWeight(solver.spine, isRunning ? 0f : 1f);
}
}
else
{
IKSystem.vrik.enabled = false;
solver.IKPositionWeight = 0f;
solver.locomotion.weight = 0f;
SetArmWeight(solver.leftArm, 0f);
SetArmWeight(solver.rightArm, 0f);
SetLegWeight(solver.leftLeg, 0f);
SetLegWeight(solver.rightLeg, 0f);
SetPelvisWeight(solver.spine, 0f);
}
}
int num = 0;

View file

@ -64,7 +64,8 @@
</ItemGroup>
<Target Name="Deploy" AfterTargets="Build">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
</Target>