Skip to content

Commit

Permalink
Merge pull request #709 from anatawa12/remove-unused-entrypoints
Browse files Browse the repository at this point in the history
feat: remove meaningless Renderers and Animators
  • Loading branch information
anatawa12 authored Nov 11, 2023
2 parents a484de5 + 28a857f commit 43266e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog].
### Added

### Changed
- Remove Unused Objects removes meaningless Animators and Renderers `#709`
- Renderers without Mesh and Animators without AnimatorController is meaningless

### Deprecated

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The format is based on [Keep a Changelog].
- Previously, multi-material multi pass rendering are flattened.
- Since 1.6, flattened if component doesn't support that.
- When you're animating activeness/enablement of source renderers, warning is shown since this release `#675`
- Remove Unused Objects removes meaningless Animators and Renderers `#709`
- Renderers without Mesh and Animators without AnimatorController is meaningless

### Deprecated

Expand Down
10 changes: 9 additions & 1 deletion Editor/APIInternal/ComponentInfos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ internal class AnimatorInformation : ComponentInformation<Animator>
// All State / Motion Changes are collected separately
protected override void CollectDependency(Animator component, ComponentDependencyCollector collector)
{
// if AnimatorController is null, it does nothing.
if (!component.runtimeAnimatorController) return;
collector.MarkEntrypoint();

for (var bone = HumanBodyBones.Hips; bone < HumanBodyBones.LastBone; bone++)
Expand Down Expand Up @@ -80,6 +82,8 @@ internal class SkinnedMeshRendererInformation : RendererInformation<SkinnedMeshR
protected override void CollectDependency(SkinnedMeshRenderer component,
ComponentDependencyCollector collector)
{
// SMR without mesh does nothing.
if (!component.sharedMesh) return;
base.CollectDependency(component, collector);

var casted = (Processors.TraceAndOptimizes.ComponentDependencyCollector.Collector)collector;
Expand All @@ -96,8 +100,12 @@ internal class MeshRendererInformation : RendererInformation<MeshRenderer>
{
protected override void CollectDependency(MeshRenderer component, ComponentDependencyCollector collector)
{
var meshFilter = component.GetComponent<MeshFilter>();
// Mesh renderer without MeshFilter does nothing
// Mesh renderer without Mesh does nothing
if (!meshFilter || !meshFilter.sharedMesh) return;
base.CollectDependency(component, collector);
collector.AddDependency(component.GetComponent<MeshFilter>());
collector.AddDependency(meshFilter);
}
}

Expand Down

0 comments on commit 43266e4

Please sign in to comment.