Skip to content

Commit

Permalink
Add Copy API for joint provider (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
FejZa authored Dec 19, 2023
1 parent 16f4a6e commit 3dcbf91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Runtime/Input/Hands/HandJointTransformProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ private void UpdateCache()

private void InvalidateCache() => Cache.Clear();

/// <inheritdoc/>
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);
}
}
}

/// <inheritdoc/>
public void SetTransform(HandJoint joint, Transform transform)
{
Expand Down
6 changes: 6 additions & 0 deletions Runtime/Input/Hands/IHandJointTransformProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public interface IHandJointTransformProvider
/// </summary>
event Action JointTransformsChanged;

/// <summary>
/// Copies all joint <see cref="Transform"/> information from the <paramref name="sourceProvider"/>.
/// </summary>
/// <param name="sourceProvider">The <see cref="IHandJointTransformProvider"/> to copy from.</param>
void Copy(IHandJointTransformProvider sourceProvider);

/// <summary>
/// Sets the <see cref="Transform"/> for a given <see cref="HandJoint"/>.
/// </summary>
Expand Down

0 comments on commit 3dcbf91

Please sign in to comment.