-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
340cd30
commit 4cfa199
Showing
17 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using Anatawa12.AvatarOptimizer.ErrorReporting; | ||
using Anatawa12.AvatarOptimizer.ndmf; | ||
using nadena.dev.ndmf; | ||
using nadena.dev.ndmf.builtin; | ||
|
||
[assembly: ExportsPlugin(typeof(OptimizerPlugin))] | ||
|
||
namespace Anatawa12.AvatarOptimizer.ndmf | ||
{ | ||
internal class OptimizerContext : IExtensionContext | ||
{ | ||
private IDisposable buildReportScope; | ||
internal OptimizerSession session; | ||
|
||
public void OnActivate(BuildContext context) | ||
{ | ||
buildReportScope = BuildReport.ReportingOnAvatar(context.AvatarDescriptor); | ||
session = new OptimizerSession(context.AvatarRootObject, context.AssetContainer, | ||
false); | ||
} | ||
|
||
public void OnDeactivate(BuildContext context) | ||
{ | ||
session.MarkDirtyAll(); | ||
buildReportScope.Dispose(); | ||
} | ||
} | ||
|
||
internal class OptimizerPlugin : Plugin<OptimizerPlugin> | ||
{ | ||
public override string DisplayName => "Anatawa12's Avatar Optimizer"; | ||
|
||
public override string QualifiedName => "com.anatawa12.avatar-optimizer"; | ||
|
||
protected override void Configure() | ||
{ | ||
// Run early steps before EditorOnly objects are purged | ||
InPhase(BuildPhase.Resolving) | ||
.WithRequiredExtension(typeof(OptimizerContext), seq => | ||
{ | ||
seq.Run("Early: UnusedBonesByReference", | ||
ctx => new Processors.UnusedBonesByReferencesToolEarlyProcessor().Process(ctx) | ||
) | ||
.Then.Run("Early: MakeChildren", | ||
ctx => new Processors.MakeChildrenProcessor(early: true).Process(ctx) | ||
) | ||
.BeforePass(RemoveEditorOnlyPass.Instance); | ||
}); | ||
|
||
// Run everything else in the optimize phase | ||
InPhase(BuildPhase.Optimizing) | ||
.WithRequiredExtension(typeof(OptimizerContext), seq => | ||
{ | ||
seq.Run("TraceAndOptimize", | ||
ctx => new Processors.TraceAndOptimizeProcessor().Process(ctx) | ||
) | ||
.Then.Run("ClearEndpointPosition", | ||
ctx => new Processors.ClearEndpointPositionProcessor().Process(ctx) | ||
) | ||
.Then.Run("MergePhysBone", | ||
ctx => new Processors.MergePhysBoneProcessor().Process(ctx) | ||
) | ||
.Then.Run("MakeChildrenProcessor", | ||
ctx => new Processors.MakeChildrenProcessor(early: false).Process(ctx) | ||
) | ||
.Then.Run("ApplyObjectMapping", | ||
ctx => new Processors.ApplyObjectMapping().Apply(ctx) | ||
); | ||
}); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
Internal/ErrorReporter/Editor/ErrorReportingInitializerProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters