Skip to content

Commit

Permalink
Merge branch 'master' into adding-localization
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 authored Mar 22, 2024
2 parents 684c78a + 752a6cd commit 5fedb03
Show file tree
Hide file tree
Showing 134 changed files with 936 additions and 313 deletions.
6 changes: 5 additions & 1 deletion .docs/content/docs/reference/trace-and-optimize/index.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ Trace and Optimizeは「**見た目に絶対に影響させてはならない**
アニメーションなどを走査して、使われていないObject(GameObjectやコンポーネントなど)を自動的に削除します。
- `endボーンを残す`\
親が削除されていないendボーン[^endbone]を削除しないようにします。
- `面積がゼロのポリゴンを自動的に削除する`
- `面積がゼロのポリゴンを自動的に削除する`\
面積がゼロのポリゴンを削除します。
- `PhysBoneの設定を最適化する`\
PhysBoneの設定について、以下の最適化を行います。
- 全く同じ設定のPhysBone Colliderを1つに統合します。
- 不要な場合に`Is Animated`のチェックを外します。
- `アニメーターの最適化`
Animator Controllerを最適化します。

Expand Down
6 changes: 5 additions & 1 deletion .docs/content/docs/reference/trace-and-optimize/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ Currently the following optimizations are applied automatically.
By scanning animation etc., automatically removes unused Objects (e.g. GameObjects, Components).
- `Preserve EndBone`\
Prevents removing end bones[^endbone] whose parent is not removed.
- `Automatically Remove Zero Sized Polygons`
- `Automatically Remove Zero Sized Polygons`\
Removes polygons whose area are zero.
- `Optimize PhysBone Settings`\
Optimizes PhysBone settings for better performance. This performs the following optimizations.
- Merges PhysBone Colliders with the exactly same settings into one PhysBone Collider.
- Unchecks `Is Animated` if it's not necessary.
- `Optimize Animator`
Optimizes Animator Controller.

Expand Down
39 changes: 31 additions & 8 deletions .github/workflows/gameci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- unity: 2019
projectRef: b552a002fa121b0d7c233b49241f5f6279d0fa90 # project-for-test-2019
- unity: 2022
projectRef: de0b2dde7824e33986730c40866d74cfe526942b # project-for-test-2022
unity:
- 2019
- 2022
permissions:
checks: write
steps:
- uses: actions/checkout@v4
with:
ref: project-for-test
ref: ${{ matrix.projectRef }}
- uses: actions/checkout@v4
with:
path: Packages/com.anatawa12.avatar-optimizer
Expand All @@ -24,11 +35,11 @@ jobs:
repos: |
https://vpm.anatawa12.com/vpm.json
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: Library
key: Library-${{ matrix.projectPath }}
restore-keys: Library-
key: Library-${{ matrix.unity }}
restore-keys: Library-${{ matrix.unity }}

- uses: game-ci/unity-test-runner@v3
id: gameci
Expand All @@ -39,14 +50,26 @@ jobs:
githubToken: ${{ github.token }}
coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+com.anatawa12.avatar-optimizer.*
customParameters: -nographics -assemblyNames com.anatawa12.avatar-optimizer.test
checkName: Test results ${{ matrix.unity }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test results
name: Test results ${{ matrix.unity }}
path: ${{ steps.gameci.outputs.artifactsPath }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Coverage results
name: Coverage results ${{ matrix.unity }}
path: ${{ steps.gameci.outputs.coveragePath }}

conclude-gameci:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build-and-test]
steps:
- name: Conclude Tests
env: { NEEDS: "${{ toJSON(needs) }}" }
run: |
echo "$NEEDS" | jq -c '. | to_entries[] | [.key, .value.result]'
echo "$NEEDS" | jq -e '. | all(.result == "success")' > /dev/null
25 changes: 24 additions & 1 deletion CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog].
## [Unreleased]
### Added
- Animator Optimizer `#854`
- Most features of Animator Optimizer is not available in Unity 2019.
- Animator Optimizer optimizes your Animator Controller without behaviour Changes
- Current Optimizer includes the following optimization
- Remove meaningless properties `#854`
Expand Down Expand Up @@ -59,6 +60,24 @@ The format is based on [Keep a Changelog].

### Security

## [1.6.9-beta.1] - 2024-03-16
### Added
- Support for VRCSDK 3.5.2-beta.1 [`#926`](https://github.com/anatawa12/AvatarOptimizer/pull/926)

## [1.6.8] - 2024-03-12
### Fixed
- If some component refers external component, internal error [`#921`](https://github.com/anatawa12/AvatarOptimizer/pull/921)

## [1.6.7] - 2024-02-28
## [1.6.7-beta.1] - 2024-02-28
### Fixed
- Compilation Error due to VRCImposterSettings with VRCSDK 3.2.x [`#905`](https://github.com/anatawa12/AvatarOptimizer/pull/905)
- Skinned Mesh Renderers with None mesh will become Mesh with no polygons [`#906`](https://github.com/anatawa12/AvatarOptimizer/pull/906)
- This may affects bounds of Performance Rank in VRChat
- Exclusions not working with Automatically Remove Zero Sized Polygons [`#907`](https://github.com/anatawa12/AvatarOptimizer/pull/907)
- Fix non-VRChat project support [`#884`](https://github.com/anatawa12/AvatarOptimizer/pull/884) (backport in `#909`)
- Merge Toonlit with uv tiling is broken [`#911`](https://github.com/anatawa12/AvatarOptimizer/pull/911)

## [1.6.6] - 2024-01-31
### Fixed
- Some features are not working well if `Trace and Optimize` is not attached [`#876`](https://github.com/anatawa12/AvatarOptimizer/pull/876)
Expand Down Expand Up @@ -1197,7 +1216,11 @@ This release is mistake.
- Merge Bone
- Clear Endpoint Position

[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.6...HEAD
[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.9-beta.1...HEAD
[1.6.9-beta.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.8...v1.6.9-beta.1
[1.6.8]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.7...v1.6.8
[1.6.7]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.7-beta.1...v1.6.7
[1.6.7-beta.1]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.6...v1.6.7-beta.1
[1.6.6]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.5...v1.6.6
[1.6.5]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.5-rc.3...v1.6.5
[1.6.5-rc.3]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.5-rc.2...v1.6.5-rc.3
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ The format is based on [Keep a Changelog].

## [Unreleased]
### Added
- Support for VRCSDK 3.5.2-beta.1 `#926`
- Animator Optimizer `#854`
- Most features of Animator Optimizer is not available in Unity 2019.
- Animator Optimizer optimizes your Animator Controller without behaviour Changes
- Current Optimizer includes the following optimization
- Remove meaningless properties `#854`
Expand Down Expand Up @@ -59,6 +61,19 @@ The format is based on [Keep a Changelog].

### Security

## [1.6.8] - 2024-03-12
### Fixed
- If some component refers external component, internal error [`#921`](https://github.com/anatawa12/AvatarOptimizer/pull/921)

## [1.6.7] - 2024-02-28
### Fixed
- Compilation Error due to VRCImposterSettings with VRCSDK 3.2.x [`#905`](https://github.com/anatawa12/AvatarOptimizer/pull/905)
- Skinned Mesh Renderers with None mesh will become Mesh with no polygons [`#906`](https://github.com/anatawa12/AvatarOptimizer/pull/906)
- This may affects bounds of Performance Rank in VRChat
- Exclusions not working with Automatically Remove Zero Sized Polygons [`#907`](https://github.com/anatawa12/AvatarOptimizer/pull/907)
- Fix non-VRChat project support [`#884`](https://github.com/anatawa12/AvatarOptimizer/pull/884) (backport in `#909`)
- Merge Toonlit with uv tiling is broken [`#911`](https://github.com/anatawa12/AvatarOptimizer/pull/911)

## [1.6.6] - 2024-01-31
### Fixed
- Some features are not working well if `Trace and Optimize` is not attached [`#876`](https://github.com/anatawa12/AvatarOptimizer/pull/876)
Expand Down Expand Up @@ -777,7 +792,9 @@ The format is based on [Keep a Changelog].
- Merge Bone
- Clear Endpoint Position

[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.6...HEAD
[Unreleased]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.8...HEAD
[1.6.8]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.7...v1.6.8
[1.6.7]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.6...v1.6.7
[1.6.6]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.5...v1.6.6
[1.6.5]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.4...v1.6.5
[1.6.4]: https://github.com/anatawa12/AvatarOptimizer/compare/v1.6.3...v1.6.4
Expand Down
39 changes: 39 additions & 0 deletions Editor/APIInternal/ComponentInfos.VRCSDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,44 @@ protected override void CollectDependency(VRCImpostorSettings component, Compone
collector.AddDependency(transform);
}
}

#if AAO_VRCSDK3_AVATARS_IMPOSTER_SETTINGS
// this component has no documentation so this implementation is based on assumption
[ComponentInformation(typeof(VRCImpostorEnvironment))]
internal class VRCImpostorEnvironmentInformation : ComponentInformation<VRCImpostorEnvironment>
{
protected override void CollectDependency(VRCImpostorEnvironment component, ComponentDependencyCollector collector)
{
// prevent from removing
collector.MarkEntrypoint();
}
}
#endif

#if AAO_VRCSDK3_AVATARS_3_5_2
[ComponentInformation(typeof(VRCHeadChop))]
internal class VRCHeadChopInformation : ComponentInformation<VRCHeadChop>
{
protected override void CollectDependency(VRCHeadChop component, ComponentDependencyCollector collector)
{
// This is ad-hoc implementation because this component has no documentation.
// see https://feedback.vrchat.com/open-beta/p/352-beta1-2-vrcheadchop-component-has-no-public-access-to-configuration-so-exter

// use AppendDesiredTransformWeights to get all bones specified in this component
var headChopBones = new Dictionary<Transform, VRCHeadChop.HeadChopData>();
component.AppendDesiredTransformWeights(headChopBones, false);
component.AppendDesiredTransformWeights(headChopBones, true);

// declare dependency relationship
foreach (var pair in headChopBones)
{
collector.AddDependency(pair.Key);
collector.AddDependency(pair.Key, component).EvenIfDependantDisabled();
}

collector.MarkBehaviour();
}
}
#endif
}
#endif
3 changes: 0 additions & 3 deletions Editor/AnimatorController.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Editor/AnimatorParserV2/AnimatorParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void CollectAvatarDescriptorModifications([NotNull] RootPropModNodeConta
new AnimatorWeightChangesList(controllers[layer]?.ComputeLayerCount() ?? 0);
var playableWeightChanged = new AnimatorLayerMap<AnimatorWeightChange>();
foreach (var layer in descriptor.baseAnimationLayers)
ACUtils.CollectWeightChangesInController(controllers[layer.type],
VRCSDKUtils.CollectWeightChangesInController(controllers[layer.type],
playableWeightChanged, animatorLayerWeightChanged);

if (_mmdWorldCompatibility)
Expand Down
13 changes: 2 additions & 11 deletions Editor/ContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@ public static T[] GetComponents<T>([NotNull] this BuildContext context) where T
return context.AvatarRootObject.GetComponentsInChildren<T>(true);
}

private static MeshInfo2Holder GetHolder([NotNull] this BuildContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));
return context.Extension<MeshInfo2Context>().Holder;
}

public static MeshInfo2 GetMeshInfoFor([NotNull] this BuildContext context, SkinnedMeshRenderer renderer) =>
context.GetHolder().GetMeshInfoFor(renderer);

public static ObjectMappingBuilder GetMappingBuilder([NotNull] this BuildContext context)
public static ObjectMappingBuilder<PropertyInfo> GetMappingBuilder([NotNull] this BuildContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));
return context.Extension<ObjectMappingContext>().MappingBuilder;
Expand All @@ -46,7 +37,7 @@ public static void RecordMoveProperty([NotNull] this BuildContext context, Compo
public static void RecordRemoveProperty([NotNull] this BuildContext context, Component from, string oldProp) =>
GetMappingBuilder(context).RecordRemoveProperty(from, oldProp);

public static AnimationComponentInfo GetAnimationComponent([NotNull] this BuildContext context,
public static AnimationComponentInfo<PropertyInfo> GetAnimationComponent([NotNull] this BuildContext context,
ComponentOrGameObject component) =>
GetMappingBuilder(context).GetAnimationComponent(component);

Expand Down
5 changes: 5 additions & 0 deletions Editor/Inspector/TraceAndOptimizeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ protected override void OnInspectorGUIInner()
EditorGUILayout.PropertyField(_optimizePhysBone);
EditorGUILayout.PropertyField(_optimizeAnimator);

#if !UNITY_2021_3_OR_NEWER
if (_optimizeAnimator.boolValue)
EditorGUILayout.HelpBox(AAOL10N.Tr("TraceAndOptimize:OptimizeAnimator:Unity2019"), MessageType.Info);
#endif

_advancedSettingsLabel.text = AAOL10N.Tr("TraceAndOptimize:prop:advancedSettings");
if (EditorGUILayout.PropertyField(_advancedSettings, _advancedSettingsLabel, false))
{
Expand Down
3 changes: 0 additions & 3 deletions Editor/Math.meta

This file was deleted.

2 changes: 0 additions & 2 deletions Editor/ObjectMapping/AnimationObjectMapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Anatawa12.AvatarOptimizer.Processors.TraceAndOptimizes;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
Expand Down
Loading

0 comments on commit 5fedb03

Please sign in to comment.