protected override void InitiateSolver() { if (references.isEmpty) { AutoDetectReferences(); } if (references.isFilled) { solver.SetToReferences(references); } base.InitiateSolver(); }
/// <summary> /// Reinitializes the IK and Solver. /// </summary> public void ReInitialize() { Debug.Log($"Reinit CustomVRIK"); solver.initiated = false; componentInitiated = false; FindAnimatorRecursive(transform, true); //We only call the base solver because on reinit we will want to assume //that the avatar has been replaced, and we'll need to find the data component that can be used to retreieve it. IAvatarIKReferenceContainer <CustomVRIKReferences> referenceContainer = this.GetComponentInChildren <IAvatarIKReferenceContainer <CustomVRIKReferences> >(); //If we contain no reference data //then we should just autodetect and wish for the best //though this could cost performance issues on failure maybe? if (referenceContainer == null) { Debug.LogWarning($"Failed to find IK reference container."); AutoDetectReferences(); } else { //Set the references in the IK controller this.references = referenceContainer.references; //We should do nothing if the references are empty. if (references.isEmpty) { return; } var oldSolver = solver; solver = new IKSolverVR { spine = { headTarget = oldSolver.spine.headTarget }, leftArm = { target = oldSolver.leftArm.target }, rightArm = { target = oldSolver.rightArm.target } }; //First let's set the trackers to the appropriate local rotation //These compute from precomputed EULER angles from the SDK. solver.leftArm.target.localEulerAngles = references.LocalLeftHandRotation; solver.rightArm.target.localEulerAngles = references.LocalRightHandRotation; solver.spine.headTarget.localEulerAngles = references.LocalHeadRotation; solver.SetToReferences(references); } base.InitiateSolver(); componentInitiated = true; }
protected override void InitiateSolver() { if (references.isEmpty) { AutoDetectReferences(); } //HelloKitty: Custom change to prevent issues with non-IK avatars. if (enabled == false) { return; } if (references.isFilled) { solver.SetToReferences(references); } base.InitiateSolver(); }