// Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. using System; #if ISDK_DEFINED using Oculus.Interaction.Input; #endif using UnityEngine; namespace Meta.XR.Movement.Retargeting { /// /// Helper class for managing ISDK (Interaction SDK) components and processors. /// public class ISDKHelper : MonoBehaviour { #if ISDK_DEFINED /// /// Structure containing references to hand components and processors. /// [Serializable] public struct ISDKData { /// /// The GameObject containing the hand component. /// [SerializeField] public GameObject Hand; /// /// Array of CCD (Cyclic Coordinate Descent) skeletal processors to control. /// [SerializeField] public CCDSkeletalProcessor[] CCDProcessors; /// /// Array of ISDK skeletal processors to control. /// [SerializeField] public ISDKSkeletalProcessor[] ISDKProcessors; /// /// Reference to the IHand component on the Hand GameObject. /// public IHand iHand; } [SerializeField] protected ISDKData[] _isdkData; /// /// Updates the weights of processors based on hand tracking state. /// Enables processors when hand tracking is valid and disables them otherwise. /// public void Update() { for (int i = 0; i < _isdkData.Length; i++) { var data = _isdkData[i]; if (data.iHand == null) { data.iHand = data.Hand.GetComponent(); } bool enableHandProcessors = data.iHand.IsConnected && data.iHand.IsHighConfidence && data.iHand.IsTrackedDataValid; if (data.CCDProcessors != null) { foreach (var ccdProcessor in data.CCDProcessors) { ccdProcessor.Weight = enableHandProcessors ? 1.0f : 0.0f; } } if (data.ISDKProcessors != null) { foreach (var isdkProcessor in data.ISDKProcessors) { isdkProcessor.Weight = enableHandProcessors ? 1.0f : 0.0f; } } } } #endif } }