mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
fix saved calibration on restart
This commit is contained in:
parent
6968b78f06
commit
7fdbac09e6
2 changed files with 38 additions and 35 deletions
|
@ -45,45 +45,47 @@ internal static class BodySystemPatches
|
||||||
[HarmonyPatch(typeof(BodySystem), "Update")]
|
[HarmonyPatch(typeof(BodySystem), "Update")]
|
||||||
private static bool Prefix_BodySystem_Update(ref BodySystem __instance)
|
private static bool Prefix_BodySystem_Update(ref BodySystem __instance)
|
||||||
{
|
{
|
||||||
if (IKSystem.vrik == null) return false;
|
if (IKSystem.vrik != null)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
IKSystem.vrik.enabled = true;
|
IKSolverVR solver = IKSystem.vrik.solver;
|
||||||
solver.IKPositionWeight = BodySystem.TrackingPositionWeight;
|
|
||||||
solver.locomotion.weight = BodySystem.TrackingLocomotionEnabled ? 1f : 0f;
|
|
||||||
|
|
||||||
// fixes arm weights not being set if leftArm & rightArm targets are null
|
// Allow avatar to rotate seperatly from Player (Desktop&VR)
|
||||||
// game handles TrackingLegs in PlayerSetup, but not for knee goals
|
// FBT needs avatar root to follow head
|
||||||
SetArmWeight(solver.leftArm, BodySystem.TrackingLeftArmEnabled && solver.leftArm.target != null ? 1f : 0f);
|
solver.spine.maxRootAngle = BodySystem.isCalibratedAsFullBody ? 0f : 180f;
|
||||||
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.TrackingEnabled)
|
||||||
if (BodySystem.isCalibratedAsFullBody)
|
|
||||||
{
|
{
|
||||||
bool isRunning = BodySystem.PlayRunningAnimationInFullBody && MovementSystem.Instance.movementVector.magnitude > 0f;
|
IKSystem.vrik.enabled = true;
|
||||||
SetPelvisWeight(solver.spine, isRunning ? 0f : 1f);
|
solver.IKPositionWeight = BodySystem.TrackingPositionWeight;
|
||||||
}
|
solver.locomotion.weight = BodySystem.TrackingLocomotionEnabled ? 1f : 0f;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IKSystem.vrik.enabled = false;
|
|
||||||
solver.IKPositionWeight = 0f;
|
|
||||||
solver.locomotion.weight = 0f;
|
|
||||||
|
|
||||||
SetArmWeight(solver.leftArm, 0f);
|
// fixes arm weights not being set if leftArm & rightArm targets are null
|
||||||
SetArmWeight(solver.rightArm, 0f);
|
// game handles TrackingLegs in PlayerSetup, but not for knee goals
|
||||||
SetLegWeight(solver.leftLeg, 0f);
|
SetArmWeight(solver.leftArm, BodySystem.TrackingLeftArmEnabled && solver.leftArm.target != null ? 1f : 0f);
|
||||||
SetLegWeight(solver.rightLeg, 0f);
|
SetArmWeight(solver.rightArm, BodySystem.TrackingRightArmEnabled && solver.rightArm.target != null ? 1f : 0f);
|
||||||
SetPelvisWeight(solver.spine, 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;
|
int num = 0;
|
||||||
|
|
|
@ -64,7 +64,8 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="Deploy" AfterTargets="Build">
|
<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" />
|
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue