From 3dcbf9112b1ed1026d0965f6117990c680a4e944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Fejzagi=C4=87?= Date: Tue, 19 Dec 2023 19:54:58 +0100 Subject: [PATCH] Add Copy API for joint provider (#105) --- Runtime/Input/Hands/HandJointTransformProvider.cs | 14 ++++++++++++++ Runtime/Input/Hands/IHandJointTransformProvider.cs | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/Runtime/Input/Hands/HandJointTransformProvider.cs b/Runtime/Input/Hands/HandJointTransformProvider.cs index 93ea3f2d..c580d722 100644 --- a/Runtime/Input/Hands/HandJointTransformProvider.cs +++ b/Runtime/Input/Hands/HandJointTransformProvider.cs @@ -48,6 +48,20 @@ private void UpdateCache() private void InvalidateCache() => Cache.Clear(); + /// + public void Copy(IHandJointTransformProvider sourceProvider) + { + var jointCount = Enum.GetNames(typeof(HandJoint)).Length; + for (var i = 0; i < jointCount; i++) + { + var joint = (HandJoint)i; + if (sourceProvider.TryGetTransform(joint, out var transform)) + { + SetTransform(joint, transform); + } + } + } + /// public void SetTransform(HandJoint joint, Transform transform) { diff --git a/Runtime/Input/Hands/IHandJointTransformProvider.cs b/Runtime/Input/Hands/IHandJointTransformProvider.cs index a4079197..37cf9597 100644 --- a/Runtime/Input/Hands/IHandJointTransformProvider.cs +++ b/Runtime/Input/Hands/IHandJointTransformProvider.cs @@ -18,6 +18,12 @@ public interface IHandJointTransformProvider /// event Action JointTransformsChanged; + /// + /// Copies all joint information from the . + /// + /// The to copy from. + void Copy(IHandJointTransformProvider sourceProvider); + /// /// Sets the for a given . ///