Skip to content

Commit

Permalink
Merge pull request #98 from suzuryg/fix/looking-up-is-used-for-blinking
Browse files Browse the repository at this point in the history
fix: "LookingUp" is used for blinking if "Blink" is set to none
  • Loading branch information
suzuryg committed Dec 21, 2023
2 parents 31e09af + 98d0100 commit a796fdd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
26 changes: 26 additions & 0 deletions Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/AV3Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,32 @@ public static HashSet<BlendShape> GetBlendShapesToBeExcluded(VRCAvatarDescriptor
return toBeExcluded;
}

// FIXME: This method should be merged with GetEyeLidsBlendShapes().
public static BlendShape GetBlinkBlendShape(VRCAvatarDescriptor avatarDescriptor)
{
if (avatarDescriptor != null &&
avatarDescriptor.customEyeLookSettings.eyelidsBlendshapes != null &&
avatarDescriptor.customEyeLookSettings.eyelidsSkinnedMesh != null &&
avatarDescriptor.customEyeLookSettings.eyelidsSkinnedMesh.sharedMesh != null)
{
var skinnedMesh = avatarDescriptor.customEyeLookSettings.eyelidsSkinnedMesh;
var transformPath = GetPathFromAvatarRoot(skinnedMesh.transform, avatarDescriptor);
if (transformPath == null) { return null; }

if (avatarDescriptor.customEyeLookSettings.eyelidsBlendshapes.Length > 0)
{
var index = avatarDescriptor.customEyeLookSettings.eyelidsBlendshapes[0];
if (0 <= index && index < skinnedMesh.sharedMesh.blendShapeCount)
{
var name = skinnedMesh.sharedMesh.GetBlendShapeName(index);
return new BlendShape(path: transformPath, name: name);
}
}
}
return null;
}

// FIXME: Refactoring is needed because of confusion between "blink" and "eyelid" blend shapes in this method calls.
public static List<BlendShape> GetEyeLidsBlendShapes(VRCAvatarDescriptor avatarDescriptor)
{
var ret = new List<BlendShape>();
Expand Down
6 changes: 3 additions & 3 deletions Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/FxGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,10 +1359,10 @@ private AacFlClip GetBlinkAnimation(AacFlBase aac, VRCAvatarDescriptor avatarDes
return clip;
}

var eyeLids = AV3Utility.GetEyeLidsBlendShapes(avatarDescriptor);
if (eyeLids.Count > 0)
var blink = AV3Utility.GetBlinkBlendShape(avatarDescriptor);
if (blink is BlendShape)
{
clip = clip.BlendShape(faceMesh, eyeLids.First().Name, GetBlinkCurve());
clip = clip.BlendShape(faceMesh, blink.Name, GetBlinkCurve());
}
else
{
Expand Down

0 comments on commit a796fdd

Please sign in to comment.