From a98b9e32d70f027d45946b21ed5a2992b71b6374 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Mon, 12 Jun 2023 20:57:25 -0500 Subject: [PATCH] [DesktopVRIK] Remove test calibration stuff. I didn't like how it made things look. Much more overcomplicated compared to what I had before. Goal was to test DesktopVRIKs calibrator with HalfbodyVRIK but im very lazy. --- DesktopVRIK/DesktopVRIKCalibrator.cs | 72 +++++++++++++-- DesktopVRIK/DesktopVRIKSystem.cs | 1 - DesktopVRIK/VRIKHelpers/VRIKConfiguration.cs | 87 ------------------- DesktopVRIK/VRIKHelpers/VRIKConfigurations.cs | 53 ----------- 4 files changed, 65 insertions(+), 148 deletions(-) delete mode 100644 DesktopVRIK/VRIKHelpers/VRIKConfiguration.cs delete mode 100644 DesktopVRIK/VRIKHelpers/VRIKConfigurations.cs diff --git a/DesktopVRIK/DesktopVRIKCalibrator.cs b/DesktopVRIK/DesktopVRIKCalibrator.cs index 66da1ab..525e609 100644 --- a/DesktopVRIK/DesktopVRIKCalibrator.cs +++ b/DesktopVRIK/DesktopVRIKCalibrator.cs @@ -123,10 +123,10 @@ internal class DesktopVRIKCalibrator Animator _animator; // Calibration Objects - public HumanPoseHandler _humanPoseHandler; - public HumanPose _humanPose; - public HumanPose _humanPoseInitial; - + HumanPoseHandler _humanPoseHandler; + HumanPose _humanPose; + HumanPose _humanPoseInitial; + // Animator Info int _animLocomotionLayer = -1; int _animIKPoseLayer = -1; @@ -198,14 +198,72 @@ internal class DesktopVRIKCalibrator // Add and configure VRIK ikSystem.avatarVRIK = ikSystem.avatarTransform.AddComponentIfMissing(); ikSystem.avatarVRIK.AutoDetectReferences(); - ikSystem.cachedSolver = new CachedSolver(ikSystem.avatarVRIK.solver); // Why do I love to overcomplicate things? VRIKUtils.ConfigureVRIKReferences(ikSystem.avatarVRIK, DesktopVRIK.EntryUseVRIKToes.Value); - VRIKConfigurator.ApplyVRIKConfiguration(ikSystem.cachedSolver, VRIKConfigurations.DesktopVRIKConfiguration()); - // Fix potential animator issue + // Fix animator issue ikSystem.avatarVRIK.fixTransforms = ikSystem.calibrationData.FixTransformsRequired; + + CachedSolver solver = new CachedSolver(ikSystem.avatarVRIK.solver); + + // Default solver settings + solver.Locomotion.weight = 0f; + solver.Locomotion.angleThreshold = 30f; + solver.Locomotion.maxLegStretch = 1f; + solver.Spine.minHeadHeight = 0f; + solver.Spine.chestClampWeight = 0f; + solver.Spine.maintainPelvisPosition = 0f; + solver.Solver.IKPositionWeight = 1f; + + // Body leaning settings + solver.Spine.bodyPosStiffness = 1f; + solver.Spine.bodyRotStiffness = 0.2f; + // this is a hack, allows chest to rotate slightly + // independent from hip rotation. Funny Spine.Solve()->Bend() + solver.Spine.neckStiffness = 0.0001f; + + // Disable locomotion + // Setting velocity to 0 aleviated nameplate jitter issue on remote + solver.Locomotion.velocityFactor = 0f; + solver.Locomotion.maxVelocity = 0f; + solver.Locomotion.rootSpeed = 1000f; + + // Disable chest rotation by hands + // this fixed Effector, Player Arm Movement, BetterInteractDesktop, ect + // from making entire body shake, as well as while running + solver.Spine.rotateChestByHands = 0f; + + // Prioritize LookAtIK + solver.Spine.headClampWeight = 0.2f; + + // Disable going on tippytoes + solver.Spine.positionWeight = 0f; + solver.Spine.rotationWeight = 1f; + + // Set so emotes play properly + solver.Spine.maxRootAngle = 180f; + // this is different in VR, as CVR player controller is not set up optimally for VRIK. + // Desktop avatar rotates 1:1 with _PlayerLocal. VR has a disconnect because you can turn IRL. + + // We disable these ourselves now, as we no longer use BodySystem + solver.Spine.maintainPelvisPosition = 1f; + solver.Spine.positionWeight = 0f; + solver.Spine.pelvisPositionWeight = 0f; + solver.LeftArm.positionWeight = 0f; + solver.LeftArm.rotationWeight = 0f; + solver.RightArm.positionWeight = 0f; + solver.RightArm.rotationWeight = 0f; + solver.LeftLeg.positionWeight = 0f; + solver.LeftLeg.rotationWeight = 0f; + solver.RightLeg.positionWeight = 0f; + solver.RightLeg.rotationWeight = 0f; + + // This is now our master Locomotion weight + solver.Locomotion.weight = 1f; + solver.Solver.IKPositionWeight = 1f; + + ikSystem.cachedSolver = solver; } void CalibrateVRIK() diff --git a/DesktopVRIK/DesktopVRIKSystem.cs b/DesktopVRIK/DesktopVRIKSystem.cs index ace7a2b..68be22d 100644 --- a/DesktopVRIK/DesktopVRIKSystem.cs +++ b/DesktopVRIK/DesktopVRIKSystem.cs @@ -42,7 +42,6 @@ internal class DesktopVRIKSystem : MonoBehaviour void Start() { Instance = this; - Calibrator = new DesktopVRIKCalibrator(); playerSetup = GetComponent(); diff --git a/DesktopVRIK/VRIKHelpers/VRIKConfiguration.cs b/DesktopVRIK/VRIKHelpers/VRIKConfiguration.cs deleted file mode 100644 index 85d783c..0000000 --- a/DesktopVRIK/VRIKHelpers/VRIKConfiguration.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace NAK.DesktopVRIK.VRIKHelper; - -public class VRIKConfiguration -{ - // Solver settings - public float LocomotionWeight { get; set; } - public float LocomotionAngleThreshold { get; set; } - public float LocomotionMaxLegStretch { get; set; } - public float SpineMinHeadHeight { get; set; } - public float SolverIKPositionWeight { get; set; } - public float SpineChestClampWeight { get; set; } - public float SpineMaintainPelvisPosition { get; set; } - - // Body leaning settings - public float SpineBodyPosStiffness { get; set; } - public float SpineBodyRotStiffness { get; set; } - public float SpineNeckStiffness { get; set; } - - // Locomotion settings - public float LocomotionVelocityFactor { get; set; } - public float LocomotionMaxVelocity { get; set; } - public float LocomotionRootSpeed { get; set; } - - // Chest rotation - public float SpineRotateChestByHands { get; set; } - - public float SpineHeadClampWeight { get; set; } - - public float SpinePositionWeight { get; set; } - public float SpineRotationWeight { get; set; } - - public float SpineMaxRootAngle { get; set; } - - // BodySystem - public float SpinePelvisPositionWeight { get; set; } - public float LeftArmPositionWeight { get; set; } - public float LeftArmRotationWeight { get; set; } - public float RightArmPositionWeight { get; set; } - public float RightArmRotationWeight { get; set; } - public float LeftLegPositionWeight { get; set; } - public float LeftLegRotationWeight { get; set; } - public float RightLegPositionWeight { get; set; } - public float RightLegRotationWeight { get; set; } -} - -public static class VRIKConfigurator -{ - public static void ApplyVRIKConfiguration(CachedSolver cachedSolver, VRIKConfiguration config) - { - cachedSolver.Solver.IKPositionWeight = config.SolverIKPositionWeight; - cachedSolver.Locomotion.weight = config.LocomotionWeight; - cachedSolver.Locomotion.angleThreshold = config.LocomotionAngleThreshold; - cachedSolver.Locomotion.maxLegStretch = config.LocomotionMaxLegStretch; - - cachedSolver.Spine.chestClampWeight = config.SpineChestClampWeight; - cachedSolver.Spine.maintainPelvisPosition = config.SpineMaintainPelvisPosition; - cachedSolver.Spine.minHeadHeight = config.SpineMinHeadHeight; - - cachedSolver.Spine.bodyPosStiffness = config.SpineBodyPosStiffness; - cachedSolver.Spine.bodyRotStiffness = config.SpineBodyRotStiffness; - cachedSolver.Spine.neckStiffness = config.SpineNeckStiffness; - - cachedSolver.Locomotion.velocityFactor = config.LocomotionVelocityFactor; - cachedSolver.Locomotion.maxVelocity = config.LocomotionMaxVelocity; - cachedSolver.Locomotion.rootSpeed = config.LocomotionRootSpeed; - - cachedSolver.Spine.rotateChestByHands = config.SpineRotateChestByHands; - - cachedSolver.Spine.headClampWeight = config.SpineHeadClampWeight; - - cachedSolver.Spine.positionWeight = config.SpinePositionWeight; - cachedSolver.Spine.rotationWeight = config.SpineRotationWeight; - - cachedSolver.Spine.maxRootAngle = config.SpineMaxRootAngle; - - cachedSolver.Spine.maintainPelvisPosition = config.SpineMaintainPelvisPosition; - cachedSolver.Spine.pelvisPositionWeight = config.SpinePelvisPositionWeight; - cachedSolver.LeftArm.positionWeight = config.LeftArmPositionWeight; - cachedSolver.LeftArm.rotationWeight = config.LeftArmRotationWeight; - cachedSolver.RightArm.positionWeight = config.RightArmPositionWeight; - cachedSolver.RightArm.rotationWeight = config.RightArmRotationWeight; - cachedSolver.LeftLeg.positionWeight = config.LeftLegPositionWeight; - cachedSolver.LeftLeg.rotationWeight = config.LeftLegRotationWeight; - cachedSolver.RightLeg.positionWeight = config.RightLegPositionWeight; - cachedSolver.RightLeg.rotationWeight = config.RightLegRotationWeight; - } -} \ No newline at end of file diff --git a/DesktopVRIK/VRIKHelpers/VRIKConfigurations.cs b/DesktopVRIK/VRIKHelpers/VRIKConfigurations.cs deleted file mode 100644 index b412460..0000000 --- a/DesktopVRIK/VRIKHelpers/VRIKConfigurations.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace NAK.DesktopVRIK.VRIKHelper; - -public static class VRIKConfigurations -{ - public static VRIKConfiguration DesktopVRIKConfiguration() - { - return new VRIKConfiguration - { - // Solver settings - LocomotionWeight = 0f, - LocomotionAngleThreshold = 30f, - LocomotionMaxLegStretch = 1f, - SpineMinHeadHeight = 0f, - SolverIKPositionWeight = 1f, - SpineChestClampWeight = 0f, - SpineMaintainPelvisPosition = 1f, - - // Body leaning settings - SpineBodyPosStiffness = 1f, - SpineBodyRotStiffness = 0.2f, - SpineNeckStiffness = 0.0001f, //hack - - // Locomotion settings - LocomotionVelocityFactor = 0f, - LocomotionMaxVelocity = 0f, - LocomotionRootSpeed = 1000f, - - // Chest rotation - SpineRotateChestByHands = 0f, //pam, bid, leap motion change - - // LookAtIK priority - SpineHeadClampWeight = 0.2f, - - // Tippytoes - SpinePositionWeight = 0f, - SpineRotationWeight = 1f, - - // Emotes - SpineMaxRootAngle = 180f, - - // BodySystem - SpinePelvisPositionWeight = 0f, - LeftArmPositionWeight = 0f, - LeftArmRotationWeight = 0f, - RightArmPositionWeight = 0f, - RightArmRotationWeight = 0f, - LeftLegPositionWeight = 0f, - LeftLegRotationWeight = 0f, - RightLegPositionWeight = 0f, - RightLegRotationWeight = 0f, - }; - } -} \ No newline at end of file