Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Correct handling of non-Body face meshes #73

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,31 @@ public override void OnInspectorGUI()
EditorGUILayout.EndHorizontal();

// Run asserts, however continue rendering GUI if errors are encountered.
bool avatarOkay = _commonChecks.RunChecks(avatar.gameObject);
bool avatarOkay = _commonChecks.RunChecks(avatar.gameObject, isBuildTime: false);

var visemeSkinnedMesh = avatar?.VisemeSkinnedMesh;
var renameFaceForMmdComponents = avatar?.gameObject.GetComponentsInChildren<RenameFaceForMmdComponent>();
if (!data.ignoreFaceMeshName && visemeSkinnedMesh.name != "Body" && renameFaceForMmdComponents.Count() == 0)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox(L.Tr("CommonChecks:AvatarFaceSMRNotCalledBody"), MessageType.Info);
EditorGUILayout.BeginVertical();
if (GUILayout.Button(L.Tr("Common:FixThis")))
{
data.gameObject.AddComponent<RenameFaceForMmdComponent>();
}
if (GUILayout.Button(L.Tr("Common:Ignore")))
{
data.ignoreFaceMeshName = true;
}
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
}

bool hasMmdShapeKeys = false;
if (!EditorApplication.isPlaying)
{
// TODO: check all languages
var visemeSkinnedMesh = avatar?.VisemeSkinnedMesh;
for (int i = 0; i < visemeSkinnedMesh?.sharedMesh.blendShapeCount; i++)
{
string blendShapeName = visemeSkinnedMesh.sharedMesh.GetBlendShapeName(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CommonChecks(bool isEditor)
_isEditor = isEditor;
}

public bool RunChecks(GameObject avatarRootObject)
public bool RunChecks(GameObject avatarRootObject, bool isBuildTime = true)
{
var avatarDescriptor = avatarRootObject.GetComponent<VRCAvatarDescriptor>();
var mappingsComponents = avatarRootObject.GetComponentsInChildren<BlendShapeMappings>();
Expand All @@ -38,7 +38,7 @@ public bool RunChecks(GameObject avatarRootObject)
LogLocalized(Severity.Error, "CommonChecks:MultipleMMDComponents");
return false;
}
if (!RunChecks(mappingsComponents.First()) || !RunChecks(avatarDescriptor))
if (!RunChecks(mappingsComponents.First()) || !RunChecks(avatarDescriptor, isBuildTime))
{
return false;
}
Expand Down Expand Up @@ -73,7 +73,7 @@ public bool RunChecks(BlendShapeMappings blendShapeMappings)
}

// TODO: use an enum or types to decide what checks to skip?
public bool RunChecks(VRCAvatarDescriptor avatarDescriptor, bool ignoreBodyName = false)
public bool RunChecks(VRCAvatarDescriptor avatarDescriptor, bool isBuildTime = true)
{
if (avatarDescriptor == null)
{
Expand All @@ -88,7 +88,7 @@ public bool RunChecks(VRCAvatarDescriptor avatarDescriptor, bool ignoreBodyName
return false;
}

if (visemeSkinnedMesh.name != "Body" && !ignoreBodyName)
if (visemeSkinnedMesh.name != "Body" && isBuildTime)
{
LogLocalized(Severity.Warning, "CommonChecks:AvatarFaceSMRNotCalledBody");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ msgstr ""
msgid "locale:en-us"
msgstr "English"

msgid "Common:FixThis"
msgstr "Fix this"

msgid "Common:Ignore"
msgstr "Ignore"

msgid "BlendShapeMappingsPass:CombiningWithMultipleFramesUnsupported"
msgstr "Currently, combining multiple blend shapes with more than one frame is unsupported. Please contact the developer if you would like to request this feature."

Expand All @@ -30,7 +36,7 @@ msgid "CommonChecks:AvatarNoFaceMeshSet"
msgstr "Avatar has not set a face mesh!"

msgid "CommonChecks:AvatarFaceSMRNotCalledBody"
msgstr "Avatar face mesh must be called \"Body\"!"
msgstr "Avatar face mesh must be called \"Body\" to be recognized in MMD worlds. You can use the \"MIM Rename Face For MMD\" component to fix this."

msgid "CommonChecks:AvatarFaceSMRNoMesh"
msgstr "Avatar face mesh is missing!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ msgstr ""
msgid "locale:ja-jp"
msgstr "日本語"

msgid "Common:FixThis"
msgstr "修正する"

msgid "Common:Ignore"
msgstr "無視する"

msgid "BlendShapeMappingsPass:CombiningWithMultipleFramesUnsupported"
msgstr "現在、複数のブレンドシェイプを複数フレームで組み合わせることはサポートされていません。この機能をリクエストしたい場合は、本ツールの開発者にお問い合わせしてお願いいたします。"

Expand All @@ -30,7 +36,7 @@ msgid "CommonChecks:AvatarNoFaceMeshSet"
msgstr "アバターのFace Meshが設定されていません!"

msgid "CommonChecks:AvatarFaceSMRNotCalledBody"
msgstr "アバターのFace Meshは「Body」と名前を付ける必要があります"
msgstr "アバターの Face Mesh は MMD ワールドで認識されるために 「Body」 と名前を付ける必要があります。 本ツールの 「MIM Rename Face For MMD」 コンポーネントを使用してこれを修正できます。"

msgid "CommonChecks:AvatarFaceSMRNoMesh"
msgstr "アバターのFace Meshに、メッシュが設定されていません!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ msgstr ""
msgid "locale:zh-hant"
msgstr "繁體中文"

msgid "Common:FixThis"
msgstr "修正"

msgid "Common:Ignore"
msgstr "忽略"

msgid "CommonChecks:NoMMDComponents"
msgstr "未在 Avatar 中發現 「Make It MMD」 元件,無事可做"

Expand All @@ -21,7 +27,7 @@ msgid "CommonChecks:AvatarNoFaceMeshSet"
msgstr "Avatar 尚未設定臉部網格!"

msgid "CommonChecks:AvatarFaceSMRNotCalledBody"
msgstr "Avatar 的臉部網格必須稱為「Body」"
msgstr "Avatar 的臉部網格必須稱為「Body」,才能在 MMD world 中被識別。您可以使用 「MIM Rename Face For MMD」 組件來修正此問題。"

msgid "CommonChecks:AvatarFaceSMRNoMesh"
msgstr "找不到 Avatar 的臉部網格!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ protected override void Configure()
{
var seq = InPhase(BuildPhase.Transforming);
seq.AfterPlugin("nadena.dev.modular-avatar");
seq.Run(BlendShapeMappingsPass.Instance);
seq.WithRequiredExtension(typeof(AnimationServicesContext), _ =>
{
seq.Run(RenameFaceForMmdPass.Instance);
});
seq.Run(BlendShapeMappingsPass.Instance);
seq.Run(RemoveAnimatorLayersPass.Instance);
seq.Run(WriteDefaultsPass.Instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void OnInspectorGUI()
EditorGUILayout.EndHorizontal();

// Run asserts, however continue rendering GUI if errors are encountered.
_commonChecks.RunChecks(avatar, ignoreBodyName: true);
_commonChecks.RunChecks(avatar, isBuildTime: false);
if (avatar.VisemeSkinnedMesh.name == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public class BlendShapeMappings : MonoBehaviour, ISerializationCallbackReceiver,

public int dataVersion;

public bool ignoreFaceMeshName = false;

[FormerlySerializedAs("blendShapeMappings")]
[SerializeField]
internal List<MMDToAvatarBlendShape> _blendShapeMappings = new List<MMDToAvatarBlendShape>();
Expand Down
Loading