Skip to content

Commit

Permalink
chore(avatarHelpers): Static function for HandModel fingers initializ…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
jorgejgnz committed Oct 24, 2020
1 parent c507715 commit c41ee97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
18 changes: 18 additions & 0 deletions Runtime/Helpers/AvatarHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ public enum GestureType

public static class AvatarHelpers
{
public static void HandModelInit(HandModel hand)
{
List<FingerModel> fingerList = new List<FingerModel>();

if (hand.thumb) fingerList.Add(hand.thumb);
if (hand.index) fingerList.Add(hand.index);
if (hand.middle) fingerList.Add(hand.middle);
if (hand.ring) fingerList.Add(hand.ring);
if (hand.pinky) fingerList.Add(hand.pinky);

hand.fingers = fingerList.ToArray();

for (int i = 0; i < hand.fingers.Length; i++)
{
hand.fingers[i].hand = hand;
}
}

public static BoneModel[] GetHandBones(HandModel hand)
{
// Same order as OVRSkeleton.Bones
Expand Down
15 changes: 1 addition & 14 deletions Runtime/Modules/ProxyHand/Hand/HandModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,7 @@ protected void Awake()

if (fingers == null || fingers.Length == 0)
{
List<FingerModel> fingerList = new List<FingerModel>();

if (thumb) fingerList.Add(thumb);
if (index) fingerList.Add(index);
if (middle) fingerList.Add(middle);
if (ring) fingerList.Add(ring);
if (pinky) fingerList.Add(pinky);

fingers = fingerList.ToArray();
}

for (int i = 0; i < fingers.Length; i++)
{
fingers[i].hand = this;
AvatarHelpers.HandModelInit(this);
}

// Bones
Expand Down

0 comments on commit c41ee97

Please sign in to comment.