-
-
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
66d8187
commit 4450911
Showing
17 changed files
with
162 additions
and
14 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,89 @@ | ||
#if NADEMOFU | ||
using System; | ||
using Anatawa12.AvatarOptimizer.ErrorReporting; | ||
using Anatawa12.AvatarOptimizer.ndmf; | ||
using Anatawa12.AvatarOptimizer.Processors; | ||
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, false, 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 => | ||
{ | ||
ctx.GetState<TraceAndOptimizeProcessor>().Process(ctx); | ||
}) | ||
.Then.Run("ClearEndpointPosition", | ||
ctx => new Processors.ClearEndpointPositionProcessor().Process(ctx) | ||
) | ||
.Then.Run("MergePhysBone", | ||
ctx => new Processors.MergePhysBoneProcessor().Process(ctx) | ||
) | ||
.Then.Run("EditSkinnedMeshComponent", | ||
ctx => new Processors.EditSkinnedMeshComponentProcessor().Process(ctx) | ||
) | ||
.Then.Run("MakeChildrenProcessor", | ||
ctx => new Processors.MakeChildrenProcessor(early: false).Process(ctx) | ||
) | ||
.Then.Run("TraceAndOptimize:ProcessLater", | ||
ctx => ctx.GetState<TraceAndOptimizeProcessor>().ProcessLater(ctx)) | ||
.Then.Run("MergeBoneProcessor", ctx => new Processors.MergeBoneProcessor().Process(ctx)) | ||
.Then.Run("ApplyObjectMapping", | ||
ctx => new Processors.ApplyObjectMapping().Apply(ctx) | ||
) | ||
.Then.Run("SaveMeshInfo2", ctx => ((OptimizerSession) ctx).SaveMeshInfo2()); | ||
}); | ||
} | ||
|
||
protected override void OnUnhandledException(Exception e) | ||
{ | ||
BuildReport.ReportInternalError(e); | ||
} | ||
} | ||
} | ||
#endif |
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