diff --git a/Assets/MeshUtility/Runtime/BoneNormalizer.cs b/Assets/MeshUtility/Runtime/BoneNormalizer.cs
index cb528d5cd..4747dbd2e 100644
--- a/Assets/MeshUtility/Runtime/BoneNormalizer.cs
+++ b/Assets/MeshUtility/Runtime/BoneNormalizer.cs
@@ -222,7 +222,7 @@ namespace MeshUtility
/// 正規化前のSkinnedMeshRendererのTransform
/// 正規化後のSkinnedMeshRendererのTransform
/// 正規化前のボーンから正規化後のボーンを得る
- static void NormalizeSkinnedMesh(Transform src, Transform dst, Dictionary boneMap, bool clearBlendShape)
+ static void NormalizeSkinnedMesh(Transform src, Transform dst, Dictionary boneMap)
{
var srcRenderer = src.GetComponent();
if (srcRenderer == null
@@ -237,15 +237,6 @@ namespace MeshUtility
var srcMesh = srcRenderer.sharedMesh;
var originalSrcMesh = srcMesh;
- if (clearBlendShape)
- {
- // clear blendShape if not bake current blendshape
- for (int i = 0; i < srcMesh.blendShapeCount; ++i)
- {
- srcRenderer.SetBlendShapeWeight(i, 0);
- }
- }
-
// 元の Transform[] bones から、無効なboneを取り除いて前に詰めた配列を作る
var dstBones = srcRenderer.bones
.Where(x => x != null && boneMap.ContainsKey(x))
@@ -307,8 +298,10 @@ namespace MeshUtility
//
// clear blendShape always
+ var backcup = new List();
for (int i = 0; i < srcMesh.blendShapeCount; ++i)
{
+ backcup.Add(srcRenderer.GetBlendShapeWeight(i));
srcRenderer.SetBlendShapeWeight(i, 0);
}
@@ -442,6 +435,11 @@ namespace MeshUtility
srcRenderer.bones = new Transform[] { };
srcRenderer.sharedMesh = originalSrcMesh;
}
+ // restore blendshape weights
+ for (int i = 0; i < backcup.Count; ++i)
+ {
+ srcRenderer.SetBlendShapeWeight(i, backcup[i]);
+ }
}
///
@@ -481,11 +479,10 @@ namespace MeshUtility
/// 回転とスケールを除去したヒエラルキーのコピーを作成する(MeshをBakeする)
///
/// 対象のヒエラルキーのルート
- /// BlendShapeを0クリアするか否か。false の場合 BlendShape の現状を Bake する
+ /// BlendShapeを0クリアするか否か。false の場合 BlendShape の現状を Bake する
/// Avatarを作る関数
///
- public static (GameObject, Dictionary) Execute(GameObject go,
- bool clearBlendShapeBeforeNormalize, CreateAvatarFunc createAvatar)
+ public static (GameObject, Dictionary) Execute(GameObject go, CreateAvatarFunc createAvatar)
{
//
// 正規化されたヒエラルキーを作る
@@ -503,7 +500,7 @@ namespace MeshUtility
continue;
}
- NormalizeSkinnedMesh(src, dst, boneMap, clearBlendShapeBeforeNormalize);
+ NormalizeSkinnedMesh(src, dst, boneMap);
NormalizeNoneSkinnedMesh(src, dst);
}
diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs
index db5dde874..03d86ae3f 100644
--- a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs
+++ b/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs
@@ -196,7 +196,7 @@ namespace VRM
if (settings.PoseFreeze)
{
// BoneNormalizer.Execute は Copy を作って正規化する。UNDO無用
- target = VRMBoneNormalizer.Execute(target, settings.ForceTPose, false);
+ target = VRMBoneNormalizer.Execute(target, settings.ForceTPose);
destroy.Add(target);
}
diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs b/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs
index 6dbb8bc29..67d80b977 100644
--- a/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs
+++ b/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs
@@ -49,7 +49,7 @@ namespace VRM
var go = Selection.activeObject as GameObject;
// BoneNormalizer.Execute はコピーを正規化する。UNDO無用
- Selection.activeGameObject = VRMBoneNormalizer.Execute(go, true, false);
+ Selection.activeGameObject = VRMBoneNormalizer.Execute(go, true);
}
}
}
diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs b/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs
index cc6b6cdd9..ce0b8170a 100644
--- a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs
+++ b/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs
@@ -42,7 +42,7 @@ namespace VRM
/// 対象モデルのルート
/// 強制的にT-Pose化するか
/// 正規化済みのモデル
- public static GameObject Execute(GameObject go, bool forceTPose, bool clearBlendShapeBeforeNormalize)
+ public static GameObject Execute(GameObject go, bool forceTPose)
{
//
// T-Poseにする
@@ -66,7 +66,7 @@ namespace VRM
//
// 正規化されたヒエラルキーを作る
//
- var (normalized, bMap) = MeshUtility.BoneNormalizer.Execute(go, clearBlendShapeBeforeNormalize, (_src, dst, boneMap) =>
+ var (normalized, bMap) = MeshUtility.BoneNormalizer.Execute(go, (_src, dst, boneMap) =>
{
var src = _src.GetComponent();