From 98d0100630a04478953af905aa34e9fb1ce495e5 Mon Sep 17 00:00:00 2001 From: suzuryg Date: Thu, 21 Dec 2023 22:52:13 +0900 Subject: [PATCH] fix: "LookingUp" is used for blinking if "Blink" is set to none --- .../Editor/Detail/AV3/AV3Utility.cs | 26 +++++++++++++++++++ .../Editor/Detail/AV3/FxGenerator.cs | 6 ++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/AV3Utility.cs b/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/AV3Utility.cs index 6b92fcd2..6a60baca 100644 --- a/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/AV3Utility.cs +++ b/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/AV3Utility.cs @@ -193,6 +193,32 @@ public static HashSet 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 GetEyeLidsBlendShapes(VRCAvatarDescriptor avatarDescriptor) { var ret = new List(); diff --git a/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/FxGenerator.cs b/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/FxGenerator.cs index b260097f..8f15624a 100644 --- a/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/FxGenerator.cs +++ b/Packages/jp.suzuryg.face-emo/Editor/Detail/AV3/FxGenerator.cs @@ -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 {