Skip to content

Commit

Permalink
Merge pull request #760 from anatawa12/fix-blendshape-broken
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 authored Nov 29, 2023
2 parents 6ed9257 + 1d03175 commit 1e0d8ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog].

### Fixed
- Error if there are None colliders for PhysBone `#758`
- BlendShapes can broken in extreamly rare cases `#760`
- It seems this is due to Unity bug.

### Security

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog].

### Fixed
- Error if there are None colliders for PhysBone `#758`
- BlendShapes can broken in extreamly rare cases `#760`
- It seems this is due to Unity bug.

### Security

Expand Down
6 changes: 6 additions & 0 deletions Editor/Processors/SkinnedMeshes/MeshInfo2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using Debug = System.Diagnostics.Debug;
using Object = UnityEngine.Object;

namespace Anatawa12.AvatarOptimizer.Processors.SkinnedMeshes
{
Expand Down Expand Up @@ -652,6 +653,11 @@ public void WriteToSkinnedMeshRenderer(SkinnedMeshRenderer targetRenderer)
var mesh = new Mesh { name = $"AAOGeneratedMesh{targetRenderer.name}" };

WriteToMesh(mesh);
// I don't know why but Instantiating mesh will fix broken blendshapes with
// https://github.com/anatawa12/AvatarOptimizer/issues/753
// https://booth.pm/ja/items/1054593.
mesh = Object.Instantiate(mesh);
mesh.name = $"AAOGeneratedMesh{targetRenderer.name}";
targetRenderer.sharedMesh = mesh;
for (var i = 0; i < BlendShapes.Count; i++)
targetRenderer.SetBlendShapeWeight(i, BlendShapes[i].weight);
Expand Down

0 comments on commit 1e0d8ad

Please sign in to comment.