Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rename BlendShape #1245

Merged
merged 47 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5df0466
feat: initial commit for prefab safe map
anatawa12 Oct 7, 2024
503f5a3
chore: reimplement PrefabSafeSet/Map with PrefabSafeUniqueCollection
anatawa12 Oct 7, 2024
5ac0fec
chore: move more function to PrefabSafeUniqueCollection.cs
anatawa12 Oct 7, 2024
1624f96
refactor: remove PrefabSafeSetRuntimeUtil
anatawa12 Oct 7, 2024
f2d04e9
refactor: refine null handling in PrefabSafeSet
anatawa12 Oct 7, 2024
d527486
feat: initial commit for EditorUtil for PrefabSafeUniqueCollection
anatawa12 Oct 7, 2024
9e3f4c6
refactor: change EditorUtil for PrefabSafeUniqueCollection
anatawa12 Oct 7, 2024
e4c58ca
refactor: reimplement EditorUtil for PrefabSafeSet with it for Prefab…
anatawa12 Oct 7, 2024
2eb297d
chore: make prefab override on drop
anatawa12 Oct 7, 2024
d0347db
refactor: move files and rename something
anatawa12 Oct 7, 2024
98dc1db
chore: remove IPrefabSafeSetApi
anatawa12 Oct 7, 2024
f6c2b65
refactor: IElement => IBaseElement
anatawa12 Oct 7, 2024
2226042
feat: add PSMEditorUtil
anatawa12 Oct 7, 2024
fa9f6c1
refactor: move PropertyScope
anatawa12 Oct 7, 2024
8105745
feat: PrefabSafeMap.PropertyScope
anatawa12 Oct 7, 2024
7251f32
Merge remote-tracking branch 'origin/master' into rename-blendshape
anatawa12 Oct 8, 2024
4ab3389
fix: PSM.PropertyScope is not IDisposable
anatawa12 Oct 8, 2024
aacd945
feat: add Add(Key,Value) to PSMEditorUtil
anatawa12 Oct 8, 2024
5e1a722
feat: initial commit for RenameBlendShape and its inspector
anatawa12 Oct 8, 2024
2fd7904
feat: initial commit for RenameBlendShapeProcessor
anatawa12 Oct 8, 2024
df31e66
feat: implement RenameBlendShape editor
anatawa12 Oct 8, 2024
156bc6a
feat: implement RenameBlendShapeProcessor
anatawa12 Oct 8, 2024
9566709
chore: localize RenameBlendShapeEditor
anatawa12 Oct 8, 2024
058de3d
fix: update CopyDataFrom (fix an bug)
anatawa12 Oct 8, 2024
4e5b44a
chore: use EnsureRemoved in RenameBlendShapeEditor
anatawa12 Oct 8, 2024
8b28167
docs: document Rename BlendShape
anatawa12 Oct 9, 2024
6c33881
docs(changelog): Rename BlendShape component to rename BlendShapes
anatawa12 Oct 9, 2024
d8cd206
fix(prefab-safe-map): remove unnecessary fakeSlot
anatawa12 Oct 9, 2024
7874f2d
fix: RenameBlendShape is unexpectedly marked as public
anatawa12 Oct 9, 2024
1252c00
test: log files after running tests
anatawa12 Oct 9, 2024
ceca4fe
docs: fix image
anatawa12 Oct 9, 2024
c4a2c14
chore(ja): add localization
Sayamame-beans Oct 9, 2024
9283075
chore(ja): update locale
Sayamame-beans Oct 9, 2024
8cf4773
docs(en): chore casing
Sayamame-beans Oct 9, 2024
b9a3e0d
docs(ja): add localization for Rename BlendShape
Sayamame-beans Oct 9, 2024
91f8051
chore(ja): update locale
Sayamame-beans Oct 9, 2024
c5b5438
fix: crash on exiting Unity due to Unity bug
anatawa12 Oct 9, 2024
1d8e060
chore: RenameBlendShape:warning:weight-conflict-some => name-conflict…
anatawa12 Oct 10, 2024
636d044
feat: add tooltip for error / warned field in RenameBlendShape inspector
anatawa12 Oct 10, 2024
ca7d687
docs: note that Rename BlendShape is Modifying Edit Skinned Mesh Comp…
anatawa12 Oct 10, 2024
1706ea9
test: add test for Rename BlendShape
anatawa12 Oct 10, 2024
f3953d4
test: add test for swapping blendShape
anatawa12 Oct 10, 2024
7ea7444
docs: add Rename BlendShape to component kind page
anatawa12 Oct 11, 2024
3e5322b
docs(en/ja): update locale
Sayamame-beans Oct 12, 2024
865df97
chore(ja): update locale
Sayamame-beans Oct 12, 2024
9307356
chore: improve RenameBlendShape:warning:weight-conflict message
anatawa12 Oct 12, 2024
d801fca
chore(ja/en): chore messages
Sayamame-beans Oct 12, 2024
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
55 changes: 53 additions & 2 deletions .docs/Unity/Anon.unity
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,30 @@ MonoBehaviour:
- {fileID: 1411353995}
- {fileID: 1411353994}
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot: {fileID: 0}
staticRenderersSet:
mainSet: []
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot: {fileID: 0}
doNotMergeMaterials:
mainSet: []
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot: {fileID: 0}
removeEmptyRendererObject: 1
skipEnablementMismatchedRenderers: 0
copyEnablementAnimation: 0
--- !u!137 &870201505
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -267,6 +280,10 @@ MonoBehaviour:
- Delete_Bra
- Delete_Pants
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot:
--- !u!1 &1391228312
GameObject:
Expand Down Expand Up @@ -493,6 +510,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 7703706129674054865, guid: 8ae2a6881bbfcd84697b56e80d826039, type: 3}
insertIndex: -1
addedObject: {fileID: 1411354005}
- targetCorrespondingSourceObject: {fileID: 7703706129674054865, guid: 8ae2a6881bbfcd84697b56e80d826039, type: 3}
insertIndex: -1
addedObject: {fileID: 1411354008}
m_SourcePrefab: {fileID: 100100000, guid: 8ae2a6881bbfcd84697b56e80d826039, type: 3}
--- !u!4 &1411353993 stripped
Transform:
Expand Down Expand Up @@ -577,6 +597,10 @@ MonoBehaviour:
- Shrink_Spine_2
- Shrink_Hip
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot:
tolerance: 0.001
--- !u!1 &1411354006 stripped
Expand All @@ -603,8 +627,10 @@ MonoBehaviour:
optimizePhysBone: 1
optimizeAnimator: 1
mergeSkinnedMesh: 1
allowShuffleMaterialSlots: 0
optimizeTexture: 1
mmdWorldCompatibility: 1
advancedSettings:
debugOptions:
exclusions: []
gcDebug: 0
noConfigureMergeBone: 0
Expand All @@ -615,11 +641,36 @@ MonoBehaviour:
skipMergePhysBoneCollider: 0
skipEntryExitToBlendTree: 0
skipRemoveUnusedAnimatingProperties: 0
skipMergeDirectBlendTreeLayers: 0
skipMergeBlendTreeLayer: 0
skipRemoveMeaninglessAnimatorLayer: 0
skipMergeStaticSkinnedMesh: 0
skipMergeAnimatingSkinnedMesh: 0
skipMergeMaterialAnimatingSkinnedMesh: 0
skipMergeMaterials: 0
skipRemoveEmptySubMesh: 0
skipAnyStateToEntryExit: 0
--- !u!114 &1411354008
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1411354004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 71ba6c5e4332471bb8048f7890eaab73, type: 3}
m_Name:
m_EditorClassIdentifier:
nameMap:
mainSet:
- key: Breast_flat
value: New Name
prefabLayers: []
usingOnSceneLayer: 0
onSceneLayer:
removes: []
additions: []
fakeSlot:
--- !u!1 &1560436838
GameObject:
m_ObjectHideFlags: 1
Expand Down
Sayamame-beans marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions .docs/content/docs/reference/rename-blendshape/index.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Rename BlendShape
weight: 30
---

# Rename BlendShape

メッシュのBlendShape名を変更することが出来ます。

変更後の名前が重複している場合、それらは1つのBlendShapeへと統合されます。

## 設定 {#Settings}

![component.png](component.png)

BlendShape名の変更一覧表が表示されます。
左上の '+' ボタンから、名前を変更するBlendShapeを追加することが出来ます。

変更後の名前が重複している場合は、それらが統合されることを示すために、入力欄が黄色でハイライトされます。
20 changes: 20 additions & 0 deletions .docs/content/docs/reference/rename-blendshape/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Rename BlendShape
weight: 30
---

# Rename BlendShape

Renames BlendShapes in the Mesh.

If renamed name is duplicated, it will merge the BlendShapes into one.

anatawa12 marked this conversation as resolved.
Show resolved Hide resolved
## Settings

![component.png](component.png)

You'll see list of BlendShape mapping.

Click upper left '+' button to add new mapping.

If the renamed name is duplicated, it will be shown in yellow color to indicate that it will be merged.
4 changes: 4 additions & 0 deletions .github/workflows/gameci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
customParameters:
checkName: Test results ${{ matrix.unity }}

- name: "Show files at root folder to find crash log"
if: always()
run: ls -la

- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog].

## [Unreleased]
### Added
- Rename BlendShape component to rename BlendShapes `#1245`
- This can be used to avoid blendShape name conflicts in Merge Skinned Mesh

### Changed
- Performance Improvements with Mesh Manipulation, especially with blendshape-heavy meshes `#1234` `#1243` `#1240`
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The format is based on [Keep a Changelog].
- If you're building your avatar with batchmode with -nographics, please remove -nographics.
- Asset Description for Avatar Modify Support bundled in an avatar, Shinano `#1189`
- API to get in advance whether a polygon will be removed `#1177`
- Rename BlendShape component to rename BlendShapes `#1245`
- This can be used to avoid blendShape name conflicts in Merge Skinned Mesh

### Changed
- Skip Enablement Mismatched Renderers is now disabled by default `#1169`
Expand Down
1 change: 1 addition & 0 deletions Editor/EditSkinnedMeshComponentUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private T CheckRecursive<T>(Func<T> compute)
[typeof(RemoveMeshByBlendShape)] = x => new RemoveMeshByBlendShapeProcessor((RemoveMeshByBlendShape)x),
[typeof(RemoveMeshByMask)] = x => new RemoveMeshByMaskProcessor((RemoveMeshByMask)x),
[typeof(InternalAutoFreezeMeaninglessBlendShape)] = x => new InternalAutoFreezeMeaninglessBlendShapeProcessor((InternalAutoFreezeMeaninglessBlendShape)x),
[typeof(RenameBlendShape)] = x => new RenameBlendShapeProcessor((RenameBlendShape)x),
[typeof(InternalRemoveEmptySubMesh)] = x => new RemoveEmptySubMeshProcessor((InternalRemoveEmptySubMesh)x),
};

Expand Down
11 changes: 8 additions & 3 deletions Editor/Inspector/FreezeBlendShapeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace Anatawa12.AvatarOptimizer
[CustomEditor(typeof(FreezeBlendShape))]
class FreezeBlendShapeEditor : AvatarTagComponentEditorBase
{
private PrefabSafeSet.EditorUtil<string> _shapeKeysSet = null!; // initialized in OnEnable
private PrefabSafeSet.PSSEditorUtil<string> _shapeKeysSet = null!; // initialized in OnEnable

private void OnEnable()
{
_shapeKeysSet = PrefabSafeSet.EditorUtil<string>.Create(
_shapeKeysSet = PrefabSafeSet.PSSEditorUtil<string>.Create(
serializedObject.FindProperty("shapeKeysSet"),
x => x.stringValue,
(x, v) => x.stringValue = v);
Expand All @@ -31,7 +31,12 @@ protected override void OnInspectorGUIInner()
label.text = shapeKeyName;
var element = _shapeKeysSet.GetElementOf(shapeKeyName);
using (new PrefabSafeSet.PropertyScope<string>(element, rect, label))
element.SetExistence(EditorGUI.ToggleLeft(rect, label, element.Contains));
{
EditorGUI.BeginChangeCheck();
var selected = EditorGUI.ToggleLeft(rect, label, element.Contains);
if (EditorGUI.EndChangeCheck())
element.SetExistence(selected);
}
}

using (new GUILayout.HorizontalScope())
Expand Down
12 changes: 9 additions & 3 deletions Editor/Inspector/MergeSkinnedMeshEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static class Style
SerializedProperty _removeEmptyRendererObjectProp = null!; // initialized in OnEnable
SerializedProperty _skipEnablementMismatchedRenderers = null!; // initialized in OnEnable
SerializedProperty _copyEnablementAnimation = null!; // initialized in OnEnable
PrefabSafeSet.EditorUtil<Material> _doNotMergeMaterials = null!; // initialized in OnEnable
PrefabSafeSet.PSSEditorUtil<Material> _doNotMergeMaterials = null!; // initialized in OnEnable

private void OnEnable()
{
Expand All @@ -38,7 +38,7 @@ private void OnEnable()
_skipEnablementMismatchedRenderers =
serializedObject.FindProperty(nameof(MergeSkinnedMesh.skipEnablementMismatchedRenderers));
_copyEnablementAnimation = serializedObject.FindProperty(nameof(MergeSkinnedMesh.copyEnablementAnimation));
_doNotMergeMaterials = PrefabSafeSet.EditorUtil<Material>.Create(
_doNotMergeMaterials = PrefabSafeSet.PSSEditorUtil<Material>.Create(
serializedObject.FindProperty("doNotMergeMaterials"),
x => (Material)x.objectReferenceValue,
(x, v) => x.objectReferenceValue = v);
Expand Down Expand Up @@ -94,7 +94,13 @@ public void MergeMaterials(MergeSkinnedMesh merge)
var fieldPosition = EditorGUILayout.GetControlRect();
var label = new GUIContent(AAOL10N.Tr("MergeSkinnedMesh:label:Merge"));
using (new PrefabSafeSet.PropertyScope<Material>(element, fieldPosition, label))
element.SetExistence(!EditorGUI.ToggleLeft(fieldPosition, label, !element.Contains));
{

EditorGUI.BeginChangeCheck();
var selected = !EditorGUI.ToggleLeft(fieldPosition, label, !element.Contains);
if (EditorGUI.EndChangeCheck())
element.SetExistence(selected);
}

EditorGUILayout.LabelField(AAOL10N.Tr("MergeSkinnedMesh:label:Renderers"));
EditorGUI.indentLevel++;
Expand Down
4 changes: 2 additions & 2 deletions Editor/Inspector/RemoveMeshByBlendShapeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Anatawa12.AvatarOptimizer
[CustomEditor(typeof(RemoveMeshByBlendShape))]
internal class RemoveMeshByBlendShapeEditor : AvatarTagComponentEditorBase
{
private PrefabSafeSet.EditorUtil<string> _shapeKeysSet = null!; // initialized in OnEnable
private PrefabSafeSet.PSSEditorUtil<string> _shapeKeysSet = null!; // initialized in OnEnable
private SerializedProperty _toleranceProp = null!; // initialized in OnEnable
private SkinnedMeshRenderer? _renderer;
public bool automaticallySetWeightWhenToggle;
Expand All @@ -16,7 +16,7 @@ private void OnEnable()
{
NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;
_renderer = targets.Length == 1 ? ((Component)target).GetComponent<SkinnedMeshRenderer>() : null;
_shapeKeysSet = PrefabSafeSet.EditorUtil<string>.Create(
_shapeKeysSet = PrefabSafeSet.PSSEditorUtil<string>.Create(
serializedObject.FindProperty("shapeKeysSet"),
x => x.stringValue,
(x, v) => x.stringValue = v);
Expand Down
Loading
Loading